	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function atmel_hsmc_nand_pmecc_write_pg
_atmel_hsmc_nand_pmecc_write_pg:        ## @atmel_hsmc_nand_pmecc_write_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, %r13d
	movl	%ecx, -44(%rbp)                 ## 4-byte Spill
	movq	%rsi, %r15
	movq	%rdi, %rbx
	callq	_nand_to_mtd
	movq	%rax, -56(%rbp)                 ## 8-byte Spill
	movq	%rbx, %rdi
	callq	_to_atmel_nand
	movq	%rax, %r12
	movl	12(%rbx), %edi
	callq	_to_hsmc_nand_controller
	movq	%rax, %r14
	movq	%rbx, %rdi
	movq	%r15, %rsi
	movl	%r13d, %r15d
	xorl	%edx, %edx
	callq	_atmel_nfc_copy_to_sram
	movq	_NAND_CMD_SEQIN@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movq	16(%r14), %rcx
	movl	%eax, (%rcx)
	movl	$1, 8(%r14)
	movq	%rbx, %rdi
	movl	-44(%rbp), %esi                 ## 4-byte Reload
	xorl	%edx, %edx
	callq	_atmel_nfc_set_op_addr
	movq	(%r12), %rax
	movl	(%rax), %eax
	movl	%eax, 12(%r14)
	movq	_ATMEL_NFC_WRITE_DATA@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, 24(%r14)
	movq	_NAND_ECC_WRITE@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%rbx, %rdi
	movl	%r13d, %edx
	callq	_atmel_nand_pmecc_enable
	movl	%eax, %r13d
	testl	%eax, %eax
	jne	LBB0_8
## %bb.1:
	movq	%r14, %rdi
	xorl	%esi, %esi
	callq	_atmel_nfc_exec_op
	testl	%eax, %eax
	je	LBB0_3
## %bb.2:
	movl	%eax, %r13d
	movq	%rbx, %rdi
	movl	%r15d, %esi
	callq	_atmel_nand_pmecc_disable
	movl	(%r14), %edi
	leaq	L_.str(%rip), %rsi
	movl	%r13d, %edx
	callq	_dev_err
	jmp	LBB0_8
LBB0_3:
	movq	%rbx, %rdi
	movl	%r15d, %esi
	callq	_atmel_nand_pmecc_generate_eccbytes
	movl	%eax, %r13d
	movq	%rbx, %rdi
	movl	%r15d, %esi
	callq	_atmel_nand_pmecc_disable
	testl	%r13d, %r13d
	movq	-56(%rbp), %rax                 ## 8-byte Reload
	jne	LBB0_8
## %bb.4:
	movl	8(%rbx), %esi
	movl	(%rax), %edx
	movq	%rbx, %rdi
	callq	_atmel_nand_write_buf
	movq	_NAND_CMD_PAGEPROG@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movq	16(%r14), %rcx
	movl	%eax, (%rcx)
	movl	$1, 8(%r14)
	movq	(%r12), %rax
	movl	(%rax), %eax
	movl	%eax, 12(%r14)
	movq	%r14, %rdi
	xorl	%esi, %esi
	callq	_atmel_nfc_exec_op
	movl	%eax, %r13d
	testl	%eax, %eax
	je	LBB0_6
## %bb.5:
	movl	(%r14), %edi
	leaq	L_.str.1(%rip), %rsi
	movl	%r13d, %edx
	callq	_dev_err
LBB0_6:
	movq	%rbx, %rdi
	callq	*(%rbx)
	movq	_NAND_STATUS_FAIL@GOTPCREL(%rip), %rcx
	testl	%eax, (%rcx)
	je	LBB0_8
## %bb.7:
	movq	_EIO@GOTPCREL(%rip), %rax
	xorl	%r13d, %r13d
	subl	(%rax), %r13d
LBB0_8:
	movl	%r13d, %eax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_NAND_CMD_SEQIN,4,2             ## @NAND_CMD_SEQIN
	.comm	_ATMEL_NFC_WRITE_DATA,4,2       ## @ATMEL_NFC_WRITE_DATA
	.comm	_NAND_ECC_WRITE,4,2             ## @NAND_ECC_WRITE
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Failed to transfer NAND page data (err = %d)\n"

	.comm	_NAND_CMD_PAGEPROG,4,2          ## @NAND_CMD_PAGEPROG
L_.str.1:                               ## @.str.1
	.asciz	"Failed to program NAND page (err = %d)\n"

	.comm	_NAND_STATUS_FAIL,4,2           ## @NAND_STATUS_FAIL
	.comm	_EIO,4,2                        ## @EIO
	.no_dead_strip	_atmel_hsmc_nand_pmecc_write_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_write_pg
_atmel_hsmc_nand_pmecc_write_pg:        ; @atmel_hsmc_nand_pmecc_write_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	x22, x4
	mov	x24, x3
	mov	x25, x1
	mov	x19, x0
	bl	_nand_to_mtd
	mov	x23, x0
	mov	x0, x19
	bl	_to_atmel_nand
	mov	x21, x0
	ldr	w0, [x19, #12]
	bl	_to_hsmc_nand_controller
	mov	x20, x0
	mov	x0, x19
	mov	x1, x25
	mov	w2, #0
	bl	_atmel_nfc_copy_to_sram
Lloh0:
	adrp	x8, _NAND_CMD_SEQIN@GOTPAGE
Lloh1:
	ldr	x8, [x8, _NAND_CMD_SEQIN@GOTPAGEOFF]
Lloh2:
	ldr	w8, [x8]
	ldr	x9, [x20, #16]
	str	w8, [x9]
	mov	w8, #1
	str	w8, [x20, #8]
	mov	x0, x19
	mov	x1, x24
	mov	w2, #0
	bl	_atmel_nfc_set_op_addr
	ldr	x8, [x21]
	ldr	w8, [x8]
Lloh3:
	adrp	x9, _ATMEL_NFC_WRITE_DATA@GOTPAGE
Lloh4:
	ldr	x9, [x9, _ATMEL_NFC_WRITE_DATA@GOTPAGEOFF]
	str	w8, [x20, #12]
Lloh5:
	ldr	w8, [x9]
	str	w8, [x20, #24]
Lloh6:
	adrp	x8, _NAND_ECC_WRITE@GOTPAGE
Lloh7:
	ldr	x8, [x8, _NAND_ECC_WRITE@GOTPAGEOFF]
Lloh8:
	ldr	w1, [x8]
	mov	x0, x19
	mov	x2, x22
	bl	_atmel_nand_pmecc_enable
	mov	x24, x0
	cbnz	w0, LBB0_8
; %bb.1:
	mov	x0, x20
	mov	w1, #0
	bl	_atmel_nfc_exec_op
	cbz	w0, LBB0_3
; %bb.2:
	mov	x24, x0
	mov	x0, x19
	mov	x1, x22
	bl	_atmel_nand_pmecc_disable
	ldr	w0, [x20]
Lloh9:
	adrp	x1, l_.str@PAGE
Lloh10:
	add	x1, x1, l_.str@PAGEOFF
	mov	x2, x24
	bl	_dev_err
	b	LBB0_8
LBB0_3:
	mov	x0, x19
	mov	x1, x22
	bl	_atmel_nand_pmecc_generate_eccbytes
	mov	x24, x0
	mov	x0, x19
	mov	x1, x22
	bl	_atmel_nand_pmecc_disable
	cbnz	w24, LBB0_8
; %bb.4:
	ldr	w1, [x19, #8]
	ldr	w2, [x23]
	mov	x0, x19
	bl	_atmel_nand_write_buf
Lloh11:
	adrp	x8, _NAND_CMD_PAGEPROG@GOTPAGE
Lloh12:
	ldr	x8, [x8, _NAND_CMD_PAGEPROG@GOTPAGEOFF]
Lloh13:
	ldr	w8, [x8]
	ldr	x9, [x20, #16]
	str	w8, [x9]
	mov	w8, #1
	ldr	x9, [x21]
	ldr	w9, [x9]
	stp	w8, w9, [x20, #8]
	mov	x0, x20
	mov	w1, #0
	bl	_atmel_nfc_exec_op
	mov	x24, x0
	cbz	w0, LBB0_6
; %bb.5:
	ldr	w0, [x20]
Lloh14:
	adrp	x1, l_.str.1@PAGE
Lloh15:
	add	x1, x1, l_.str.1@PAGEOFF
	mov	x2, x24
	bl	_dev_err
LBB0_6:
	ldr	x8, [x19]
	mov	x0, x19
	blr	x8
Lloh16:
	adrp	x8, _NAND_STATUS_FAIL@GOTPAGE
Lloh17:
	ldr	x8, [x8, _NAND_STATUS_FAIL@GOTPAGEOFF]
Lloh18:
	ldr	w8, [x8]
	tst	w8, w0
	b.eq	LBB0_8
; %bb.7:
Lloh19:
	adrp	x8, _EIO@GOTPAGE
Lloh20:
	ldr	x8, [x8, _EIO@GOTPAGEOFF]
Lloh21:
	ldr	w8, [x8]
	neg	w24, w8
LBB0_8:
	mov	x0, x24
	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 AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpAdd	Lloh9, Lloh10
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.loh AdrpAdd	Lloh14, Lloh15
	.loh AdrpLdrGotLdr	Lloh16, Lloh17, Lloh18
	.loh AdrpLdrGotLdr	Lloh19, Lloh20, Lloh21
	.cfi_endproc
                                        ; -- End function
	.comm	_NAND_CMD_SEQIN,4,2             ; @NAND_CMD_SEQIN
	.comm	_ATMEL_NFC_WRITE_DATA,4,2       ; @ATMEL_NFC_WRITE_DATA
	.comm	_NAND_ECC_WRITE,4,2             ; @NAND_ECC_WRITE
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Failed to transfer NAND page data (err = %d)\n"

	.comm	_NAND_CMD_PAGEPROG,4,2          ; @NAND_CMD_PAGEPROG
l_.str.1:                               ; @.str.1
	.asciz	"Failed to program NAND page (err = %d)\n"

	.comm	_NAND_STATUS_FAIL,4,2           ; @NAND_STATUS_FAIL
	.comm	_EIO,4,2                        ; @EIO
	.no_dead_strip	_atmel_hsmc_nand_pmecc_write_pg
.subsections_via_symbols
