	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function mtk_nfc_write_page
_mtk_nfc_write_page:                    ## @mtk_nfc_write_page
	.cfi_startproc
## %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$40, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	%r8d, %r13d
	movl	%ecx, %ebx
	movq	%rdx, -56(%rbp)                 ## 8-byte Spill
	movq	%rsi, %r12
	movq	%rdi, %r14
	movq	%rsi, %rdi
	callq	_nand_get_controller_data
	movq	%rax, -72(%rbp)                 ## 8-byte Spill
	movq	%r12, %rdi
	callq	_to_mtk_nand
	movq	%rax, %r15
	movq	%r12, %rdi
	movl	%ebx, %esi
	xorl	%edx, %edx
	xorl	%ecx, %ecx
	xorl	%r8d, %r8d
	callq	_nand_prog_page_begin_op
	testl	%r13d, %r13d
	je	LBB0_1
## %bb.3:
	movq	8(%r14), %r8
	addq	(%r14), %r8
	movq	%r14, %rdi
	movq	%r12, %rsi
	movq	-56(%rbp), %rdx                 ## 8-byte Reload
	movl	%ebx, %ecx
	callq	_mtk_nfc_do_write_page
	movl	%eax, %r13d
	movq	%r12, %r15
	testl	%r13d, %r13d
	jne	LBB0_6
	jmp	LBB0_7
LBB0_1:
	movq	%r12, -64(%rbp)                 ## 8-byte Spill
	movl	%ebx, -44(%rbp)                 ## 4-byte Spill
	movq	_NFI_CNFG@GOTPCREL(%rip), %r12
	movl	(%r12), %esi
	movq	-72(%rbp), %rbx                 ## 8-byte Reload
	movq	%rbx, %rdi
	callq	_nfi_readw
	movq	_CNFG_AUTO_FMT_EN@GOTPCREL(%rip), %rcx
	orl	(%rcx), %eax
	movq	_CNFG_HW_ECC_EN@GOTPCREL(%rip), %rcx
	orl	(%rcx), %eax
	movl	(%r12), %edx
	movq	%rbx, %rdi
	movl	%eax, %esi
	callq	_nfi_writew
	movq	_ECC_ENCODE@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movq	%rbx, %rsi
	addq	$16, %rsi
	movl	%eax, 20(%rbx)
	movq	_ECC_NFI_MODE@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, 16(%rbx)
	movl	(%rbx), %edi
	callq	_mtk_ecc_enable
	testl	%eax, %eax
	je	LBB0_4
## %bb.2:
	movl	%eax, %r13d
	movl	(%r12), %esi
	movq	%rbx, %rdi
	callq	_nfi_readw
	movq	_CNFG_HW_ECC_EN@GOTPCREL(%rip), %rcx
	movl	(%rcx), %esi
	movq	_CNFG_AUTO_FMT_EN@GOTPCREL(%rip), %rcx
	orl	(%rcx), %esi
	notl	%esi
	andl	%eax, %esi
	movl	(%r12), %edx
	movq	%rbx, %rdi
	callq	_nfi_writew
	jmp	LBB0_6
LBB0_4:
	movq	8(%rbx), %rdi
	movq	%r14, %r12
	movq	(%r14), %rdx
	movq	-56(%rbp), %rsi                 ## 8-byte Reload
	callq	_memcpy
	movq	8(%rbx), %rsi
	movq	%r14, %rdi
	xorl	%edx, %edx
	callq	*(%r15)
	movq	8(%rbx), %r14
	movq	-64(%rbp), %r15                 ## 8-byte Reload
	movq	%r15, %rdi
	callq	_mtk_nfc_write_fdm
	movq	(%r12), %r8
	movq	%r12, %rdi
	movq	%r15, %rsi
	movq	%r14, %rdx
	movl	-44(%rbp), %ecx                 ## 4-byte Reload
	callq	_mtk_nfc_do_write_page
	movl	%eax, %r13d
	movl	(%rbx), %edi
	callq	_mtk_ecc_disable
	testl	%r13d, %r13d
	je	LBB0_7
LBB0_6:
	movl	%r13d, %eax
	addq	$40, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_7:
	movq	%r15, %rdi
	addq	$40, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	jmp	_nand_prog_page_end_op          ## TAILCALL
	.cfi_endproc
                                        ## -- End function
	.comm	_NFI_CNFG,4,2                   ## @NFI_CNFG
	.comm	_CNFG_AUTO_FMT_EN,4,2           ## @CNFG_AUTO_FMT_EN
	.comm	_CNFG_HW_ECC_EN,4,2             ## @CNFG_HW_ECC_EN
	.comm	_ECC_ENCODE,4,2                 ## @ECC_ENCODE
	.comm	_ECC_NFI_MODE,4,2               ## @ECC_NFI_MODE
	.no_dead_strip	_mtk_nfc_write_page
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function mtk_nfc_write_page
_mtk_nfc_write_page:                    ; @mtk_nfc_write_page
	.cfi_startproc
; %bb.0:
	stp	x28, x27, [sp, #-96]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 96
	stp	x26, x25, [sp, #16]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #32]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #48]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #64]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #80]             ; 16-byte Folded Spill
	add	x29, sp, #80
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
	.cfi_offset w19, -24
	.cfi_offset w20, -32
	.cfi_offset w21, -40
	.cfi_offset w22, -48
	.cfi_offset w23, -56
	.cfi_offset w24, -64
	.cfi_offset w25, -72
	.cfi_offset w26, -80
	.cfi_offset w27, -88
	.cfi_offset w28, -96
	mov	x25, x4
	mov	x21, x3
	mov	x23, x2
	mov	x19, x1
	mov	x22, x0
	mov	x0, x1
	bl	_nand_get_controller_data
	mov	x20, x0
	mov	x0, x19
	bl	_to_mtk_nand
	mov	x24, x0
	mov	x0, x19
	mov	x1, x21
	mov	w2, #0
	mov	x3, #0
	mov	w4, #0
	bl	_nand_prog_page_begin_op
	cbz	w25, LBB0_2
; %bb.1:
	ldp	x8, x9, [x22]
	add	x4, x9, x8
	mov	x0, x22
	mov	x1, x19
	mov	x2, x23
	mov	x3, x21
	bl	_mtk_nfc_do_write_page
	mov	x25, x0
	cbnz	w25, LBB0_5
	b	LBB0_6
LBB0_2:
Lloh0:
	adrp	x26, _NFI_CNFG@GOTPAGE
Lloh1:
	ldr	x26, [x26, _NFI_CNFG@GOTPAGEOFF]
	ldr	w1, [x26]
	mov	x0, x20
	bl	_nfi_readw
Lloh2:
	adrp	x27, _CNFG_AUTO_FMT_EN@GOTPAGE
Lloh3:
	ldr	x27, [x27, _CNFG_AUTO_FMT_EN@GOTPAGEOFF]
	ldr	w8, [x27]
	orr	w8, w8, w0
Lloh4:
	adrp	x28, _CNFG_HW_ECC_EN@GOTPAGE
Lloh5:
	ldr	x28, [x28, _CNFG_HW_ECC_EN@GOTPAGEOFF]
	ldr	w9, [x28]
	orr	w1, w8, w9
	ldr	w2, [x26]
	mov	x0, x20
	bl	_nfi_writew
Lloh6:
	adrp	x8, _ECC_ENCODE@GOTPAGE
Lloh7:
	ldr	x8, [x8, _ECC_ENCODE@GOTPAGEOFF]
Lloh8:
	ldr	w8, [x8]
Lloh9:
	adrp	x9, _ECC_NFI_MODE@GOTPAGE
Lloh10:
	ldr	x9, [x9, _ECC_NFI_MODE@GOTPAGEOFF]
	str	w8, [x20, #20]
Lloh11:
	ldr	w8, [x9]
	mov	x1, x20
	str	w8, [x1, #16]!
	ldr	w0, [x20]
	bl	_mtk_ecc_enable
	cbz	w0, LBB0_4
; %bb.3:
	mov	x25, x0
	ldr	w1, [x26]
	mov	x0, x20
	bl	_nfi_readw
	ldr	w8, [x27]
	ldr	w9, [x28]
	orr	w8, w9, w8
	bic	w1, w0, w8
	ldr	w2, [x26]
	mov	x0, x20
	bl	_nfi_writew
	b	LBB0_5
LBB0_4:
	ldr	x0, [x20, #8]
	ldr	x2, [x22]
	mov	x1, x23
	bl	_memcpy
	ldr	x8, [x24]
	ldr	x1, [x20, #8]
	mov	x0, x22
	mov	w2, #0
	blr	x8
	ldr	x23, [x20, #8]
	mov	x0, x19
	bl	_mtk_nfc_write_fdm
	ldr	x4, [x22]
	mov	x0, x22
	mov	x1, x19
	mov	x2, x23
	mov	x3, x21
	bl	_mtk_nfc_do_write_page
	mov	x25, x0
	ldr	w0, [x20]
	bl	_mtk_ecc_disable
	cbz	w25, LBB0_6
LBB0_5:
	mov	x0, x25
	ldp	x29, x30, [sp, #80]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #64]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #48]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #32]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #16]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp], #96             ; 16-byte Folded Reload
	ret
LBB0_6:
	mov	x0, x19
	ldp	x29, x30, [sp, #80]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #64]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #48]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #32]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #16]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp], #96             ; 16-byte Folded Reload
	b	_nand_prog_page_end_op
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGot	Lloh4, Lloh5
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh0, Lloh1
	.cfi_endproc
                                        ; -- End function
	.comm	_NFI_CNFG,4,2                   ; @NFI_CNFG
	.comm	_CNFG_AUTO_FMT_EN,4,2           ; @CNFG_AUTO_FMT_EN
	.comm	_CNFG_HW_ECC_EN,4,2             ; @CNFG_HW_ECC_EN
	.comm	_ECC_ENCODE,4,2                 ; @ECC_ENCODE
	.comm	_ECC_NFI_MODE,4,2               ; @ECC_NFI_MODE
	.no_dead_strip	_mtk_nfc_write_page
.subsections_via_symbols
