	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function flctl_chip_attach_chip
_flctl_chip_attach_chip:                ## @flctl_chip_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	%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	%rdi, %r13
	addq	$40, %rdi
	callq	_nanddev_target_size
	movl	%eax, %r12d
	movq	%r13, %rdi
	callq	_nand_to_mtd
	movq	%rax, %r15
	movq	%rax, %rdi
	callq	_mtd_to_flctl
	movq	%rax, %r14
	movq	_NAND_BUSWIDTH_16@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	testl	%eax, (%r13)
	je	LBB0_2
## %bb.1:
	movq	_SEL_16BIT@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	orl	%eax, 4(%r14)
LBB0_2:
	movl	(%r15), %eax
	cmpl	$512, %eax                      ## imm = 0x200
	jne	LBB0_6
## %bb.3:
	movl	$0, (%r14)
	cmpl	$33554432, %r12d                ## imm = 0x2000000
	jle	LBB0_5
## %bb.4:
	movq	_ADRCNT_3@GOTPCREL(%rip), %rcx
	movq	_ADRCNT_4@GOTPCREL(%rip), %rdx
	jmp	LBB0_9
LBB0_6:
	movl	$1, (%r14)
	cmpl	$134217728, %r12d               ## imm = 0x8000000
	jle	LBB0_8
## %bb.7:
	movq	_ADRCNT_3@GOTPCREL(%rip), %rcx
	movq	_ADRCNT2_E@GOTPCREL(%rip), %rdx
	jmp	LBB0_9
LBB0_5:
	cmpl	$131073, %r12d                  ## imm = 0x20001
	movq	_ADRCNT_2@GOTPCREL(%rip), %rcx
	movq	_ADRCNT_3@GOTPCREL(%rip), %rdx
	cmovlq	%rcx, %rdx
	cmovlq	_ADRCNT_1@GOTPCREL(%rip), %rcx
	jmp	LBB0_9
LBB0_8:
	cmpl	$524289, %r12d                  ## imm = 0x80001
	movq	_ADRCNT_3@GOTPCREL(%rip), %rdx
	cmovgeq	_ADRCNT_4@GOTPCREL(%rip), %rdx
	movq	_ADRCNT_1@GOTPCREL(%rip), %rcx
	cmovgeq	_ADRCNT_2@GOTPCREL(%rip), %rcx
LBB0_9:
	movq	(%rdx), %rdx
	movq	%rdx, 24(%r14)
	movq	(%rcx), %rcx
	movq	%rcx, 16(%r14)
	cmpq	$0, 8(%r14)
	je	LBB0_11
## %bb.10:
	cmpl	$512, %eax                      ## imm = 0x200
	movq	_flctl_4secc_oob_largepage_ops@GOTPCREL(%rip), %rsi
	cmoveq	_flctl_4secc_oob_smallpage_ops@GOTPCREL(%rip), %rsi
	movq	_flctl_4secc_largepage@GOTPCREL(%rip), %rbx
	cmoveq	_flctl_4secc_smallpage@GOTPCREL(%rip), %rbx
	movq	%r15, %rdi
	callq	_mtd_set_ooblayout
	movq	%rbx, 32(%r13)
	movabsq	$42949673472, %rax              ## imm = 0xA00000200
	movq	%rax, 4(%r13)
	movl	$4, 12(%r13)
	movq	_flctl_read_page_hwecc@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, 28(%r13)
	movq	_flctl_write_page_hwecc@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, 24(%r13)
	movq	_NAND_ECC_HW@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, 20(%r13)
	movq	__4ECCEN@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	orl	%eax, 4(%r14)
	jmp	LBB0_12
LBB0_11:
	movq	_NAND_ECC_SOFT@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, 20(%r13)
	movq	_NAND_ECC_HAMMING@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, 16(%r13)
LBB0_12:
	xorl	%eax, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_NAND_BUSWIDTH_16,4,2           ## @NAND_BUSWIDTH_16
	.comm	_SEL_16BIT,4,2                  ## @SEL_16BIT
	.comm	_ADRCNT_4,8,3                   ## @ADRCNT_4
	.comm	_ADRCNT_3,8,3                   ## @ADRCNT_3
	.comm	_ADRCNT_2,8,3                   ## @ADRCNT_2
	.comm	_ADRCNT_1,8,3                   ## @ADRCNT_1
	.comm	_ADRCNT2_E,8,3                  ## @ADRCNT2_E
	.comm	_flctl_4secc_oob_smallpage_ops,4,2 ## @flctl_4secc_oob_smallpage_ops
	.comm	_flctl_4secc_smallpage,4,2      ## @flctl_4secc_smallpage
	.comm	_flctl_4secc_oob_largepage_ops,4,2 ## @flctl_4secc_oob_largepage_ops
	.comm	_flctl_4secc_largepage,4,2      ## @flctl_4secc_largepage
	.comm	_flctl_read_page_hwecc,4,2      ## @flctl_read_page_hwecc
	.comm	_flctl_write_page_hwecc,4,2     ## @flctl_write_page_hwecc
	.comm	_NAND_ECC_HW,4,2                ## @NAND_ECC_HW
	.comm	__4ECCEN,4,2                    ## @_4ECCEN
	.comm	_NAND_ECC_SOFT,4,2              ## @NAND_ECC_SOFT
	.comm	_NAND_ECC_HAMMING,4,2           ## @NAND_ECC_HAMMING
	.no_dead_strip	_flctl_chip_attach_chip
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.section	__TEXT,__literal8,8byte_literals
	.p2align	3                               ; -- Begin function flctl_chip_attach_chip
lCPI0_0:
	.long	512                             ; 0x200
	.long	10                              ; 0xa
	.section	__TEXT,__text,regular,pure_instructions
	.p2align	2
_flctl_chip_attach_chip:                ; @flctl_chip_attach_chip
	.cfi_startproc
; %bb.0:
	stp	x22, x21, [sp, #-48]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 48
	stp	x20, x19, [sp, #16]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #32]             ; 16-byte Folded Spill
	add	x29, sp, #32
	.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
	mov	x19, x0
	add	x0, x0, #40
	bl	_nanddev_target_size
	mov	x22, x0
	mov	x0, x19
	bl	_nand_to_mtd
	mov	x21, x0
	bl	_mtd_to_flctl
	mov	x20, x0
	ldr	w8, [x19]
Lloh0:
	adrp	x9, _NAND_BUSWIDTH_16@GOTPAGE
Lloh1:
	ldr	x9, [x9, _NAND_BUSWIDTH_16@GOTPAGEOFF]
Lloh2:
	ldr	w9, [x9]
	tst	w9, w8
	b.eq	LBB0_2
; %bb.1:
Lloh3:
	adrp	x8, _SEL_16BIT@GOTPAGE
Lloh4:
	ldr	x8, [x8, _SEL_16BIT@GOTPAGEOFF]
Lloh5:
	ldr	w8, [x8]
	ldr	w9, [x20, #4]
	orr	w8, w9, w8
	str	w8, [x20, #4]
LBB0_2:
	ldr	w8, [x21]
	cmp	w8, #512
	b.ne	LBB0_4
; %bb.3:
Lloh6:
	adrp	x10, _ADRCNT_3@GOTPAGE
Lloh7:
	ldr	x10, [x10, _ADRCNT_3@GOTPAGEOFF]
Lloh8:
	adrp	x9, _ADRCNT_4@GOTPAGE
Lloh9:
	ldr	x9, [x9, _ADRCNT_4@GOTPAGEOFF]
	str	wzr, [x20]
	mov	w11, #33554432
Lloh10:
	adrp	x12, _ADRCNT_2@GOTPAGE
Lloh11:
	ldr	x12, [x12, _ADRCNT_2@GOTPAGEOFF]
	cmp	w22, #32, lsl #12               ; =131072
	csel	x13, x10, x12, gt
Lloh12:
	adrp	x14, _ADRCNT_1@GOTPAGE
Lloh13:
	ldr	x14, [x14, _ADRCNT_1@GOTPAGEOFF]
	csel	x12, x12, x14, gt
	cmp	w22, w11
	csel	x9, x9, x13, gt
	csel	x10, x10, x12, gt
	b	LBB0_5
LBB0_4:
	mov	w9, #1
	str	w9, [x20]
Lloh14:
	adrp	x10, _ADRCNT_3@GOTPAGE
Lloh15:
	ldr	x10, [x10, _ADRCNT_3@GOTPAGEOFF]
Lloh16:
	adrp	x9, _ADRCNT2_E@GOTPAGE
Lloh17:
	ldr	x9, [x9, _ADRCNT2_E@GOTPAGEOFF]
	mov	w11, #134217728
Lloh18:
	adrp	x12, _ADRCNT_4@GOTPAGE
Lloh19:
	ldr	x12, [x12, _ADRCNT_4@GOTPAGEOFF]
	cmp	w22, #128, lsl #12              ; =524288
	csel	x12, x12, x10, gt
Lloh20:
	adrp	x13, _ADRCNT_1@GOTPAGE
Lloh21:
	ldr	x13, [x13, _ADRCNT_1@GOTPAGEOFF]
Lloh22:
	adrp	x14, _ADRCNT_2@GOTPAGE
Lloh23:
	ldr	x14, [x14, _ADRCNT_2@GOTPAGEOFF]
	csel	x13, x14, x13, gt
	cmp	w22, w11
	csel	x9, x9, x12, gt
	csel	x10, x10, x13, gt
LBB0_5:
	ldr	x9, [x9]
	ldr	x10, [x10]
	stp	x10, x9, [x20, #16]
	ldr	x9, [x20, #8]
	cbz	x9, LBB0_7
; %bb.6:
Lloh24:
	adrp	x9, _flctl_4secc_oob_largepage_ops@GOTPAGE
Lloh25:
	ldr	x9, [x9, _flctl_4secc_oob_largepage_ops@GOTPAGEOFF]
Lloh26:
	adrp	x10, _flctl_4secc_oob_smallpage_ops@GOTPAGE
Lloh27:
	ldr	x10, [x10, _flctl_4secc_oob_smallpage_ops@GOTPAGEOFF]
	cmp	w8, #512
	csel	x1, x10, x9, eq
Lloh28:
	adrp	x8, _flctl_4secc_largepage@GOTPAGE
Lloh29:
	ldr	x8, [x8, _flctl_4secc_largepage@GOTPAGEOFF]
Lloh30:
	adrp	x9, _flctl_4secc_smallpage@GOTPAGE
Lloh31:
	ldr	x9, [x9, _flctl_4secc_smallpage@GOTPAGEOFF]
	csel	x22, x9, x8, eq
	mov	x0, x21
	bl	_mtd_set_ooblayout
	str	x22, [x19, #32]
Lloh32:
	adrp	x8, lCPI0_0@PAGE
Lloh33:
	ldr	d0, [x8, lCPI0_0@PAGEOFF]
	stur	d0, [x19, #4]
	mov	w8, #4
	str	w8, [x19, #12]
Lloh34:
	adrp	x8, _flctl_read_page_hwecc@GOTPAGE
Lloh35:
	ldr	x8, [x8, _flctl_read_page_hwecc@GOTPAGEOFF]
Lloh36:
	ldr	w8, [x8]
	str	w8, [x19, #28]
Lloh37:
	adrp	x8, _flctl_write_page_hwecc@GOTPAGE
Lloh38:
	ldr	x8, [x8, _flctl_write_page_hwecc@GOTPAGEOFF]
Lloh39:
	ldr	w8, [x8]
Lloh40:
	adrp	x9, _NAND_ECC_HW@GOTPAGE
Lloh41:
	ldr	x9, [x9, _NAND_ECC_HW@GOTPAGEOFF]
Lloh42:
	ldr	w9, [x9]
	stp	w9, w8, [x19, #20]
Lloh43:
	adrp	x8, __4ECCEN@GOTPAGE
Lloh44:
	ldr	x8, [x8, __4ECCEN@GOTPAGEOFF]
Lloh45:
	ldr	w8, [x8]
	ldr	w9, [x20, #4]
	orr	w8, w9, w8
	str	w8, [x20, #4]
	b	LBB0_8
LBB0_7:
Lloh46:
	adrp	x8, _NAND_ECC_SOFT@GOTPAGE
Lloh47:
	ldr	x8, [x8, _NAND_ECC_SOFT@GOTPAGEOFF]
Lloh48:
	ldr	w8, [x8]
Lloh49:
	adrp	x9, _NAND_ECC_HAMMING@GOTPAGE
Lloh50:
	ldr	x9, [x9, _NAND_ECC_HAMMING@GOTPAGEOFF]
Lloh51:
	ldr	w9, [x9]
	stp	w9, w8, [x19, #16]
LBB0_8:
	mov	w0, #0
	ldp	x29, x30, [sp, #32]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #16]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp], #48             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGot	Lloh12, Lloh13
	.loh AdrpLdrGot	Lloh10, Lloh11
	.loh AdrpLdrGot	Lloh8, Lloh9
	.loh AdrpLdrGot	Lloh6, Lloh7
	.loh AdrpLdrGot	Lloh22, Lloh23
	.loh AdrpLdrGot	Lloh20, Lloh21
	.loh AdrpLdrGot	Lloh18, Lloh19
	.loh AdrpLdrGot	Lloh16, Lloh17
	.loh AdrpLdrGot	Lloh14, Lloh15
	.loh AdrpLdrGotLdr	Lloh43, Lloh44, Lloh45
	.loh AdrpLdrGotLdr	Lloh40, Lloh41, Lloh42
	.loh AdrpLdrGotLdr	Lloh37, Lloh38, Lloh39
	.loh AdrpLdrGotLdr	Lloh34, Lloh35, Lloh36
	.loh AdrpLdr	Lloh32, Lloh33
	.loh AdrpLdrGot	Lloh30, Lloh31
	.loh AdrpLdrGot	Lloh28, Lloh29
	.loh AdrpLdrGot	Lloh26, Lloh27
	.loh AdrpLdrGot	Lloh24, Lloh25
	.loh AdrpLdrGotLdr	Lloh49, Lloh50, Lloh51
	.loh AdrpLdrGotLdr	Lloh46, Lloh47, Lloh48
	.cfi_endproc
                                        ; -- End function
	.comm	_NAND_BUSWIDTH_16,4,2           ; @NAND_BUSWIDTH_16
	.comm	_SEL_16BIT,4,2                  ; @SEL_16BIT
	.comm	_ADRCNT_4,8,3                   ; @ADRCNT_4
	.comm	_ADRCNT_3,8,3                   ; @ADRCNT_3
	.comm	_ADRCNT_2,8,3                   ; @ADRCNT_2
	.comm	_ADRCNT_1,8,3                   ; @ADRCNT_1
	.comm	_ADRCNT2_E,8,3                  ; @ADRCNT2_E
	.comm	_flctl_4secc_oob_smallpage_ops,4,2 ; @flctl_4secc_oob_smallpage_ops
	.comm	_flctl_4secc_smallpage,4,2      ; @flctl_4secc_smallpage
	.comm	_flctl_4secc_oob_largepage_ops,4,2 ; @flctl_4secc_oob_largepage_ops
	.comm	_flctl_4secc_largepage,4,2      ; @flctl_4secc_largepage
	.comm	_flctl_read_page_hwecc,4,2      ; @flctl_read_page_hwecc
	.comm	_flctl_write_page_hwecc,4,2     ; @flctl_write_page_hwecc
	.comm	_NAND_ECC_HW,4,2                ; @NAND_ECC_HW
	.comm	__4ECCEN,4,2                    ; @_4ECCEN
	.comm	_NAND_ECC_SOFT,4,2              ; @NAND_ECC_SOFT
	.comm	_NAND_ECC_HAMMING,4,2           ; @NAND_ECC_HAMMING
	.no_dead_strip	_flctl_chip_attach_chip
.subsections_via_symbols
