	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function mpc5121_nfc_copy_spare
_mpc5121_nfc_copy_spare:                ## @mpc5121_nfc_copy_spare
	.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, -48(%rbp)                 ## 4-byte Spill
	movl	%ecx, %r13d
	movq	%rdx, %r12
	movl	%esi, %r15d
	movq	%rdi, %r14
	callq	_mtd_to_nand
	movq	%rax, %rdi
	callq	_nand_get_controller_data
	movq	%rax, -64(%rbp)                 ## 8-byte Spill
	movl	(%r14), %eax
	movl	4(%r14), %ecx
	leal	511(%rcx), %esi
	testl	%ecx, %ecx
	cmovnsl	%ecx, %esi
	sarl	$9, %esi
	cltd
	idivl	%esi
	movl	%eax, -44(%rbp)                 ## 4-byte Spill
	testl	%r13d, %r13d
	je	LBB0_6
## %bb.1:
	andl	$-2, -44(%rbp)                  ## 4-byte Folded Spill
	jmp	LBB0_2
	.p2align	4, 0x90
LBB0_4:                                 ##   in Loop: Header=BB0_2 Depth=1
	movq	%r12, %rdi
	movq	%rax, %rsi
	movl	%r13d, %edx
	callq	_memcpy_fromio
LBB0_5:                                 ##   in Loop: Header=BB0_2 Depth=1
	movslq	%r13d, %rax
	leaq	(%r12,%rax,4), %r12
	addl	%r13d, %r15d
	movl	-52(%rbp), %eax                 ## 4-byte Reload
	subl	%r13d, %eax
	movl	%eax, %r13d
	je	LBB0_6
LBB0_2:                                 ## =>This Inner Loop Header: Depth=1
	movl	%r15d, %eax
	cltd
	movl	-44(%rbp), %edi                 ## 4-byte Reload
	idivl	%edi
	movq	_NFC_SPARE_BUFFERS@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	leal	-1(%rcx), %r14d
	cmpl	%ecx, %eax
	cmovll	%eax, %r14d
	movl	%r14d, %eax
	imull	%edi, %eax
	movl	%r15d, %ebx
	subl	%eax, %ebx
	subl	%ebx, %edi
	movl	%r13d, -52(%rbp)                ## 4-byte Spill
	movl	%r13d, %esi
	callq	_min
	movl	%eax, %r13d
	movslq	%ebx, %rbx
	movq	-64(%rbp), %rax                 ## 8-byte Reload
	addq	(%rax), %rbx
	movl	%r14d, %edi
	callq	_NFC_SPARE_AREA
	addq	%rbx, %rax
	cmpl	$0, -48(%rbp)                   ## 4-byte Folded Reload
	je	LBB0_4
## %bb.3:                               ##   in Loop: Header=BB0_2 Depth=1
	movq	%rax, %rdi
	movq	%r12, %rsi
	movl	%r13d, %edx
	callq	_memcpy_toio
	jmp	LBB0_5
LBB0_6:
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_NFC_SPARE_BUFFERS,4,2          ## @NFC_SPARE_BUFFERS
	.no_dead_strip	_mpc5121_nfc_copy_spare
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function mpc5121_nfc_copy_spare
_mpc5121_nfc_copy_spare:                ; @mpc5121_nfc_copy_spare
	.cfi_startproc
; %bb.0:
	stp	x28, x27, [sp, #-96]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 96
	stp	x26, x25, [sp, #16]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #32]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #48]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #64]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #80]             ; 16-byte Folded Spill
	add	x29, sp, #80
	.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
	.cfi_offset w27, -88
	.cfi_offset w28, -96
	mov	x19, x4
	mov	x20, x3
	mov	x21, x2
	mov	x22, x1
	mov	x24, x0
	bl	_mtd_to_nand
	bl	_nand_get_controller_data
	ldr	w8, [x24, #4]
	add	w9, w8, #511
	cmp	w8, #0
	csel	w8, w9, w8, lt
	cbz	w20, LBB0_6
; %bb.1:
	mov	x23, x0
	ldr	w9, [x24]
	asr	w8, w8, #9
	sdiv	w8, w9, w8
	and	w26, w8, #0xfffffffe
	b	LBB0_4
LBB0_2:                                 ;   in Loop: Header=BB0_4 Depth=1
	mov	x0, x21
	mov	x2, x24
	bl	_memcpy_fromio
LBB0_3:                                 ;   in Loop: Header=BB0_4 Depth=1
	add	x21, x21, w24, sxtw #2
	add	w22, w24, w22
	subs	w20, w20, w24
	b.eq	LBB0_6
LBB0_4:                                 ; =>This Inner Loop Header: Depth=1
	sdiv	w8, w22, w26
Lloh0:
	adrp	x9, _NFC_SPARE_BUFFERS@GOTPAGE
Lloh1:
	ldr	x9, [x9, _NFC_SPARE_BUFFERS@GOTPAGEOFF]
Lloh2:
	ldr	w9, [x9]
	sub	w10, w9, #1
	cmp	w8, w9
	csel	w25, w8, w10, lt
	msub	w28, w25, w26, w22
	sub	w0, w26, w28
	mov	x1, x20
	bl	_min
	mov	x24, x0
	ldr	x27, [x23]
	mov	x0, x25
	bl	_NFC_SPARE_AREA
	add	x8, x27, w28, sxtw
	add	x1, x8, x0
	cbz	w19, LBB0_2
; %bb.5:                                ;   in Loop: Header=BB0_4 Depth=1
	mov	x0, x1
	mov	x1, x21
	mov	x2, x24
	bl	_memcpy_toio
	b	LBB0_3
LBB0_6:
	ldp	x29, x30, [sp, #80]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #64]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #48]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #32]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #16]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp], #96             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.cfi_endproc
                                        ; -- End function
	.comm	_NFC_SPARE_BUFFERS,4,2          ; @NFC_SPARE_BUFFERS
	.no_dead_strip	_mpc5121_nfc_copy_spare
.subsections_via_symbols
