	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function spear_mtd_erase
_spear_mtd_erase:                       ## @spear_mtd_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	$24, %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
	callq	_get_flash_data
	testq	%rax, %rax
	je	LBB0_2
## %bb.1:
	movq	%rax, %r15
	movq	8(%rbx), %rax
	testq	%rax, %rax
	je	LBB0_2
## %bb.4:
	movl	(%r15), %ecx
	movl	%ecx, -44(%rbp)                 ## 4-byte Spill
	cmpl	(%rax), %ecx
	jge	LBB0_5
## %bb.6:
	movq	%rax, -64(%rbp)                 ## 8-byte Spill
	movl	(%r12), %r13d
	movl	4(%r12), %r14d
	movq	%r15, %rdi
	addq	$4, %rdi
	movq	%rdi, -56(%rbp)                 ## 8-byte Spill
	callq	_mutex_lock
	testl	%r14d, %r14d
	je	LBB0_10
	.p2align	4, 0x90
LBB0_7:                                 ## =>This Inner Loop Header: Depth=1
	movq	%r15, %rdi
	movl	%r13d, %esi
	callq	_get_sector_erase_cmd
	movq	-64(%rbp), %rdi                 ## 8-byte Reload
	movl	-44(%rbp), %esi                 ## 4-byte Reload
	movl	%eax, %edx
	movl	$4, %ecx
	callq	_spear_smi_erase_sector
	testl	%eax, %eax
	jne	LBB0_8
## %bb.9:                               ##   in Loop: Header=BB0_7 Depth=1
	movl	(%rbx), %eax
	addl	%eax, %r13d
	subl	%eax, %r14d
	jne	LBB0_7
LBB0_10:
	movq	-56(%rbp), %rdi                 ## 8-byte Reload
	callq	_mutex_unlock
	xorl	%r12d, %r12d
	jmp	LBB0_11
LBB0_2:
	movq	_ENODEV@GOTPCREL(%rip), %rax
	jmp	LBB0_3
LBB0_5:
	movq	8(%rax), %rdi
	leaq	L_.str(%rip), %rsi
	callq	_dev_err
	movq	_EINVAL@GOTPCREL(%rip), %rax
LBB0_3:
	xorl	%r12d, %r12d
	subl	(%rax), %r12d
LBB0_11:
	movl	%r12d, %eax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_8:
	movl	%eax, %r12d
	movq	-56(%rbp), %rdi                 ## 8-byte Reload
	callq	_mutex_unlock
	jmp	LBB0_11
	.cfi_endproc
                                        ## -- End function
	.comm	_ENODEV,4,2                     ## @ENODEV
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Invalid Bank Num"

	.comm	_EINVAL,4,2                     ## @EINVAL
	.no_dead_strip	_spear_mtd_erase
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function spear_mtd_erase
_spear_mtd_erase:                       ; @spear_mtd_erase
	.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	x23, x1
	mov	x19, x0
	bl	_get_flash_data
	cbz	x0, LBB0_7
; %bb.1:
	ldr	x21, [x19, #8]
	cbz	x21, LBB0_7
; %bb.2:
	mov	x20, x0
	ldr	w22, [x0]
	ldr	w8, [x21]
	cmp	w22, w8
	b.ge	LBB0_8
; %bb.3:
	ldp	w24, w26, [x23]
	add	x23, x20, #4
	mov	x0, x23
	bl	_mutex_lock
	cbz	w26, LBB0_6
LBB0_4:                                 ; =>This Inner Loop Header: Depth=1
	mov	x0, x20
	mov	x1, x24
	bl	_get_sector_erase_cmd
	mov	x2, x0
	mov	x0, x21
	mov	x1, x22
	mov	w3, #4
	bl	_spear_smi_erase_sector
	cbnz	w0, LBB0_11
; %bb.5:                                ;   in Loop: Header=BB0_4 Depth=1
	ldr	w8, [x19]
	add	w24, w24, w8
	subs	w26, w26, w8
	b.ne	LBB0_4
LBB0_6:
	mov	x0, x23
	bl	_mutex_unlock
	mov	w25, #0
	b	LBB0_10
LBB0_7:
Lloh0:
	adrp	x8, _ENODEV@GOTPAGE
Lloh1:
	ldr	x8, [x8, _ENODEV@GOTPAGEOFF]
	b	LBB0_9
LBB0_8:
	ldr	x0, [x21, #8]
Lloh2:
	adrp	x1, l_.str@PAGE
Lloh3:
	add	x1, x1, l_.str@PAGEOFF
	bl	_dev_err
Lloh4:
	adrp	x8, _EINVAL@GOTPAGE
Lloh5:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
LBB0_9:
	ldr	w8, [x8]
	neg	w25, w8
LBB0_10:
	mov	x0, x25
	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_11:
	mov	x25, x0
	mov	x0, x23
	bl	_mutex_unlock
	b	LBB0_10
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGot	Lloh4, Lloh5
	.loh AdrpAdd	Lloh2, Lloh3
	.cfi_endproc
                                        ; -- End function
	.comm	_ENODEV,4,2                     ; @ENODEV
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Invalid Bank Num"

	.comm	_EINVAL,4,2                     ; @EINVAL
	.no_dead_strip	_spear_mtd_erase
.subsections_via_symbols
