	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function sunxi_nand_attach_chip
_sunxi_nand_attach_chip:                ## @sunxi_nand_attach_chip
	.cfi_startproc
## %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	pushq	%rbx
	pushq	%rax
	.cfi_offset %rbx, -24
	movq	%rdi, %rbx
	callq	_nand_get_flash_node
	movl	(%rbx), %ecx
	movq	_NAND_BBT_USE_FLASH@GOTPCREL(%rip), %rdx
	testl	%ecx, (%rdx)
	je	LBB0_2
## %bb.1:
	movq	_NAND_BBT_NO_OOB@GOTPCREL(%rip), %rdx
	orl	(%rdx), %ecx
	movl	%ecx, (%rbx)
LBB0_2:
	movl	4(%rbx), %ecx
	movq	_NAND_NEED_SCRAMBLING@GOTPCREL(%rip), %rdx
	movl	(%rdx), %edx
	andl	%ecx, %edx
	je	LBB0_4
## %bb.3:
	movq	_NAND_NO_SUBPAGE_WRITE@GOTPCREL(%rip), %rdx
	movl	(%rdx), %edx
LBB0_4:
	orl	%edx, %ecx
	movq	_NAND_SUBPAGE_READ@GOTPCREL(%rip), %rdx
	orl	(%rdx), %ecx
	movl	%ecx, 4(%rbx)
	cmpq	$0, 32(%rbx)
	je	LBB0_6
## %bb.5:
	movl	28(%rbx), %ecx
	jmp	LBB0_7
LBB0_6:
	movq	16(%rbx), %rdx
	movq	%rdx, 32(%rbx)
	movl	8(%rbx), %ecx
	movl	%ecx, 28(%rbx)
	testq	%rdx, %rdx
	je	LBB0_8
LBB0_7:
	testl	%ecx, %ecx
	je	LBB0_8
## %bb.9:
	leaq	24(%rbx), %rsi
	movl	(%rsi), %ecx
	leal	-128(%rcx), %edx
	cmpl	$2, %edx
	jae	LBB0_10
LBB0_12:
	xorl	%eax, %eax
	jmp	LBB0_13
LBB0_10:
	cmpl	$130, %ecx
	jne	LBB0_8
## %bb.11:
	movq	%rbx, %rdi
	movq	%rax, %rdx
	callq	_sunxi_nand_hw_ecc_ctrl_init
	testl	%eax, %eax
	jne	LBB0_13
	jmp	LBB0_12
LBB0_8:
	movq	_EINVAL@GOTPCREL(%rip), %rcx
	xorl	%eax, %eax
	subl	(%rcx), %eax
LBB0_13:
	addq	$8, %rsp
	popq	%rbx
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_NAND_BBT_USE_FLASH,4,2         ## @NAND_BBT_USE_FLASH
	.comm	_NAND_BBT_NO_OOB,4,2            ## @NAND_BBT_NO_OOB
	.comm	_NAND_NEED_SCRAMBLING,4,2       ## @NAND_NEED_SCRAMBLING
	.comm	_NAND_NO_SUBPAGE_WRITE,4,2      ## @NAND_NO_SUBPAGE_WRITE
	.comm	_NAND_SUBPAGE_READ,4,2          ## @NAND_SUBPAGE_READ
	.comm	_EINVAL,4,2                     ## @EINVAL
	.no_dead_strip	_sunxi_nand_attach_chip
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function sunxi_nand_attach_chip
_sunxi_nand_attach_chip:                ; @sunxi_nand_attach_chip
	.cfi_startproc
; %bb.0:
	stp	x20, x19, [sp, #-32]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 32
	stp	x29, x30, [sp, #16]             ; 16-byte Folded Spill
	add	x29, sp, #16
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
	.cfi_offset w19, -24
	.cfi_offset w20, -32
	mov	x19, x0
	bl	_nand_get_flash_node
	mov	x2, x0
	mov	x1, x19
	ldr	w8, [x1], #24
Lloh0:
	adrp	x9, _NAND_BBT_USE_FLASH@GOTPAGE
Lloh1:
	ldr	x9, [x9, _NAND_BBT_USE_FLASH@GOTPAGEOFF]
Lloh2:
	ldr	w9, [x9]
	tst	w9, w8
	b.eq	LBB0_2
; %bb.1:
Lloh3:
	adrp	x9, _NAND_BBT_NO_OOB@GOTPAGE
Lloh4:
	ldr	x9, [x9, _NAND_BBT_NO_OOB@GOTPAGEOFF]
Lloh5:
	ldr	w9, [x9]
	orr	w8, w9, w8
	str	w8, [x19]
LBB0_2:
	ldr	w8, [x19, #4]
Lloh6:
	adrp	x9, _NAND_NEED_SCRAMBLING@GOTPAGE
Lloh7:
	ldr	x9, [x9, _NAND_NEED_SCRAMBLING@GOTPAGEOFF]
Lloh8:
	ldr	w9, [x9]
Lloh9:
	adrp	x10, _NAND_NO_SUBPAGE_WRITE@GOTPAGE
Lloh10:
	ldr	x10, [x10, _NAND_NO_SUBPAGE_WRITE@GOTPAGEOFF]
Lloh11:
	ldr	w10, [x10]
	tst	w9, w8
	csel	w9, wzr, w10, eq
	orr	w8, w8, w9
Lloh12:
	adrp	x9, _NAND_SUBPAGE_READ@GOTPAGE
Lloh13:
	ldr	x9, [x9, _NAND_SUBPAGE_READ@GOTPAGEOFF]
Lloh14:
	ldr	w9, [x9]
	orr	w8, w8, w9
	str	w8, [x19, #4]
	ldr	x8, [x19, #32]
	cbz	x8, LBB0_4
; %bb.3:
	ldr	w8, [x19, #28]
	b	LBB0_5
LBB0_4:
	ldr	x9, [x19, #16]
	str	x9, [x19, #32]
	ldr	w8, [x19, #8]
	str	w8, [x19, #28]
	cbz	x9, LBB0_10
LBB0_5:
	cbz	w8, LBB0_10
; %bb.6:
	ldr	w8, [x1]
	sub	w9, w8, #128
	cmp	w9, #2
	b.hs	LBB0_8
LBB0_7:
	mov	w0, #0
	b	LBB0_11
LBB0_8:
	cmp	w8, #130
	b.ne	LBB0_10
; %bb.9:
	mov	x0, x19
	bl	_sunxi_nand_hw_ecc_ctrl_init
	cbnz	w0, LBB0_11
	b	LBB0_7
LBB0_10:
Lloh15:
	adrp	x8, _EINVAL@GOTPAGE
Lloh16:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh17:
	ldr	w8, [x8]
	neg	w0, w8
LBB0_11:
	ldp	x29, x30, [sp, #16]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp], #32             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh15, Lloh16, Lloh17
	.cfi_endproc
                                        ; -- End function
	.comm	_NAND_BBT_USE_FLASH,4,2         ; @NAND_BBT_USE_FLASH
	.comm	_NAND_BBT_NO_OOB,4,2            ; @NAND_BBT_NO_OOB
	.comm	_NAND_NEED_SCRAMBLING,4,2       ; @NAND_NEED_SCRAMBLING
	.comm	_NAND_NO_SUBPAGE_WRITE,4,2      ; @NAND_NO_SUBPAGE_WRITE
	.comm	_NAND_SUBPAGE_READ,4,2          ; @NAND_SUBPAGE_READ
	.comm	_EINVAL,4,2                     ; @EINVAL
	.no_dead_strip	_sunxi_nand_attach_chip
.subsections_via_symbols
