	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function heap_alloc
_heap_alloc:                            ## @heap_alloc
	.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, %r14d
	movq	%rdi, %rbx
	callq	_heap_avail
	movl	%eax, %edi
	callq	_assert
	movq	%rbx, %r8
	movl	(%rbx), %ecx
	movl	%ecx, %edx
	subl	%r14d, %edx
	movq	8(%rbx), %rax
	testl	%edx, %edx
	jle	LBB0_1
## %bb.2:
	movl	$1, %edx
	jmp	LBB0_3
	.p2align	4, 0x90
LBB0_6:                                 ##   in Loop: Header=BB0_3 Depth=1
	cmpl	%r14d, %esi
	cmovll	%edx, %edi
	movl	%edi, %r13d
LBB0_7:                                 ##   in Loop: Header=BB0_3 Depth=1
	decl	%ecx
	movl	%r13d, %edx
	cmpl	%ecx, %r14d
	je	LBB0_8
LBB0_3:                                 ## =>This Inner Loop Header: Depth=1
	movl	%edx, %r13d
	addl	%edx, %r13d
	addl	%edx, %edx
	incl	%edx
	movslq	%edx, %rsi
	movl	(%rax,%rsi,4), %ebx
	cmpl	%r14d, %ebx
	jl	LBB0_7
## %bb.4:                               ##   in Loop: Header=BB0_3 Depth=1
	movslq	%r13d, %rsi
	movl	(%rax,%rsi,4), %esi
	movl	%edx, %edi
	cmpl	%ebx, %esi
	jg	LBB0_6
## %bb.5:                               ##   in Loop: Header=BB0_3 Depth=1
	movl	%r13d, %edi
	jmp	LBB0_6
LBB0_1:
	movl	$1, %r13d
LBB0_8:
	movl	%r14d, -44(%rbp)                ## 4-byte Spill
	movslq	%r13d, %r12
	movl	$0, (%rax,%r12,4)
	movl	%r12d, %ecx
	xorl	$1, %ecx
	movslq	%ecx, %rcx
	movl	(%rax,%rcx,4), %esi
	sarl	%r12d
	movslq	%r12d, %rbx
	cmpl	(%rax,%rbx,4), %esi
	jge	LBB0_12
## %bb.9:
	xorl	%edi, %edi
	movq	%r8, -56(%rbp)                  ## 8-byte Spill
	callq	__max
	movq	-56(%rbp), %r8                  ## 8-byte Reload
	movq	8(%r8), %rcx
	movl	%eax, (%rcx,%rbx,4)
	xorl	$1, %ebx
	movslq	%ebx, %rax
	movl	(%rcx,%rax,4), %esi
	movl	%r13d, %ebx
	sarl	$2, %ebx
	movslq	%ebx, %r14
	cmpl	(%rcx,%r14,4), %esi
	jge	LBB0_12
	.p2align	4, 0x90
LBB0_10:                                ## =>This Inner Loop Header: Depth=1
	movl	%ebx, %r15d
	movslq	%r12d, %rax
	movl	(%rcx,%rax,4), %edi
	callq	__max
	movq	-56(%rbp), %r8                  ## 8-byte Reload
	movq	8(%r8), %rcx
	movl	%eax, (%rcx,%r14,4)
	movl	%ebx, %eax
	xorl	$1, %eax
	cltq
	movl	(%rcx,%rax,4), %esi
	sarl	%ebx
	movslq	%ebx, %r14
	movl	%r15d, %r12d
	cmpl	(%rcx,%r14,4), %esi
	jl	LBB0_10
LBB0_12:
	movl	-44(%rbp), %ecx                 ## 4-byte Reload
	decb	%cl
                                        ## kill: def $cl killed $cl killed $ecx
	shll	%cl, %r13d
	movb	(%r8), %cl
	decb	%cl
	movl	$-1, %eax
	shll	%cl, %eax
	addl	%r13d, %eax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.no_dead_strip	_heap_alloc
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function heap_alloc
_heap_alloc:                            ; @heap_alloc
	.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	x20, x1
	mov	x19, x0
	bl	_heap_avail
	bl	_assert
	ldr	w9, [x19]
	sub	w10, w9, w20
	ldr	x8, [x19, #8]
	mov	w21, #1
	cmp	w10, #1
	b.ge	LBB0_7
LBB0_1:
	mov	x9, x21
	sxtw	x10, w9
	str	wzr, [x8, w21, sxtw #2]
	eor	x10, x10, #0x1
	ldr	w1, [x8, x10, lsl #2]
	asr	w22, w21, #1
	ldr	w8, [x8, w22, sxtw #2]
	cmp	w1, w8
	b.ge	LBB0_5
; %bb.2:
	sbfx	x23, x9, #1, #31
	mov	w0, #0
	bl	__max
	ldr	x8, [x19, #8]
	str	w0, [x8, x23, lsl #2]
	eor	x9, x23, #0x1
	ldr	w1, [x8, x9, lsl #2]
	asr	w9, w21, #2
	ldr	w10, [x8, w9, sxtw #2]
	cmp	w1, w10
	b.ge	LBB0_5
; %bb.3:
	mov	x10, x21
	sbfx	x23, x10, #2, #30
LBB0_4:                                 ; =>This Inner Loop Header: Depth=1
	mov	x24, x9
	ldr	w0, [x8, w22, sxtw #2]
	bl	__max
	ldr	x8, [x19, #8]
	str	w0, [x8, x23, lsl #2]
	eor	w9, w24, #0x1
	ldr	w1, [x8, w9, sxtw #2]
	asr	w9, w24, #1
	sbfx	x23, x24, #1, #31
	ldr	w10, [x8, w9, sxtw #2]
	mov	x22, x24
	cmp	w1, w10
	b.lt	LBB0_4
LBB0_5:
	sub	w8, w20, #1
	lsl	w8, w21, w8
	ldr	w9, [x19]
	sub	w9, w9, #1
	mov	w10, #-1
	lsl	w9, w10, w9
	add	w0, w9, w8
	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
LBB0_6:                                 ;   in Loop: Header=BB0_7 Depth=1
	sub	w9, w9, #1
	cmp	w20, w9
	b.eq	LBB0_1
LBB0_7:                                 ; =>This Inner Loop Header: Depth=1
	lsl	w21, w21, #1
	sxtw	x11, w21
	orr	x10, x11, #0x1
	ldr	w12, [x8, x10, lsl #2]
	cmp	w12, w20
	b.lt	LBB0_6
; %bb.8:                                ;   in Loop: Header=BB0_7 Depth=1
	ldr	w11, [x8, x11, lsl #2]
	cmp	w11, w12
	ccmp	w11, w20, #8, le
	csel	w21, w10, w21, lt
	b	LBB0_6
	.cfi_endproc
                                        ; -- End function
	.no_dead_strip	_heap_alloc
.subsections_via_symbols
