	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function jz4740_ecc_calculate
_jz4740_ecc_calculate:                  ## @jz4740_ecc_calculate
	.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
	pushq	%rax
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rcx, -48(%rbp)                 ## 8-byte Spill
	movq	%rsi, %r15
	movq	%rdi, %r12
	movl	$1, %esi
	callq	_jz4740_ecc_reset
	movl	$-1000, %ebx                    ## imm = 0xFC18
	movq	_JZ_REG_NAND_IRQ_STAT@GOTPCREL(%rip), %r13
	movq	_JZ_NAND_STATUS_ENC_FINISH@GOTPCREL(%rip), %r14
	.p2align	4, 0x90
LBB0_1:                                 ## =>This Inner Loop Header: Depth=1
	movq	(%r13), %rdi
	addq	(%r12), %rdi
	callq	_readl
	testl	%eax, (%r14)
	jne	LBB0_4
## %bb.2:                               ##   in Loop: Header=BB0_1 Depth=1
	incl	%ebx
	jne	LBB0_1
## %bb.3:
	movq	_ETIMEDOUT@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
	jmp	LBB0_9
LBB0_4:
	movq	_JZ_REG_NAND_ECC_CTRL@GOTPCREL(%rip), %rbx
	movq	(%rbx), %rdi
	addq	(%r12), %rdi
	callq	_readl
	movq	_JZ_NAND_ECC_CTRL_ENABLE@GOTPCREL(%rip), %rcx
	movl	(%rcx), %edi
	notl	%edi
	andl	%eax, %edi
	movq	(%rbx), %rsi
	addq	(%r12), %rsi
	callq	_writel
	cmpl	$0, (%r15)
	movq	-48(%rbp), %r14                 ## 8-byte Reload
	jle	LBB0_7
## %bb.5:
	xorl	%ebx, %ebx
	movq	_JZ_REG_NAND_PAR0@GOTPCREL(%rip), %r13
	.p2align	4, 0x90
LBB0_6:                                 ## =>This Inner Loop Header: Depth=1
	movq	(%r12), %rdi
	addq	(%r13), %rdi
	addq	%rbx, %rdi
	callq	_readb
	movl	%eax, (%r14,%rbx,4)
	incq	%rbx
	movslq	(%r15), %rax
	cmpq	%rax, %rbx
	jl	LBB0_6
LBB0_7:
	movq	%r14, %r15
	movq	_empty_block_ecc@GOTPCREL(%rip), %r14
	movl	(%r14), %ebx
	movl	%ebx, %edi
	callq	_ARRAY_SIZE
	movq	%r15, %rdi
	movl	%ebx, %esi
	movl	%eax, %edx
	callq	_memcmp
	xorl	%ebx, %ebx
	testq	%rax, %rax
	jne	LBB0_9
## %bb.8:
	movl	(%r14), %edi
	callq	_ARRAY_SIZE
	movq	%r15, %rdi
	movl	$255, %esi
	movl	%eax, %edx
	callq	_memset
LBB0_9:
	movl	%ebx, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_JZ_REG_NAND_IRQ_STAT,8,3       ## @JZ_REG_NAND_IRQ_STAT
	.comm	_JZ_NAND_STATUS_ENC_FINISH,4,2  ## @JZ_NAND_STATUS_ENC_FINISH
	.comm	_ETIMEDOUT,4,2                  ## @ETIMEDOUT
	.comm	_JZ_REG_NAND_ECC_CTRL,8,3       ## @JZ_REG_NAND_ECC_CTRL
	.comm	_JZ_NAND_ECC_CTRL_ENABLE,4,2    ## @JZ_NAND_ECC_CTRL_ENABLE
	.comm	_JZ_REG_NAND_PAR0,8,3           ## @JZ_REG_NAND_PAR0
	.comm	_empty_block_ecc,4,2            ## @empty_block_ecc
	.no_dead_strip	_jz4740_ecc_calculate
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function jz4740_ecc_calculate
_jz4740_ecc_calculate:                  ; @jz4740_ecc_calculate
	.cfi_startproc
; %bb.0:
	stp	x24, x23, [sp, #-64]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 64
	stp	x22, x21, [sp, #16]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #32]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #48]             ; 16-byte Folded Spill
	add	x29, sp, #48
	.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
	mov	x19, x3
	mov	x20, x1
	mov	x21, x0
	mov	w1, #1
	bl	_jz4740_ecc_reset
	mov	w22, #-1000
Lloh0:
	adrp	x23, _JZ_REG_NAND_IRQ_STAT@GOTPAGE
Lloh1:
	ldr	x23, [x23, _JZ_REG_NAND_IRQ_STAT@GOTPAGEOFF]
Lloh2:
	adrp	x24, _JZ_NAND_STATUS_ENC_FINISH@GOTPAGE
Lloh3:
	ldr	x24, [x24, _JZ_NAND_STATUS_ENC_FINISH@GOTPAGEOFF]
LBB0_1:                                 ; =>This Inner Loop Header: Depth=1
	ldr	x8, [x21]
	ldr	x9, [x23]
	add	x0, x9, x8
	bl	_readl
	ldr	w8, [x24]
	tst	w8, w0
	b.ne	LBB0_4
; %bb.2:                                ;   in Loop: Header=BB0_1 Depth=1
	adds	w22, w22, #1
	b.lo	LBB0_1
; %bb.3:
Lloh4:
	adrp	x8, _ETIMEDOUT@GOTPAGE
Lloh5:
	ldr	x8, [x8, _ETIMEDOUT@GOTPAGEOFF]
Lloh6:
	ldr	w8, [x8]
	neg	w0, w8
	b	LBB0_10
LBB0_4:
	ldr	x8, [x21]
Lloh7:
	adrp	x22, _JZ_REG_NAND_ECC_CTRL@GOTPAGE
Lloh8:
	ldr	x22, [x22, _JZ_REG_NAND_ECC_CTRL@GOTPAGEOFF]
	ldr	x9, [x22]
	add	x0, x9, x8
	bl	_readl
Lloh9:
	adrp	x8, _JZ_NAND_ECC_CTRL_ENABLE@GOTPAGE
Lloh10:
	ldr	x8, [x8, _JZ_NAND_ECC_CTRL_ENABLE@GOTPAGEOFF]
Lloh11:
	ldr	w8, [x8]
	bic	w0, w0, w8
	ldr	x8, [x21]
	ldr	x9, [x22]
	add	x1, x9, x8
	bl	_writel
	ldr	w8, [x20]
	cmp	w8, #1
	b.lt	LBB0_7
; %bb.5:
	mov	x22, #0
Lloh12:
	adrp	x23, _JZ_REG_NAND_PAR0@GOTPAGE
Lloh13:
	ldr	x23, [x23, _JZ_REG_NAND_PAR0@GOTPAGEOFF]
LBB0_6:                                 ; =>This Inner Loop Header: Depth=1
	ldr	x8, [x21]
	ldr	x9, [x23]
	add	x8, x8, x9
	add	x0, x22, x8
	bl	_readb
	str	w0, [x19, x22, lsl #2]
	add	x22, x22, #1
	ldrsw	x8, [x20]
	cmp	x22, x8
	b.lt	LBB0_6
LBB0_7:
Lloh14:
	adrp	x21, _empty_block_ecc@GOTPAGE
Lloh15:
	ldr	x21, [x21, _empty_block_ecc@GOTPAGEOFF]
	ldr	w20, [x21]
	mov	x0, x20
	bl	_ARRAY_SIZE
	mov	x2, x0
	mov	x0, x19
	mov	x1, x20
	bl	_memcmp
	cbnz	x0, LBB0_9
; %bb.8:
	ldr	w0, [x21]
	bl	_ARRAY_SIZE
	mov	x2, x0
	mov	x0, x19
	mov	w1, #255
	bl	_memset
LBB0_9:
	mov	w0, #0
LBB0_10:
	ldp	x29, x30, [sp, #48]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #32]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #16]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp], #64             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh4, Lloh5, Lloh6
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGot	Lloh7, Lloh8
	.loh AdrpLdrGot	Lloh12, Lloh13
	.loh AdrpLdrGot	Lloh14, Lloh15
	.cfi_endproc
                                        ; -- End function
	.comm	_JZ_REG_NAND_IRQ_STAT,8,3       ; @JZ_REG_NAND_IRQ_STAT
	.comm	_JZ_NAND_STATUS_ENC_FINISH,4,2  ; @JZ_NAND_STATUS_ENC_FINISH
	.comm	_ETIMEDOUT,4,2                  ; @ETIMEDOUT
	.comm	_JZ_REG_NAND_ECC_CTRL,8,3       ; @JZ_REG_NAND_ECC_CTRL
	.comm	_JZ_NAND_ECC_CTRL_ENABLE,4,2    ; @JZ_NAND_ECC_CTRL_ENABLE
	.comm	_JZ_REG_NAND_PAR0,8,3           ; @JZ_REG_NAND_PAR0
	.comm	_empty_block_ecc,4,2            ; @empty_block_ecc
	.no_dead_strip	_jz4740_ecc_calculate
.subsections_via_symbols
