	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function denali_sw_ecc_fixup
_denali_sw_ecc_fixup:                   ## @denali_sw_ecc_fixup
	.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	$56, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdx, -88(%rbp)                 ## 8-byte Spill
	movq	%rsi, -96(%rbp)                 ## 8-byte Spill
	movq	%rdi, %rbx
	callq	_to_denali_controller
	movq	%rax, %r14
	movq	%rbx, %rdi
	callq	_nand_to_mtd
	movq	%rax, -80(%rbp)                 ## 8-byte Spill
	movl	(%rbx), %eax
	movl	%eax, -68(%rbp)                 ## 4-byte Spill
	movq	%r14, -64(%rbp)                 ## 8-byte Spill
	movq	%r14, %rdi
	callq	_denali_reset_irq
	xorl	%r14d, %r14d
	movl	$0, -44(%rbp)                   ## 4-byte Folded Spill
	movl	$0, -56(%rbp)                   ## 4-byte Folded Spill
	jmp	LBB0_1
	.p2align	4, 0x90
LBB0_2:                                 ##   in Loop: Header=BB0_1 Depth=1
	movl	%esi, -56(%rbp)                 ## 4-byte Spill
	movl	%r14d, %edi
	callq	_BIT
	movq	-96(%rbp), %rcx                 ## 8-byte Reload
	orq	%rax, (%rcx)
LBB0_6:                                 ##   in Loop: Header=BB0_1 Depth=1
	movq	_ERR_CORRECTION_INFO__LAST_ERR@GOTPCREL(%rip), %rax
	testl	%r13d, (%rax)
	jne	LBB0_7
LBB0_1:                                 ## =>This Inner Loop Header: Depth=1
	movl	%r14d, %r12d
	movq	_ECC_ERROR_ADDRESS@GOTPCREL(%rip), %rax
	movq	(%rax), %rdi
	movq	-64(%rbp), %r13                 ## 8-byte Reload
	addq	8(%r13), %rdi
	callq	_ioread32
	movl	%eax, %ebx
	movq	_ECC_ERROR_ADDRESS__SECTOR@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movl	%ebx, %esi
	callq	_FIELD_GET
	movq	%rax, %r14
	movq	_ECC_ERROR_ADDRESS__OFFSET@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movl	%ebx, %esi
	callq	_FIELD_GET
	movq	%rax, %r15
	movq	_ERR_CORRECTION_INFO@GOTPCREL(%rip), %rax
	movq	(%rax), %rdi
	addq	8(%r13), %rdi
	callq	_ioread32
	movl	%eax, %r13d
	movq	_ERR_CORRECTION_INFO__BYTE@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movl	%r13d, %esi
	callq	_FIELD_GET
	movq	%rax, %rbx
	movq	_ERR_CORRECTION_INFO__DEVICE@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movl	%r13d, %esi
	callq	_FIELD_GET
	cmpl	%r14d, %r12d
	movl	$0, %ecx
	movl	-56(%rbp), %esi                 ## 4-byte Reload
	cmovnel	%ecx, %esi
	movq	_ERR_CORRECTION_INFO__UNCOR@GOTPCREL(%rip), %rcx
	testl	%r13d, (%rcx)
	jne	LBB0_2
## %bb.3:                               ##   in Loop: Header=BB0_1 Depth=1
	movl	-68(%rbp), %ecx                 ## 4-byte Reload
	cmpl	%r15d, %ecx
	jbe	LBB0_4
## %bb.5:                               ##   in Loop: Header=BB0_1 Depth=1
	imull	%r14d, %ecx
	addl	%r15d, %ecx
	movq	-64(%rbp), %rdx                 ## 8-byte Reload
	imull	(%rdx), %ecx
	addl	%eax, %ecx
	movslq	%ecx, %rax
	movq	%rax, -56(%rbp)                 ## 8-byte Spill
	movq	-88(%rbp), %r12                 ## 8-byte Reload
	movl	(%r12,%rax,4), %edi
	xorl	%ebx, %edi
	movl	%esi, %r15d
	callq	_hweight8
	movq	-56(%rbp), %rcx                 ## 8-byte Reload
	xorl	%ebx, (%r12,%rcx,4)
	movq	-80(%rbp), %rcx                 ## 8-byte Reload
	addl	%eax, (%rcx)
	addl	%eax, %r15d
	movl	-44(%rbp), %edi                 ## 4-byte Reload
	movl	%r15d, -56(%rbp)                ## 4-byte Spill
	movl	%r15d, %esi
	callq	_max
	movl	%eax, -44(%rbp)                 ## 4-byte Spill
	jmp	LBB0_6
LBB0_4:                                 ##   in Loop: Header=BB0_1 Depth=1
	movl	%esi, -56(%rbp)                 ## 4-byte Spill
	jmp	LBB0_6
LBB0_7:
	movq	_INTR__ECC_TRANSACTION_DONE@GOTPCREL(%rip), %rbx
	movl	(%rbx), %esi
	movq	-64(%rbp), %rdi                 ## 8-byte Reload
	callq	_denali_wait_for_irq
	movq	_EIO@GOTPCREL(%rip), %rcx
	xorl	%edx, %edx
	subl	(%rcx), %edx
	testl	%eax, (%rbx)
	movl	-44(%rbp), %eax                 ## 4-byte Reload
	cmovel	%edx, %eax
	addq	$56, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_ECC_ERROR_ADDRESS,8,3          ## @ECC_ERROR_ADDRESS
	.comm	_ECC_ERROR_ADDRESS__SECTOR,4,2  ## @ECC_ERROR_ADDRESS__SECTOR
	.comm	_ECC_ERROR_ADDRESS__OFFSET,4,2  ## @ECC_ERROR_ADDRESS__OFFSET
	.comm	_ERR_CORRECTION_INFO,8,3        ## @ERR_CORRECTION_INFO
	.comm	_ERR_CORRECTION_INFO__BYTE,4,2  ## @ERR_CORRECTION_INFO__BYTE
	.comm	_ERR_CORRECTION_INFO__DEVICE,4,2 ## @ERR_CORRECTION_INFO__DEVICE
	.comm	_ERR_CORRECTION_INFO__UNCOR,4,2 ## @ERR_CORRECTION_INFO__UNCOR
	.comm	_ERR_CORRECTION_INFO__LAST_ERR,4,2 ## @ERR_CORRECTION_INFO__LAST_ERR
	.comm	_INTR__ECC_TRANSACTION_DONE,4,2 ## @INTR__ECC_TRANSACTION_DONE
	.comm	_EIO,4,2                        ## @EIO
	.no_dead_strip	_denali_sw_ecc_fixup
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function denali_sw_ecc_fixup
_denali_sw_ecc_fixup:                   ; @denali_sw_ecc_fixup
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #128
	.cfi_def_cfa_offset 128
	stp	x28, x27, [sp, #32]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #48]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #64]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #80]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #96]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #112]            ; 16-byte Folded Spill
	add	x29, sp, #112
	.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
	str	x2, [sp, #16]                   ; 8-byte Folded Spill
	mov	x20, x1
	mov	x22, x0
	bl	_to_denali_controller
	mov	x21, x0
	mov	x0, x22
	bl	_nand_to_mtd
	str	x0, [sp, #8]                    ; 8-byte Folded Spill
	ldr	w23, [x22]
	mov	x0, x21
	bl	_denali_reset_irq
	mov	w25, #0
	str	wzr, [sp, #28]                  ; 4-byte Folded Spill
	mov	w24, #0
Lloh0:
	adrp	x22, _ERR_CORRECTION_INFO__LAST_ERR@GOTPAGE
Lloh1:
	ldr	x22, [x22, _ERR_CORRECTION_INFO__LAST_ERR@GOTPAGEOFF]
	b	LBB0_3
LBB0_1:                                 ;   in Loop: Header=BB0_3 Depth=1
	mov	x0, x25
	bl	_BIT
	ldr	x8, [x20]
	orr	x8, x8, x0
	str	x8, [x20]
LBB0_2:                                 ;   in Loop: Header=BB0_3 Depth=1
	ldr	w8, [x22]
	tst	w8, w26
	b.ne	LBB0_6
LBB0_3:                                 ; =>This Inner Loop Header: Depth=1
	mov	x19, x25
	ldr	x8, [x21, #8]
Lloh2:
	adrp	x9, _ECC_ERROR_ADDRESS@GOTPAGE
Lloh3:
	ldr	x9, [x9, _ECC_ERROR_ADDRESS@GOTPAGEOFF]
Lloh4:
	ldr	x9, [x9]
	add	x0, x9, x8
	bl	_ioread32
	mov	x26, x0
Lloh5:
	adrp	x8, _ECC_ERROR_ADDRESS__SECTOR@GOTPAGE
Lloh6:
	ldr	x8, [x8, _ECC_ERROR_ADDRESS__SECTOR@GOTPAGEOFF]
Lloh7:
	ldr	w0, [x8]
	mov	x1, x26
	bl	_FIELD_GET
	mov	x25, x0
Lloh8:
	adrp	x8, _ECC_ERROR_ADDRESS__OFFSET@GOTPAGE
Lloh9:
	ldr	x8, [x8, _ECC_ERROR_ADDRESS__OFFSET@GOTPAGEOFF]
Lloh10:
	ldr	w0, [x8]
	mov	x1, x26
	bl	_FIELD_GET
	mov	x27, x0
	ldr	x8, [x21, #8]
Lloh11:
	adrp	x9, _ERR_CORRECTION_INFO@GOTPAGE
Lloh12:
	ldr	x9, [x9, _ERR_CORRECTION_INFO@GOTPAGEOFF]
Lloh13:
	ldr	x9, [x9]
	add	x0, x9, x8
	bl	_ioread32
	mov	x26, x0
Lloh14:
	adrp	x8, _ERR_CORRECTION_INFO__BYTE@GOTPAGE
Lloh15:
	ldr	x8, [x8, _ERR_CORRECTION_INFO__BYTE@GOTPAGEOFF]
Lloh16:
	ldr	w0, [x8]
	mov	x1, x26
	bl	_FIELD_GET
	mov	x28, x0
Lloh17:
	adrp	x8, _ERR_CORRECTION_INFO__DEVICE@GOTPAGE
Lloh18:
	ldr	x8, [x8, _ERR_CORRECTION_INFO__DEVICE@GOTPAGEOFF]
Lloh19:
	ldr	w0, [x8]
	mov	x1, x26
	bl	_FIELD_GET
	cmp	w19, w25
	csel	w24, w24, wzr, eq
Lloh20:
	adrp	x8, _ERR_CORRECTION_INFO__UNCOR@GOTPAGE
Lloh21:
	ldr	x8, [x8, _ERR_CORRECTION_INFO__UNCOR@GOTPAGEOFF]
Lloh22:
	ldr	w8, [x8]
	tst	w8, w26
	b.ne	LBB0_1
; %bb.4:                                ;   in Loop: Header=BB0_3 Depth=1
	cmp	w23, w27
	b.ls	LBB0_2
; %bb.5:                                ;   in Loop: Header=BB0_3 Depth=1
	madd	w8, w23, w25, w27
	ldr	w9, [x21]
	madd	w8, w9, w8, w0
	sbfiz	x19, x8, #2, #32
	ldr	x27, [sp, #16]                  ; 8-byte Folded Reload
	ldr	w8, [x27, x19]
	eor	w0, w8, w28
	bl	_hweight8
	ldr	w8, [x27, x19]
	eor	w8, w8, w28
	str	w8, [x27, x19]
	ldr	x9, [sp, #8]                    ; 8-byte Folded Reload
	ldr	w8, [x9]
	add	w8, w8, w0
	str	w8, [x9]
	add	w24, w0, w24
	ldr	w0, [sp, #28]                   ; 4-byte Folded Reload
	mov	x1, x24
	bl	_max
	str	w0, [sp, #28]                   ; 4-byte Folded Spill
	b	LBB0_2
LBB0_6:
Lloh23:
	adrp	x19, _INTR__ECC_TRANSACTION_DONE@GOTPAGE
Lloh24:
	ldr	x19, [x19, _INTR__ECC_TRANSACTION_DONE@GOTPAGEOFF]
	ldr	w1, [x19]
	mov	x0, x21
	bl	_denali_wait_for_irq
	ldr	w8, [x19]
Lloh25:
	adrp	x9, _EIO@GOTPAGE
Lloh26:
	ldr	x9, [x9, _EIO@GOTPAGEOFF]
Lloh27:
	ldr	w9, [x9]
	tst	w8, w0
	ldr	w8, [sp, #28]                   ; 4-byte Folded Reload
	csneg	w0, w8, w9, ne
	ldp	x29, x30, [sp, #112]            ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #96]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #80]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #64]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #48]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #32]             ; 16-byte Folded Reload
	add	sp, sp, #128
	ret
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh20, Lloh21, Lloh22
	.loh AdrpLdrGotLdr	Lloh17, Lloh18, Lloh19
	.loh AdrpLdrGotLdr	Lloh14, Lloh15, Lloh16
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh25, Lloh26, Lloh27
	.loh AdrpLdrGot	Lloh23, Lloh24
	.cfi_endproc
                                        ; -- End function
	.comm	_ECC_ERROR_ADDRESS,8,3          ; @ECC_ERROR_ADDRESS
	.comm	_ECC_ERROR_ADDRESS__SECTOR,4,2  ; @ECC_ERROR_ADDRESS__SECTOR
	.comm	_ECC_ERROR_ADDRESS__OFFSET,4,2  ; @ECC_ERROR_ADDRESS__OFFSET
	.comm	_ERR_CORRECTION_INFO,8,3        ; @ERR_CORRECTION_INFO
	.comm	_ERR_CORRECTION_INFO__BYTE,4,2  ; @ERR_CORRECTION_INFO__BYTE
	.comm	_ERR_CORRECTION_INFO__DEVICE,4,2 ; @ERR_CORRECTION_INFO__DEVICE
	.comm	_ERR_CORRECTION_INFO__UNCOR,4,2 ; @ERR_CORRECTION_INFO__UNCOR
	.comm	_ERR_CORRECTION_INFO__LAST_ERR,4,2 ; @ERR_CORRECTION_INFO__LAST_ERR
	.comm	_INTR__ECC_TRANSACTION_DONE,4,2 ; @INTR__ECC_TRANSACTION_DONE
	.comm	_EIO,4,2                        ; @EIO
	.no_dead_strip	_denali_sw_ecc_fixup
.subsections_via_symbols
