	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function brcmnand_write
_brcmnand_write:                        ## @brcmnand_write
	.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	%r8, -48(%rbp)                  ## 8-byte Spill
	movq	%rcx, %r14
	movq	%rdx, %r12
	movq	%rdi, %rbx
	movq	%rsi, -88(%rbp)                 ## 8-byte Spill
	movq	%rsi, %rdi
	callq	_nand_get_controller_data
	movq	%rax, %r13
	movq	8(%rax), %r15
	movq	%rbx, -72(%rbp)                 ## 8-byte Spill
	movl	(%rbx), %edx
	movq	_FC_SHIFT@GOTPCREL(%rip), %rax
	movb	(%rax), %cl
	shrl	%cl, %edx
	movl	%edx, -52(%rbp)                 ## 4-byte Spill
	movl	4(%r15), %edi
	leaq	L_.str(%rip), %rsi
	movq	%r12, %rdx
	movq	%r14, %rcx
	callq	_dev_dbg
	movl	%r14d, %edi
	andl	$3, %edi
	callq	_unlikely
	testq	%rax, %rax
	movq	%r12, -64(%rbp)                 ## 8-byte Spill
	je	LBB0_2
## %bb.1:
	movl	4(%r15), %edi
	leaq	L_.str.1(%rip), %rsi
	movq	%r14, %rdx
	callq	_dev_warn
	andq	$-4, %r14
LBB0_2:
	xorl	%ebx, %ebx
	movq	-72(%rbp), %rdi                 ## 8-byte Reload
	xorl	%esi, %esi
	callq	_brcmnand_wp
	cmpl	$0, (%r15)
	je	LBB0_4
	.p2align	4, 0x90
LBB0_3:                                 ## =>This Inner Loop Header: Depth=1
	movq	%r15, %rdi
	movl	%ebx, %esi
	movl	$-1, %edx
	callq	_oob_reg_write
	addl	$4, %ebx
	cmpl	(%r15), %ebx
	jb	LBB0_3
LBB0_4:
	movq	%r15, %rdi
	callq	_has_flash_dma
	cmpq	$0, -48(%rbp)                   ## 8-byte Folded Reload
	jne	LBB0_9
## %bb.5:
	testq	%rax, %rax
	je	LBB0_9
## %bb.6:
	movq	%r14, %rdi
	callq	_flash_dma_buf_ok
	testq	%rax, %rax
	je	LBB0_9
## %bb.7:
	movq	-72(%rbp), %rax                 ## 8-byte Reload
	movl	(%rax), %ecx
	movq	_CMD_PROGRAM_PAGE@GOTPCREL(%rip), %rax
	movl	(%rax), %r8d
	movq	%r13, %rdi
	movq	-64(%rbp), %rsi                 ## 8-byte Reload
	movq	%r14, %rdx
	callq	_brcmnand_dma_trans
	testq	%rax, %rax
	jne	LBB0_8
	jmp	LBB0_29
LBB0_9:
	cmpl	$0, -52(%rbp)                   ## 4-byte Folded Reload
	je	LBB0_29
## %bb.10:
	movq	%r13, -80(%rbp)                 ## 8-byte Spill
	xorl	%r13d, %r13d
	movq	_FC_WORDS@GOTPCREL(%rip), %r12
	movq	-64(%rbp), %rbx                 ## 8-byte Reload
	.p2align	4, 0x90
LBB0_11:                                ## =>This Loop Header: Depth=1
                                        ##     Child Loop BB0_14 Depth 2
                                        ##     Child Loop BB0_22 Depth 2
	movq	-72(%rbp), %rdi                 ## 8-byte Reload
	movq	%rbx, %rsi
	callq	_brcmnand_set_cmd_addr
	testq	%r14, %r14
	movq	%r13, -96(%rbp)                 ## 8-byte Spill
	je	LBB0_16
## %bb.12:                              ##   in Loop: Header=BB0_11 Depth=1
	movq	%rbx, -64(%rbp)                 ## 8-byte Spill
	movl	8(%r15), %edi
	xorl	%esi, %esi
	callq	_brcmnand_soc_data_bus_prepare
	cmpl	$0, (%r12)
	je	LBB0_15
## %bb.13:                              ##   in Loop: Header=BB0_11 Depth=1
	xorl	%ebx, %ebx
	.p2align	4, 0x90
LBB0_14:                                ##   Parent Loop BB0_11 Depth=1
                                        ## =>  This Inner Loop Header: Depth=2
	movl	(%r14), %edx
	movq	%r15, %rdi
	movl	%ebx, %esi
	callq	_brcmnand_write_fc
	incl	%ebx
	addq	$4, %r14
	cmpl	(%r12), %ebx
	jb	LBB0_14
LBB0_15:                                ##   in Loop: Header=BB0_11 Depth=1
	movl	8(%r15), %edi
	xorl	%esi, %esi
	callq	_brcmnand_soc_data_bus_unprepare
LBB0_24:                                ##   in Loop: Header=BB0_11 Depth=1
	movq	-64(%rbp), %rbx                 ## 8-byte Reload
	cmpq	$0, -48(%rbp)                   ## 8-byte Folded Reload
	je	LBB0_25
LBB0_20:                                ##   in Loop: Header=BB0_11 Depth=1
	movq	-72(%rbp), %rax                 ## 8-byte Reload
	movl	4(%rax), %eax
	xorl	%edx, %edx
	divl	-52(%rbp)                       ## 4-byte Folded Reload
	movq	-80(%rbp), %r12                 ## 8-byte Reload
	movl	(%r12), %r8d
	movq	%r15, %rdi
	movl	%r13d, %esi
	movq	-48(%rbp), %r13                 ## 8-byte Reload
	movq	%r13, %rdx
	movl	%eax, %ecx
	callq	_write_oob_to_regs
	cltq
	leaq	(%r13,%rax,4), %r13
	movq	%r13, -48(%rbp)                 ## 8-byte Spill
	jmp	LBB0_26
	.p2align	4, 0x90
LBB0_16:                                ##   in Loop: Header=BB0_11 Depth=1
	cmpq	$0, -48(%rbp)                   ## 8-byte Folded Reload
	je	LBB0_17
## %bb.18:                              ##   in Loop: Header=BB0_11 Depth=1
	cmpl	$0, (%r12)
	je	LBB0_19
## %bb.21:                              ##   in Loop: Header=BB0_11 Depth=1
	movq	%rbx, -64(%rbp)                 ## 8-byte Spill
	xorl	%ebx, %ebx
	.p2align	4, 0x90
LBB0_22:                                ##   Parent Loop BB0_11 Depth=1
                                        ## =>  This Inner Loop Header: Depth=2
	movq	%r15, %rdi
	movl	%ebx, %esi
	movl	$-1, %edx
	callq	_brcmnand_write_fc
	incl	%ebx
	cmpl	(%r12), %ebx
	jb	LBB0_22
## %bb.23:                              ##   in Loop: Header=BB0_11 Depth=1
	xorl	%r14d, %r14d
	jmp	LBB0_24
LBB0_17:                                ##   in Loop: Header=BB0_11 Depth=1
	xorl	%r14d, %r14d
LBB0_25:                                ##   in Loop: Header=BB0_11 Depth=1
	xorl	%eax, %eax
	movq	%rax, -48(%rbp)                 ## 8-byte Spill
	movq	-80(%rbp), %r12                 ## 8-byte Reload
LBB0_26:                                ##   in Loop: Header=BB0_11 Depth=1
	movq	_CMD_PROGRAM_PAGE@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r12, %rdi
	callq	_brcmnand_send_cmd
	movq	-88(%rbp), %rdi                 ## 8-byte Reload
	callq	_brcmnand_waitfunc
	movq	_NAND_STATUS_FAIL@GOTPCREL(%rip), %rcx
	testl	%eax, (%rcx)
	jne	LBB0_27
## %bb.28:                              ##   in Loop: Header=BB0_11 Depth=1
	movq	-96(%rbp), %r13                 ## 8-byte Reload
	incl	%r13d
	movq	_FC_BYTES@GOTPCREL(%rip), %rax
	addq	(%rax), %rbx
	cmpl	-52(%rbp), %r13d                ## 4-byte Folded Reload
	movq	_FC_WORDS@GOTPCREL(%rip), %r12
	jne	LBB0_11
	jmp	LBB0_29
LBB0_19:                                ##   in Loop: Header=BB0_11 Depth=1
	xorl	%r14d, %r14d
	jmp	LBB0_20
LBB0_29:
	xorl	%ebx, %ebx
	jmp	LBB0_30
LBB0_27:
	movl	4(%r15), %edi
	leaq	L_.str.2(%rip), %rsi
	movq	%rbx, %rdx
	callq	_dev_info
LBB0_8:
	movq	_EIO@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
LBB0_30:
	movq	-72(%rbp), %rdi                 ## 8-byte Reload
	movl	$1, %esi
	callq	_brcmnand_wp
	movl	%ebx, %eax
	addq	$56, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_FC_SHIFT,4,2                   ## @FC_SHIFT
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"write %llx <- %p\n"

L_.str.1:                               ## @.str.1
	.asciz	"unaligned buffer: %p\n"

	.comm	_CMD_PROGRAM_PAGE,4,2           ## @CMD_PROGRAM_PAGE
	.comm	_EIO,4,2                        ## @EIO
	.comm	_FC_WORDS,4,2                   ## @FC_WORDS
	.comm	_NAND_STATUS_FAIL,4,2           ## @NAND_STATUS_FAIL
L_.str.2:                               ## @.str.2
	.asciz	"program failed at %llx\n"

	.comm	_FC_BYTES,8,3                   ## @FC_BYTES
	.no_dead_strip	_brcmnand_write
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function brcmnand_write
_brcmnand_write:                        ; @brcmnand_write
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #112
	.cfi_def_cfa_offset 112
	stp	x28, x27, [sp, #16]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #32]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #48]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #64]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #80]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #96]             ; 16-byte Folded Spill
	add	x29, sp, #96
	.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	x23, x4
	mov	x25, x3
	mov	x20, x2
	mov	x19, x0
	str	x1, [sp, #8]                    ; 8-byte Folded Spill
	mov	x0, x1
	bl	_nand_get_controller_data
	mov	x22, x0
	ldr	x24, [x0, #8]
	ldr	w21, [x19]
Lloh0:
	adrp	x8, _FC_SHIFT@GOTPAGE
Lloh1:
	ldr	x8, [x8, _FC_SHIFT@GOTPAGEOFF]
Lloh2:
	ldr	w27, [x8]
	ldr	w0, [x24, #4]
Lloh3:
	adrp	x1, l_.str@PAGE
Lloh4:
	add	x1, x1, l_.str@PAGEOFF
	mov	x2, x20
	mov	x3, x25
	bl	_dev_dbg
	and	x0, x25, #0x3
	bl	_unlikely
	cbz	x0, LBB0_2
; %bb.1:
	ldr	w0, [x24, #4]
Lloh5:
	adrp	x1, l_.str.1@PAGE
Lloh6:
	add	x1, x1, l_.str.1@PAGEOFF
	mov	x2, x25
	bl	_dev_warn
	and	x25, x25, #0xfffffffffffffffc
LBB0_2:
	mov	x0, x19
	mov	w1, #0
	bl	_brcmnand_wp
	ldr	w8, [x24]
	cbz	w8, LBB0_5
; %bb.3:
	mov	w26, #0
LBB0_4:                                 ; =>This Inner Loop Header: Depth=1
	mov	x0, x24
	mov	x1, x26
	mov	w2, #-1
	bl	_oob_reg_write
	add	w26, w26, #4
	ldr	w8, [x24]
	cmp	w26, w8
	b.lo	LBB0_4
LBB0_5:
	mov	x0, x24
	bl	_has_flash_dma
	cbnz	x23, LBB0_9
; %bb.6:
	cbz	x0, LBB0_9
; %bb.7:
	mov	x0, x25
	bl	_flash_dma_buf_ok
	cbz	x0, LBB0_9
; %bb.8:
	ldr	w3, [x19]
Lloh7:
	adrp	x8, _CMD_PROGRAM_PAGE@GOTPAGE
Lloh8:
	ldr	x8, [x8, _CMD_PROGRAM_PAGE@GOTPAGEOFF]
Lloh9:
	ldr	w4, [x8]
	mov	x0, x22
	mov	x1, x20
	mov	x2, x25
	bl	_brcmnand_dma_trans
	cbnz	x0, LBB0_28
	b	LBB0_26
LBB0_9:
	lsr	w28, w21, w27
	cbz	w28, LBB0_26
; %bb.10:
	mov	w26, #0
Lloh10:
	adrp	x21, _FC_WORDS@GOTPAGE
Lloh11:
	ldr	x21, [x21, _FC_WORDS@GOTPAGEOFF]
LBB0_11:                                ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_14 Depth 2
                                        ;     Child Loop BB0_22 Depth 2
	mov	x0, x19
	mov	x1, x20
	bl	_brcmnand_set_cmd_addr
	cbz	x25, LBB0_19
; %bb.12:                               ;   in Loop: Header=BB0_11 Depth=1
	ldr	w0, [x24, #8]
	mov	w1, #0
	bl	_brcmnand_soc_data_bus_prepare
	ldr	w8, [x21]
	cbz	w8, LBB0_15
; %bb.13:                               ;   in Loop: Header=BB0_11 Depth=1
	mov	w27, #0
LBB0_14:                                ;   Parent Loop BB0_11 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	ldr	w2, [x25], #4
	mov	x0, x24
	mov	x1, x27
	bl	_brcmnand_write_fc
	add	w27, w27, #1
	ldr	w8, [x21]
	cmp	w27, w8
	b.lo	LBB0_14
LBB0_15:                                ;   in Loop: Header=BB0_11 Depth=1
	ldr	w0, [x24, #8]
	mov	w1, #0
	bl	_brcmnand_soc_data_bus_unprepare
	cbz	x23, LBB0_17
LBB0_16:                                ;   in Loop: Header=BB0_11 Depth=1
	ldr	w8, [x19, #4]
	ldr	w4, [x22]
	udiv	w3, w8, w28
	mov	x0, x24
	mov	x1, x26
	mov	x2, x23
	bl	_write_oob_to_regs
	add	x23, x23, w0, sxtw #2
LBB0_17:                                ;   in Loop: Header=BB0_11 Depth=1
Lloh12:
	adrp	x8, _CMD_PROGRAM_PAGE@GOTPAGE
Lloh13:
	ldr	x8, [x8, _CMD_PROGRAM_PAGE@GOTPAGEOFF]
Lloh14:
	ldr	w1, [x8]
	mov	x0, x22
	bl	_brcmnand_send_cmd
	ldr	x0, [sp, #8]                    ; 8-byte Folded Reload
	bl	_brcmnand_waitfunc
Lloh15:
	adrp	x8, _NAND_STATUS_FAIL@GOTPAGE
Lloh16:
	ldr	x8, [x8, _NAND_STATUS_FAIL@GOTPAGEOFF]
Lloh17:
	ldr	w8, [x8]
	tst	w8, w0
	b.ne	LBB0_27
; %bb.18:                               ;   in Loop: Header=BB0_11 Depth=1
	add	w26, w26, #1
Lloh18:
	adrp	x8, _FC_BYTES@GOTPAGE
Lloh19:
	ldr	x8, [x8, _FC_BYTES@GOTPAGEOFF]
Lloh20:
	ldr	x8, [x8]
	add	x20, x8, x20
	cmp	w26, w28
	b.ne	LBB0_11
	b	LBB0_26
LBB0_19:                                ;   in Loop: Header=BB0_11 Depth=1
	cbz	x23, LBB0_24
; %bb.20:                               ;   in Loop: Header=BB0_11 Depth=1
	ldr	w8, [x21]
	cbz	w8, LBB0_25
; %bb.21:                               ;   in Loop: Header=BB0_11 Depth=1
	mov	w25, #0
LBB0_22:                                ;   Parent Loop BB0_11 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	mov	x0, x24
	mov	x1, x25
	mov	w2, #-1
	bl	_brcmnand_write_fc
	add	w25, w25, #1
	ldr	w8, [x21]
	cmp	w25, w8
	b.lo	LBB0_22
; %bb.23:                               ;   in Loop: Header=BB0_11 Depth=1
	mov	x25, #0
	cbnz	x23, LBB0_16
	b	LBB0_17
LBB0_24:                                ;   in Loop: Header=BB0_11 Depth=1
	mov	x25, #0
	b	LBB0_17
LBB0_25:                                ;   in Loop: Header=BB0_11 Depth=1
	mov	x25, #0
	b	LBB0_16
LBB0_26:
	mov	w20, #0
	b	LBB0_29
LBB0_27:
	ldr	w0, [x24, #4]
Lloh21:
	adrp	x1, l_.str.2@PAGE
Lloh22:
	add	x1, x1, l_.str.2@PAGEOFF
	mov	x2, x20
	bl	_dev_info
LBB0_28:
Lloh23:
	adrp	x8, _EIO@GOTPAGE
Lloh24:
	ldr	x8, [x8, _EIO@GOTPAGEOFF]
Lloh25:
	ldr	w8, [x8]
	neg	w20, w8
LBB0_29:
	mov	x0, x19
	mov	w1, #1
	bl	_brcmnand_wp
	mov	x0, x20
	ldp	x29, x30, [sp, #96]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #80]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #64]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #48]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #32]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #112
	ret
	.loh AdrpAdd	Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpAdd	Lloh5, Lloh6
	.loh AdrpLdrGotLdr	Lloh7, Lloh8, Lloh9
	.loh AdrpLdrGot	Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh15, Lloh16, Lloh17
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh18, Lloh19, Lloh20
	.loh AdrpAdd	Lloh21, Lloh22
	.loh AdrpLdrGotLdr	Lloh23, Lloh24, Lloh25
	.cfi_endproc
                                        ; -- End function
	.comm	_FC_SHIFT,4,2                   ; @FC_SHIFT
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"write %llx <- %p\n"

l_.str.1:                               ; @.str.1
	.asciz	"unaligned buffer: %p\n"

	.comm	_CMD_PROGRAM_PAGE,4,2           ; @CMD_PROGRAM_PAGE
	.comm	_EIO,4,2                        ; @EIO
	.comm	_FC_WORDS,4,2                   ; @FC_WORDS
	.comm	_NAND_STATUS_FAIL,4,2           ; @NAND_STATUS_FAIL
l_.str.2:                               ; @.str.2
	.asciz	"program failed at %llx\n"

	.comm	_FC_BYTES,8,3                   ; @FC_BYTES
	.no_dead_strip	_brcmnand_write
.subsections_via_symbols
