	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function bf5xx_nand_calculate_ecc
_bf5xx_nand_calculate_ecc:              ## @bf5xx_nand_calculate_ecc
	.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	%r12
	pushq	%rbx
	subq	$16, %rsp
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdx, %r15
	movq	___stack_chk_guard@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movq	%rax, -40(%rbp)
	callq	_mtd_to_nand_info
	movq	%rax, %r14
	movq	8(%rax), %rax
	movq	(%rax), %r12
	xorl	%eax, %eax
	callq	_bfin_read_NFC_ECC0
	movl	%eax, %ebx
	xorl	%eax, %eax
	callq	_bfin_read_NFC_ECC1
	andl	$2047, %ebx                     ## imm = 0x7FF
	shll	$11, %eax
	andl	$4192256, %eax                  ## imm = 0x3FF800
	orl	%eax, %ebx
	movl	%ebx, -48(%rbp)
	movl	(%r14), %edi
	leaq	L_.str(%rip), %rsi
	movl	%ebx, %edx
	callq	_dev_dbg
	leaq	-48(%rbp), %rsi
	movq	%r15, %rdi
	movl	$3, %edx
	callq	_memcpy
	testq	%r12, %r12
	je	LBB0_2
## %bb.1:
	xorl	%eax, %eax
	callq	_bfin_read_NFC_ECC2
	movl	%eax, %ebx
	xorl	%eax, %eax
	callq	_bfin_read_NFC_ECC3
	andl	$2047, %ebx                     ## imm = 0x7FF
	shll	$11, %eax
	andl	$4192256, %eax                  ## imm = 0x3FF800
	orl	%ebx, %eax
	leaq	-44(%rbp), %rsi
	movl	%eax, -44(%rbp)
	addq	$12, %r15
	movq	%r15, %rdi
	movl	$3, %edx
	callq	_memcpy
	movl	(%r14), %edi
	movl	-44(%rbp), %edx
	leaq	L_.str(%rip), %rsi
	callq	_dev_dbg
LBB0_2:
	movq	___stack_chk_guard@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	cmpq	-40(%rbp), %rax
	jne	LBB0_4
## %bb.3:
	xorl	%eax, %eax
	addq	$16, %rsp
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_4:
	callq	___stack_chk_fail
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"returning ecc 0x%08x\n"

	.no_dead_strip	_bf5xx_nand_calculate_ecc
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function bf5xx_nand_calculate_ecc
_bf5xx_nand_calculate_ecc:              ; @bf5xx_nand_calculate_ecc
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #80
	.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
	mov	x20, x2
Lloh0:
	adrp	x8, ___stack_chk_guard@GOTPAGE
Lloh1:
	ldr	x8, [x8, ___stack_chk_guard@GOTPAGEOFF]
Lloh2:
	ldr	x8, [x8]
	str	x8, [sp, #8]
	bl	_mtd_to_nand_info
	mov	x19, x0
	ldr	x8, [x0, #8]
	ldr	x23, [x8]
	bl	_bfin_read_NFC_ECC0
	mov	x21, x0
	bl	_bfin_read_NFC_ECC1
	and	w2, w21, #0x7ff
	bfi	w2, w0, #11, #11
	str	w2, [sp]
	ldr	w0, [x19]
Lloh3:
	adrp	x1, l_.str@PAGE
Lloh4:
	add	x1, x1, l_.str@PAGEOFF
	bl	_dev_dbg
	mov	x22, sp
	mov	x1, sp
	mov	x0, x20
	mov	w2, #3
	bl	_memcpy
	cbz	x23, LBB0_2
; %bb.1:
	bl	_bfin_read_NFC_ECC2
	mov	x21, x0
	bl	_bfin_read_NFC_ECC3
	and	w8, w21, #0x7ff
	bfi	w8, w0, #11, #11
	add	x1, x22, #4
	str	w8, [sp, #4]
	add	x0, x20, #12
	mov	w2, #3
	bl	_memcpy
	ldr	w0, [x19]
	ldr	w2, [sp, #4]
Lloh5:
	adrp	x1, l_.str@PAGE
Lloh6:
	add	x1, x1, l_.str@PAGEOFF
	bl	_dev_dbg
LBB0_2:
	ldr	x8, [sp, #8]
Lloh7:
	adrp	x9, ___stack_chk_guard@GOTPAGE
Lloh8:
	ldr	x9, [x9, ___stack_chk_guard@GOTPAGEOFF]
Lloh9:
	ldr	x9, [x9]
	cmp	x9, x8
	b.ne	LBB0_4
; %bb.3:
	mov	w0, #0
	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
	add	sp, sp, #80
	ret
LBB0_4:
	bl	___stack_chk_fail
	.loh AdrpAdd	Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpAdd	Lloh5, Lloh6
	.loh AdrpLdrGotLdr	Lloh7, Lloh8, Lloh9
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"returning ecc 0x%08x\n"

	.no_dead_strip	_bf5xx_nand_calculate_ecc
.subsections_via_symbols
