	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function scan_mtd
_scan_mtd:                              ## @scan_mtd
	.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	_mtdfd@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movq	_MEMGETINFO@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	leaq	-48(%rbp), %rdx
	callq	_ioctl
	xorl	%r14d, %r14d
	testq	%rax, %rax
	je	LBB0_1
LBB0_11:
	movl	%r14d, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_1:
	movq	_blocksize@GOTPCREL(%rip), %rcx
	movl	-48(%rbp), %edx
	movl	-44(%rbp), %eax
	movl	%edx, (%rcx)
	movq	_TFFS_SECTOR_SIZE@GOTPCREL(%rip), %r13
	cltd
	idivl	(%r13)
                                        ## kill: def $eax killed $eax def $rax
	leal	7(%rax), %ecx
	leal	14(%rax), %edi
	testl	%ecx, %ecx
	cmovnsl	%ecx, %edi
	sarl	$3, %edi
	addl	$8, %edi
	callq	_malloc
	movq	%rax, %rcx
	movq	_sectors@GOTPCREL(%rip), %rax
	movq	%rcx, (%rax)
	testq	%rcx, %rcx
	je	LBB0_12
## %bb.2:
	movl	-44(%rbp), %esi
	movl	%esi, %eax
	cltd
	idivl	(%r13)
	movl	%eax, (%rcx)
	movl	4(%rcx), %edi
	movl	%esi, %eax
	cltd
	idivl	(%r13)
                                        ## kill: def $eax killed $eax def $rax
	leal	7(%rax), %ecx
	leal	14(%rax), %edx
	testl	%ecx, %ecx
	cmovnsl	%ecx, %edx
	sarl	$3, %edx
	movl	$255, %esi
	callq	_memset
	cmpl	$0, -44(%rbp)
	jle	LBB0_11
## %bb.3:
	xorl	%ebx, %ebx
	xorl	%r12d, %r12d
	xorl	%r14d, %r14d
	xorl	%r15d, %r15d
	jmp	LBB0_4
	.p2align	4, 0x90
LBB0_9:                                 ##   in Loop: Header=BB0_4 Depth=1
	movl	%r15d, %edi
	callq	_sector_mark_bad
LBB0_10:                                ##   in Loop: Header=BB0_4 Depth=1
	incl	%r15d
	addl	(%r13), %ebx
	cmpl	-44(%rbp), %ebx
	jge	LBB0_11
LBB0_4:                                 ## =>This Inner Loop Header: Depth=1
	movl	%ebx, %eax
	cltd
	idivl	-48(%rbp)
	testl	%edx, %edx
	je	LBB0_5
## %bb.6:                               ##   in Loop: Header=BB0_4 Depth=1
	testq	%r12, %r12
	je	LBB0_9
## %bb.7:                               ##   in Loop: Header=BB0_4 Depth=1
	movl	%r15d, %edi
	callq	_sector_get_good
	testl	%eax, %eax
	je	LBB0_9
## %bb.8:                               ##   in Loop: Header=BB0_4 Depth=1
	movl	%ebx, %edi
	callq	_check_sector
	testl	%eax, %eax
	jne	LBB0_10
	jmp	LBB0_9
	.p2align	4, 0x90
LBB0_5:                                 ##   in Loop: Header=BB0_4 Depth=1
	movl	%ebx, %edi
	movl	%r15d, %esi
	callq	_check_block
	movq	%rax, %r12
	movl	%r15d, %edi
	callq	_sector_mark_bad
	cmpq	$1, %r12
	sbbl	$-1, %r14d
	jmp	LBB0_10
LBB0_12:
	movq	_stderr@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	leaq	L_.str(%rip), %rsi
	callq	_fprintf
	movq	_EXIT_FAILURE@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	callq	_exit
	.cfi_endproc
                                        ## -- End function
	.comm	_mtdfd,4,2                      ## @mtdfd
	.comm	_MEMGETINFO,4,2                 ## @MEMGETINFO
	.comm	_blocksize,4,2                  ## @blocksize
	.comm	_TFFS_SECTOR_SIZE,4,2           ## @TFFS_SECTOR_SIZE
	.comm	_sectors,8,3                    ## @sectors
	.comm	_stderr,4,2                     ## @stderr
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"ERROR: memory allocation failed!\n"

	.comm	_EXIT_FAILURE,4,2               ## @EXIT_FAILURE
	.no_dead_strip	_scan_mtd
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function scan_mtd
_scan_mtd:                              ; @scan_mtd
	.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
Lloh0:
	adrp	x8, _mtdfd@GOTPAGE
Lloh1:
	ldr	x8, [x8, _mtdfd@GOTPAGEOFF]
Lloh2:
	ldr	w0, [x8]
Lloh3:
	adrp	x8, _MEMGETINFO@GOTPAGE
Lloh4:
	ldr	x8, [x8, _MEMGETINFO@GOTPAGEOFF]
Lloh5:
	ldr	w1, [x8]
	add	x2, sp, #8
	bl	_ioctl
	cbz	x0, LBB0_3
LBB0_1:
	mov	w19, #0
LBB0_2:
	mov	x0, x19
	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
LBB0_3:
Lloh6:
	adrp	x8, _blocksize@GOTPAGE
Lloh7:
	ldr	x8, [x8, _blocksize@GOTPAGEOFF]
	ldp	w9, w10, [sp, #8]
Lloh8:
	str	w9, [x8]
Lloh9:
	adrp	x23, _TFFS_SECTOR_SIZE@GOTPAGE
Lloh10:
	ldr	x23, [x23, _TFFS_SECTOR_SIZE@GOTPAGEOFF]
	ldr	w8, [x23]
	sdiv	w8, w10, w8
	add	w9, w8, #7
	add	w8, w8, #14
	cmp	w9, #0
	csel	w8, w8, w9, lt
	asr	w8, w8, #3
	add	w0, w8, #8
	bl	_malloc
Lloh11:
	adrp	x8, _sectors@GOTPAGE
Lloh12:
	ldr	x8, [x8, _sectors@GOTPAGEOFF]
Lloh13:
	str	x0, [x8]
	cbz	x0, LBB0_13
; %bb.4:
	ldr	w8, [sp, #12]
	ldr	w9, [x23]
	sdiv	w9, w8, w9
	str	w9, [x0]
	ldr	w0, [x0, #4]
	ldr	w9, [x23]
	sdiv	w8, w8, w9
	add	w9, w8, #7
	add	w8, w8, #14
	cmp	w9, #0
	csel	w8, w8, w9, lt
	asr	w2, w8, #3
	mov	w1, #255
	bl	_memset
	ldr	w8, [sp, #12]
	cmp	w8, #1
	b.lt	LBB0_1
; %bb.5:
	mov	w20, #0
	mov	x22, #0
	mov	w19, #0
	mov	w21, #0
	b	LBB0_8
LBB0_6:                                 ;   in Loop: Header=BB0_8 Depth=1
	mov	x0, x21
	bl	_sector_mark_bad
LBB0_7:                                 ;   in Loop: Header=BB0_8 Depth=1
	add	w21, w21, #1
	ldr	w8, [x23]
	ldr	w9, [sp, #12]
	add	w20, w8, w20
	cmp	w20, w9
	b.ge	LBB0_2
LBB0_8:                                 ; =>This Inner Loop Header: Depth=1
	ldr	w8, [sp, #8]
	sdiv	w9, w20, w8
	msub	w8, w9, w8, w20
	cbz	w8, LBB0_12
; %bb.9:                                ;   in Loop: Header=BB0_8 Depth=1
	cbz	x22, LBB0_6
; %bb.10:                               ;   in Loop: Header=BB0_8 Depth=1
	mov	x0, x21
	bl	_sector_get_good
	cbz	w0, LBB0_6
; %bb.11:                               ;   in Loop: Header=BB0_8 Depth=1
	mov	x0, x20
	bl	_check_sector
	cbnz	w0, LBB0_7
	b	LBB0_6
LBB0_12:                                ;   in Loop: Header=BB0_8 Depth=1
	mov	x0, x20
	mov	x1, x21
	bl	_check_block
	mov	x22, x0
	mov	x0, x21
	bl	_sector_mark_bad
	cmp	x22, #0
	cinc	w19, w19, ne
	b	LBB0_7
LBB0_13:
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
Lloh19:
	adrp	x8, _EXIT_FAILURE@GOTPAGE
Lloh20:
	ldr	x8, [x8, _EXIT_FAILURE@GOTPAGEOFF]
Lloh21:
	ldr	w0, [x8]
	bl	_exit
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotStr	Lloh11, Lloh12, Lloh13
	.loh AdrpLdrGot	Lloh9, Lloh10
	.loh AdrpLdrGotStr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh19, Lloh20, Lloh21
	.loh AdrpAdd	Lloh17, Lloh18
	.loh AdrpLdrGotLdr	Lloh14, Lloh15, Lloh16
	.cfi_endproc
                                        ; -- End function
	.comm	_mtdfd,4,2                      ; @mtdfd
	.comm	_MEMGETINFO,4,2                 ; @MEMGETINFO
	.comm	_blocksize,4,2                  ; @blocksize
	.comm	_TFFS_SECTOR_SIZE,4,2           ; @TFFS_SECTOR_SIZE
	.comm	_sectors,8,3                    ; @sectors
	.comm	_stderr,4,2                     ; @stderr
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"ERROR: memory allocation failed!\n"

	.comm	_EXIT_FAILURE,4,2               ; @EXIT_FAILURE
	.no_dead_strip	_scan_mtd
.subsections_via_symbols
