	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function dataflash_erase
_dataflash_erase:                       ## @dataflash_erase
	.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	$72, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rsi, %r12
	movq	(%rdi), %rbx
	movq	24(%rbx), %r14
	movq	$0, -104(%rbp)
	movl	(%rbx), %r15d
	movq	(%rsi), %rdx
	movq	8(%rsi), %rcx
	leaq	L_.str(%rip), %rsi
	xorl	%r13d, %r13d
	movq	%r14, %rdi
	xorl	%eax, %eax
	callq	_dev_dbg
	movq	8(%r12), %rdi
	movl	(%rbx), %esi
	leaq	-64(%rbp), %rdx
	callq	_div_u64_rem
	cmpq	$0, -64(%rbp)
	je	LBB0_2
## %bb.1:
	movq	_EINVAL@GOTPCREL(%rip), %rax
	subl	(%rax), %r13d
	jmp	LBB0_18
LBB0_2:
	movq	(%r12), %rdi
	movl	(%rbx), %esi
	leaq	-64(%rbp), %rdx
	callq	_div_u64_rem
	cmpq	$0, -64(%rbp)
	je	LBB0_4
## %bb.3:
	movq	_EINVAL@GOTPCREL(%rip), %rax
	xorl	%r13d, %r13d
	subl	(%rax), %r13d
	jmp	LBB0_18
LBB0_4:
	movq	%rbx, -56(%rbp)                 ## 8-byte Spill
	leaq	-72(%rbp), %rbx
	movq	%rbx, %rdi
	callq	_spi_message_init
	movq	-56(%rbp), %rax                 ## 8-byte Reload
	movq	16(%rax), %r13
	movq	%r13, -96(%rbp)
	movl	$4, -104(%rbp)
	leaq	-104(%rbp), %rdi
	movq	%rbx, %rsi
	movq	-56(%rbp), %rbx                 ## 8-byte Reload
	callq	_spi_message_add_tail
	leaq	8(%rbx), %rdi
	movq	%rdi, -88(%rbp)                 ## 8-byte Spill
	callq	_mutex_lock
	cmpq	$0, 8(%r12)
	jle	LBB0_17
## %bb.5:
	shll	$3, %r15d
	movl	%r15d, %eax
	movq	%rax, -80(%rbp)                 ## 8-byte Spill
	jmp	LBB0_6
	.p2align	4, 0x90
LBB0_15:                                ##   in Loop: Header=BB0_6 Depth=1
	addq	%rax, (%r12)
	movq	8(%r12), %rcx
	subq	%rax, %rcx
	movq	%rcx, 8(%r12)
	testq	%rcx, %rcx
	jle	LBB0_17
LBB0_6:                                 ## =>This Inner Loop Header: Depth=1
	movq	(%r12), %rdi
	movl	(%rbx), %esi
	callq	_div_u64
	movl	%eax, %r15d
	testb	$7, %r15b
	je	LBB0_8
## %bb.7:                               ##   in Loop: Header=BB0_6 Depth=1
	movl	4(%rbx), %ecx
	jmp	LBB0_9
	.p2align	4, 0x90
LBB0_8:                                 ##   in Loop: Header=BB0_6 Depth=1
	movl	4(%rbx), %ecx
	movq	-80(%rbp), %rax                 ## 8-byte Reload
	cmpq	%rax, 8(%r12)
	jge	LBB0_10
LBB0_9:                                 ##   in Loop: Header=BB0_6 Depth=1
	movl	$0, -44(%rbp)                   ## 4-byte Folded Spill
	movq	_OP_ERASE_PAGE@GOTPCREL(%rip), %rax
	leaq	L_.str.3(%rip), %rdx
LBB0_11:                                ##   in Loop: Header=BB0_6 Depth=1
                                        ## kill: def $cl killed $cl killed $ecx
	shll	%cl, %r15d
	movl	(%rax), %ecx
	movl	%ecx, (%r13)
	movl	%r15d, %r8d
	shrl	$16, %r8d
	movl	%r8d, 4(%r13)
	movl	%r15d, %r9d
	shrl	$8, %r9d
	movl	%r9d, 8(%r13)
	movl	$0, 12(%r13)
	movq	%r14, %rdi
	leaq	L_.str.1(%rip), %rsi
	xorl	%eax, %eax
	pushq	%r15
	pushq	$0
	callq	_dev_dbg
	addq	$16, %rsp
	movq	%r14, %rdi
	leaq	-72(%rbp), %rsi
	callq	_spi_sync
	movl	%eax, %ebx
	movq	%r14, %rdi
	callq	_dataflash_waitready
	testl	%ebx, %ebx
	js	LBB0_12
## %bb.13:                              ##   in Loop: Header=BB0_6 Depth=1
	movq	-80(%rbp), %rax                 ## 8-byte Reload
	cmpb	$0, -44(%rbp)                   ## 1-byte Folded Reload
	movq	-56(%rbp), %rbx                 ## 8-byte Reload
	jne	LBB0_15
## %bb.14:                              ##   in Loop: Header=BB0_6 Depth=1
	movslq	(%rbx), %rax
	jmp	LBB0_15
	.p2align	4, 0x90
LBB0_12:                                ##   in Loop: Header=BB0_6 Depth=1
	movq	%r14, %rdi
	leaq	L_.str.4(%rip), %rsi
	movl	%r15d, %edx
	movl	%ebx, %ecx
	callq	_dev_err
	movq	8(%r12), %rcx
	movq	-56(%rbp), %rbx                 ## 8-byte Reload
	testq	%rcx, %rcx
	jg	LBB0_6
	jmp	LBB0_17
LBB0_10:                                ##   in Loop: Header=BB0_6 Depth=1
	movb	$1, %al
	movl	%eax, -44(%rbp)                 ## 4-byte Spill
	movq	_OP_ERASE_BLOCK@GOTPCREL(%rip), %rax
	leaq	L_.str.2(%rip), %rdx
	jmp	LBB0_11
LBB0_17:
	movq	-88(%rbp), %rdi                 ## 8-byte Reload
	callq	_mutex_unlock
	xorl	%r13d, %r13d
LBB0_18:
	movl	%r13d, %eax
	addq	$72, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"erase addr=0x%llx len 0x%llx\n"

	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_OP_ERASE_BLOCK,4,2             ## @OP_ERASE_BLOCK
	.comm	_OP_ERASE_PAGE,4,2              ## @OP_ERASE_PAGE
L_.str.1:                               ## @.str.1
	.asciz	"ERASE %s: (%x) %x %x %x [%i]\n"

L_.str.2:                               ## @.str.2
	.asciz	"block"

L_.str.3:                               ## @.str.3
	.asciz	"page"

L_.str.4:                               ## @.str.4
	.asciz	"erase %x, err %d\n"

	.no_dead_strip	_dataflash_erase
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function dataflash_erase
_dataflash_erase:                       ; @dataflash_erase
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #192
	.cfi_def_cfa_offset 192
	stp	x28, x27, [sp, #96]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #112]            ; 16-byte Folded Spill
	stp	x24, x23, [sp, #128]            ; 16-byte Folded Spill
	stp	x22, x21, [sp, #144]            ; 16-byte Folded Spill
	stp	x20, x19, [sp, #160]            ; 16-byte Folded Spill
	stp	x29, x30, [sp, #176]            ; 16-byte Folded Spill
	add	x29, sp, #176
	.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, x1
	ldr	x26, [x0]
	ldr	x20, [x26, #24]
	str	xzr, [sp, #80]
	ldr	w21, [x26]
	ldp	x8, x9, [x1]
	stp	x8, x9, [sp]
Lloh0:
	adrp	x1, l_.str@PAGE
Lloh1:
	add	x1, x1, l_.str@PAGEOFF
	mov	x0, x20
	bl	_dev_dbg
	ldr	x0, [x19, #8]
	ldr	w1, [x26]
	add	x2, sp, #64
	bl	_div_u64_rem
	ldr	x8, [sp, #64]
	cbnz	x8, LBB0_2
; %bb.1:
	ldr	x0, [x19]
	ldr	w1, [x26]
	add	x2, sp, #64
	bl	_div_u64_rem
	ldr	x8, [sp, #64]
	cbz	x8, LBB0_4
LBB0_2:
Lloh2:
	adrp	x8, _EINVAL@GOTPAGE
Lloh3:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh4:
	ldr	w8, [x8]
	neg	w0, w8
LBB0_3:
	ldp	x29, x30, [sp, #176]            ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #160]            ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #144]            ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #128]            ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #112]            ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #96]             ; 16-byte Folded Reload
	add	sp, sp, #192
	ret
LBB0_4:
	add	x0, sp, #72
	bl	_spi_message_init
	ldr	x27, [x26, #16]
	str	x27, [sp, #88]
	mov	w8, #4
	str	w8, [sp, #80]
	add	x0, sp, #80
	add	x1, sp, #72
	bl	_spi_message_add_tail
	add	x0, x26, #8
	str	x0, [sp, #56]                   ; 8-byte Folded Spill
	bl	_mutex_lock
	ldr	x8, [x19, #8]
	cmp	x8, #1
	b.lt	LBB0_14
; %bb.5:
	lsl	w21, w21, #3
Lloh5:
	adrp	x23, _OP_ERASE_PAGE@GOTPAGE
Lloh6:
	ldr	x23, [x23, _OP_ERASE_PAGE@GOTPAGEOFF]
Lloh7:
	adrp	x22, l_.str.1@PAGE
Lloh8:
	add	x22, x22, l_.str.1@PAGEOFF
	b	LBB0_7
LBB0_6:                                 ;   in Loop: Header=BB0_7 Depth=1
	ldp	x9, x10, [x19]
	add	x9, x9, x8
	sub	x8, x10, x8
	stp	x9, x8, [x19]
	cmp	x8, #0
	b.le	LBB0_14
LBB0_7:                                 ; =>This Inner Loop Header: Depth=1
	ldr	x0, [x19]
	ldr	w1, [x26]
	bl	_div_u64
	tst	w0, #0x7
	b.eq	LBB0_9
; %bb.8:                                ;   in Loop: Header=BB0_7 Depth=1
	mov	w28, #0
	ldr	w9, [x26, #4]
	mov	x10, x23
Lloh9:
	adrp	x8, l_.str.3@PAGE
Lloh10:
	add	x8, x8, l_.str.3@PAGEOFF
	b	LBB0_10
LBB0_9:                                 ;   in Loop: Header=BB0_7 Depth=1
	ldr	x8, [x19, #8]
	ldr	w9, [x26, #4]
	cmp	x8, x21
Lloh11:
	adrp	x8, _OP_ERASE_BLOCK@GOTPAGE
Lloh12:
	ldr	x8, [x8, _OP_ERASE_BLOCK@GOTPAGEOFF]
	csel	x10, x23, x8, lt
	mov	w8, #1
	csel	w28, wzr, w8, lt
Lloh13:
	adrp	x8, l_.str.3@PAGE
Lloh14:
	add	x8, x8, l_.str.3@PAGEOFF
Lloh15:
	adrp	x11, l_.str.2@PAGE
Lloh16:
	add	x11, x11, l_.str.2@PAGEOFF
	csel	x8, x8, x11, lt
LBB0_10:                                ;   in Loop: Header=BB0_7 Depth=1
	ldr	w10, [x10]
	lsl	w24, w0, w9
	lsr	w9, w24, #16
	stp	w10, w9, [x27]
	lsr	w11, w24, #8
	stp	w11, wzr, [x27, #8]
	stp	xzr, x24, [sp, #32]
	stp	x9, x11, [sp, #16]
	stp	x8, x10, [sp]
	mov	x0, x20
	mov	x1, x22
	bl	_dev_dbg
	add	x1, sp, #72
	mov	x0, x20
	bl	_spi_sync
	mov	x25, x0
	mov	x0, x20
	bl	_dataflash_waitready
	tbnz	w25, #31, LBB0_13
; %bb.11:                               ;   in Loop: Header=BB0_7 Depth=1
	mov	x8, x21
	tbnz	w28, #0, LBB0_6
; %bb.12:                               ;   in Loop: Header=BB0_7 Depth=1
	ldrsw	x8, [x26]
	b	LBB0_6
LBB0_13:                                ;   in Loop: Header=BB0_7 Depth=1
	mov	x0, x20
Lloh17:
	adrp	x1, l_.str.4@PAGE
Lloh18:
	add	x1, x1, l_.str.4@PAGEOFF
	mov	x2, x24
	mov	x3, x25
	bl	_dev_err
	ldr	x8, [x19, #8]
	cmp	x8, #0
	b.gt	LBB0_7
LBB0_14:
	ldr	x0, [sp, #56]                   ; 8-byte Folded Reload
	bl	_mutex_unlock
	mov	w0, #0
	b	LBB0_3
	.loh AdrpAdd	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.loh AdrpAdd	Lloh7, Lloh8
	.loh AdrpLdrGot	Lloh5, Lloh6
	.loh AdrpAdd	Lloh9, Lloh10
	.loh AdrpAdd	Lloh15, Lloh16
	.loh AdrpAdd	Lloh13, Lloh14
	.loh AdrpLdrGot	Lloh11, Lloh12
	.loh AdrpAdd	Lloh17, Lloh18
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"erase addr=0x%llx len 0x%llx\n"

	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_OP_ERASE_BLOCK,4,2             ; @OP_ERASE_BLOCK
	.comm	_OP_ERASE_PAGE,4,2              ; @OP_ERASE_PAGE
l_.str.1:                               ; @.str.1
	.asciz	"ERASE %s: (%x) %x %x %x [%i]\n"

l_.str.2:                               ; @.str.2
	.asciz	"block"

l_.str.3:                               ; @.str.3
	.asciz	"page"

l_.str.4:                               ; @.str.4
	.asciz	"erase %x, err %d\n"

	.no_dead_strip	_dataflash_erase
.subsections_via_symbols
