	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function msb_get_free_block
_msb_get_free_block:                    ## @msb_get_free_block
	.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	%r12
	pushq	%rbx
	subq	$16, %rsp
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	%esi, %r14d
	movq	%rdi, %r15
	movq	_MS_BLOCKS_IN_ZONE@GOTPCREL(%rip), %rax
	movl	(%rax), %ebx
	leaq	-36(%rbp), %rdi
	movl	$4, %esi
	callq	_get_random_bytes
	movq	(%r15), %rcx
	movslq	%r14d, %rsi
	movl	(%rcx,%rsi,4), %edi
	testl	%edi, %edi
	je	LBB0_1
## %bb.2:
	imull	%r14d, %ebx
	movl	-36(%rbp), %eax
	cltd
	idivl	%edi
	movl	%edx, -36(%rbp)
	movl	(%rcx,%rsi,4), %esi
	leaq	L_.str.1(%rip), %rdi
	xorl	%r12d, %r12d
	xorl	%eax, %eax
	callq	_dbg_verbose
	movl	12(%r15), %esi
	movl	16(%r15), %edi
	movl	%ebx, %edx
	callq	_find_next_zero_bit
	movl	%eax, %ebx
	cmpl	$0, -36(%rbp)
	jle	LBB0_4
	.p2align	4, 0x90
LBB0_3:                                 ## =>This Inner Loop Header: Depth=1
	movl	12(%r15), %esi
	movl	16(%r15), %edi
	incl	%ebx
	movl	%ebx, %edx
	callq	_find_next_zero_bit
	movl	%eax, %ebx
	incl	%r12d
	cmpl	-36(%rbp), %r12d
	jl	LBB0_3
LBB0_4:
	leaq	L_.str.2(%rip), %rdi
	movl	%ebx, %esi
	xorl	%eax, %eax
	callq	_dbg_verbose
	cmpl	12(%r15), %ebx
	je	LBB0_6
## %bb.5:
	movl	%ebx, %edi
	callq	_msb_get_zone_from_pba
	cmpl	%r14d, %eax
	jne	LBB0_6
## %bb.8:
	movq	%r15, %rdi
	movl	%ebx, %esi
	callq	_msb_mark_block_used
	jmp	LBB0_9
LBB0_6:
	leaq	L_.str.3(%rip), %rdi
	xorl	%eax, %eax
	callq	_pr_err
	jmp	LBB0_7
LBB0_1:
	leaq	L_.str(%rip), %rdi
	movl	%r14d, %esi
	xorl	%eax, %eax
	callq	_pr_err
LBB0_7:
	movl	$1, 8(%r15)
	movq	_MS_BLOCK_INVALID@GOTPCREL(%rip), %rax
	movl	(%rax), %ebx
LBB0_9:
	movl	%ebx, %eax
	addq	$16, %rsp
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_MS_BLOCKS_IN_ZONE,4,2          ## @MS_BLOCKS_IN_ZONE
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"NO free blocks in the zone %d, to use for a write, (media is WORN out) switching to RO mode"

	.comm	_MS_BLOCK_INVALID,4,2           ## @MS_BLOCK_INVALID
L_.str.1:                               ## @.str.1
	.asciz	"have %d choices for a free block, selected randomly: %d"

L_.str.2:                               ## @.str.2
	.asciz	"result of the free blocks scan: pba %d"

L_.str.3:                               ## @.str.3
	.asciz	"BUG: cant get a free block"

	.no_dead_strip	_msb_get_free_block
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function msb_get_free_block
_msb_get_free_block:                    ; @msb_get_free_block
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #64
	.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
	mov	x20, x1
	mov	x19, x0
Lloh0:
	adrp	x8, _MS_BLOCKS_IN_ZONE@GOTPAGE
Lloh1:
	ldr	x8, [x8, _MS_BLOCKS_IN_ZONE@GOTPAGEOFF]
Lloh2:
	ldr	w21, [x8]
	add	x0, sp, #12
	mov	w1, #4
	bl	_get_random_bytes
	ldr	x8, [x19]
	ldr	w9, [x8, w20, sxtw #2]
	cbz	w9, LBB0_8
; %bb.1:
	sxtw	x10, w20
	mul	w21, w21, w20
	ldr	w11, [sp, #12]
	sdiv	w12, w11, w9
	msub	w9, w12, w9, w11
	str	w9, [sp, #12]
	ldr	w1, [x8, x10, lsl #2]
	str	x9, [sp]
Lloh3:
	adrp	x0, l_.str.1@PAGE
Lloh4:
	add	x0, x0, l_.str.1@PAGEOFF
	bl	_dbg_verbose
	ldp	w1, w0, [x19, #12]
	mov	x2, x21
	bl	_find_next_zero_bit
	mov	x21, x0
	ldr	w8, [sp, #12]
	cmp	w8, #1
	b.lt	LBB0_4
; %bb.2:
	mov	w22, #0
LBB0_3:                                 ; =>This Inner Loop Header: Depth=1
	ldp	w1, w0, [x19, #12]
	add	w2, w21, #1
	bl	_find_next_zero_bit
	mov	x21, x0
	add	w22, w22, #1
	ldr	w8, [sp, #12]
	cmp	w22, w8
	b.lt	LBB0_3
LBB0_4:
Lloh5:
	adrp	x0, l_.str.2@PAGE
Lloh6:
	add	x0, x0, l_.str.2@PAGEOFF
	mov	x1, x21
	bl	_dbg_verbose
	ldr	w8, [x19, #12]
	cmp	w21, w8
	b.eq	LBB0_7
; %bb.5:
	mov	x0, x21
	bl	_msb_get_zone_from_pba
	cmp	w0, w20
	b.ne	LBB0_7
; %bb.6:
	mov	x0, x19
	mov	x1, x21
	bl	_msb_mark_block_used
	b	LBB0_10
LBB0_7:
Lloh7:
	adrp	x0, l_.str.3@PAGE
Lloh8:
	add	x0, x0, l_.str.3@PAGEOFF
	b	LBB0_9
LBB0_8:
                                        ; kill: def $w20 killed $w20 killed $x20 def $x20
	str	x20, [sp]
Lloh9:
	adrp	x0, l_.str@PAGE
Lloh10:
	add	x0, x0, l_.str@PAGEOFF
LBB0_9:
	bl	_pr_err
	mov	w8, #1
	str	w8, [x19, #8]
Lloh11:
	adrp	x8, _MS_BLOCK_INVALID@GOTPAGE
Lloh12:
	ldr	x8, [x8, _MS_BLOCK_INVALID@GOTPAGEOFF]
Lloh13:
	ldr	w21, [x8]
LBB0_10:
	mov	x0, x21
	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
	add	sp, sp, #64
	ret
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpAdd	Lloh3, Lloh4
	.loh AdrpAdd	Lloh5, Lloh6
	.loh AdrpAdd	Lloh7, Lloh8
	.loh AdrpAdd	Lloh9, Lloh10
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.cfi_endproc
                                        ; -- End function
	.comm	_MS_BLOCKS_IN_ZONE,4,2          ; @MS_BLOCKS_IN_ZONE
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"NO free blocks in the zone %d, to use for a write, (media is WORN out) switching to RO mode"

	.comm	_MS_BLOCK_INVALID,4,2           ; @MS_BLOCK_INVALID
l_.str.1:                               ; @.str.1
	.asciz	"have %d choices for a free block, selected randomly: %d"

l_.str.2:                               ; @.str.2
	.asciz	"result of the free blocks scan: pba %d"

l_.str.3:                               ; @.str.3
	.asciz	"BUG: cant get a free block"

	.no_dead_strip	_msb_get_free_block
.subsections_via_symbols
