	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_AT91F_DataFlashWrite           ## -- Begin function AT91F_DataFlashWrite
	.p2align	4, 0x90
_AT91F_DataFlashWrite:                  ## @AT91F_DataFlashWrite
	.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	%ecx, %r15d
	movl	%edx, %r13d
	movq	%rsi, %r12
	movq	%rdi, %r14
	movq	8(%rdi), %rax
	movl	8(%rax), %edi
	callq	_AT91F_SpiEnable
	movq	%r15, %rbx
	leal	(%r15,%r13), %eax
	movq	%r14, -48(%rbp)                 ## 8-byte Spill
	movq	8(%r14), %rcx
	movl	(%rcx), %r15d
	movl	4(%rcx), %ecx
	imull	%r15d, %ecx
	cmpl	%ecx, %eax
	jle	LBB0_3
## %bb.1:
	movq	_AT91C_DATAFLASH_MEMORY_OVERFLOW@GOTPCREL(%rip), %r15
	jmp	LBB0_2
LBB0_3:
	movl	%r13d, %eax
	xorl	%edx, %edx
	divl	%r15d
	testl	%edx, %edx
	je	LBB0_6
## %bb.4:
	subl	%edx, %r15d
	cmpl	%ebx, %r15d
	cmovael	%ebx, %r15d
	movq	-48(%rbp), %r14                 ## 8-byte Reload
	movq	%r14, %rdi
	movq	%r12, %rsi
	movl	%r13d, %edx
	movl	%r15d, %ecx
	callq	_AT91F_PartialPageWrite
	testl	%eax, %eax
	je	LBB0_14
## %bb.5:
	movl	(%r14), %edi
	movq	_AT91C_DATAFLASH_TIMEOUT@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	callq	_AT91F_DataFlashWaitReady
	subl	%r15d, %ebx
	addl	%r15d, %r13d
	movl	%r15d, %eax
	addq	%rax, %r12
	movq	8(%r14), %rax
	movl	(%rax), %r15d
LBB0_6:
	movq	%r12, %rcx
	cmpl	%r15d, %ebx
	jl	LBB0_11
## %bb.7:
	movq	_AT91C_DATAFLASH_TIMEOUT@GOTPCREL(%rip), %r14
	movq	-48(%rbp), %r12                 ## 8-byte Reload
	.p2align	4, 0x90
LBB0_8:                                 ## =>This Inner Loop Header: Depth=1
	movq	%rbx, -64(%rbp)                 ## 8-byte Spill
	movl	%r13d, %eax
	xorl	%edx, %edx
	divl	%r15d
	movl	%eax, %ebx
	movq	_DB_BUF1_WRITE@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r12, %rdi
	movq	%rcx, -56(%rbp)                 ## 8-byte Spill
	movq	%rcx, %rdx
	xorl	%ecx, %ecx
	movl	%r15d, %r8d
	callq	_AT91F_DataFlashWriteBuffer
	movl	(%r12), %edi
	movl	(%r14), %esi
	callq	_AT91F_DataFlashWaitReady
	movq	%r12, %rdi
	movl	%ebx, %esi
	callq	_AT91F_PageErase
	movl	%eax, %ebx
	movl	(%r12), %edi
	movl	(%r14), %esi
	callq	_AT91F_DataFlashWaitReady
	testl	%ebx, %ebx
	je	LBB0_14
## %bb.9:                               ##   in Loop: Header=BB0_8 Depth=1
	movq	_DB_BUF1_PAGE_PGM@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r12, %rdi
	movl	%r13d, %edx
	callq	_AT91F_WriteBufferToMain
	testl	%eax, %eax
	je	LBB0_14
## %bb.10:                              ##   in Loop: Header=BB0_8 Depth=1
	movl	(%r12), %edi
	movl	(%r14), %esi
	callq	_AT91F_DataFlashWaitReady
	movq	8(%r12), %rax
	movslq	(%rax), %r15
	movq	-64(%rbp), %rbx                 ## 8-byte Reload
	subl	%r15d, %ebx
	addl	%r15d, %r13d
	movq	-56(%rbp), %rcx                 ## 8-byte Reload
	addq	%r15, %rcx
	cmpl	%r15d, %ebx
	jge	LBB0_8
LBB0_11:
	movq	_AT91C_DATAFLASH_OK@GOTPCREL(%rip), %r15
	testl	%ebx, %ebx
	jle	LBB0_2
## %bb.12:
	movq	-48(%rbp), %r14                 ## 8-byte Reload
	movq	%r14, %rdi
	movq	%rcx, %rsi
	movl	%r13d, %edx
	movl	%ebx, %ecx
	callq	_AT91F_PartialPageWrite
	testl	%eax, %eax
	je	LBB0_14
## %bb.13:
	movl	(%r14), %edi
	movq	_AT91C_DATAFLASH_TIMEOUT@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	callq	_AT91F_DataFlashWaitReady
	jmp	LBB0_2
LBB0_14:
	movq	_AT91C_DATAFLASH_ERROR@GOTPCREL(%rip), %r15
LBB0_2:
	movl	(%r15), %eax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_AT91C_DATAFLASH_MEMORY_OVERFLOW,4,2 ## @AT91C_DATAFLASH_MEMORY_OVERFLOW
	.comm	_AT91C_DATAFLASH_ERROR,4,2      ## @AT91C_DATAFLASH_ERROR
	.comm	_AT91C_DATAFLASH_TIMEOUT,4,2    ## @AT91C_DATAFLASH_TIMEOUT
	.comm	_DB_BUF1_WRITE,4,2              ## @DB_BUF1_WRITE
	.comm	_DB_BUF1_PAGE_PGM,4,2           ## @DB_BUF1_PAGE_PGM
	.comm	_AT91C_DATAFLASH_OK,4,2         ## @AT91C_DATAFLASH_OK
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_AT91F_DataFlashWrite           ; -- Begin function AT91F_DataFlashWrite
	.p2align	2
_AT91F_DataFlashWrite:                  ; @AT91F_DataFlashWrite
	.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	x20, x3
	mov	x21, x2
	mov	x22, x1
	mov	x19, x0
	ldr	x8, [x0, #8]
	ldr	w0, [x8, #8]
	bl	_AT91F_SpiEnable
	ldr	x8, [x19, #8]
	ldp	w4, w8, [x8]
	mul	w8, w8, w4
	add	w9, w20, w21
	cmp	w9, w8
	b.le	LBB0_2
; %bb.1:
Lloh0:
	adrp	x24, _AT91C_DATAFLASH_MEMORY_OVERFLOW@GOTPAGE
Lloh1:
	ldr	x24, [x24, _AT91C_DATAFLASH_MEMORY_OVERFLOW@GOTPAGEOFF]
	b	LBB0_15
LBB0_2:
	udiv	w8, w21, w4
	msub	w8, w8, w4, w21
	cbz	w8, LBB0_5
; %bb.3:
	sub	w8, w4, w8
	cmp	w8, w20
	csel	w23, w8, w20, lo
	mov	x0, x19
	mov	x1, x22
	mov	x2, x21
	mov	x3, x23
	bl	_AT91F_PartialPageWrite
	cbz	w0, LBB0_14
; %bb.4:
	ldr	w0, [x19]
Lloh2:
	adrp	x8, _AT91C_DATAFLASH_TIMEOUT@GOTPAGE
Lloh3:
	ldr	x8, [x8, _AT91C_DATAFLASH_TIMEOUT@GOTPAGEOFF]
Lloh4:
	ldr	w1, [x8]
	bl	_AT91F_DataFlashWaitReady
	sub	w20, w20, w23
	add	w21, w23, w21
	add	x22, x22, w23, uxtw
	ldr	x8, [x19, #8]
	ldr	w4, [x8]
LBB0_5:
	cmp	w20, w4
	b.lt	LBB0_10
; %bb.6:
Lloh5:
	adrp	x25, _DB_BUF1_WRITE@GOTPAGE
Lloh6:
	ldr	x25, [x25, _DB_BUF1_WRITE@GOTPAGEOFF]
Lloh7:
	adrp	x26, _AT91C_DATAFLASH_TIMEOUT@GOTPAGE
Lloh8:
	ldr	x26, [x26, _AT91C_DATAFLASH_TIMEOUT@GOTPAGEOFF]
Lloh9:
	adrp	x24, _AT91C_DATAFLASH_ERROR@GOTPAGE
Lloh10:
	ldr	x24, [x24, _AT91C_DATAFLASH_ERROR@GOTPAGEOFF]
Lloh11:
	adrp	x27, _DB_BUF1_PAGE_PGM@GOTPAGE
Lloh12:
	ldr	x27, [x27, _DB_BUF1_PAGE_PGM@GOTPAGEOFF]
LBB0_7:                                 ; =>This Inner Loop Header: Depth=1
	ldr	w1, [x25]
	udiv	w23, w21, w4
	mov	x0, x19
	mov	x2, x22
	mov	w3, #0
                                        ; kill: def $w4 killed $w4 killed $x4
	bl	_AT91F_DataFlashWriteBuffer
	ldr	w0, [x19]
	ldr	w1, [x26]
	bl	_AT91F_DataFlashWaitReady
	mov	x0, x19
	mov	x1, x23
	bl	_AT91F_PageErase
	mov	x23, x0
	ldr	w0, [x19]
	ldr	w1, [x26]
	bl	_AT91F_DataFlashWaitReady
	cbz	w23, LBB0_15
; %bb.8:                                ;   in Loop: Header=BB0_7 Depth=1
	ldr	w1, [x27]
	mov	x0, x19
	mov	x2, x21
	bl	_AT91F_WriteBufferToMain
	cbz	w0, LBB0_15
; %bb.9:                                ;   in Loop: Header=BB0_7 Depth=1
	ldr	w0, [x19]
	ldr	w1, [x26]
	bl	_AT91F_DataFlashWaitReady
	ldr	x8, [x19, #8]
	ldrsw	x4, [x8]
	add	w21, w4, w21
	add	x22, x22, x4
	sub	w20, w20, w4
	cmp	w20, w4
	b.ge	LBB0_7
LBB0_10:
	cmp	w20, #1
	b.lt	LBB0_13
; %bb.11:
	mov	x0, x19
	mov	x1, x22
	mov	x2, x21
	mov	x3, x20
	bl	_AT91F_PartialPageWrite
	cbz	w0, LBB0_14
; %bb.12:
	ldr	w0, [x19]
Lloh13:
	adrp	x8, _AT91C_DATAFLASH_TIMEOUT@GOTPAGE
Lloh14:
	ldr	x8, [x8, _AT91C_DATAFLASH_TIMEOUT@GOTPAGEOFF]
Lloh15:
	ldr	w1, [x8]
	bl	_AT91F_DataFlashWaitReady
LBB0_13:
Lloh16:
	adrp	x24, _AT91C_DATAFLASH_OK@GOTPAGE
Lloh17:
	ldr	x24, [x24, _AT91C_DATAFLASH_OK@GOTPAGEOFF]
	b	LBB0_15
LBB0_14:
Lloh18:
	adrp	x24, _AT91C_DATAFLASH_ERROR@GOTPAGE
Lloh19:
	ldr	x24, [x24, _AT91C_DATAFLASH_ERROR@GOTPAGEOFF]
LBB0_15:
	ldr	w0, [x24]
	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 AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.loh AdrpLdrGot	Lloh11, Lloh12
	.loh AdrpLdrGot	Lloh9, Lloh10
	.loh AdrpLdrGot	Lloh7, Lloh8
	.loh AdrpLdrGot	Lloh5, Lloh6
	.loh AdrpLdrGotLdr	Lloh13, Lloh14, Lloh15
	.loh AdrpLdrGot	Lloh16, Lloh17
	.loh AdrpLdrGot	Lloh18, Lloh19
	.cfi_endproc
                                        ; -- End function
	.comm	_AT91C_DATAFLASH_MEMORY_OVERFLOW,4,2 ; @AT91C_DATAFLASH_MEMORY_OVERFLOW
	.comm	_AT91C_DATAFLASH_ERROR,4,2      ; @AT91C_DATAFLASH_ERROR
	.comm	_AT91C_DATAFLASH_TIMEOUT,4,2    ; @AT91C_DATAFLASH_TIMEOUT
	.comm	_DB_BUF1_WRITE,4,2              ; @DB_BUF1_WRITE
	.comm	_DB_BUF1_PAGE_PGM,4,2           ; @DB_BUF1_PAGE_PGM
	.comm	_AT91C_DATAFLASH_OK,4,2         ; @AT91C_DATAFLASH_OK
.subsections_via_symbols
