	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_memguard_alloc                 ## -- Begin function memguard_alloc
	.p2align	4, 0x90
_memguard_alloc:                        ## @memguard_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, %ebx
	movq	%rdi, %r13
	callq	_round_page
	movq	%rax, %r15
	xorl	%eax, %eax
	testq	%r15, %r15
	je	LBB0_16
## %bb.1:
	movl	%ebx, -52(%rbp)                 ## 4-byte Spill
	movq	_memguard_options@GOTPCREL(%rip), %rcx
	movq	_MG_GUARD_AROUND@GOTPCREL(%rip), %rdx
	movl	(%rdx), %r12d
	movq	_PAGE_SIZE@GOTPCREL(%rip), %r14
	movl	(%r14), %ebx
	addl	%ebx, %ebx
	andl	(%rcx), %r12d
	cmovel	%eax, %ebx
	movq	_memguard_arena@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movq	_VMEM_ALLOC@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	callq	_vmem_size
	movq	_memguard_physlimit@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jl	LBB0_5
## %bb.2:
	movslq	(%r14), %rax
	cmpq	%r13, %rax
	jbe	LBB0_5
LBB0_3:
	movq	_memguard_fail_pgs@GOTPCREL(%rip), %rax
	jmp	LBB0_4
LBB0_5:
	movslq	%ebx, %rbx
	addq	%r15, %rbx
	movq	_memguard_arena@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movq	_M_NEXTFIT@GOTPCREL(%rip), %rax
	movq	_M_NOWAIT@GOTPCREL(%rip), %rcx
	movl	(%rcx), %edx
	orl	(%rax), %edx
	leaq	-44(%rbp), %rcx
	movq	%rbx, %rsi
	callq	_vmem_alloc
	testl	%eax, %eax
	je	LBB0_7
## %bb.6:
	movq	_memguard_fail_kva@GOTPCREL(%rip), %rax
LBB0_4:
	incl	(%rax)
	xorl	%r14d, %r14d
LBB0_15:
	movslq	%r14d, %rax
LBB0_16:
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_7:
	movl	-44(%rbp), %r14d
	movl	%r12d, %ecx
	testl	%r12d, %r12d
	je	LBB0_9
## %bb.8:
	movq	_PAGE_SIZE@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
LBB0_9:
	addl	%r14d, %ecx
	movq	_kernel_object@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movl	%ecx, %esi
	movl	%ecx, -48(%rbp)                 ## 4-byte Spill
	movq	%r15, %rdx
	movl	-52(%rbp), %ecx                 ## 4-byte Reload
	callq	_kmem_back
	movq	_KERN_SUCCESS@GOTPCREL(%rip), %rcx
	cmpl	(%rcx), %eax
	jne	LBB0_10
## %bb.11:
	movl	-48(%rbp), %r15d                ## 4-byte Reload
	movl	%r15d, %edi
	callq	_trunc_page
	movl	%eax, %edi
	callq	_v2sizep
	movq	%r13, (%rax)
	movl	%r15d, %edi
	callq	_trunc_page
	movl	%eax, %edi
	callq	_v2sizev
	movq	%rbx, (%rax)
	movq	_memguard_succ@GOTPCREL(%rip), %rax
	incl	(%rax)
	movq	_PAGE_SIZE@GOTPCREL(%rip), %rax
	movslq	(%rax), %rax
	cmpq	%r13, %rax
	jbe	LBB0_14
## %bb.12:
	movq	_memguard_wasted@GOTPCREL(%rip), %rcx
	subl	%r13d, %eax
	addl	%eax, (%rcx)
	testl	%r12d, %r12d
	je	LBB0_15
## %bb.13:
	movq	%r13, %rdi
	movl	$16, %esi
	callq	_roundup2
	subl	%eax, %r15d
	movq	_PAGE_SIZE@GOTPCREL(%rip), %rax
	addl	(%rax), %r15d
LBB0_14:
	movl	%r15d, %r14d
	jmp	LBB0_15
LBB0_10:
	movq	_memguard_arena@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movl	-44(%rbp), %esi
	movq	%rbx, %rdx
	callq	_vmem_xfree
	jmp	LBB0_3
	.cfi_endproc
                                        ## -- End function
	.comm	_memguard_options,4,2           ## @memguard_options
	.comm	_MG_GUARD_AROUND,4,2            ## @MG_GUARD_AROUND
	.comm	_PAGE_SIZE,4,2                  ## @PAGE_SIZE
	.comm	_memguard_arena,4,2             ## @memguard_arena
	.comm	_VMEM_ALLOC,4,2                 ## @VMEM_ALLOC
	.comm	_memguard_physlimit,8,3         ## @memguard_physlimit
	.comm	_memguard_fail_pgs,4,2          ## @memguard_fail_pgs
	.comm	_M_NEXTFIT,4,2                  ## @M_NEXTFIT
	.comm	_M_NOWAIT,4,2                   ## @M_NOWAIT
	.comm	_memguard_fail_kva,4,2          ## @memguard_fail_kva
	.comm	_kernel_object,4,2              ## @kernel_object
	.comm	_KERN_SUCCESS,4,2               ## @KERN_SUCCESS
	.comm	_memguard_succ,4,2              ## @memguard_succ
	.comm	_memguard_wasted,4,2            ## @memguard_wasted
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_memguard_alloc                 ; -- Begin function memguard_alloc
	.p2align	2
_memguard_alloc:                        ; @memguard_alloc
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #112
	.cfi_def_cfa_offset 112
	stp	x28, x27, [sp, #16]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #32]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #48]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #64]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #80]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #96]             ; 16-byte Folded Spill
	add	x29, sp, #96
	.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	x22, x1
	mov	x19, x0
	bl	_round_page
	cbz	x0, LBB0_12
; %bb.1:
	mov	x23, x0
Lloh0:
	adrp	x8, _memguard_options@GOTPAGE
Lloh1:
	ldr	x8, [x8, _memguard_options@GOTPAGEOFF]
Lloh2:
	ldr	w8, [x8]
Lloh3:
	adrp	x9, _MG_GUARD_AROUND@GOTPAGE
Lloh4:
	ldr	x9, [x9, _MG_GUARD_AROUND@GOTPAGEOFF]
Lloh5:
	ldr	w9, [x9]
	ands	w25, w9, w8
Lloh6:
	adrp	x24, _PAGE_SIZE@GOTPAGE
Lloh7:
	ldr	x24, [x24, _PAGE_SIZE@GOTPAGEOFF]
	ldr	w8, [x24]
	lsl	w8, w8, #1
	csel	w20, wzr, w8, eq
Lloh8:
	adrp	x27, _memguard_arena@GOTPAGE
Lloh9:
	ldr	x27, [x27, _memguard_arena@GOTPAGEOFF]
	ldr	w0, [x27]
Lloh10:
	adrp	x8, _VMEM_ALLOC@GOTPAGE
Lloh11:
	ldr	x8, [x8, _VMEM_ALLOC@GOTPAGEOFF]
Lloh12:
	ldr	w1, [x8]
	bl	_vmem_size
Lloh13:
	adrp	x8, _memguard_physlimit@GOTPAGE
Lloh14:
	ldr	x8, [x8, _memguard_physlimit@GOTPAGEOFF]
Lloh15:
	ldr	x8, [x8]
	ldrsw	x9, [x24]
	cmp	x0, x8
	ccmp	x9, x19, #0, ge
	b.hi	LBB0_9
; %bb.2:
	add	x21, x23, w20, sxtw
Lloh16:
	adrp	x8, _M_NEXTFIT@GOTPAGE
Lloh17:
	ldr	x8, [x8, _M_NEXTFIT@GOTPAGEOFF]
	ldr	w0, [x27]
Lloh18:
	ldr	w8, [x8]
Lloh19:
	adrp	x9, _M_NOWAIT@GOTPAGE
Lloh20:
	ldr	x9, [x9, _M_NOWAIT@GOTPAGEOFF]
Lloh21:
	ldr	w9, [x9]
	orr	w2, w9, w8
	add	x3, sp, #12
	mov	x1, x21
	bl	_vmem_alloc
	cbz	w0, LBB0_4
; %bb.3:
	mov	w20, #0
Lloh22:
	adrp	x8, _memguard_fail_kva@GOTPAGE
Lloh23:
	ldr	x8, [x8, _memguard_fail_kva@GOTPAGEOFF]
	b	LBB0_10
LBB0_4:
	ldr	w26, [sp, #12]
	ldr	w8, [x24]
	cmp	w25, #0
	csel	w8, wzr, w8, eq
	add	w20, w8, w26
Lloh24:
	adrp	x8, _kernel_object@GOTPAGE
Lloh25:
	ldr	x8, [x8, _kernel_object@GOTPAGEOFF]
Lloh26:
	ldr	w0, [x8]
	mov	x1, x20
	mov	x2, x23
	mov	x3, x22
	bl	_kmem_back
Lloh27:
	adrp	x8, _KERN_SUCCESS@GOTPAGE
Lloh28:
	ldr	x8, [x8, _KERN_SUCCESS@GOTPAGEOFF]
Lloh29:
	ldr	w8, [x8]
	cmp	w0, w8
	b.ne	LBB0_8
; %bb.5:
	mov	x0, x20
	bl	_trunc_page
	bl	_v2sizep
	str	x19, [x0]
	mov	x0, x20
	bl	_trunc_page
	bl	_v2sizev
Lloh30:
	adrp	x8, _memguard_succ@GOTPAGE
Lloh31:
	ldr	x8, [x8, _memguard_succ@GOTPAGEOFF]
	str	x21, [x0]
	ldr	w9, [x8]
	add	w9, w9, #1
	str	w9, [x8]
	ldrsw	x8, [x24]
	cmp	x8, x19
	b.ls	LBB0_11
; %bb.6:
Lloh32:
	adrp	x9, _memguard_wasted@GOTPAGE
Lloh33:
	ldr	x9, [x9, _memguard_wasted@GOTPAGEOFF]
	ldr	w10, [x9]
	sub	w8, w8, w19
	add	w8, w8, w10
	str	w8, [x9]
	cbz	w25, LBB0_13
; %bb.7:
	mov	x0, x19
	mov	w1, #16
	bl	_roundup2
	ldr	w8, [x24]
	sub	w9, w20, w0
	add	w20, w9, w8
	b	LBB0_11
LBB0_8:
	ldr	w0, [x27]
	ldr	w1, [sp, #12]
	mov	x2, x21
	bl	_vmem_xfree
LBB0_9:
	mov	w20, #0
Lloh34:
	adrp	x8, _memguard_fail_pgs@GOTPAGE
Lloh35:
	ldr	x8, [x8, _memguard_fail_pgs@GOTPAGEOFF]
LBB0_10:
	ldr	w9, [x8]
	add	w9, w9, #1
	str	w9, [x8]
LBB0_11:
	sxtw	x0, w20
LBB0_12:
	ldp	x29, x30, [sp, #96]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #80]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #64]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #48]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #32]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #112
	ret
LBB0_13:
	mov	x20, x26
	b	LBB0_11
	.loh AdrpLdrGotLdr	Lloh13, Lloh14, Lloh15
	.loh AdrpLdrGotLdr	Lloh10, Lloh11, Lloh12
	.loh AdrpLdrGot	Lloh8, Lloh9
	.loh AdrpLdrGot	Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh19, Lloh20, Lloh21
	.loh AdrpLdrGotLdr	Lloh16, Lloh17, Lloh18
	.loh AdrpLdrGot	Lloh22, Lloh23
	.loh AdrpLdrGotLdr	Lloh27, Lloh28, Lloh29
	.loh AdrpLdrGotLdr	Lloh24, Lloh25, Lloh26
	.loh AdrpLdrGot	Lloh30, Lloh31
	.loh AdrpLdrGot	Lloh32, Lloh33
	.loh AdrpLdrGot	Lloh34, Lloh35
	.cfi_endproc
                                        ; -- End function
	.comm	_memguard_options,4,2           ; @memguard_options
	.comm	_MG_GUARD_AROUND,4,2            ; @MG_GUARD_AROUND
	.comm	_PAGE_SIZE,4,2                  ; @PAGE_SIZE
	.comm	_memguard_arena,4,2             ; @memguard_arena
	.comm	_VMEM_ALLOC,4,2                 ; @VMEM_ALLOC
	.comm	_memguard_physlimit,8,3         ; @memguard_physlimit
	.comm	_memguard_fail_pgs,4,2          ; @memguard_fail_pgs
	.comm	_M_NEXTFIT,4,2                  ; @M_NEXTFIT
	.comm	_M_NOWAIT,4,2                   ; @M_NOWAIT
	.comm	_memguard_fail_kva,4,2          ; @memguard_fail_kva
	.comm	_kernel_object,4,2              ; @kernel_object
	.comm	_KERN_SUCCESS,4,2               ; @KERN_SUCCESS
	.comm	_memguard_succ,4,2              ; @memguard_succ
	.comm	_memguard_wasted,4,2            ; @memguard_wasted
.subsections_via_symbols
