	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_phyp_iommu_map                 ## -- Begin function phyp_iommu_map
	.p2align	4, 0x90
_phyp_iommu_map:                        ## @phyp_iommu_map
	.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	$72, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	24(%rbp), %r12
	movq	8(%r12), %rax
	cmpq	%rcx, %rax
	cmovlq	%rax, %rcx
	movq	%rdx, -80(%rbp)                 ## 8-byte Spill
	cmpl	$0, (%rdx)
	jle	LBB0_16
## %bb.1:
	movq	%rsi, %r13
	movq	(%r12), %rsi
	xorl	%r14d, %r14d
	movq	_PAGE_MASK@GOTPCREL(%rip), %rax
	movq	_M_NOWAIT@GOTPCREL(%rip), %rbx
	movq	%r9, -72(%rbp)                  ## 8-byte Spill
	movq	%rcx, -64(%rbp)                 ## 8-byte Spill
	movq	%r13, -56(%rbp)                 ## 8-byte Spill
	movq	%r9, %r15
	movq	%rsi, -88(%rbp)                 ## 8-byte Spill
	jmp	LBB0_2
	.p2align	4, 0x90
LBB0_15:                                ##   in Loop: Header=BB0_2 Depth=1
	movq	-56(%rbp), %r13                 ## 8-byte Reload
	addq	%r13, %r14
	movq	_PAGE_MASK@GOTPCREL(%rip), %rbx
	movq	(%rbx), %rax
	movq	-96(%rbp), %r15                 ## 8-byte Reload
	andq	(%r15), %rax
	xorl	%edi, %edi
	addq	-48(%rbp), %rax
	movq	%rax, (%r15)
	setg	%dil
	leaq	L_.str.4(%rip), %rsi
	callq	_KASSERT
	movq	(%r14), %rax
	addq	(%r15), %rax
	xorl	%edi, %edi
	cmpq	-64(%rbp), %rax                 ## 8-byte Folded Reload
	setl	%dil
	leaq	L_.str.5(%rip), %rsi
	callq	_KASSERT
	movq	-104(%rbp), %r14                ## 8-byte Reload
	incq	%r14
	movq	-80(%rbp), %rax                 ## 8-byte Reload
	movslq	(%rax), %rax
	cmpq	%rax, %r14
	movq	-72(%rbp), %r15                 ## 8-byte Reload
	movq	24(%rbp), %r12
	movq	_M_NOWAIT@GOTPCREL(%rip), %rbx
	movq	_PAGE_MASK@GOTPCREL(%rip), %rax
	jge	LBB0_16
LBB0_2:                                 ## =>This Loop Header: Depth=1
                                        ##     Child Loop BB0_12 Depth 2
	movq	%r14, -104(%rbp)                ## 8-byte Spill
	shlq	$4, %r14
	movq	(%rax), %rdi
	andq	8(%r13,%r14), %rdi
	addq	(%r13,%r14), %rdi
	callq	_round_page
	movq	%rax, %r13
	movq	16(%r12), %rax
	movq	_PAGE_SIZE@GOTPCREL(%rip), %r12
	movq	(%r12), %rdx
	cmpq	%r15, %rdx
	cmovleq	%r15, %rdx
	movl	4(%rax), %edi
	movl	(%rbx), %eax
	movq	_M_BESTFIT@GOTPCREL(%rip), %rcx
	orl	(%rcx), %eax
	subq	$8, %rsp
	movq	%r13, %rsi
	xorl	%ecx, %ecx
	movq	16(%rbp), %r8
	movq	-88(%rbp), %r9                  ## 8-byte Reload
	leaq	-48(%rbp), %rbx
	pushq	%rbx
	pushq	%rax
	pushq	-64(%rbp)                       ## 8-byte Folded Reload
	callq	_vmem_xalloc
	addq	$32, %rsp
	testl	%eax, %eax
	jne	LBB0_3
## %bb.4:                               ##   in Loop: Header=BB0_2 Depth=1
	movq	-48(%rbp), %rax
	movq	(%r12), %rcx
	movq	%rax, %rdx
	orq	%rcx, %rdx
	shrq	$32, %rdx
	movq	%r12, %rbx
	je	LBB0_5
## %bb.6:                               ##   in Loop: Header=BB0_2 Depth=1
	cqto
	idivq	%rcx
	jmp	LBB0_7
	.p2align	4, 0x90
LBB0_5:                                 ##   in Loop: Header=BB0_2 Depth=1
                                        ## kill: def $eax killed $eax killed $rax
	xorl	%edx, %edx
	divl	%ecx
                                        ## kill: def $edx killed $edx def $rdx
LBB0_7:                                 ##   in Loop: Header=BB0_2 Depth=1
	movq	-56(%rbp), %rax                 ## 8-byte Reload
	leaq	(%rax,%r14), %r12
	addq	$8, %r12
	xorl	%edi, %edi
	testq	%rdx, %rdx
	sete	%dil
	leaq	L_.str.1(%rip), %rsi
	callq	_KASSERT
	movq	_PAGE_MASK@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	andq	(%r12), %rax
	addq	-48(%rbp), %rax
	movq	%rax, %rcx
	orq	%r15, %rcx
	shrq	$32, %rcx
	je	LBB0_8
## %bb.9:                               ##   in Loop: Header=BB0_2 Depth=1
	cqto
	idivq	%r15
	jmp	LBB0_10
	.p2align	4, 0x90
LBB0_8:                                 ##   in Loop: Header=BB0_2 Depth=1
                                        ## kill: def $eax killed $eax killed $rax
	xorl	%edx, %edx
	divl	%r15d
                                        ## kill: def $edx killed $edx def $rdx
LBB0_10:                                ##   in Loop: Header=BB0_2 Depth=1
	xorl	%edi, %edi
	testq	%rdx, %rdx
	sete	%dil
	leaq	L_.str.2(%rip), %rsi
	callq	_KASSERT
	movq	%r12, -96(%rbp)                 ## 8-byte Spill
	movq	(%r12), %rdi
	callq	_trunc_page
	testq	%r13, %r13
	jle	LBB0_15
## %bb.11:                              ##   in Loop: Header=BB0_2 Depth=1
	movl	%eax, %r15d
	orl	$3, %r15d
	xorl	%edx, %edx
	xorl	%r12d, %r12d
	.p2align	4, 0x90
LBB0_12:                                ##   Parent Loop BB0_2 Depth=1
                                        ## =>  This Inner Loop Header: Depth=2
	movq	_H_PUT_TCE@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movq	24(%rbp), %rax
	movq	16(%rax), %rax
	movl	(%rax), %esi
	addq	-48(%rbp), %rdx
	leal	(%r12,%r15), %ecx
	callq	_phyp_hcall
	testl	%eax, %eax
	js	LBB0_13
## %bb.14:                              ##   in Loop: Header=BB0_12 Depth=2
	addl	(%rbx), %r12d
	movslq	%r12d, %rdx
	cmpq	%rdx, %r13
	jg	LBB0_12
	jmp	LBB0_15
LBB0_13:
	leaq	L_.str.3(%rip), %rdi
	movl	%eax, %esi
	callq	_panic
	movq	_ENOMEM@GOTPCREL(%rip), %rax
	movl	(%rax), %ebx
	jmp	LBB0_17
LBB0_16:
	xorl	%ebx, %ebx
LBB0_17:
	movl	%ebx, %eax
	addq	$72, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_3:
	movl	%eax, %ebx
	leaq	L_.str(%rip), %rdi
	movl	%eax, %esi
	callq	_panic
	jmp	LBB0_17
	.cfi_endproc
                                        ## -- End function
	.comm	_PAGE_MASK,8,3                  ## @PAGE_MASK
	.comm	_PAGE_SIZE,8,3                  ## @PAGE_SIZE
	.comm	_M_BESTFIT,4,2                  ## @M_BESTFIT
	.comm	_M_NOWAIT,4,2                   ## @M_NOWAIT
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"VMEM failure: %d\n"

L_.str.1:                               ## @.str.1
	.asciz	"Alloc not page aligned"

L_.str.2:                               ## @.str.2
	.asciz	"Allocated segment does not match alignment constraint"

	.comm	_H_PUT_TCE,4,2                  ## @H_PUT_TCE
L_.str.3:                               ## @.str.3
	.asciz	"IOMMU mapping error: %d\n"

	.comm	_ENOMEM,4,2                     ## @ENOMEM
L_.str.4:                               ## @.str.4
	.asciz	"Address needs to be positive"

L_.str.5:                               ## @.str.5
	.asciz	"Address not in range"

.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_phyp_iommu_map                 ; -- Begin function phyp_iommu_map
	.p2align	2
_phyp_iommu_map:                        ; @phyp_iommu_map
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #160
	.cfi_def_cfa_offset 160
	stp	x28, x27, [sp, #64]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #80]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #96]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #112]            ; 16-byte Folded Spill
	stp	x20, x19, [sp, #128]            ; 16-byte Folded Spill
	stp	x29, x30, [sp, #144]            ; 16-byte Folded Spill
	add	x29, sp, #144
	.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
	stp	x1, x6, [sp, #32]               ; 16-byte Folded Spill
	ldr	x8, [x7, #8]
	cmp	x8, x3
	csel	x24, x8, x3, lt
	str	x2, [sp, #16]                   ; 8-byte Folded Spill
	ldr	w8, [x2]
	cmp	w8, #1
	b.lt	LBB0_9
; %bb.1:
	mov	x19, x7
	mov	x21, x5
	mov	x9, #0
Lloh0:
	adrp	x26, _PAGE_MASK@GOTPAGE
Lloh1:
	ldr	x26, [x26, _PAGE_MASK@GOTPAGEOFF]
	ldr	x8, [x7]
	str	x8, [sp, #24]                   ; 8-byte Folded Spill
Lloh2:
	adrp	x20, _PAGE_SIZE@GOTPAGE
Lloh3:
	ldr	x20, [x20, _PAGE_SIZE@GOTPAGEOFF]
Lloh4:
	adrp	x27, _M_BESTFIT@GOTPAGE
Lloh5:
	ldr	x27, [x27, _M_BESTFIT@GOTPAGEOFF]
Lloh6:
	adrp	x23, _M_NOWAIT@GOTPAGE
Lloh7:
	ldr	x23, [x23, _M_NOWAIT@GOTPAGEOFF]
	str	x24, [sp, #8]                   ; 8-byte Folded Spill
	b	LBB0_3
LBB0_2:                                 ;   in Loop: Header=BB0_3 Depth=1
	ldr	x8, [sp, #56]
	ldr	x9, [x25]
Lloh8:
	adrp	x26, _PAGE_MASK@GOTPAGE
Lloh9:
	ldr	x26, [x26, _PAGE_MASK@GOTPAGEOFF]
	ldr	x10, [x26]
	and	x9, x10, x9
	add	x8, x9, x8
	str	x8, [x25]
	cmp	x8, #0
	cset	w0, gt
Lloh10:
	adrp	x1, l_.str.4@PAGE
Lloh11:
	add	x1, x1, l_.str.4@PAGEOFF
	bl	_KASSERT
	ldr	x8, [x25]
	ldr	x9, [x22]
	add	x8, x9, x8
	ldr	x24, [sp, #8]                   ; 8-byte Folded Reload
	cmp	x8, x24
	cset	w0, lt
Lloh12:
	adrp	x1, l_.str.5@PAGE
Lloh13:
	add	x1, x1, l_.str.5@PAGEOFF
	bl	_KASSERT
	ldr	x9, [sp, #48]                   ; 8-byte Folded Reload
	add	x9, x9, #1
	ldr	x8, [sp, #16]                   ; 8-byte Folded Reload
	ldrsw	x8, [x8]
	cmp	x9, x8
Lloh14:
	adrp	x27, _M_BESTFIT@GOTPAGE
Lloh15:
	ldr	x27, [x27, _M_BESTFIT@GOTPAGEOFF]
Lloh16:
	adrp	x23, _M_NOWAIT@GOTPAGE
Lloh17:
	ldr	x23, [x23, _M_NOWAIT@GOTPAGEOFF]
	b.ge	LBB0_9
LBB0_3:                                 ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_6 Depth 2
	ldr	x8, [sp, #32]                   ; 8-byte Folded Reload
	str	x9, [sp, #48]                   ; 8-byte Folded Spill
	add	x22, x8, x9, lsl #4
	ldr	x8, [x22]
	mov	x25, x22
	ldr	x9, [x25, #8]!
	ldr	x10, [x26]
	and	x9, x10, x9
	add	x0, x9, x8
	bl	_round_page
	mov	x28, x0
	ldr	x8, [x19, #16]
	ldr	w0, [x8, #4]
	ldr	x8, [x20]
	cmp	x8, x21
	csel	x2, x8, x21, gt
	ldr	w8, [x27]
	ldr	w9, [x23]
	orr	w7, w9, w8
	add	x8, sp, #56
	str	x8, [sp]
	mov	x1, x28
	mov	w3, #0
	ldr	x4, [sp, #40]                   ; 8-byte Folded Reload
	ldr	x5, [sp, #24]                   ; 8-byte Folded Reload
	mov	x6, x24
	bl	_vmem_xalloc
	cbnz	w0, LBB0_11
; %bb.4:                                ;   in Loop: Header=BB0_3 Depth=1
	mov	x23, x21
	ldr	x8, [sp, #56]
	ldr	x9, [x20]
	sdiv	x10, x8, x9
	msub	x8, x10, x9, x8
	cmp	x8, #0
	cset	w0, eq
Lloh18:
	adrp	x1, l_.str.1@PAGE
Lloh19:
	add	x1, x1, l_.str.1@PAGEOFF
	bl	_KASSERT
	ldr	x8, [sp, #56]
	ldr	x9, [x25]
	ldr	x10, [x26]
	and	x9, x10, x9
	add	x8, x9, x8
	sdiv	x9, x8, x21
	msub	x8, x9, x21, x8
	cmp	x8, #0
	cset	w0, eq
Lloh20:
	adrp	x1, l_.str.2@PAGE
Lloh21:
	add	x1, x1, l_.str.2@PAGEOFF
	bl	_KASSERT
	ldr	x0, [x25]
	bl	_trunc_page
	cmp	x28, #1
Lloh22:
	adrp	x23, _H_PUT_TCE@GOTPAGE
Lloh23:
	ldr	x23, [x23, _H_PUT_TCE@GOTPAGEOFF]
	b.lt	LBB0_2
; %bb.5:                                ;   in Loop: Header=BB0_3 Depth=1
	mov	x8, #0
	mov	w26, #0
	orr	w24, w0, #0x3
LBB0_6:                                 ;   Parent Loop BB0_3 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	ldr	w0, [x23]
	ldr	x9, [x19, #16]
	ldr	w1, [x9]
	ldr	x9, [sp, #56]
	add	x2, x9, x8
	add	w3, w26, w24
	bl	_phyp_hcall
	tbnz	w0, #31, LBB0_8
; %bb.7:                                ;   in Loop: Header=BB0_6 Depth=2
	ldr	w8, [x20]
	add	w26, w26, w8
	sxtw	x8, w26
	cmp	x28, x8
	b.gt	LBB0_6
	b	LBB0_2
LBB0_8:
	mov	x1, x0
Lloh24:
	adrp	x0, l_.str.3@PAGE
Lloh25:
	add	x0, x0, l_.str.3@PAGEOFF
	bl	_panic
Lloh26:
	adrp	x8, _ENOMEM@GOTPAGE
Lloh27:
	ldr	x8, [x8, _ENOMEM@GOTPAGEOFF]
Lloh28:
	ldr	w21, [x8]
	b	LBB0_10
LBB0_9:
	mov	w21, #0
LBB0_10:
	mov	x0, x21
	ldp	x29, x30, [sp, #144]            ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #128]            ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #112]            ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #96]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #80]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #64]             ; 16-byte Folded Reload
	add	sp, sp, #160
	ret
LBB0_11:
	mov	x21, x0
Lloh29:
	adrp	x0, l_.str@PAGE
Lloh30:
	add	x0, x0, l_.str@PAGEOFF
	mov	x1, x21
	bl	_panic
	b	LBB0_10
	.loh AdrpLdrGot	Lloh6, Lloh7
	.loh AdrpLdrGot	Lloh4, Lloh5
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGot	Lloh16, Lloh17
	.loh AdrpLdrGot	Lloh14, Lloh15
	.loh AdrpAdd	Lloh12, Lloh13
	.loh AdrpAdd	Lloh10, Lloh11
	.loh AdrpLdrGot	Lloh8, Lloh9
	.loh AdrpLdrGot	Lloh22, Lloh23
	.loh AdrpAdd	Lloh20, Lloh21
	.loh AdrpAdd	Lloh18, Lloh19
	.loh AdrpLdrGotLdr	Lloh26, Lloh27, Lloh28
	.loh AdrpAdd	Lloh24, Lloh25
	.loh AdrpAdd	Lloh29, Lloh30
	.cfi_endproc
                                        ; -- End function
	.comm	_PAGE_MASK,8,3                  ; @PAGE_MASK
	.comm	_PAGE_SIZE,8,3                  ; @PAGE_SIZE
	.comm	_M_BESTFIT,4,2                  ; @M_BESTFIT
	.comm	_M_NOWAIT,4,2                   ; @M_NOWAIT
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"VMEM failure: %d\n"

l_.str.1:                               ; @.str.1
	.asciz	"Alloc not page aligned"

l_.str.2:                               ; @.str.2
	.asciz	"Allocated segment does not match alignment constraint"

	.comm	_H_PUT_TCE,4,2                  ; @H_PUT_TCE
l_.str.3:                               ; @.str.3
	.asciz	"IOMMU mapping error: %d\n"

	.comm	_ENOMEM,4,2                     ; @ENOMEM
l_.str.4:                               ; @.str.4
	.asciz	"Address needs to be positive"

l_.str.5:                               ; @.str.5
	.asciz	"Address not in range"

.subsections_via_symbols
