	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function brcmstb_choose_ecc_layout
_brcmstb_choose_ecc_layout:             ## @brcmstb_choose_ecc_layout
	.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	$24, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdi, %rbx
	leaq	16(%rdi), %r12
	addq	$12, %rdi
	movq	%rdi, -64(%rbp)                 ## 8-byte Spill
	callq	_nand_to_mtd
	movq	%rax, -56(%rbp)                 ## 8-byte Spill
	movl	8(%rbx), %edi
	movl	16(%rbx), %r14d
	movl	20(%rbx), %r15d
	movl	24(%rbx), %r13d
	movl	%r13d, %ecx
	shll	%cl, %r15d
	movl	28(%rbx), %eax
	movl	%eax, -44(%rbp)                 ## 4-byte Spill
	movq	%r12, %rsi
	callq	_is_hamming_ecc
	testq	%rax, %rax
	je	LBB0_2
## %bb.1:
	movl	$512, %esi                      ## imm = 0x200
	movl	%r13d, %ecx
	shll	%cl, %esi
	movl	-44(%rbp), %eax                 ## 4-byte Reload
	cltd
	idivl	%esi
                                        ## kill: def $eax killed $eax def $rax
	leal	(%rax,%rax,2), %eax
	movq	-64(%rbp), %rcx                 ## 8-byte Reload
	movl	%eax, (%rcx)
	movq	_brcmnand_hamming_ooblayout_ops@GOTPCREL(%rip), %rsi
	movq	-56(%rbp), %rdi                 ## 8-byte Reload
	callq	_mtd_set_ooblayout
	xorl	%eax, %eax
	jmp	LBB0_7
LBB0_2:
	testl	%r13d, %r13d
	setne	%cl
	shll	%cl, %r14d
	movl	%r14d, %edi
	shll	$4, %edi
	subl	%r14d, %edi
	subl	%r14d, %edi
	movl	$8, %esi
	callq	_DIV_ROUND_UP
	movl	%eax, 12(%rbx)
	cmpl	$512, 28(%rbx)                  ## imm = 0x200
	movq	-56(%rbp), %rdi                 ## 8-byte Reload
	jne	LBB0_3
## %bb.4:
	movq	_brcmnand_bch_sp_ooblayout_ops@GOTPCREL(%rip), %rsi
	jmp	LBB0_5
LBB0_3:
	movq	_brcmnand_bch_lp_ooblayout_ops@GOTPCREL(%rip), %rsi
LBB0_5:
	callq	_mtd_set_ooblayout
	movl	12(%rbx), %edx
	xorl	%eax, %eax
	cmpl	%r15d, %edx
	jl	LBB0_7
## %bb.6:
	movq	(%rbx), %rdi
	leaq	L_.str(%rip), %rsi
	movl	%r15d, %ecx
	callq	_dev_err
	movq	_EINVAL@GOTPCREL(%rip), %rcx
	xorl	%eax, %eax
	subl	(%rcx), %eax
LBB0_7:
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_brcmnand_hamming_ooblayout_ops,4,2 ## @brcmnand_hamming_ooblayout_ops
	.comm	_brcmnand_bch_sp_ooblayout_ops,4,2 ## @brcmnand_bch_sp_ooblayout_ops
	.comm	_brcmnand_bch_lp_ooblayout_ops,4,2 ## @brcmnand_bch_lp_ooblayout_ops
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"error: ECC too large for OOB (ECC bytes %d, spare sector %d)\n"

	.comm	_EINVAL,4,2                     ## @EINVAL
	.no_dead_strip	_brcmstb_choose_ecc_layout
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function brcmstb_choose_ecc_layout
_brcmstb_choose_ecc_layout:             ; @brcmstb_choose_ecc_layout
	.cfi_startproc
; %bb.0:
	stp	x26, x25, [sp, #-80]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 80
	stp	x24, x23, [sp, #16]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #32]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #48]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #64]             ; 16-byte Folded Spill
	add	x29, sp, #64
	.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
	mov	x19, x0
	add	x21, x0, #12
	mov	x0, x21
	bl	_nand_to_mtd
	mov	x20, x0
	mov	x1, x19
	ldp	w22, w24, [x1, #16]!
	ldp	w23, w25, [x1, #8]
	ldur	w0, [x1, #-8]
	bl	_is_hamming_ecc
	cbz	x0, LBB0_2
; %bb.1:
	mov	w8, #512
	lsl	w8, w8, w23
	sdiv	w8, w25, w8
	add	w8, w8, w8, lsl #1
	str	w8, [x21]
Lloh0:
	adrp	x1, _brcmnand_hamming_ooblayout_ops@GOTPAGE
Lloh1:
	ldr	x1, [x1, _brcmnand_hamming_ooblayout_ops@GOTPAGEOFF]
	mov	x0, x20
	bl	_mtd_set_ooblayout
	mov	w0, #0
	b	LBB0_5
LBB0_2:
	lsl	w21, w24, w23
	cmp	w23, #0
	cset	w8, ne
	lsl	w8, w22, w8
	mov	w9, #14
	mul	w0, w8, w9
	mov	w1, #8
	bl	_DIV_ROUND_UP
	str	w0, [x19, #12]
	ldr	w8, [x19, #28]
Lloh2:
	adrp	x9, _brcmnand_bch_lp_ooblayout_ops@GOTPAGE
Lloh3:
	ldr	x9, [x9, _brcmnand_bch_lp_ooblayout_ops@GOTPAGEOFF]
Lloh4:
	adrp	x10, _brcmnand_bch_sp_ooblayout_ops@GOTPAGE
Lloh5:
	ldr	x10, [x10, _brcmnand_bch_sp_ooblayout_ops@GOTPAGEOFF]
	cmp	w8, #512
	csel	x1, x10, x9, eq
	mov	x0, x20
	bl	_mtd_set_ooblayout
	ldr	w2, [x19, #12]
	cmp	w2, w21
	b.ge	LBB0_4
; %bb.3:
	mov	w0, #0
	b	LBB0_5
LBB0_4:
	ldr	x0, [x19]
Lloh6:
	adrp	x1, l_.str@PAGE
Lloh7:
	add	x1, x1, l_.str@PAGEOFF
	mov	x3, x21
	bl	_dev_err
Lloh8:
	adrp	x8, _EINVAL@GOTPAGE
Lloh9:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh10:
	ldr	w8, [x8]
	neg	w0, w8
LBB0_5:
	ldp	x29, x30, [sp, #64]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #48]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #32]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #16]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp], #80             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGot	Lloh4, Lloh5
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpAdd	Lloh6, Lloh7
	.cfi_endproc
                                        ; -- End function
	.comm	_brcmnand_hamming_ooblayout_ops,4,2 ; @brcmnand_hamming_ooblayout_ops
	.comm	_brcmnand_bch_sp_ooblayout_ops,4,2 ; @brcmnand_bch_sp_ooblayout_ops
	.comm	_brcmnand_bch_lp_ooblayout_ops,4,2 ; @brcmnand_bch_lp_ooblayout_ops
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"error: ECC too large for OOB (ECC bytes %d, spare sector %d)\n"

	.comm	_EINVAL,4,2                     ; @EINVAL
	.no_dead_strip	_brcmstb_choose_ecc_layout
.subsections_via_symbols
