	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function jz4740_ecc_correct
_jz4740_ecc_correct:                    ## @jz4740_ecc_correct
	.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	$24, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rcx, %r12
	movq	%rdx, -48(%rbp)                 ## 8-byte Spill
	movq	%rsi, %r15
	movq	%rdi, %r14
	xorl	%esi, %esi
	callq	_jz4740_ecc_reset
	cmpl	$0, (%r15)
	jle	LBB0_3
## %bb.1:
	xorl	%ebx, %ebx
	movq	_JZ_REG_NAND_PAR0@GOTPCREL(%rip), %r13
	.p2align	4, 0x90
LBB0_2:                                 ## =>This Inner Loop Header: Depth=1
	movl	(%r12,%rbx,4), %edi
	movq	(%r14), %rsi
	addq	(%r13), %rsi
	addq	%rbx, %rsi
	callq	_writeb
	incq	%rbx
	movslq	(%r15), %rax
	cmpq	%rax, %rbx
	jl	LBB0_2
LBB0_3:
	movq	%r15, -56(%rbp)                 ## 8-byte Spill
	movq	_JZ_REG_NAND_ECC_CTRL@GOTPCREL(%rip), %rbx
	movq	(%rbx), %rdi
	addq	(%r14), %rdi
	callq	_readl
	movq	_JZ_NAND_ECC_CTRL_PAR_READY@GOTPCREL(%rip), %rcx
	orl	(%rcx), %eax
	movq	(%rbx), %rsi
	addq	(%r14), %rsi
	movl	%eax, %edi
	callq	_writel
	movl	$-1000, %ebx                    ## imm = 0xFC18
	movq	_JZ_REG_NAND_IRQ_STAT@GOTPCREL(%rip), %r12
	movq	_JZ_NAND_STATUS_DEC_FINISH@GOTPCREL(%rip), %r15
	.p2align	4, 0x90
LBB0_4:                                 ## =>This Inner Loop Header: Depth=1
	movq	(%r12), %rdi
	addq	(%r14), %rdi
	callq	_readl
	testl	%eax, (%r15)
	jne	LBB0_8
## %bb.5:                               ##   in Loop: Header=BB0_4 Depth=1
	incl	%ebx
	jne	LBB0_4
## %bb.6:
	movq	_ETIMEDOUT@GOTPCREL(%rip), %rax
	jmp	LBB0_7
LBB0_8:
	movl	%eax, %r13d
	movq	_JZ_REG_NAND_ECC_CTRL@GOTPCREL(%rip), %rbx
	movq	(%rbx), %rdi
	addq	(%r14), %rdi
	callq	_readl
	movq	_JZ_NAND_ECC_CTRL_ENABLE@GOTPCREL(%rip), %rcx
	movl	(%rcx), %edi
	notl	%edi
	andl	%eax, %edi
	movq	(%rbx), %rsi
	addq	(%r14), %rsi
	callq	_writel
	movq	_JZ_NAND_STATUS_ERROR@GOTPCREL(%rip), %rax
	testl	%r13d, (%rax)
	je	LBB0_9
## %bb.10:
	movq	_JZ_NAND_STATUS_UNCOR_ERROR@GOTPCREL(%rip), %rax
	testl	%r13d, (%rax)
	je	LBB0_12
## %bb.11:
	movq	_EBADMSG@GOTPCREL(%rip), %rax
LBB0_7:
	xorl	%r12d, %r12d
	subl	(%rax), %r12d
	jmp	LBB0_18
LBB0_9:
	xorl	%r12d, %r12d
	jmp	LBB0_18
LBB0_12:
	movq	_JZ_NAND_STATUS_ERR_COUNT@GOTPCREL(%rip), %rax
	andl	(%rax), %r13d
	movl	%r13d, %r12d
	sarl	$29, %r12d
	cmpl	$536870912, %r13d               ## imm = 0x20000000
	jl	LBB0_18
## %bb.13:
	cmpl	$2, %r12d
	movl	$1, %r15d
	cmovgel	%r12d, %r15d
	xorl	%r13d, %r13d
	jmp	LBB0_14
	.p2align	4, 0x90
LBB0_17:                                ##   in Loop: Header=BB0_14 Depth=1
	incl	%r13d
	cmpl	%r13d, %r15d
	je	LBB0_18
LBB0_14:                                ## =>This Inner Loop Header: Depth=1
	movq	(%r14), %rbx
	movl	%r13d, %edi
	callq	_JZ_REG_NAND_ERR
	addq	%rax, %rbx
	movq	%rbx, %rdi
	callq	_readl
	movl	%eax, %ecx
	shrl	$16, %ecx
	andl	$511, %ecx                      ## imm = 0x1FF
	movl	%ecx, %esi
	subl	$1, %esi
	jb	LBB0_17
## %bb.15:                              ##   in Loop: Header=BB0_14 Depth=1
	movq	-56(%rbp), %rdx                 ## 8-byte Reload
	cmpl	4(%rdx), %ecx
	jg	LBB0_17
## %bb.16:                              ##   in Loop: Header=BB0_14 Depth=1
	andl	$511, %eax                      ## imm = 0x1FF
	movq	-48(%rbp), %rdi                 ## 8-byte Reload
	movl	%eax, %edx
	callq	_jz_nand_correct_data
	jmp	LBB0_17
LBB0_18:
	movl	%r12d, %eax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_JZ_REG_NAND_PAR0,8,3           ## @JZ_REG_NAND_PAR0
	.comm	_JZ_REG_NAND_ECC_CTRL,8,3       ## @JZ_REG_NAND_ECC_CTRL
	.comm	_JZ_NAND_ECC_CTRL_PAR_READY,4,2 ## @JZ_NAND_ECC_CTRL_PAR_READY
	.comm	_JZ_REG_NAND_IRQ_STAT,8,3       ## @JZ_REG_NAND_IRQ_STAT
	.comm	_JZ_NAND_STATUS_DEC_FINISH,4,2  ## @JZ_NAND_STATUS_DEC_FINISH
	.comm	_ETIMEDOUT,4,2                  ## @ETIMEDOUT
	.comm	_JZ_NAND_ECC_CTRL_ENABLE,4,2    ## @JZ_NAND_ECC_CTRL_ENABLE
	.comm	_JZ_NAND_STATUS_ERROR,4,2       ## @JZ_NAND_STATUS_ERROR
	.comm	_JZ_NAND_STATUS_UNCOR_ERROR,4,2 ## @JZ_NAND_STATUS_UNCOR_ERROR
	.comm	_EBADMSG,4,2                    ## @EBADMSG
	.comm	_JZ_NAND_STATUS_ERR_COUNT,4,2   ## @JZ_NAND_STATUS_ERR_COUNT
	.no_dead_strip	_jz4740_ecc_correct
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function jz4740_ecc_correct
_jz4740_ecc_correct:                    ; @jz4740_ecc_correct
	.cfi_startproc
; %bb.0:
	stp	x26, x25, [sp, #-80]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 80
	stp	x24, x23, [sp, #16]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #32]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #48]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #64]             ; 16-byte Folded Spill
	add	x29, sp, #64
	.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
	mov	x22, x3
	mov	x19, x2
	mov	x20, x1
	mov	x21, x0
	mov	w1, #0
	bl	_jz4740_ecc_reset
	ldr	w8, [x20]
	cmp	w8, #1
	b.lt	LBB0_3
; %bb.1:
	mov	x23, #0
Lloh0:
	adrp	x24, _JZ_REG_NAND_PAR0@GOTPAGE
Lloh1:
	ldr	x24, [x24, _JZ_REG_NAND_PAR0@GOTPAGEOFF]
LBB0_2:                                 ; =>This Inner Loop Header: Depth=1
	ldr	w0, [x22, x23, lsl #2]
	ldr	x8, [x21]
	ldr	x9, [x24]
	add	x8, x8, x9
	add	x1, x23, x8
	bl	_writeb
	add	x23, x23, #1
	ldrsw	x8, [x20]
	cmp	x23, x8
	b.lt	LBB0_2
LBB0_3:
	ldr	x8, [x21]
Lloh2:
	adrp	x23, _JZ_REG_NAND_ECC_CTRL@GOTPAGE
Lloh3:
	ldr	x23, [x23, _JZ_REG_NAND_ECC_CTRL@GOTPAGEOFF]
	ldr	x9, [x23]
	add	x0, x9, x8
	bl	_readl
Lloh4:
	adrp	x8, _JZ_NAND_ECC_CTRL_PAR_READY@GOTPAGE
Lloh5:
	ldr	x8, [x8, _JZ_NAND_ECC_CTRL_PAR_READY@GOTPAGEOFF]
Lloh6:
	ldr	w8, [x8]
	orr	w0, w8, w0
	ldr	x8, [x21]
	ldr	x9, [x23]
	add	x1, x9, x8
	bl	_writel
	mov	w24, #-1000
Lloh7:
	adrp	x25, _JZ_REG_NAND_IRQ_STAT@GOTPAGE
Lloh8:
	ldr	x25, [x25, _JZ_REG_NAND_IRQ_STAT@GOTPAGEOFF]
Lloh9:
	adrp	x26, _JZ_NAND_STATUS_DEC_FINISH@GOTPAGE
Lloh10:
	ldr	x26, [x26, _JZ_NAND_STATUS_DEC_FINISH@GOTPAGEOFF]
LBB0_4:                                 ; =>This Inner Loop Header: Depth=1
	ldr	x8, [x21]
	ldr	x9, [x25]
	add	x0, x9, x8
	bl	_readl
	ldr	w8, [x26]
	tst	w8, w0
	b.ne	LBB0_7
; %bb.5:                                ;   in Loop: Header=BB0_4 Depth=1
	adds	w24, w24, #1
	b.lo	LBB0_4
; %bb.6:
Lloh11:
	adrp	x8, _ETIMEDOUT@GOTPAGE
Lloh12:
	ldr	x8, [x8, _ETIMEDOUT@GOTPAGEOFF]
	b	LBB0_10
LBB0_7:
	mov	x22, x0
	ldr	x8, [x21]
	ldr	x9, [x23]
	add	x0, x9, x8
	bl	_readl
Lloh13:
	adrp	x8, _JZ_NAND_ECC_CTRL_ENABLE@GOTPAGE
Lloh14:
	ldr	x8, [x8, _JZ_NAND_ECC_CTRL_ENABLE@GOTPAGEOFF]
Lloh15:
	ldr	w8, [x8]
	bic	w0, w0, w8
	ldr	x8, [x21]
	ldr	x9, [x23]
	add	x1, x9, x8
	bl	_writel
Lloh16:
	adrp	x8, _JZ_NAND_STATUS_ERROR@GOTPAGE
Lloh17:
	ldr	x8, [x8, _JZ_NAND_STATUS_ERROR@GOTPAGEOFF]
Lloh18:
	ldr	w8, [x8]
	tst	w8, w22
	b.eq	LBB0_11
; %bb.8:
Lloh19:
	adrp	x8, _JZ_NAND_STATUS_UNCOR_ERROR@GOTPAGE
Lloh20:
	ldr	x8, [x8, _JZ_NAND_STATUS_UNCOR_ERROR@GOTPAGEOFF]
Lloh21:
	ldr	w8, [x8]
	tst	w8, w22
	b.eq	LBB0_12
; %bb.9:
Lloh22:
	adrp	x8, _EBADMSG@GOTPAGE
Lloh23:
	ldr	x8, [x8, _EBADMSG@GOTPAGEOFF]
LBB0_10:
	ldr	w8, [x8]
	neg	w22, w8
	b	LBB0_24
LBB0_11:
	mov	w22, #0
	b	LBB0_24
LBB0_12:
Lloh24:
	adrp	x8, _JZ_NAND_STATUS_ERR_COUNT@GOTPAGE
Lloh25:
	ldr	x8, [x8, _JZ_NAND_STATUS_ERR_COUNT@GOTPAGEOFF]
Lloh26:
	ldr	w8, [x8]
	and	w24, w8, w22
	asr	w22, w24, #29
	mov	w8, #536870912
	cmp	w24, w8
	b.lt	LBB0_24
; %bb.13:
	cmp	w22, #1
	csinc	w23, w22, wzr, gt
	ldr	x25, [x21]
	mov	w0, #0
	bl	_JZ_REG_NAND_ERR
	add	x0, x0, x25
	bl	_readl
	ubfx	w8, w0, #16, #9
	cbz	w8, LBB0_16
; %bb.14:
	ldr	w9, [x20, #4]
	cmp	w8, w9
	b.gt	LBB0_16
; %bb.15:
	sub	w1, w8, #1
	and	w2, w0, #0x1ff
	mov	x0, x19
	bl	_jz_nand_correct_data
LBB0_16:
	mov	w8, #1073741824
	cmp	w24, w8
	b.lt	LBB0_24
; %bb.17:
	ldr	x24, [x21]
	mov	w0, #1
	bl	_JZ_REG_NAND_ERR
	add	x0, x0, x24
	bl	_readl
	ubfx	w8, w0, #16, #9
	cbz	w8, LBB0_20
; %bb.18:
	ldr	w9, [x20, #4]
	cmp	w8, w9
	b.gt	LBB0_20
; %bb.19:
	sub	w1, w8, #1
	and	w2, w0, #0x1ff
	mov	x0, x19
	bl	_jz_nand_correct_data
LBB0_20:
	cmp	w23, #2
	b.eq	LBB0_24
; %bb.21:
	ldr	x21, [x21]
	mov	w0, #2
	bl	_JZ_REG_NAND_ERR
	add	x0, x0, x21
	bl	_readl
	ubfx	w8, w0, #16, #9
	cbz	w8, LBB0_24
; %bb.22:
	ldr	w9, [x20, #4]
	cmp	w8, w9
	b.gt	LBB0_24
; %bb.23:
	sub	w1, w8, #1
	and	w2, w0, #0x1ff
	mov	x0, x19
	bl	_jz_nand_correct_data
LBB0_24:
	mov	x0, x22
	ldp	x29, x30, [sp, #64]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #48]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #32]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #16]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp], #80             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGot	Lloh9, Lloh10
	.loh AdrpLdrGot	Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh4, Lloh5, Lloh6
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh11, Lloh12
	.loh AdrpLdrGotLdr	Lloh16, Lloh17, Lloh18
	.loh AdrpLdrGotLdr	Lloh13, Lloh14, Lloh15
	.loh AdrpLdrGotLdr	Lloh19, Lloh20, Lloh21
	.loh AdrpLdrGot	Lloh22, Lloh23
	.loh AdrpLdrGotLdr	Lloh24, Lloh25, Lloh26
	.cfi_endproc
                                        ; -- End function
	.comm	_JZ_REG_NAND_PAR0,8,3           ; @JZ_REG_NAND_PAR0
	.comm	_JZ_REG_NAND_ECC_CTRL,8,3       ; @JZ_REG_NAND_ECC_CTRL
	.comm	_JZ_NAND_ECC_CTRL_PAR_READY,4,2 ; @JZ_NAND_ECC_CTRL_PAR_READY
	.comm	_JZ_REG_NAND_IRQ_STAT,8,3       ; @JZ_REG_NAND_IRQ_STAT
	.comm	_JZ_NAND_STATUS_DEC_FINISH,4,2  ; @JZ_NAND_STATUS_DEC_FINISH
	.comm	_ETIMEDOUT,4,2                  ; @ETIMEDOUT
	.comm	_JZ_NAND_ECC_CTRL_ENABLE,4,2    ; @JZ_NAND_ECC_CTRL_ENABLE
	.comm	_JZ_NAND_STATUS_ERROR,4,2       ; @JZ_NAND_STATUS_ERROR
	.comm	_JZ_NAND_STATUS_UNCOR_ERROR,4,2 ; @JZ_NAND_STATUS_UNCOR_ERROR
	.comm	_EBADMSG,4,2                    ; @EBADMSG
	.comm	_JZ_NAND_STATUS_ERR_COUNT,4,2   ; @JZ_NAND_STATUS_ERR_COUNT
	.no_dead_strip	_jz4740_ecc_correct
.subsections_via_symbols
