	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function mtdswap_choose_wl_tree
_mtdswap_choose_wl_tree:                ## @mtdswap_choose_wl_tree
	.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	%rdi, %r15
	movl	$-1, %r14d
	xorl	%r13d, %r13d
	xorl	%ebx, %ebx
	jmp	LBB0_1
	.p2align	4, 0x90
LBB0_3:                                 ##   in Loop: Header=BB0_1 Depth=1
	incl	%ebx
	movq	_MTDSWAP_DIRTY@GOTPCREL(%rip), %rax
	cmpl	(%rax), %ebx
	ja	LBB0_4
LBB0_1:                                 ## =>This Inner Loop Header: Depth=1
	movq	8(%r15), %rax
	movl	%ebx, %ecx
	cmpq	$0, (%rax,%rcx,8)
	je	LBB0_3
## %bb.2:                               ##   in Loop: Header=BB0_1 Depth=1
	leaq	(%rax,%rcx,8), %rdi
	movl	(%r15), %r12d
	callq	_MTDSWAP_ECNT_MIN
	subl	%eax, %r12d
	cmpl	%r13d, %r12d
	cmoval	%ebx, %r14d
	cmoval	%r12d, %r13d
	jmp	LBB0_3
LBB0_4:
	movq	_MAX_ERASE_DIFF@GOTPCREL(%rip), %rax
	cmpl	(%rax), %r13d
	jbe	LBB0_6
## %bb.5:
	movl	_mtdswap_choose_wl_tree.pick_cnt(%rip), %ebx
	movl	%r13d, %edi
	callq	_mtdswap_wlfreq
	decl	%eax
	xorl	%ecx, %ecx
	cmpl	%eax, %ebx
	jae	LBB0_7
LBB0_6:
	movl	_mtdswap_choose_wl_tree.pick_cnt(%rip), %ecx
	incl	%ecx
	movl	$-1, %r14d
LBB0_7:
	movl	%ecx, _mtdswap_choose_wl_tree.pick_cnt(%rip)
	movl	%r14d, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
.zerofill __DATA,__bss,_mtdswap_choose_wl_tree.pick_cnt,4,2 ## @mtdswap_choose_wl_tree.pick_cnt
	.comm	_MTDSWAP_DIRTY,4,2              ## @MTDSWAP_DIRTY
	.comm	_MAX_ERASE_DIFF,4,2             ## @MAX_ERASE_DIFF
	.no_dead_strip	_mtdswap_choose_wl_tree
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function mtdswap_choose_wl_tree
_mtdswap_choose_wl_tree:                ; @mtdswap_choose_wl_tree
	.cfi_startproc
; %bb.0:
	stp	x24, x23, [sp, #-64]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 64
	stp	x22, x21, [sp, #16]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #32]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #48]             ; 16-byte Folded Spill
	add	x29, sp, #48
	.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	x21, x0
	mov	w20, #0
	mov	w22, #0
	mov	w19, #-1
Lloh0:
	adrp	x23, _MTDSWAP_DIRTY@GOTPAGE
Lloh1:
	ldr	x23, [x23, _MTDSWAP_DIRTY@GOTPAGEOFF]
	b	LBB0_2
LBB0_1:                                 ;   in Loop: Header=BB0_2 Depth=1
	add	w22, w22, #1
	ldr	w8, [x23]
	cmp	w22, w8
	b.hi	LBB0_4
LBB0_2:                                 ; =>This Inner Loop Header: Depth=1
	ldr	x8, [x21, #8]
	add	x0, x8, w22, uxtw #3
	ldr	x8, [x0]
	cbz	x8, LBB0_1
; %bb.3:                                ;   in Loop: Header=BB0_2 Depth=1
	ldr	w24, [x21]
	bl	_MTDSWAP_ECNT_MIN
	sub	w8, w24, w0
	cmp	w8, w20
	csel	w19, w22, w19, hi
	csel	w20, w8, w20, hi
	b	LBB0_1
LBB0_4:
Lloh2:
	adrp	x8, _MAX_ERASE_DIFF@GOTPAGE
Lloh3:
	ldr	x8, [x8, _MAX_ERASE_DIFF@GOTPAGEOFF]
Lloh4:
	ldr	w8, [x8]
	adrp	x21, _mtdswap_choose_wl_tree.pick_cnt@PAGE
	cmp	w20, w8
	b.ls	LBB0_6
; %bb.5:
	ldr	w22, [x21, _mtdswap_choose_wl_tree.pick_cnt@PAGEOFF]
	mov	x0, x20
	bl	_mtdswap_wlfreq
	sub	w8, w0, #1
	cmp	w22, w8
	b.hs	LBB0_7
LBB0_6:
	ldr	w8, [x21, _mtdswap_choose_wl_tree.pick_cnt@PAGEOFF]
	add	w8, w8, #1
	mov	w19, #-1
	b	LBB0_8
LBB0_7:
	mov	w8, #0
LBB0_8:
	str	w8, [x21, _mtdswap_choose_wl_tree.pick_cnt@PAGEOFF]
	mov	x0, x19
	ldp	x29, x30, [sp, #48]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #32]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #16]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp], #64             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.cfi_endproc
                                        ; -- End function
.zerofill __DATA,__bss,_mtdswap_choose_wl_tree.pick_cnt,4,2 ; @mtdswap_choose_wl_tree.pick_cnt
	.comm	_MTDSWAP_DIRTY,4,2              ; @MTDSWAP_DIRTY
	.comm	_MAX_ERASE_DIFF,4,2             ; @MAX_ERASE_DIFF
	.no_dead_strip	_mtdswap_choose_wl_tree
.subsections_via_symbols
