	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_mtd_resetbc                    ## -- Begin function mtd_resetbc
	.p2align	4, 0x90
_mtd_resetbc:                           ## @mtd_resetbc
	.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	%rdi, %rbx
	movq	_page@GOTPCREL(%rip), %rax
	movq	(%rax), %r12
	xorl	%eax, %eax
	callq	_DLOG_OPEN
	movq	%rbx, %rdi
	callq	_mtd_check_open
	movl	%eax, %edi
	movq	_MEMGETINFO@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	leaq	-80(%rbp), %rdx
	movl	%edi, -44(%rbp)                 ## 4-byte Spill
	callq	_ioctl
	testq	%rax, %rax
	js	LBB0_1
## %bb.2:
	movl	-80(%rbp), %edx
	movq	_BC_OFFSET_INCREMENT_MIN@GOTPCREL(%rip), %rax
	movl	(%rax), %ebx
	cmpl	%ebx, %edx
	jae	LBB0_3
## %bb.4:
	leaq	L_.str.1(%rip), %rdi
	movl	%ebx, %esi
	callq	_DLOG_DEBUG
	jmp	LBB0_5
LBB0_1:
	leaq	L_.str(%rip), %rdi
	xorl	%eax, %eax
	callq	_DLOG_ERR
	movl	$-1, %r14d
	jmp	LBB0_20
LBB0_3:
	movl	%edx, %ebx
LBB0_5:
	movl	-76(%rbp), %ecx
	xorl	%r14d, %r14d
	movl	%ecx, %eax
	xorl	%edx, %edx
	divl	%ebx
	cmpl	%ecx, %ebx
	ja	LBB0_20
## %bb.6:
	movl	%ebx, -48(%rbp)                 ## 4-byte Spill
	cmpl	$2, %eax
	movl	$1, %r14d
	movl	%eax, -52(%rbp)                 ## 4-byte Spill
	cmovael	%eax, %r14d
	xorl	%r13d, %r13d
	xorl	%ebx, %ebx
	xorl	%r15d, %r15d
	.p2align	4, 0x90
LBB0_7:                                 ## =>This Inner Loop Header: Depth=1
	movl	-44(%rbp), %edi                 ## 4-byte Reload
	movq	%r12, %rsi
	movl	$24, %edx
	movl	%r13d, %ecx
	callq	_pread
	movl	$4294967295, %ecx               ## imm = 0xFFFFFFFF
	movq	(%r12), %rsi
	cmpq	%rcx, %rsi
	je	LBB0_10
## %bb.8:                               ##   in Loop: Header=BB0_7 Depth=1
	movq	_BOOTCOUNT_MAGIC@GOTPCREL(%rip), %rax
	cmpq	(%rax), %rsi
	jne	LBB0_9
LBB0_10:                                ##   in Loop: Header=BB0_7 Depth=1
	cmpq	%rcx, %rsi
	je	LBB0_12
## %bb.11:                              ##   in Loop: Header=BB0_7 Depth=1
	movl	8(%r12), %r15d
	incl	%ebx
	addl	-48(%rbp), %r13d                ## 4-byte Folded Reload
	cmpl	%r14d, %ebx
	jne	LBB0_7
LBB0_12:
	testl	%r15d, %r15d
	je	LBB0_13
## %bb.14:
	movl	-52(%rbp), %esi                 ## 4-byte Reload
	cmpl	%esi, %ebx
	movl	-48(%rbp), %r14d                ## 4-byte Reload
	jne	LBB0_17
## %bb.15:
	leaq	L_.str.3(%rip), %rdi
	xorl	%ebx, %ebx
	xorl	%eax, %eax
	callq	_DLOG_NOTICE
	movq	$0, -88(%rbp)
	movl	-76(%rbp), %eax
	movl	%eax, -96(%rbp)
	movq	_MEMERASE@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	leaq	-104(%rbp), %rdx
	movl	-44(%rbp), %edi                 ## 4-byte Reload
	callq	_ioctl
	testl	%eax, %eax
	js	LBB0_16
LBB0_17:
	movq	%r12, %rdi
	movl	$255, %esi
	movl	%r14d, %edx
	callq	_memset
	movq	_BOOTCOUNT_MAGIC@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rax
	movq	%rax, (%r12)
	movl	$0, 8(%r12)
	movq	(%rcx), %rax
	movq	%rax, 16(%r12)
	imull	%r14d, %ebx
	movl	-44(%rbp), %edi                 ## 4-byte Reload
	movq	%r12, %rsi
	movl	%r14d, %edx
	movl	%ebx, %ecx
	callq	_pwrite
	testl	%eax, %eax
	js	LBB0_18
## %bb.19:
	xorl	%r14d, %r14d
	xorl	%eax, %eax
	callq	_sync
	leaq	L_.str.6(%rip), %rdi
	xorl	%eax, %eax
	callq	_DLOG_NOTICE
	jmp	LBB0_20
LBB0_9:
	leaq	L_.str.2(%rip), %rdi
	movl	%r13d, %edx
	xorl	%eax, %eax
	callq	_DLOG_ERR
	movl	$-2, %r14d
	jmp	LBB0_20
LBB0_13:
	xorl	%r14d, %r14d
	jmp	LBB0_20
LBB0_18:
	movq	_errno@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	leaq	L_.str.5(%rip), %rdi
	xorl	%eax, %eax
	callq	_DLOG_ERR
	movl	$-4, %r14d
	jmp	LBB0_20
LBB0_16:
	leaq	L_.str.4(%rip), %rdi
	movl	%eax, %esi
	xorl	%eax, %eax
	callq	_DLOG_ERR
	movl	$-3, %r14d
LBB0_20:
	movl	-44(%rbp), %edi                 ## 4-byte Reload
	callq	_close
	movl	%r14d, %eax
	addq	$72, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_page,8,3                       ## @page
	.comm	_MEMGETINFO,4,2                 ## @MEMGETINFO
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Unable to obtain mtd_info for given partition name."

	.comm	_BC_OFFSET_INCREMENT_MIN,4,2    ## @BC_OFFSET_INCREMENT_MIN
L_.str.1:                               ## @.str.1
	.asciz	"Offset increment set to %i for writesize of %i"

	.comm	_BOOTCOUNT_MAGIC,8,3            ## @BOOTCOUNT_MAGIC
L_.str.2:                               ## @.str.2
	.asciz	"Unexpected magic %08x at offset %08x; aborting."

L_.str.3:                               ## @.str.3
	.asciz	"Boot-count log full with %i entries; erasing (expected occasionally)."

	.comm	_MEMERASE,4,2                   ## @MEMERASE
L_.str.4:                               ## @.str.4
	.asciz	"Failed to erase boot-count log MTD; ioctl() MEMERASE returned %i"

L_.str.5:                               ## @.str.5
	.asciz	"Failed to write boot-count log entry; pwrite() returned %i"

	.comm	_errno,4,2                      ## @errno
L_.str.6:                               ## @.str.6
	.asciz	"Boot count sucessfully reset to zero."

.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_mtd_resetbc                    ; -- Begin function mtd_resetbc
	.p2align	2
_mtd_resetbc:                           ; @mtd_resetbc
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #160
	.cfi_def_cfa_offset 160
	stp	x28, x27, [sp, #64]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #80]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #96]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #112]            ; 16-byte Folded Spill
	stp	x20, x19, [sp, #128]            ; 16-byte Folded Spill
	stp	x29, x30, [sp, #144]            ; 16-byte Folded Spill
	add	x29, sp, #144
	.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	x8, _page@GOTPAGE
Lloh1:
	ldr	x8, [x8, _page@GOTPAGEOFF]
Lloh2:
	ldr	x20, [x8]
	bl	_DLOG_OPEN
	mov	x0, x19
	bl	_mtd_check_open
	mov	x19, x0
Lloh3:
	adrp	x8, _MEMGETINFO@GOTPAGE
Lloh4:
	ldr	x8, [x8, _MEMGETINFO@GOTPAGEOFF]
Lloh5:
	ldr	w1, [x8]
	add	x2, sp, #40
	bl	_ioctl
	tbnz	x0, #63, LBB0_5
; %bb.1:
	ldr	w21, [sp, #40]
Lloh6:
	adrp	x8, _BC_OFFSET_INCREMENT_MIN@GOTPAGE
Lloh7:
	ldr	x8, [x8, _BC_OFFSET_INCREMENT_MIN@GOTPAGEOFF]
Lloh8:
	ldr	w22, [x8]
	cmp	w21, w22
	b.hs	LBB0_3
; %bb.2:
Lloh9:
	adrp	x0, l_.str.1@PAGE
Lloh10:
	add	x0, x0, l_.str.1@PAGEOFF
	mov	x1, x22
	mov	x2, x21
	bl	_DLOG_DEBUG
	mov	x21, x22
LBB0_3:
	ldr	w8, [sp, #44]
	cmp	w21, w8
	b.ls	LBB0_6
LBB0_4:
	mov	w20, #0
	b	LBB0_19
LBB0_5:
Lloh11:
	adrp	x0, l_.str@PAGE
Lloh12:
	add	x0, x0, l_.str@PAGEOFF
	bl	_DLOG_ERR
	mov	w20, #-1
	b	LBB0_19
LBB0_6:
	mov	w22, #0
	mov	w24, #0
	mov	w26, #0
	udiv	w25, w8, w21
	cmp	w25, #1
	csinc	w27, w25, wzr, hi
Lloh13:
	adrp	x23, _BOOTCOUNT_MAGIC@GOTPAGE
Lloh14:
	ldr	x23, [x23, _BOOTCOUNT_MAGIC@GOTPAGEOFF]
	mov	w28, #-1
LBB0_7:                                 ; =>This Inner Loop Header: Depth=1
	mov	x0, x19
	mov	x1, x20
	mov	w2, #24
	mov	x3, x22
	bl	_pread
	ldr	x8, [x20]
	ldr	x9, [x23]
	cmp	x8, x28
	ccmp	x8, x9, #4, ne
	b.ne	LBB0_16
; %bb.8:                                ;   in Loop: Header=BB0_7 Depth=1
	cmp	x8, x28
	b.eq	LBB0_10
; %bb.9:                                ;   in Loop: Header=BB0_7 Depth=1
	ldr	w26, [x20, #8]
	add	w24, w24, #1
	add	w22, w22, w21
	cmp	w24, w27
	b.ne	LBB0_7
LBB0_10:
	cbz	w26, LBB0_4
; %bb.11:
	cmp	w24, w25
	b.ne	LBB0_14
; %bb.12:
	str	x25, [sp]
Lloh15:
	adrp	x0, l_.str.3@PAGE
Lloh16:
	add	x0, x0, l_.str.3@PAGEOFF
	bl	_DLOG_NOTICE
	str	xzr, [sp, #32]
	ldr	w8, [sp, #44]
	str	w8, [sp, #24]
Lloh17:
	adrp	x8, _MEMERASE@GOTPAGE
Lloh18:
	ldr	x8, [x8, _MEMERASE@GOTPAGEOFF]
Lloh19:
	ldr	w1, [x8]
	add	x2, sp, #16
	mov	x0, x19
	bl	_ioctl
	tbnz	w0, #31, LBB0_18
; %bb.13:
	mov	w24, #0
LBB0_14:
	mov	x0, x20
	mov	w1, #255
	mov	x2, x21
	bl	_memset
	ldr	x8, [x23]
	str	x8, [x20]
	str	wzr, [x20, #8]
	ldr	x8, [x23]
	str	x8, [x20, #16]
	mul	w3, w24, w21
	mov	x0, x19
	mov	x1, x20
	mov	x2, x21
	bl	_pwrite
	tbnz	w0, #31, LBB0_17
; %bb.15:
	bl	_sync
Lloh20:
	adrp	x0, l_.str.6@PAGE
Lloh21:
	add	x0, x0, l_.str.6@PAGEOFF
	bl	_DLOG_NOTICE
	b	LBB0_4
LBB0_16:
	stp	x8, x22, [sp]
Lloh22:
	adrp	x0, l_.str.2@PAGE
Lloh23:
	add	x0, x0, l_.str.2@PAGEOFF
	bl	_DLOG_ERR
	mov	w20, #-2
	b	LBB0_19
LBB0_17:
Lloh24:
	adrp	x8, _errno@GOTPAGE
Lloh25:
	ldr	x8, [x8, _errno@GOTPAGEOFF]
Lloh26:
	ldr	w8, [x8]
	str	x8, [sp]
Lloh27:
	adrp	x0, l_.str.5@PAGE
Lloh28:
	add	x0, x0, l_.str.5@PAGEOFF
	bl	_DLOG_ERR
	mov	w20, #-4
	b	LBB0_19
LBB0_18:
                                        ; kill: def $w0 killed $w0 killed $x0 def $x0
	str	x0, [sp]
Lloh29:
	adrp	x0, l_.str.4@PAGE
Lloh30:
	add	x0, x0, l_.str.4@PAGEOFF
	bl	_DLOG_ERR
	mov	w20, #-3
LBB0_19:
	mov	x0, x19
	bl	_close
	mov	x0, x20
	ldp	x29, x30, [sp, #144]            ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #128]            ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #112]            ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #96]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #80]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #64]             ; 16-byte Folded Reload
	add	sp, sp, #160
	ret
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpAdd	Lloh9, Lloh10
	.loh AdrpAdd	Lloh11, Lloh12
	.loh AdrpLdrGot	Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh17, Lloh18, Lloh19
	.loh AdrpAdd	Lloh15, Lloh16
	.loh AdrpAdd	Lloh20, Lloh21
	.loh AdrpAdd	Lloh22, Lloh23
	.loh AdrpAdd	Lloh27, Lloh28
	.loh AdrpLdrGotLdr	Lloh24, Lloh25, Lloh26
	.loh AdrpAdd	Lloh29, Lloh30
	.cfi_endproc
                                        ; -- End function
	.comm	_page,8,3                       ; @page
	.comm	_MEMGETINFO,4,2                 ; @MEMGETINFO
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Unable to obtain mtd_info for given partition name."

	.comm	_BC_OFFSET_INCREMENT_MIN,4,2    ; @BC_OFFSET_INCREMENT_MIN
l_.str.1:                               ; @.str.1
	.asciz	"Offset increment set to %i for writesize of %i"

	.comm	_BOOTCOUNT_MAGIC,8,3            ; @BOOTCOUNT_MAGIC
l_.str.2:                               ; @.str.2
	.asciz	"Unexpected magic %08x at offset %08x; aborting."

l_.str.3:                               ; @.str.3
	.asciz	"Boot-count log full with %i entries; erasing (expected occasionally)."

	.comm	_MEMERASE,4,2                   ; @MEMERASE
l_.str.4:                               ; @.str.4
	.asciz	"Failed to erase boot-count log MTD; ioctl() MEMERASE returned %i"

l_.str.5:                               ; @.str.5
	.asciz	"Failed to write boot-count log entry; pwrite() returned %i"

	.comm	_errno,4,2                      ; @errno
l_.str.6:                               ; @.str.6
	.asciz	"Boot count sucessfully reset to zero."

.subsections_via_symbols
