	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_MmAllocateMemoryWithType       ## -- Begin function MmAllocateMemoryWithType
	.p2align	4, 0x90
_MmAllocateMemoryWithType:              ## @MmAllocateMemoryWithType
	.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
	testl	%edi, %edi
	je	LBB0_1
## %bb.3:
	movl	%esi, %r14d
	movl	$4, %esi
	callq	_ROUND_UP
	movl	%eax, %r15d
	movq	_MM_PAGE_SIZE@GOTPCREL(%rip), %rbx
	movl	(%rbx), %esi
	movl	%eax, %edi
	callq	_ROUND_UP
	cltd
	idivl	(%rbx)
	movslq	%eax, %r12
	movq	_FreePagesInLookupTable@GOTPCREL(%rip), %rax
	cmpq	%r12, (%rax)
	jl	LBB0_4
## %bb.5:
	movq	_PageLookupTableAddress@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movq	_TotalPagesInLookupTable@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	_FALSE@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	movq	%r12, %rdx
	callq	_MmFindAvailablePages
	testq	%rax, %rax
	je	LBB0_4
## %bb.6:
	movq	%rax, %r13
	movq	_PageLookupTableAddress@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movq	%r13, %rsi
	movq	%r12, %rdx
	movl	%r14d, %ecx
	callq	_MmAllocatePagesInLookupTable
	movq	_FreePagesInLookupTable@GOTPCREL(%rip), %rax
	subq	%r12, (%rax)
	movslq	(%rbx), %rax
	movslq	%r13d, %rbx
	imulq	%rax, %rbx
	leaq	L_.str.4(%rip), %rdi
	movl	%r15d, %esi
	movq	%r12, %rdx
	movl	%r14d, %ecx
	movq	%r13, %r8
	xorl	%eax, %eax
	callq	_TRACE
	leaq	L_.str.5(%rip), %rdi
	movl	%ebx, %esi
	xorl	%eax, %eax
	callq	_TRACE
	movq	_PAGE_SIZE@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	addl	%ebx, %r15d
	addl	%r15d, %eax
	decl	%eax
	movq	_PAGE_SHIFT@GOTPCREL(%rip), %rcx
	movb	(%rcx), %cl
	sarl	%cl, %eax
	movq	_LoaderPagesSpanned@GOTPCREL(%rip), %rcx
	cmpl	(%rcx), %eax
	jle	LBB0_8
## %bb.7:
	movl	%eax, (%rcx)
	jmp	LBB0_8
LBB0_4:
	leaq	L_.str.2(%rip), %rdi
	movl	%r15d, %esi
	callq	_ERR
	leaq	L_.str.3(%rip), %rdi
	jmp	LBB0_2
LBB0_1:
	leaq	L_.str(%rip), %rdi
	callq	_WARN
	leaq	L_.str.1(%rip), %rdi
LBB0_2:
	callq	_UiMessageBoxCritical
	xorl	%ebx, %ebx
LBB0_8:
	movq	%rbx, %rax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"MmAllocateMemory() called for 0 bytes. Returning NULL.\n"

L_.str.1:                               ## @.str.1
	.asciz	"Memory allocation failed: MmAllocateMemory() called for 0 bytes."

	.comm	_MM_PAGE_SIZE,4,2               ## @MM_PAGE_SIZE
	.comm	_FreePagesInLookupTable,8,3     ## @FreePagesInLookupTable
L_.str.2:                               ## @.str.2
	.asciz	"Memory allocation failed in MmAllocateMemory(). Not enough free memory to allocate %d bytes.\n"

L_.str.3:                               ## @.str.3
	.asciz	"Memory allocation failed: out of memory."

	.comm	_PageLookupTableAddress,4,2     ## @PageLookupTableAddress
	.comm	_TotalPagesInLookupTable,4,2    ## @TotalPagesInLookupTable
	.comm	_FALSE,4,2                      ## @FALSE
L_.str.4:                               ## @.str.4
	.asciz	"Allocated %d bytes (%d pages) of memory (type %ld) starting at page 0x%lx.\n"

L_.str.5:                               ## @.str.5
	.asciz	"Memory allocation pointer: 0x%x\n"

	.comm	_PAGE_SIZE,4,2                  ## @PAGE_SIZE
	.comm	_PAGE_SHIFT,4,2                 ## @PAGE_SHIFT
	.comm	_LoaderPagesSpanned,4,2         ## @LoaderPagesSpanned
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_MmAllocateMemoryWithType       ; -- Begin function MmAllocateMemoryWithType
	.p2align	2
_MmAllocateMemoryWithType:              ; @MmAllocateMemoryWithType
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #112
	.cfi_def_cfa_offset 112
	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
	cbz	w0, LBB0_6
; %bb.1:
	mov	x20, x1
	mov	w1, #4
	bl	_ROUND_UP
	mov	x19, x0
Lloh0:
	adrp	x21, _MM_PAGE_SIZE@GOTPAGE
Lloh1:
	ldr	x21, [x21, _MM_PAGE_SIZE@GOTPAGEOFF]
	ldr	w1, [x21]
	bl	_ROUND_UP
	ldr	w8, [x21]
	sdiv	w8, w0, w8
	sxtw	x22, w8
Lloh2:
	adrp	x24, _FreePagesInLookupTable@GOTPAGE
Lloh3:
	ldr	x24, [x24, _FreePagesInLookupTable@GOTPAGEOFF]
	ldr	x8, [x24]
	cmp	x8, x22
	b.lt	LBB0_5
; %bb.2:
Lloh4:
	adrp	x25, _PageLookupTableAddress@GOTPAGE
Lloh5:
	ldr	x25, [x25, _PageLookupTableAddress@GOTPAGEOFF]
	ldr	w0, [x25]
Lloh6:
	adrp	x8, _TotalPagesInLookupTable@GOTPAGE
Lloh7:
	ldr	x8, [x8, _TotalPagesInLookupTable@GOTPAGEOFF]
Lloh8:
	ldr	w1, [x8]
Lloh9:
	adrp	x8, _FALSE@GOTPAGE
Lloh10:
	ldr	x8, [x8, _FALSE@GOTPAGEOFF]
Lloh11:
	ldr	w3, [x8]
	mov	x2, x22
	bl	_MmFindAvailablePages
	cbz	x0, LBB0_5
; %bb.3:
	mov	x23, x0
	ldr	w0, [x25]
	mov	x1, x23
	mov	x2, x22
	mov	x3, x20
	bl	_MmAllocatePagesInLookupTable
	ldr	x8, [x24]
	sub	x8, x8, x22
	str	x8, [x24]
	ldrsw	x8, [x21]
	sxtw	x9, w23
	mul	x21, x8, x9
	stp	x20, x23, [sp, #8]
	str	x22, [sp]
Lloh12:
	adrp	x0, l_.str.4@PAGE
Lloh13:
	add	x0, x0, l_.str.4@PAGEOFF
	mov	x1, x19
	bl	_TRACE
Lloh14:
	adrp	x0, l_.str.5@PAGE
Lloh15:
	add	x0, x0, l_.str.5@PAGEOFF
	mov	x1, x21
	bl	_TRACE
Lloh16:
	adrp	x8, _PAGE_SIZE@GOTPAGE
Lloh17:
	ldr	x8, [x8, _PAGE_SIZE@GOTPAGEOFF]
Lloh18:
	ldr	w8, [x8]
	add	w9, w19, w21
	add	w8, w9, w8
	sub	w8, w8, #1
Lloh19:
	adrp	x9, _PAGE_SHIFT@GOTPAGE
Lloh20:
	ldr	x9, [x9, _PAGE_SHIFT@GOTPAGEOFF]
Lloh21:
	ldr	w9, [x9]
	asr	w8, w8, w9
Lloh22:
	adrp	x9, _LoaderPagesSpanned@GOTPAGE
Lloh23:
	ldr	x9, [x9, _LoaderPagesSpanned@GOTPAGEOFF]
	ldr	w10, [x9]
	cmp	w8, w10
	b.le	LBB0_8
; %bb.4:
	str	w8, [x9]
	b	LBB0_8
LBB0_5:
Lloh24:
	adrp	x0, l_.str.2@PAGE
Lloh25:
	add	x0, x0, l_.str.2@PAGEOFF
	mov	x1, x19
	bl	_ERR
Lloh26:
	adrp	x0, l_.str.3@PAGE
Lloh27:
	add	x0, x0, l_.str.3@PAGEOFF
	b	LBB0_7
LBB0_6:
Lloh28:
	adrp	x0, l_.str@PAGE
Lloh29:
	add	x0, x0, l_.str@PAGEOFF
	bl	_WARN
Lloh30:
	adrp	x0, l_.str.1@PAGE
Lloh31:
	add	x0, x0, l_.str.1@PAGEOFF
LBB0_7:
	bl	_UiMessageBoxCritical
	mov	x21, #0
LBB0_8:
	mov	x0, x21
	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
	add	sp, sp, #112
	ret
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGot	Lloh4, Lloh5
	.loh AdrpLdrGot	Lloh22, Lloh23
	.loh AdrpLdrGotLdr	Lloh19, Lloh20, Lloh21
	.loh AdrpLdrGotLdr	Lloh16, Lloh17, Lloh18
	.loh AdrpAdd	Lloh14, Lloh15
	.loh AdrpAdd	Lloh12, Lloh13
	.loh AdrpAdd	Lloh26, Lloh27
	.loh AdrpAdd	Lloh24, Lloh25
	.loh AdrpAdd	Lloh30, Lloh31
	.loh AdrpAdd	Lloh28, Lloh29
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"MmAllocateMemory() called for 0 bytes. Returning NULL.\n"

l_.str.1:                               ; @.str.1
	.asciz	"Memory allocation failed: MmAllocateMemory() called for 0 bytes."

	.comm	_MM_PAGE_SIZE,4,2               ; @MM_PAGE_SIZE
	.comm	_FreePagesInLookupTable,8,3     ; @FreePagesInLookupTable
l_.str.2:                               ; @.str.2
	.asciz	"Memory allocation failed in MmAllocateMemory(). Not enough free memory to allocate %d bytes.\n"

l_.str.3:                               ; @.str.3
	.asciz	"Memory allocation failed: out of memory."

	.comm	_PageLookupTableAddress,4,2     ; @PageLookupTableAddress
	.comm	_TotalPagesInLookupTable,4,2    ; @TotalPagesInLookupTable
	.comm	_FALSE,4,2                      ; @FALSE
l_.str.4:                               ; @.str.4
	.asciz	"Allocated %d bytes (%d pages) of memory (type %ld) starting at page 0x%lx.\n"

l_.str.5:                               ; @.str.5
	.asciz	"Memory allocation pointer: 0x%x\n"

	.comm	_PAGE_SIZE,4,2                  ; @PAGE_SIZE
	.comm	_PAGE_SHIFT,4,2                 ; @PAGE_SHIFT
	.comm	_LoaderPagesSpanned,4,2         ; @LoaderPagesSpanned
.subsections_via_symbols
