	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function brcmnand_read
_brcmnand_read:                         ## @brcmnand_read
	.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	$72, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%r9, %rbx
	movq	%r8, %r14
	movl	%ecx, -44(%rbp)                 ## 4-byte Spill
	movq	%rdx, %r15
	movq	%rdi, -56(%rbp)                 ## 8-byte Spill
	movq	%rsi, -88(%rbp)                 ## 8-byte Spill
	movq	%rsi, %rdi
	callq	_nand_get_controller_data
	movq	%rax, -104(%rbp)                ## 8-byte Spill
	movq	(%rax), %r13
	movq	$0, -80(%rbp)
	movl	4(%r13), %edi
	leaq	L_.str(%rip), %rsi
	xorl	%r12d, %r12d
	movq	%r15, -64(%rbp)                 ## 8-byte Spill
	movq	%r15, %rdx
	movq	%r14, -72(%rbp)                 ## 8-byte Spill
	movq	%r14, %rcx
	xorl	%eax, %eax
	callq	_dev_dbg
	movb	$1, %r15b
	movq	%rbx, -96(%rbp)                 ## 8-byte Spill
	jmp	LBB0_1
	.p2align	4, 0x90
LBB0_14:                                ##   in Loop: Header=BB0_1 Depth=1
	cmpl	$1793, %eax                     ## imm = 0x701
	sete	%cl
	movb	$1, %r12b
	testb	%cl, %r15b
	movl	$0, %r15d
	movq	-96(%rbp), %rbx                 ## 8-byte Reload
	je	LBB0_15
LBB0_1:                                 ## =>This Inner Loop Header: Depth=1
	movq	%r13, %rdi
	callq	_brcmnand_clear_ecc_addr
	movq	%r13, %rdi
	callq	_has_flash_dma
	testq	%rbx, %rbx
	jne	LBB0_9
## %bb.2:                               ##   in Loop: Header=BB0_1 Depth=1
	testq	%rax, %rax
	je	LBB0_9
## %bb.3:                               ##   in Loop: Header=BB0_1 Depth=1
	movq	-72(%rbp), %rdi                 ## 8-byte Reload
	callq	_flash_dma_buf_ok
	testq	%rax, %rax
	je	LBB0_9
## %bb.4:                               ##   in Loop: Header=BB0_1 Depth=1
	movq	_FC_BYTES@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	imull	-44(%rbp), %ecx                 ## 4-byte Folded Reload
	movq	_CMD_PAGE_READ@GOTPCREL(%rip), %rax
	movl	(%rax), %r8d
	movq	-104(%rbp), %rdi                ## 8-byte Reload
	movq	-64(%rbp), %rsi                 ## 8-byte Reload
	movq	-72(%rbp), %rdx                 ## 8-byte Reload
	callq	_brcmnand_dma_trans
	testl	%eax, %eax
	je	LBB0_5
## %bb.6:                               ##   in Loop: Header=BB0_1 Depth=1
	movl	%eax, %r14d
	movl	%eax, %edi
	callq	_mtd_is_bitflip_or_eccerr
	testq	%rax, %rax
	je	LBB0_8
## %bb.7:                               ##   in Loop: Header=BB0_1 Depth=1
	movq	-64(%rbp), %rax                 ## 8-byte Reload
	movq	%rax, -80(%rbp)
	jmp	LBB0_12
	.p2align	4, 0x90
LBB0_9:                                 ##   in Loop: Header=BB0_1 Depth=1
	testq	%rbx, %rbx
	movq	-56(%rbp), %r14                 ## 8-byte Reload
	je	LBB0_11
## %bb.10:                              ##   in Loop: Header=BB0_1 Depth=1
	movl	12(%r14), %edx
	movq	%rbx, %rdi
	movl	$153, %esi
	callq	_memset
LBB0_11:                                ##   in Loop: Header=BB0_1 Depth=1
	leaq	-80(%rbp), %rax
	movq	%rax, (%rsp)
	movq	%r14, %rdi
	movq	-88(%rbp), %rsi                 ## 8-byte Reload
	movq	-64(%rbp), %rdx                 ## 8-byte Reload
	movl	-44(%rbp), %ecx                 ## 4-byte Reload
	movq	-72(%rbp), %r8                  ## 8-byte Reload
	movq	%rbx, %r9
	callq	_brcmnand_read_by_pio
	movl	%eax, %r14d
LBB0_12:                                ##   in Loop: Header=BB0_1 Depth=1
	movl	%r14d, %edi
	callq	_mtd_is_eccerr
	testq	%rax, %rax
	je	LBB0_18
## %bb.13:                              ##   in Loop: Header=BB0_1 Depth=1
	movl	(%r13), %eax
	cmpl	$1792, %eax                     ## imm = 0x700
	jne	LBB0_14
## %bb.22:                              ##   in Loop: Header=BB0_1 Depth=1
	xorl	%r15d, %r15d
	testb	$1, %r12b
	movb	$1, %r12b
	movq	-96(%rbp), %rbx                 ## 8-byte Reload
	je	LBB0_1
	jmp	LBB0_16
LBB0_5:                                 ##   in Loop: Header=BB0_1 Depth=1
	xorl	%r14d, %r14d
	jmp	LBB0_12
LBB0_18:
	movl	%r14d, %edi
	callq	_mtd_is_bitflip
	testq	%rax, %rax
	je	LBB0_19
## %bb.20:
	movq	%r13, %rdi
	callq	_brcmnand_count_corrected
	movl	%eax, %r14d
	movl	4(%r13), %edi
	movq	-80(%rbp), %rdx
	leaq	L_.str.2(%rip), %rsi
	xorl	%eax, %eax
	callq	_dev_dbg
	movq	-56(%rbp), %rax                 ## 8-byte Reload
	addl	%r14d, 4(%rax)
	movl	(%rax), %edi
	movl	%r14d, %esi
	callq	_max
	movl	%eax, %r14d
	jmp	LBB0_21
LBB0_15:
	cmpl	$1793, %eax                     ## imm = 0x701
	jg	LBB0_17
LBB0_16:
	movq	-56(%rbp), %rdi                 ## 8-byte Reload
	movq	-88(%rbp), %rsi                 ## 8-byte Reload
	movq	-72(%rbp), %rdx                 ## 8-byte Reload
	movq	-64(%rbp), %rcx                 ## 8-byte Reload
	callq	_brcmstb_nand_verify_erased_page
	movl	%eax, %r14d
	testl	%eax, %eax
	jns	LBB0_21
LBB0_17:
	movl	4(%r13), %edi
	movq	-80(%rbp), %rdx
	leaq	L_.str.1(%rip), %rsi
	xorl	%r14d, %r14d
	xorl	%eax, %eax
	callq	_dev_dbg
	movq	-56(%rbp), %rax                 ## 8-byte Reload
	incl	8(%rax)
	jmp	LBB0_21
LBB0_19:
	xorl	%r14d, %r14d
	jmp	LBB0_21
LBB0_8:
	movq	_EIO@GOTPCREL(%rip), %rax
	xorl	%r14d, %r14d
	subl	(%rax), %r14d
LBB0_21:
	movl	%r14d, %eax
	addq	$72, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"read %llx -> %p\n"

	.comm	_FC_BYTES,4,2                   ## @FC_BYTES
	.comm	_CMD_PAGE_READ,4,2              ## @CMD_PAGE_READ
	.comm	_EIO,4,2                        ## @EIO
L_.str.1:                               ## @.str.1
	.asciz	"uncorrectable error at 0x%llx\n"

L_.str.2:                               ## @.str.2
	.asciz	"corrected error at 0x%llx\n"

	.no_dead_strip	_brcmnand_read
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function brcmnand_read
_brcmnand_read:                         ; @brcmnand_read
	.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
	mov	x24, x5
	mov	x21, x4
	mov	x25, x3
	mov	x22, x2
	mov	x23, x1
	mov	x19, x0
	mov	x0, x1
	bl	_nand_get_controller_data
	ldr	x20, [x0]
	stp	x0, xzr, [sp, #16]              ; 8-byte Folded Spill
	ldr	w0, [x20, #4]
	str	x21, [sp]
Lloh0:
	adrp	x1, l_.str@PAGE
Lloh1:
	add	x1, x1, l_.str@PAGEOFF
	mov	x2, x22
	bl	_dev_dbg
	mov	w8, #0
	mov	w28, #1
	b	LBB0_2
LBB0_1:                                 ;   in Loop: Header=BB0_2 Depth=1
	cmp	w9, #1793
	cset	w8, eq
	and	w10, w28, w8
	mov	w8, #1
	mov	w28, #0
	tbz	w10, #0, LBB0_16
LBB0_2:                                 ; =>This Inner Loop Header: Depth=1
	mov	x26, x8
	mov	x0, x20
	bl	_brcmnand_clear_ecc_addr
	mov	x0, x20
	bl	_has_flash_dma
	cbnz	x24, LBB0_8
; %bb.3:                                ;   in Loop: Header=BB0_2 Depth=1
	cbz	x0, LBB0_8
; %bb.4:                                ;   in Loop: Header=BB0_2 Depth=1
	mov	x0, x21
	bl	_flash_dma_buf_ok
	cbz	x0, LBB0_8
; %bb.5:                                ;   in Loop: Header=BB0_2 Depth=1
Lloh2:
	adrp	x8, _FC_BYTES@GOTPAGE
Lloh3:
	ldr	x8, [x8, _FC_BYTES@GOTPAGEOFF]
Lloh4:
	ldr	w8, [x8]
	mul	w3, w8, w25
Lloh5:
	adrp	x8, _CMD_PAGE_READ@GOTPAGE
Lloh6:
	ldr	x8, [x8, _CMD_PAGE_READ@GOTPAGEOFF]
Lloh7:
	ldr	w4, [x8]
	ldr	x0, [sp, #16]                   ; 8-byte Folded Reload
	mov	x1, x22
	mov	x2, x21
	bl	_brcmnand_dma_trans
	mov	x27, x0
	cbz	w0, LBB0_11
; %bb.6:                                ;   in Loop: Header=BB0_2 Depth=1
	mov	x0, x27
	bl	_mtd_is_bitflip_or_eccerr
	cbz	x0, LBB0_19
; %bb.7:                                ;   in Loop: Header=BB0_2 Depth=1
	str	x22, [sp, #24]
	b	LBB0_11
LBB0_8:                                 ;   in Loop: Header=BB0_2 Depth=1
	cbz	x24, LBB0_10
; %bb.9:                                ;   in Loop: Header=BB0_2 Depth=1
	ldr	w2, [x19, #12]
	mov	x0, x24
	mov	w1, #153
	bl	_memset
LBB0_10:                                ;   in Loop: Header=BB0_2 Depth=1
	add	x6, sp, #24
	mov	x0, x19
	mov	x1, x23
	mov	x2, x22
	mov	x3, x25
	mov	x4, x21
	mov	x5, x24
	bl	_brcmnand_read_by_pio
	mov	x27, x0
LBB0_11:                                ;   in Loop: Header=BB0_2 Depth=1
	mov	x0, x27
	bl	_mtd_is_eccerr
	cbz	x0, LBB0_14
; %bb.12:                               ;   in Loop: Header=BB0_2 Depth=1
	ldr	w9, [x20]
	cmp	w9, #1792
	b.ne	LBB0_1
; %bb.13:                               ;   in Loop: Header=BB0_2 Depth=1
	mov	w28, #0
	mov	w8, #1
	tbz	w26, #0, LBB0_2
	b	LBB0_17
LBB0_14:
	mov	x0, x27
	bl	_mtd_is_bitflip
	cbz	x0, LBB0_20
; %bb.15:
	mov	x0, x20
	bl	_brcmnand_count_corrected
	mov	x21, x0
	ldr	w0, [x20, #4]
	ldr	x2, [sp, #24]
Lloh8:
	adrp	x1, l_.str.2@PAGE
Lloh9:
	add	x1, x1, l_.str.2@PAGEOFF
	bl	_dev_dbg
	ldp	w0, w8, [x19]
	add	w8, w8, w21
	str	w8, [x19, #4]
	mov	x1, x21
	bl	_max
	b	LBB0_20
LBB0_16:
	cmp	w9, #1793
	b.gt	LBB0_18
LBB0_17:
	mov	x0, x19
	mov	x1, x23
	mov	x2, x21
	mov	x3, x22
	bl	_brcmstb_nand_verify_erased_page
	tbz	w0, #31, LBB0_20
LBB0_18:
	ldr	w0, [x20, #4]
	ldr	x2, [sp, #24]
Lloh10:
	adrp	x1, l_.str.1@PAGE
Lloh11:
	add	x1, x1, l_.str.1@PAGEOFF
	bl	_dev_dbg
	mov	w0, #0
	ldr	w8, [x19, #8]
	add	w8, w8, #1
	str	w8, [x19, #8]
	b	LBB0_20
LBB0_19:
Lloh12:
	adrp	x8, _EIO@GOTPAGE
Lloh13:
	ldr	x8, [x8, _EIO@GOTPAGEOFF]
Lloh14:
	ldr	w8, [x8]
	neg	w0, w8
LBB0_20:
	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 AdrpAdd	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.loh AdrpAdd	Lloh8, Lloh9
	.loh AdrpAdd	Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"read %llx -> %p\n"

	.comm	_FC_BYTES,4,2                   ; @FC_BYTES
	.comm	_CMD_PAGE_READ,4,2              ; @CMD_PAGE_READ
	.comm	_EIO,4,2                        ; @EIO
l_.str.1:                               ; @.str.1
	.asciz	"uncorrectable error at 0x%llx\n"

l_.str.2:                               ; @.str.2
	.asciz	"corrected error at 0x%llx\n"

	.no_dead_strip	_brcmnand_read
.subsections_via_symbols
