	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function atmel_hsmc_nand_pmecc_read_pg
_atmel_hsmc_nand_pmecc_read_pg:         ## @atmel_hsmc_nand_pmecc_read_pg
	.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
	movl	%r8d, -44(%rbp)                 ## 4-byte Spill
	movl	%ecx, %r13d
	movl	%edx, -56(%rbp)                 ## 4-byte Spill
	movq	%rsi, %r14
	movq	%rdi, %rbx
	callq	_nand_to_mtd
	movq	%rax, -64(%rbp)                 ## 8-byte Spill
	movq	%rbx, %rdi
	callq	_to_atmel_nand
	movq	%rax, %r15
	movl	(%rbx), %edi
	callq	_to_hsmc_nand_controller
	movq	%rax, %r12
	movq	(%r15), %rax
	movq	8(%rax), %rax
	movq	_ATMEL_NAND_NATIVE_RB@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_8
## %bb.1:
	movl	%r13d, %esi
	movq	%r14, -56(%rbp)                 ## 8-byte Spill
	movl	-44(%rbp), %r13d                ## 4-byte Reload
	movq	_NAND_CMD_READ0@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	movq	24(%r12), %rax
	movslq	16(%r12), %rdx
	leal	1(%rdx), %edi
	movl	%edi, 16(%r12)
	movl	%ecx, (%rax,%rdx,4)
	movq	-64(%rbp), %rcx                 ## 8-byte Reload
	cmpl	$513, (%rcx)                    ## imm = 0x201
	jl	LBB0_3
## %bb.2:
	movq	_NAND_CMD_READSTART@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	movslq	16(%r12), %rdx
	leal	1(%rdx), %edi
	movl	%edi, 16(%r12)
	movl	%ecx, (%rax,%rdx,4)
LBB0_3:
	movq	%rbx, %rdi
	xorl	%edx, %edx
	callq	_atmel_nfc_set_op_addr
	movq	(%r15), %rax
	movl	(%rax), %eax
	movl	%eax, 12(%r12)
	movq	_ATMEL_NFC_READ_DATA@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, 8(%r12)
	movq	_NAND_ECC_READ@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%rbx, %rdi
	movl	%r13d, %r15d
	movl	%r13d, %edx
	callq	_atmel_nand_pmecc_enable
	movl	%eax, %r14d
	testl	%eax, %eax
	jne	LBB0_7
## %bb.4:
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	_atmel_nfc_exec_op
	testl	%eax, %eax
	je	LBB0_6
## %bb.5:
	movl	%eax, %r14d
	movq	%rbx, %rdi
	movl	%r15d, %esi
	callq	_atmel_nand_pmecc_disable
	movl	(%r12), %edi
	leaq	L_.str(%rip), %rsi
	movl	%r14d, %edx
	callq	_dev_err
	jmp	LBB0_7
LBB0_8:
	movq	%rbx, %rdi
	movl	%r13d, %esi
	xorl	%edx, %edx
	xorl	%ecx, %ecx
	xorl	%r8d, %r8d
	callq	_nand_read_page_op
	movq	%rbx, %rdi
	movq	%r14, %rsi
	movl	-56(%rbp), %edx                 ## 4-byte Reload
	movl	%r13d, %ecx
	movl	-44(%rbp), %r8d                 ## 4-byte Reload
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	jmp	_atmel_nand_pmecc_read_pg       ## TAILCALL
LBB0_6:
	movq	%rbx, %rdi
	movq	-56(%rbp), %r14                 ## 8-byte Reload
	movq	%r14, %rsi
	movl	$1, %edx
	callq	_atmel_nfc_copy_from_sram
	movq	%rbx, %rdi
	movq	%r14, %rsi
	movl	%r15d, %edx
	callq	_atmel_nand_pmecc_correct_data
	movl	%eax, %r14d
	movq	%rbx, %rdi
	movl	%r15d, %esi
	callq	_atmel_nand_pmecc_disable
LBB0_7:
	movl	%r14d, %eax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_ATMEL_NAND_NATIVE_RB,8,3       ## @ATMEL_NAND_NATIVE_RB
	.comm	_NAND_CMD_READ0,4,2             ## @NAND_CMD_READ0
	.comm	_NAND_CMD_READSTART,4,2         ## @NAND_CMD_READSTART
	.comm	_ATMEL_NFC_READ_DATA,4,2        ## @ATMEL_NFC_READ_DATA
	.comm	_NAND_ECC_READ,4,2              ## @NAND_ECC_READ
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Failed to load NAND page data (err = %d)\n"

	.no_dead_strip	_atmel_hsmc_nand_pmecc_read_pg
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function atmel_hsmc_nand_pmecc_read_pg
_atmel_hsmc_nand_pmecc_read_pg:         ; @atmel_hsmc_nand_pmecc_read_pg
	.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, x4
	mov	x23, x3
	mov	x25, x2
	mov	x21, x1
	mov	x20, x0
	bl	_nand_to_mtd
	mov	x26, x0
	mov	x0, x20
	bl	_to_atmel_nand
	mov	x24, x0
	ldr	w0, [x20]
	bl	_to_hsmc_nand_controller
	ldr	x8, [x24]
	ldr	x8, [x8, #8]
Lloh0:
	adrp	x9, _ATMEL_NAND_NATIVE_RB@GOTPAGE
Lloh1:
	ldr	x9, [x9, _ATMEL_NAND_NATIVE_RB@GOTPAGEOFF]
Lloh2:
	ldr	x9, [x9]
	cmp	x8, x9
	b.ne	LBB0_8
; %bb.1:
	mov	x22, x0
Lloh3:
	adrp	x8, _NAND_CMD_READ0@GOTPAGE
Lloh4:
	ldr	x8, [x8, _NAND_CMD_READ0@GOTPAGEOFF]
Lloh5:
	ldr	w9, [x8]
	ldr	x8, [x0, #24]
	ldrsw	x10, [x0, #16]
	add	w11, w10, #1
	str	w11, [x0, #16]
	str	w9, [x8, x10, lsl #2]
	ldr	w9, [x26]
	cmp	w9, #513
	b.lt	LBB0_3
; %bb.2:
Lloh6:
	adrp	x9, _NAND_CMD_READSTART@GOTPAGE
Lloh7:
	ldr	x9, [x9, _NAND_CMD_READSTART@GOTPAGEOFF]
Lloh8:
	ldr	w9, [x9]
	ldrsw	x10, [x22, #16]
	add	w11, w10, #1
	str	w11, [x22, #16]
	str	w9, [x8, x10, lsl #2]
LBB0_3:
	mov	x0, x20
	mov	x1, x23
	mov	w2, #0
	bl	_atmel_nfc_set_op_addr
	ldr	x8, [x24]
	ldr	w8, [x8]
Lloh9:
	adrp	x9, _ATMEL_NFC_READ_DATA@GOTPAGE
Lloh10:
	ldr	x9, [x9, _ATMEL_NFC_READ_DATA@GOTPAGEOFF]
Lloh11:
	ldr	w9, [x9]
	stp	w9, w8, [x22, #8]
Lloh12:
	adrp	x8, _NAND_ECC_READ@GOTPAGE
Lloh13:
	ldr	x8, [x8, _NAND_ECC_READ@GOTPAGEOFF]
Lloh14:
	ldr	w1, [x8]
	mov	x0, x20
	mov	x2, x19
	bl	_atmel_nand_pmecc_enable
	mov	x23, x0
	cbnz	w0, LBB0_6
; %bb.4:
	mov	x0, x22
	mov	w1, #0
	bl	_atmel_nfc_exec_op
	cbz	w0, LBB0_9
; %bb.5:
	mov	x23, x0
	mov	x0, x20
	mov	x1, x19
	bl	_atmel_nand_pmecc_disable
	ldr	w0, [x22]
Lloh15:
	adrp	x1, l_.str@PAGE
Lloh16:
	add	x1, x1, l_.str@PAGEOFF
	mov	x2, x23
	bl	_dev_err
LBB0_6:
	mov	x0, x23
LBB0_7:
	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
LBB0_8:
	mov	x0, x20
	mov	x1, x23
	mov	w2, #0
	mov	x3, #0
	mov	w4, #0
	bl	_nand_read_page_op
	mov	x0, x20
	mov	x1, x21
	mov	x2, x25
	mov	x3, x23
	mov	x4, x19
	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
	b	_atmel_nand_pmecc_read_pg
LBB0_9:
	mov	x0, x20
	mov	x1, x21
	mov	w2, #1
	bl	_atmel_nfc_copy_from_sram
	mov	x0, x20
	mov	x1, x21
	mov	x2, x19
	bl	_atmel_nand_pmecc_correct_data
	mov	x21, x0
	mov	x0, x20
	mov	x1, x19
	bl	_atmel_nand_pmecc_disable
	mov	x0, x21
	b	LBB0_7
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpAdd	Lloh15, Lloh16
	.cfi_endproc
                                        ; -- End function
	.comm	_ATMEL_NAND_NATIVE_RB,8,3       ; @ATMEL_NAND_NATIVE_RB
	.comm	_NAND_CMD_READ0,4,2             ; @NAND_CMD_READ0
	.comm	_NAND_CMD_READSTART,4,2         ; @NAND_CMD_READSTART
	.comm	_ATMEL_NFC_READ_DATA,4,2        ; @ATMEL_NFC_READ_DATA
	.comm	_NAND_ECC_READ,4,2              ; @NAND_ECC_READ
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Failed to load NAND page data (err = %d)\n"

	.no_dead_strip	_atmel_hsmc_nand_pmecc_read_pg
.subsections_via_symbols
