	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function spi_nor_erase
_spi_nor_erase:                         ## @spi_nor_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
	pushq	%rax
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rsi, %rbx
	movq	%rdi, %r14
	callq	_mtd_to_spi_nor
	movq	%rax, %r15
	movl	4(%rax), %edi
	movslq	(%rbx), %rdx
	movslq	4(%rbx), %rcx
	leaq	L_.str(%rip), %rsi
	callq	_dev_dbg
	movq	%r15, %rdi
	callq	_spi_nor_has_uniform_erase
	testq	%rax, %rax
	je	LBB0_3
## %bb.1:
	movl	4(%rbx), %edi
	movl	(%r14), %esi
	leaq	-48(%rbp), %rdx
	callq	_div_u64_rem
	cmpq	$0, -48(%rbp)
	je	LBB0_3
## %bb.2:
	movq	_EINVAL@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
	jmp	LBB0_19
LBB0_3:
	movl	(%rbx), %r12d
	movl	4(%rbx), %r13d
	movq	_SPI_NOR_OPS_ERASE@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r15, %rdi
	callq	_spi_nor_lock_and_prep
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	LBB0_19
## %bb.4:
	cmpl	4(%r14), %r13d
	jne	LBB0_6
## %bb.5:
	movq	_SNOR_F_NO_OP_CHIP_ERASE@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	testl	%eax, (%r15)
	je	LBB0_12
LBB0_6:
	movq	%r15, %rdi
	callq	_spi_nor_has_uniform_erase
	testq	%rax, %rax
	je	LBB0_11
	.p2align	4, 0x90
LBB0_7:                                 ## =>This Inner Loop Header: Depth=1
	testl	%r13d, %r13d
	je	LBB0_17
## %bb.8:                               ##   in Loop: Header=BB0_7 Depth=1
	movq	%r15, %rdi
	callq	_write_enable
	movq	%r15, %rdi
	movl	%r12d, %esi
	callq	_spi_nor_erase_sector
	testl	%eax, %eax
	jne	LBB0_14
## %bb.9:                               ##   in Loop: Header=BB0_7 Depth=1
	movl	(%r14), %eax
	addl	%eax, %r12d
	subl	%eax, %r13d
	movq	%r15, %rdi
	callq	_spi_nor_wait_till_ready
	testl	%eax, %eax
	je	LBB0_7
LBB0_14:
	movl	%eax, %ebx
	jmp	LBB0_18
LBB0_11:
	movq	%r15, %rdi
	movl	%r12d, %esi
	movl	%r13d, %edx
	callq	_spi_nor_erase_multi_sectors
	jmp	LBB0_16
LBB0_12:
	movq	%r15, %rdi
	callq	_write_enable
	movq	%r15, %rdi
	callq	_erase_chip
	testq	%rax, %rax
	je	LBB0_15
## %bb.13:
	movq	_EIO@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
	jmp	LBB0_18
LBB0_15:
	movq	_CHIP_ERASE_2MB_READY_WAIT_JIFFIES@GOTPCREL(%rip), %rax
	movq	(%rax), %rdi
	movl	4(%r14), %eax
	movq	_SZ_2M@GOTPCREL(%rip), %rcx
	cltd
	idivl	(%rcx)
	movslq	%eax, %rsi
	imulq	%rdi, %rsi
	callq	_max
	movq	%r15, %rdi
	movq	%rax, %rsi
	callq	_spi_nor_wait_till_ready_with_timeout
LBB0_16:
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	LBB0_18
LBB0_17:
	movq	%r15, %rdi
	callq	_write_disable
	xorl	%ebx, %ebx
LBB0_18:
	movq	_SPI_NOR_OPS_ERASE@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r15, %rdi
	callq	_spi_nor_unlock_and_unprep
LBB0_19:
	movl	%ebx, %eax
	addq	$8, %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	"at 0x%llx, len %lld\n"

	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_SPI_NOR_OPS_ERASE,4,2          ## @SPI_NOR_OPS_ERASE
	.comm	_SNOR_F_NO_OP_CHIP_ERASE,4,2    ## @SNOR_F_NO_OP_CHIP_ERASE
	.comm	_EIO,4,2                        ## @EIO
	.comm	_CHIP_ERASE_2MB_READY_WAIT_JIFFIES,8,3 ## @CHIP_ERASE_2MB_READY_WAIT_JIFFIES
	.comm	_SZ_2M,4,2                      ## @SZ_2M
	.no_dead_strip	_spi_nor_erase
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function spi_nor_erase
_spi_nor_erase:                         ; @spi_nor_erase
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #80
	.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
	mov	x22, x1
	mov	x20, x0
	bl	_mtd_to_spi_nor
	mov	x19, x0
	ldr	w0, [x0, #4]
	ldpsw	x2, x3, [x22]
Lloh0:
	adrp	x1, l_.str@PAGE
Lloh1:
	add	x1, x1, l_.str@PAGEOFF
	bl	_dev_dbg
	mov	x0, x19
	bl	_spi_nor_has_uniform_erase
	cbz	x0, LBB0_3
; %bb.1:
	ldr	w0, [x22, #4]
	ldr	w1, [x20]
	add	x2, sp, #8
	bl	_div_u64_rem
	ldr	x8, [sp, #8]
	cbz	x8, LBB0_3
; %bb.2:
Lloh2:
	adrp	x8, _EINVAL@GOTPAGE
Lloh3:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh4:
	ldr	w8, [x8]
	neg	w23, w8
	b	LBB0_17
LBB0_3:
	ldp	w21, w22, [x22]
Lloh5:
	adrp	x24, _SPI_NOR_OPS_ERASE@GOTPAGE
Lloh6:
	ldr	x24, [x24, _SPI_NOR_OPS_ERASE@GOTPAGEOFF]
	ldr	w1, [x24]
	mov	x0, x19
	bl	_spi_nor_lock_and_prep
	mov	x23, x0
	cbnz	w0, LBB0_17
; %bb.4:
	ldr	w8, [x20, #4]
	cmp	w22, w8
	b.ne	LBB0_6
; %bb.5:
	ldr	w8, [x19]
Lloh7:
	adrp	x9, _SNOR_F_NO_OP_CHIP_ERASE@GOTPAGE
Lloh8:
	ldr	x9, [x9, _SNOR_F_NO_OP_CHIP_ERASE@GOTPAGEOFF]
Lloh9:
	ldr	w9, [x9]
	tst	w9, w8
	b.eq	LBB0_13
LBB0_6:
	mov	x0, x19
	bl	_spi_nor_has_uniform_erase
	cbz	x0, LBB0_11
LBB0_7:                                 ; =>This Inner Loop Header: Depth=1
	cbz	w22, LBB0_12
; %bb.8:                                ;   in Loop: Header=BB0_7 Depth=1
	mov	x0, x19
	bl	_write_enable
	mov	x0, x19
	mov	x1, x21
	bl	_spi_nor_erase_sector
	cbnz	w0, LBB0_10
; %bb.9:                                ;   in Loop: Header=BB0_7 Depth=1
	ldr	w8, [x20]
	add	w21, w8, w21
	sub	w22, w22, w8
	mov	x0, x19
	bl	_spi_nor_wait_till_ready
	cbz	w0, LBB0_7
LBB0_10:
	mov	x23, x0
	b	LBB0_16
LBB0_11:
	mov	x0, x19
	mov	x1, x21
	mov	x2, x22
	bl	_spi_nor_erase_multi_sectors
	mov	x23, x0
	cbnz	w0, LBB0_16
LBB0_12:
	mov	x0, x19
	bl	_write_disable
	mov	w23, #0
	b	LBB0_16
LBB0_13:
	mov	x0, x19
	bl	_write_enable
	mov	x0, x19
	bl	_erase_chip
	cbz	x0, LBB0_15
; %bb.14:
Lloh10:
	adrp	x8, _EIO@GOTPAGE
Lloh11:
	ldr	x8, [x8, _EIO@GOTPAGEOFF]
Lloh12:
	ldr	w8, [x8]
	neg	w23, w8
	b	LBB0_16
LBB0_15:
Lloh13:
	adrp	x8, _CHIP_ERASE_2MB_READY_WAIT_JIFFIES@GOTPAGE
Lloh14:
	ldr	x8, [x8, _CHIP_ERASE_2MB_READY_WAIT_JIFFIES@GOTPAGEOFF]
Lloh15:
	ldr	x0, [x8]
	ldr	w8, [x20, #4]
Lloh16:
	adrp	x9, _SZ_2M@GOTPAGE
Lloh17:
	ldr	x9, [x9, _SZ_2M@GOTPAGEOFF]
Lloh18:
	ldr	w9, [x9]
	sdiv	w8, w8, w9
	sxtw	x8, w8
	mul	x1, x0, x8
	bl	_max
	mov	x1, x0
	mov	x0, x19
	bl	_spi_nor_wait_till_ready_with_timeout
	mov	x23, x0
	cbz	w0, LBB0_12
LBB0_16:
	ldr	w1, [x24]
	mov	x0, x19
	bl	_spi_nor_unlock_and_unprep
LBB0_17:
	mov	x0, x23
	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
	add	sp, sp, #80
	ret
	.loh AdrpAdd	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.loh AdrpLdrGot	Lloh5, Lloh6
	.loh AdrpLdrGotLdr	Lloh7, Lloh8, Lloh9
	.loh AdrpLdrGotLdr	Lloh10, Lloh11, Lloh12
	.loh AdrpLdrGotLdr	Lloh16, Lloh17, Lloh18
	.loh AdrpLdrGotLdr	Lloh13, Lloh14, Lloh15
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"at 0x%llx, len %lld\n"

	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_SPI_NOR_OPS_ERASE,4,2          ; @SPI_NOR_OPS_ERASE
	.comm	_SNOR_F_NO_OP_CHIP_ERASE,4,2    ; @SNOR_F_NO_OP_CHIP_ERASE
	.comm	_EIO,4,2                        ; @EIO
	.comm	_CHIP_ERASE_2MB_READY_WAIT_JIFFIES,8,3 ; @CHIP_ERASE_2MB_READY_WAIT_JIFFIES
	.comm	_SZ_2M,4,2                      ; @SZ_2M
	.no_dead_strip	_spi_nor_erase
.subsections_via_symbols
