	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_mtd_tpl_recoverflag_write      ## -- Begin function mtd_tpl_recoverflag_write
	.p2align	4, 0x90
_mtd_tpl_recoverflag_write:             ## @mtd_tpl_recoverflag_write
	.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	%esi, %r12d
	movq	%rdi, %rbx
	movq	_erasesize@GOTPCREL(%rip), %r13
	movl	(%r13), %edi
	callq	_malloc
	testq	%rax, %rax
	je	LBB0_1
## %bb.2:
	movq	%rax, %r15
	movq	%rbx, %rdi
	callq	_mtd_check_open
	movl	%eax, %r14d
	testl	%eax, %eax
	js	LBB0_3
## %bb.4:
	movl	(%r13), %edx
	xorl	%ebx, %ebx
	movl	%r14d, %edi
	movq	%r15, %rsi
	xorl	%ecx, %ecx
	callq	_pread
	testl	%r12d, %r12d
	jne	LBB0_5
## %bb.6:
	movq	_TPL_NO_RECOVER_MAGIC@GOTPCREL(%rip), %rax
	jmp	LBB0_7
LBB0_1:
	movq	_stderr@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	leaq	L_.str(%rip), %rsi
	xorl	%eax, %eax
	callq	_fprintf
	movl	$-1, %ebx
	jmp	LBB0_14
LBB0_3:
	movq	_stderr@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	leaq	L_.str.1(%rip), %rsi
	movq	%rbx, %rdx
	xorl	%eax, %eax
	callq	_fprintf
	movl	$-1, %ebx
	jmp	LBB0_13
LBB0_5:
	movq	_TPL_RECOVER_MAGIC@GOTPCREL(%rip), %rax
LBB0_7:
	movq	(%rax), %r12
	cmpq	(%r15), %r12
	je	LBB0_13
## %bb.8:
	movq	$0, -48(%rbp)
	movl	(%r13), %eax
	movl	%eax, -56(%rbp)
	movq	_MEMERASE@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	leaq	-56(%rbp), %rdx
	movl	%r14d, %edi
	callq	_ioctl
	testl	%eax, %eax
	js	LBB0_9
## %bb.10:
	movq	%r12, (%r15)
	movl	(%r13), %edx
	movl	%r14d, %edi
	movq	%r15, %rsi
	xorl	%ecx, %ecx
	callq	_pwrite
	movl	%eax, %ebx
	testl	%eax, %eax
	jns	LBB0_12
## %bb.11:
	movq	_stderr@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	leaq	L_.str.3(%rip), %rsi
	movl	%ebx, %edx
	xorl	%eax, %eax
	callq	_fprintf
LBB0_12:
	xorl	%eax, %eax
	callq	_sync
	jmp	LBB0_13
LBB0_9:
	movl	%eax, %ebx
	movq	_stderr@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	leaq	L_.str.2(%rip), %rsi
	movl	%ebx, %edx
	xorl	%eax, %eax
	callq	_fprintf
LBB0_13:
	movq	%r15, %rdi
	callq	_free
	movl	%r14d, %edi
	callq	_close
LBB0_14:
	movl	%ebx, %eax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_erasesize,4,2                  ## @erasesize
	.comm	_stderr,4,2                     ## @stderr
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Could not allocate memory!\n"

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

	.comm	_TPL_RECOVER_MAGIC,8,3          ## @TPL_RECOVER_MAGIC
	.comm	_TPL_NO_RECOVER_MAGIC,8,3       ## @TPL_NO_RECOVER_MAGIC
	.comm	_MEMERASE,4,2                   ## @MEMERASE
L_.str.2:                               ## @.str.2
	.asciz	"failed to erase block: %i\n"

L_.str.3:                               ## @.str.3
	.asciz	"failed to write: %i\n"

.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_mtd_tpl_recoverflag_write      ; -- Begin function mtd_tpl_recoverflag_write
	.p2align	2
_mtd_tpl_recoverflag_write:             ; @mtd_tpl_recoverflag_write
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #96
	.cfi_def_cfa_offset 96
	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
	mov	x22, x1
	mov	x21, x0
Lloh0:
	adrp	x23, _erasesize@GOTPAGE
Lloh1:
	ldr	x23, [x23, _erasesize@GOTPAGEOFF]
	ldr	w0, [x23]
	bl	_malloc
	cbz	x0, LBB0_7
; %bb.1:
	mov	x19, x0
	mov	x0, x21
	bl	_mtd_check_open
	mov	x20, x0
	tbnz	w0, #31, LBB0_8
; %bb.2:
	ldr	w2, [x23]
	mov	x0, x20
	mov	x1, x19
	mov	w3, #0
	bl	_pread
	mov	w21, #0
Lloh2:
	adrp	x8, _TPL_NO_RECOVER_MAGIC@GOTPAGE
Lloh3:
	ldr	x8, [x8, _TPL_NO_RECOVER_MAGIC@GOTPAGEOFF]
Lloh4:
	adrp	x9, _TPL_RECOVER_MAGIC@GOTPAGE
Lloh5:
	ldr	x9, [x9, _TPL_RECOVER_MAGIC@GOTPAGEOFF]
	cmp	w22, #0
	csel	x8, x8, x9, eq
	ldr	x22, [x8]
	ldr	x8, [x19]
	cmp	x22, x8
	b.eq	LBB0_10
; %bb.3:
	str	xzr, [sp, #24]
	ldr	w8, [x23]
	str	w8, [sp, #16]
Lloh6:
	adrp	x8, _MEMERASE@GOTPAGE
Lloh7:
	ldr	x8, [x8, _MEMERASE@GOTPAGEOFF]
Lloh8:
	ldr	w1, [x8]
	add	x2, sp, #16
	mov	x0, x20
	bl	_ioctl
	tbnz	w0, #31, LBB0_9
; %bb.4:
	str	x22, [x19]
	ldr	w2, [x23]
	mov	x0, x20
	mov	x1, x19
	mov	w3, #0
	bl	_pwrite
	mov	x21, x0
	tbz	w0, #31, LBB0_6
; %bb.5:
Lloh9:
	adrp	x8, _stderr@GOTPAGE
Lloh10:
	ldr	x8, [x8, _stderr@GOTPAGEOFF]
Lloh11:
	ldr	w0, [x8]
	mov	x8, x21
	str	x8, [sp]
Lloh12:
	adrp	x1, l_.str.3@PAGE
Lloh13:
	add	x1, x1, l_.str.3@PAGEOFF
	bl	_fprintf
LBB0_6:
	bl	_sync
	b	LBB0_10
LBB0_7:
Lloh14:
	adrp	x8, _stderr@GOTPAGE
Lloh15:
	ldr	x8, [x8, _stderr@GOTPAGEOFF]
Lloh16:
	ldr	w0, [x8]
Lloh17:
	adrp	x1, l_.str@PAGE
Lloh18:
	add	x1, x1, l_.str@PAGEOFF
	bl	_fprintf
	mov	w21, #-1
	b	LBB0_11
LBB0_8:
Lloh19:
	adrp	x8, _stderr@GOTPAGE
Lloh20:
	ldr	x8, [x8, _stderr@GOTPAGEOFF]
Lloh21:
	ldr	w0, [x8]
	str	x21, [sp]
Lloh22:
	adrp	x1, l_.str.1@PAGE
Lloh23:
	add	x1, x1, l_.str.1@PAGEOFF
	bl	_fprintf
	mov	w21, #-1
	b	LBB0_10
LBB0_9:
	mov	x21, x0
Lloh24:
	adrp	x8, _stderr@GOTPAGE
Lloh25:
	ldr	x8, [x8, _stderr@GOTPAGEOFF]
Lloh26:
	ldr	w0, [x8]
	str	x21, [sp]
Lloh27:
	adrp	x1, l_.str.2@PAGE
Lloh28:
	add	x1, x1, l_.str.2@PAGEOFF
	bl	_fprintf
LBB0_10:
	mov	x0, x19
	bl	_free
	mov	x0, x20
	bl	_close
LBB0_11:
	mov	x0, x21
	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
	add	sp, sp, #96
	ret
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGot	Lloh4, Lloh5
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpAdd	Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpAdd	Lloh17, Lloh18
	.loh AdrpLdrGotLdr	Lloh14, Lloh15, Lloh16
	.loh AdrpAdd	Lloh22, Lloh23
	.loh AdrpLdrGotLdr	Lloh19, Lloh20, Lloh21
	.loh AdrpAdd	Lloh27, Lloh28
	.loh AdrpLdrGotLdr	Lloh24, Lloh25, Lloh26
	.cfi_endproc
                                        ; -- End function
	.comm	_erasesize,4,2                  ; @erasesize
	.comm	_stderr,4,2                     ; @stderr
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Could not allocate memory!\n"

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

	.comm	_TPL_RECOVER_MAGIC,8,3          ; @TPL_RECOVER_MAGIC
	.comm	_TPL_NO_RECOVER_MAGIC,8,3       ; @TPL_NO_RECOVER_MAGIC
	.comm	_MEMERASE,4,2                   ; @MEMERASE
l_.str.2:                               ; @.str.2
	.asciz	"failed to erase block: %i\n"

l_.str.3:                               ; @.str.3
	.asciz	"failed to write: %i\n"

.subsections_via_symbols
