	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function mtd_erase
_mtd_erase:                             ## @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	%rdi, %rbx
	movq	_quiet@GOTPCREL(%rip), %r12
	cmpl	$1, (%r12)
	jg	LBB0_2
## %bb.1:
	movq	_stderr@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	leaq	L_.str(%rip), %rsi
	movq	%rbx, %rdx
	xorl	%eax, %eax
	callq	_fprintf
LBB0_2:
	movq	%rbx, -56(%rbp)                 ## 8-byte Spill
	movq	%rbx, %rdi
	callq	_mtd_check_open
	testl	%eax, %eax
	js	LBB0_12
## %bb.3:
	movl	%eax, %ebx
	movq	_erasesize@GOTPCREL(%rip), %r13
	movl	(%r13), %eax
	movl	%eax, -44(%rbp)
	movl	$0, -48(%rbp)
	movq	_mtdsize@GOTPCREL(%rip), %r14
	cmpl	$0, (%r14)
	jle	LBB0_11
## %bb.4:
	leaq	-48(%rbp), %r15
	xorl	%esi, %esi
	jmp	LBB0_5
	.p2align	4, 0x90
LBB0_10:                                ##   in Loop: Header=BB0_5 Depth=1
	movl	-48(%rbp), %esi
	addl	(%r13), %esi
	movl	%esi, -48(%rbp)
	cmpl	(%r14), %esi
	jge	LBB0_11
LBB0_5:                                 ## =>This Inner Loop Header: Depth=1
	movl	%ebx, %edi
	callq	_mtd_block_is_bad
	testq	%rax, %rax
	je	LBB0_8
## %bb.6:                               ##   in Loop: Header=BB0_5 Depth=1
	cmpl	$0, (%r12)
	jne	LBB0_10
## %bb.7:                               ##   in Loop: Header=BB0_5 Depth=1
	movq	_stderr@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movl	-48(%rbp), %edx
	leaq	L_.str.2(%rip), %rsi
	xorl	%eax, %eax
	callq	_fprintf
	jmp	LBB0_10
	.p2align	4, 0x90
LBB0_8:                                 ##   in Loop: Header=BB0_5 Depth=1
	movq	_MEMUNLOCK@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movl	%ebx, %edi
	movq	%r15, %rdx
	callq	_ioctl
	movq	_MEMERASE@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movl	%ebx, %edi
	movq	%r15, %rdx
	callq	_ioctl
	testq	%rax, %rax
	je	LBB0_10
## %bb.9:                               ##   in Loop: Header=BB0_5 Depth=1
	movq	_stderr@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movl	-48(%rbp), %ecx
	leaq	L_.str.3(%rip), %rsi
	movq	-56(%rbp), %rdx                 ## 8-byte Reload
	xorl	%eax, %eax
	callq	_fprintf
	jmp	LBB0_10
LBB0_11:
	movl	%ebx, %edi
	callq	_close
	xorl	%eax, %eax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_12:
	movq	_stderr@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	leaq	L_.str.1(%rip), %rsi
	movq	-56(%rbp), %rdx                 ## 8-byte Reload
	xorl	%eax, %eax
	callq	_fprintf
	movl	$1, %edi
	callq	_exit
	.cfi_endproc
                                        ## -- End function
	.comm	_quiet,4,2                      ## @quiet
	.comm	_stderr,4,2                     ## @stderr
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Erasing %s ...\n"

L_.str.1:                               ## @.str.1
	.asciz	"Could not open mtd device: %s\n"

	.comm	_erasesize,4,2                  ## @erasesize
	.comm	_mtdsize,4,2                    ## @mtdsize
L_.str.2:                               ## @.str.2
	.asciz	"\nSkipping bad block at 0x%x   "

	.comm	_MEMUNLOCK,4,2                  ## @MEMUNLOCK
	.comm	_MEMERASE,4,2                   ## @MEMERASE
L_.str.3:                               ## @.str.3
	.asciz	"Failed to erase block on %s at 0x%x\n"

	.no_dead_strip	_mtd_erase
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function mtd_erase
_mtd_erase:                             ; @mtd_erase
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #128
	.cfi_def_cfa_offset 128
	stp	x28, x27, [sp, #32]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #48]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #64]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #80]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #96]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #112]            ; 16-byte Folded Spill
	add	x29, sp, #112
	.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, x0
Lloh0:
	adrp	x23, _quiet@GOTPAGE
Lloh1:
	ldr	x23, [x23, _quiet@GOTPAGEOFF]
	ldr	w8, [x23]
Lloh2:
	adrp	x24, _stderr@GOTPAGE
Lloh3:
	ldr	x24, [x24, _stderr@GOTPAGEOFF]
	cmp	w8, #1
	b.gt	LBB0_2
; %bb.1:
	ldr	w0, [x24]
	str	x19, [sp]
Lloh4:
	adrp	x1, l_.str@PAGE
Lloh5:
	add	x1, x1, l_.str@PAGEOFF
	bl	_fprintf
LBB0_2:
	mov	x0, x19
	bl	_mtd_check_open
	tbnz	w0, #31, LBB0_13
; %bb.3:
	mov	x20, x0
Lloh6:
	adrp	x25, _erasesize@GOTPAGE
Lloh7:
	ldr	x25, [x25, _erasesize@GOTPAGEOFF]
	ldr	w8, [x25]
	stp	wzr, w8, [sp, #24]
Lloh8:
	adrp	x26, _mtdsize@GOTPAGE
Lloh9:
	ldr	x26, [x26, _mtdsize@GOTPAGEOFF]
	ldr	w8, [x26]
	cmp	w8, #1
	b.lt	LBB0_12
; %bb.4:
	mov	w1, #0
Lloh10:
	adrp	x27, _MEMUNLOCK@GOTPAGE
Lloh11:
	ldr	x27, [x27, _MEMUNLOCK@GOTPAGEOFF]
Lloh12:
	adrp	x28, _MEMERASE@GOTPAGE
Lloh13:
	ldr	x28, [x28, _MEMERASE@GOTPAGEOFF]
Lloh14:
	adrp	x21, l_.str.3@PAGE
Lloh15:
	add	x21, x21, l_.str.3@PAGEOFF
Lloh16:
	adrp	x22, l_.str.2@PAGE
Lloh17:
	add	x22, x22, l_.str.2@PAGEOFF
	b	LBB0_9
LBB0_5:                                 ;   in Loop: Header=BB0_9 Depth=1
	ldr	w1, [x27]
	add	x2, sp, #24
	mov	x0, x20
	bl	_ioctl
	ldr	w1, [x28]
	add	x2, sp, #24
	mov	x0, x20
	bl	_ioctl
	cbz	x0, LBB0_8
; %bb.6:                                ;   in Loop: Header=BB0_9 Depth=1
	ldr	w0, [x24]
	ldr	w8, [sp, #24]
	stp	x19, x8, [sp]
	mov	x1, x21
LBB0_7:                                 ;   in Loop: Header=BB0_9 Depth=1
	bl	_fprintf
LBB0_8:                                 ;   in Loop: Header=BB0_9 Depth=1
	ldr	w8, [x25]
	ldr	w9, [sp, #24]
	ldr	w10, [x26]
	add	w1, w9, w8
	cmp	w1, w10
	str	w1, [sp, #24]
	b.ge	LBB0_12
LBB0_9:                                 ; =>This Inner Loop Header: Depth=1
	mov	x0, x20
	bl	_mtd_block_is_bad
	cbz	x0, LBB0_5
; %bb.10:                               ;   in Loop: Header=BB0_9 Depth=1
	ldr	w8, [x23]
	cbnz	w8, LBB0_8
; %bb.11:                               ;   in Loop: Header=BB0_9 Depth=1
	ldr	w0, [x24]
	ldr	w8, [sp, #24]
	str	x8, [sp]
	mov	x1, x22
	b	LBB0_7
LBB0_12:
	mov	x0, x20
	bl	_close
	mov	w0, #0
	ldp	x29, x30, [sp, #112]            ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #96]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #80]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #64]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #48]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #32]             ; 16-byte Folded Reload
	add	sp, sp, #128
	ret
LBB0_13:
	ldr	w0, [x24]
	str	x19, [sp]
Lloh18:
	adrp	x1, l_.str.1@PAGE
Lloh19:
	add	x1, x1, l_.str.1@PAGEOFF
	bl	_fprintf
	mov	w0, #1
	bl	_exit
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpAdd	Lloh4, Lloh5
	.loh AdrpLdrGot	Lloh8, Lloh9
	.loh AdrpLdrGot	Lloh6, Lloh7
	.loh AdrpAdd	Lloh16, Lloh17
	.loh AdrpAdd	Lloh14, Lloh15
	.loh AdrpLdrGot	Lloh12, Lloh13
	.loh AdrpLdrGot	Lloh10, Lloh11
	.loh AdrpAdd	Lloh18, Lloh19
	.cfi_endproc
                                        ; -- End function
	.comm	_quiet,4,2                      ; @quiet
	.comm	_stderr,4,2                     ; @stderr
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Erasing %s ...\n"

l_.str.1:                               ; @.str.1
	.asciz	"Could not open mtd device: %s\n"

	.comm	_erasesize,4,2                  ; @erasesize
	.comm	_mtdsize,4,2                    ; @mtdsize
l_.str.2:                               ; @.str.2
	.asciz	"\nSkipping bad block at 0x%x   "

	.comm	_MEMUNLOCK,4,2                  ; @MEMUNLOCK
	.comm	_MEMERASE,4,2                   ; @MEMERASE
l_.str.3:                               ; @.str.3
	.asciz	"Failed to erase block on %s at 0x%x\n"

	.no_dead_strip	_mtd_erase
.subsections_via_symbols
