	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function dmar_get_ctx_for_dev1
_dmar_get_ctx_for_dev1:                 ## @dmar_get_ctx_for_dev1
	.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	$56, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%r9, -56(%rbp)                  ## 8-byte Spill
                                        ## kill: def $r8d killed $r8d def $r8
	movq	%r8, -64(%rbp)                  ## 8-byte Spill
	movl	%ecx, -44(%rbp)                 ## 4-byte Spill
	movl	%edx, %r15d
	movq	%rsi, %r12
	movq	%rdi, %r14
	testq	%rsi, %rsi
	je	LBB0_2
## %bb.1:
	movq	%r12, %rdi
	callq	_pci_get_bus
	movl	%eax, %r13d
	movq	%r12, %rdi
	callq	_pci_get_slot
	movl	%eax, -48(%rbp)                 ## 4-byte Spill
	movq	%r12, %rdi
	callq	_pci_get_function
	jmp	LBB0_3
LBB0_2:
	movl	%r15d, %edi
	callq	_PCI_RID2BUS
	movl	%eax, %r13d
	movl	%r15d, %edi
	callq	_PCI_RID2SLOT
	movl	%eax, -48(%rbp)                 ## 4-byte Spill
	movl	%r15d, %edi
	callq	_PCI_RID2FUNC
LBB0_3:
                                        ## kill: def $eax killed $eax def $rax
	movq	%rax, -72(%rbp)                 ## 8-byte Spill
	movq	%r14, %rdi
	callq	_DMAR_LOCK
	movq	%r14, %rdi
	movl	%r15d, %esi
	callq	_dmar_find_ctx_locked
	testq	%rax, %rax
	je	LBB0_9
## %bb.4:
	movq	%rax, %rbx
	cmpq	$0, 8(%rax)
	jne	LBB0_6
## %bb.5:
	movq	%r12, 8(%rbx)
LBB0_6:
	incl	(%rbx)
	xorl	%r13d, %r13d
LBB0_7:
	movq	%r14, %rdi
	movl	%r13d, %esi
	callq	_dmar_flush_for_ctx_entry
	testl	%eax, %eax
	je	LBB0_13
LBB0_8:
	movq	%r14, %rdi
	movq	%rbx, %rsi
	callq	_dmar_free_ctx_locked
	jmp	LBB0_20
LBB0_9:
	movl	24(%rbp), %ebx
	movq	%r14, %rdi
	callq	_DMAR_UNLOCK
	movl	%r15d, %edi
	callq	_PCI_RID2BUS
	movq	%r14, %rdi
	movl	%eax, %esi
	callq	_dmar_ensure_ctx_page
	movq	%r14, %rdi
	movl	%ebx, %esi
	callq	_dmar_domain_alloc
	testq	%rax, %rax
	je	LBB0_20
## %bb.10:
	movq	%rax, %rdi
	testl	%ebx, %ebx
	je	LBB0_18
LBB0_11:
	movq	%rdi, -64(%rbp)                 ## 8-byte Spill
	movl	%r15d, %esi
	callq	_dmar_ctx_alloc
	movq	%rax, %rbx
	leaq	-88(%rbp), %rsi
	movq	%rax, %rdi
	callq	_dmar_map_ctx_entry
	movq	%rax, -56(%rbp)                 ## 8-byte Spill
	movq	%r14, %rdi
	callq	_DMAR_LOCK
	movq	%r14, %rdi
	movl	%r15d, %esi
	callq	_dmar_find_ctx_locked
	testq	%rax, %rax
	je	LBB0_22
## %bb.12:
	movq	-88(%rbp), %rdi
	movq	%rax, %r15
	callq	_dmar_unmap_pgtbl
	movq	-64(%rbp), %rdi                 ## 8-byte Reload
	callq	_dmar_domain_destroy
	movq	_M_DMAR_CTX@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%rbx, %rdi
	callq	_free
	incl	(%r15)
	xorl	%r13d, %r13d
	movq	%r15, %rbx
	jmp	LBB0_7
LBB0_13:
	cmpl	$0, 32(%rbp)
	jne	LBB0_16
## %bb.14:
	testl	%r13d, %r13d
	je	LBB0_16
## %bb.15:
	movq	_DMAR_GCMD_TE@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	testl	%eax, 4(%r14)
	je	LBB0_25
LBB0_16:
	movq	%r14, %rdi
	callq	_DMAR_UNLOCK
	jmp	LBB0_21
LBB0_18:
	movl	16(%rbp), %eax
	subq	$8, %rsp
	movq	%rdi, %rbx
	movq	%r12, %rsi
	movl	%r13d, %edx
	movl	-48(%rbp), %ecx                 ## 4-byte Reload
	movq	-72(%rbp), %r8                  ## 8-byte Reload
                                        ## kill: def $r8d killed $r8d killed $r8
	movl	-44(%rbp), %r9d                 ## 4-byte Reload
	pushq	%rax
	pushq	-56(%rbp)                       ## 8-byte Folded Reload
	pushq	-64(%rbp)                       ## 8-byte Folded Reload
	callq	_domain_init_rmrr
	movq	%rbx, %rdi
	addq	$32, %rsp
	testl	%eax, %eax
	je	LBB0_11
## %bb.19:
	callq	_dmar_domain_destroy
LBB0_20:
	xorl	%ebx, %ebx
LBB0_21:
	movq	%rbx, %rax
	addq	$56, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_22:
	movl	%r13d, -76(%rbp)                ## 4-byte Spill
	movq	%rbx, %rdi
	callq	_dmar_ctx_link
	movq	%r12, 8(%rbx)
	movq	%rbx, %rdi
	movq	%r12, %rsi
	callq	_ctx_tag_init
	leaq	12(%r14), %rdi
	movq	%rdi, -96(%rbp)                 ## 8-byte Spill
	callq	_LIST_EMPTY
	xorl	%r13d, %r13d
	testq	%rax, %rax
	setne	-44(%rbp)                       ## 1-byte Folded Spill
	movq	_link@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	-96(%rbp), %rdi                 ## 8-byte Reload
	movq	-64(%rbp), %rsi                 ## 8-byte Reload
	callq	_LIST_INSERT_HEAD
	movq	%rbx, %rdi
	movq	-56(%rbp), %rsi                 ## 8-byte Reload
	xorl	%edx, %edx
	callq	_ctx_id_entry_init
	testq	%r12, %r12
	je	LBB0_24
## %bb.23:
	cmpl	$0, 24(%rbp)
	movl	(%r14), %edx
	movl	8(%r14), %ecx
	movq	-64(%rbp), %rsi                 ## 8-byte Reload
	movl	8(%rsi), %eax
	movq	%rax, -56(%rbp)                 ## 8-byte Spill
	movl	(%rsi), %eax
	movl	4(%rsi), %r11d
	leaq	L_.str.2(%rip), %rsi
	leaq	L_.str.1(%rip), %r10
	cmoveq	%rsi, %r10
	leaq	L_.str(%rip), %rsi
	movq	%r12, %rdi
	movl	-76(%rbp), %r8d                 ## 4-byte Reload
	movl	-48(%rbp), %r9d                 ## 4-byte Reload
	pushq	%r10
	pushq	%rax
	pushq	%r11
	pushq	-56(%rbp)                       ## 8-byte Folded Reload
	pushq	%r15
	pushq	-72(%rbp)                       ## 8-byte Folded Reload
	callq	_device_printf
	addq	$48, %rsp
LBB0_24:
	movb	-44(%rbp), %al                  ## 1-byte Reload
	movb	%al, %r13b
	movq	-88(%rbp), %rdi
	callq	_dmar_unmap_pgtbl
	jmp	LBB0_7
LBB0_25:
	movq	%r14, %rdi
	callq	_dmar_enable_translation
	testl	%eax, %eax
	je	LBB0_27
## %bb.26:
	movl	(%r14), %esi
	leaq	L_.str.4(%rip), %rdi
	movl	%eax, %edx
	xorl	%eax, %eax
	callq	_printf
	jmp	LBB0_8
LBB0_27:
	movq	_bootverbose@GOTPCREL(%rip), %rax
	cmpq	$0, (%rax)
	je	LBB0_16
## %bb.28:
	movl	(%r14), %esi
	leaq	L_.str.3(%rip), %rdi
	xorl	%eax, %eax
	callq	_printf
	jmp	LBB0_16
	.cfi_endproc
                                        ## -- End function
	.comm	_TD_PREP_PINNED_ASSERT,4,2      ## @TD_PREP_PINNED_ASSERT
	.comm	_TD_PINNED_ASSERT,4,2           ## @TD_PINNED_ASSERT
	.comm	_link,4,2                       ## @link
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"dmar%d pci%d:%d:%d:%d rid %x domain %d mgaw %d agaw %d %s-mapped\n"

L_.str.1:                               ## @.str.1
	.asciz	"id"

L_.str.2:                               ## @.str.2
	.asciz	"re"

	.comm	_M_DMAR_CTX,4,2                 ## @M_DMAR_CTX
	.comm	_DMAR_GCMD_TE,4,2               ## @DMAR_GCMD_TE
	.comm	_bootverbose,8,3                ## @bootverbose
L_.str.3:                               ## @.str.3
	.asciz	"dmar%d: enabled translation\n"

L_.str.4:                               ## @.str.4
	.asciz	"dmar%d: enabling translation failed, error %d\n"

	.no_dead_strip	_dmar_get_ctx_for_dev1
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function dmar_get_ctx_for_dev1
_dmar_get_ctx_for_dev1:                 ; @dmar_get_ctx_for_dev1
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #144
	.cfi_def_cfa_offset 144
	stp	x28, x27, [sp, #48]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #64]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #80]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #96]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #112]            ; 16-byte Folded Spill
	stp	x29, x30, [sp, #128]            ; 16-byte Folded Spill
	add	x29, sp, #128
	.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	x23, x7
	mov	x26, x6
	mov	x27, x5
	mov	x28, x4
	mov	x25, x3
	mov	x21, x2
	mov	x22, x1
	mov	x19, x0
	cbz	x1, LBB0_2
; %bb.1:
	mov	x0, x22
	bl	_pci_get_bus
	mov	x24, x0
	mov	x0, x22
	bl	_pci_get_slot
	str	w0, [sp, #36]                   ; 4-byte Folded Spill
	mov	x0, x22
	bl	_pci_get_function
	b	LBB0_3
LBB0_2:
	mov	x0, x21
	bl	_PCI_RID2BUS
	mov	x24, x0
	mov	x0, x21
	bl	_PCI_RID2SLOT
	str	w0, [sp, #36]                   ; 4-byte Folded Spill
	mov	x0, x21
	bl	_PCI_RID2FUNC
LBB0_3:
	str	w0, [sp, #32]                   ; 4-byte Folded Spill
	mov	x0, x19
	bl	_DMAR_LOCK
	mov	x0, x19
	mov	x1, x21
	bl	_dmar_find_ctx_locked
	cbz	x0, LBB0_9
; %bb.4:
	mov	x20, x0
	ldr	x8, [x0, #8]
	cbnz	x8, LBB0_6
; %bb.5:
	str	x22, [x20, #8]
LBB0_6:
	mov	w25, #0
	ldr	w8, [x20]
	add	w8, w8, #1
	str	w8, [x20]
LBB0_7:
	mov	x0, x19
	mov	x1, x25
	bl	_dmar_flush_for_ctx_entry
	cbz	w0, LBB0_13
LBB0_8:
	mov	x0, x19
	mov	x1, x20
	bl	_dmar_free_ctx_locked
	b	LBB0_19
LBB0_9:
	str	w24, [sp, #28]                  ; 4-byte Folded Spill
	mov	x0, x19
	bl	_DMAR_UNLOCK
	mov	x0, x21
	bl	_PCI_RID2BUS
	mov	x1, x0
	mov	x0, x19
	bl	_dmar_ensure_ctx_page
	mov	x0, x19
	mov	x1, x23
	bl	_dmar_domain_alloc
	cbz	x0, LBB0_19
; %bb.10:
	mov	x24, x0
	cbz	w23, LBB0_17
LBB0_11:
	mov	x0, x24
	mov	x1, x21
	bl	_dmar_ctx_alloc
	mov	x20, x0
	add	x1, sp, #40
	bl	_dmar_map_ctx_entry
	mov	x26, x0
	mov	x0, x19
	bl	_DMAR_LOCK
	mov	x0, x19
	mov	x1, x21
	bl	_dmar_find_ctx_locked
	cbz	x0, LBB0_21
; %bb.12:
	mov	x27, x0
	ldr	x0, [sp, #40]
	bl	_dmar_unmap_pgtbl
	mov	x0, x24
	bl	_dmar_domain_destroy
Lloh0:
	adrp	x8, _M_DMAR_CTX@GOTPAGE
Lloh1:
	ldr	x8, [x8, _M_DMAR_CTX@GOTPAGEOFF]
Lloh2:
	ldr	w1, [x8]
	mov	x0, x20
	bl	_free
	mov	w25, #0
	ldr	w8, [x27]
	add	w8, w8, #1
	str	w8, [x27]
	mov	x20, x27
	b	LBB0_7
LBB0_13:
	ldr	w8, [x29, #16]
	cbnz	w8, LBB0_16
; %bb.14:
	cbz	w25, LBB0_16
; %bb.15:
	ldr	w8, [x19, #4]
Lloh3:
	adrp	x9, _DMAR_GCMD_TE@GOTPAGE
Lloh4:
	ldr	x9, [x9, _DMAR_GCMD_TE@GOTPAGEOFF]
Lloh5:
	ldr	w9, [x9]
	tst	w9, w8
	b.eq	LBB0_24
LBB0_16:
	mov	x0, x19
	bl	_DMAR_UNLOCK
	b	LBB0_20
LBB0_17:
	str	w26, [sp]
	mov	x0, x24
	mov	x1, x22
	ldp	w2, w4, [sp, #28]               ; 8-byte Folded Reload
	ldr	w3, [sp, #36]                   ; 4-byte Folded Reload
	mov	x5, x25
	mov	x6, x28
	mov	x7, x27
	bl	_domain_init_rmrr
	cbz	w0, LBB0_11
; %bb.18:
	mov	x0, x24
	bl	_dmar_domain_destroy
LBB0_19:
	mov	x20, #0
LBB0_20:
	mov	x0, x20
	ldp	x29, x30, [sp, #128]            ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #112]            ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #96]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #80]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #64]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #48]             ; 16-byte Folded Reload
	add	sp, sp, #144
	ret
LBB0_21:
	mov	x0, x20
	bl	_dmar_ctx_link
	str	x22, [x20, #8]
	mov	x0, x20
	mov	x1, x22
	bl	_ctx_tag_init
	add	x27, x19, #12
	mov	x0, x27
	bl	_LIST_EMPTY
	cmp	x0, #0
	cset	w25, ne
Lloh6:
	adrp	x8, _link@GOTPAGE
Lloh7:
	ldr	x8, [x8, _link@GOTPAGEOFF]
Lloh8:
	ldr	w2, [x8]
	mov	x0, x27
	mov	x1, x24
	bl	_LIST_INSERT_HEAD
	mov	x0, x20
	mov	x1, x26
	mov	w2, #0
	bl	_ctx_id_entry_init
	cbz	x22, LBB0_23
; %bb.22:
	ldr	w2, [x19]
	ldr	w3, [x19, #8]
	ldp	w9, w8, [x24, #4]
	ldr	w10, [x24]
Lloh9:
	adrp	x11, l_.str.1@PAGE
Lloh10:
	add	x11, x11, l_.str.1@PAGEOFF
Lloh11:
	adrp	x12, l_.str.2@PAGE
Lloh12:
	add	x12, x12, l_.str.2@PAGEOFF
	cmp	w23, #0
	csel	x11, x12, x11, eq
	str	x11, [sp, #16]
	stp	w9, w10, [sp, #4]
	str	w8, [sp]
Lloh13:
	adrp	x1, l_.str@PAGE
Lloh14:
	add	x1, x1, l_.str@PAGEOFF
	mov	x0, x22
	ldp	w4, w6, [sp, #28]               ; 8-byte Folded Reload
	ldr	w5, [sp, #36]                   ; 4-byte Folded Reload
	mov	x7, x21
	bl	_device_printf
LBB0_23:
	ldr	x0, [sp, #40]
	bl	_dmar_unmap_pgtbl
	b	LBB0_7
LBB0_24:
	mov	x0, x19
	bl	_dmar_enable_translation
                                        ; kill: def $w0 killed $w0 def $x0
	cbz	w0, LBB0_26
; %bb.25:
	ldr	w1, [x19]
	str	x0, [sp]
Lloh15:
	adrp	x0, l_.str.4@PAGE
Lloh16:
	add	x0, x0, l_.str.4@PAGEOFF
	bl	_printf
	b	LBB0_8
LBB0_26:
Lloh17:
	adrp	x8, _bootverbose@GOTPAGE
Lloh18:
	ldr	x8, [x8, _bootverbose@GOTPAGEOFF]
Lloh19:
	ldr	x8, [x8]
	cbz	x8, LBB0_16
; %bb.27:
	ldr	w1, [x19]
Lloh20:
	adrp	x0, l_.str.3@PAGE
Lloh21:
	add	x0, x0, l_.str.3@PAGEOFF
	bl	_printf
	b	LBB0_16
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpAdd	Lloh13, Lloh14
	.loh AdrpAdd	Lloh11, Lloh12
	.loh AdrpAdd	Lloh9, Lloh10
	.loh AdrpAdd	Lloh15, Lloh16
	.loh AdrpLdrGotLdr	Lloh17, Lloh18, Lloh19
	.loh AdrpAdd	Lloh20, Lloh21
	.cfi_endproc
                                        ; -- End function
	.comm	_TD_PREP_PINNED_ASSERT,4,2      ; @TD_PREP_PINNED_ASSERT
	.comm	_TD_PINNED_ASSERT,4,2           ; @TD_PINNED_ASSERT
	.comm	_link,4,2                       ; @link
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"dmar%d pci%d:%d:%d:%d rid %x domain %d mgaw %d agaw %d %s-mapped\n"

l_.str.1:                               ; @.str.1
	.asciz	"id"

l_.str.2:                               ; @.str.2
	.asciz	"re"

	.comm	_M_DMAR_CTX,4,2                 ; @M_DMAR_CTX
	.comm	_DMAR_GCMD_TE,4,2               ; @DMAR_GCMD_TE
	.comm	_bootverbose,8,3                ; @bootverbose
l_.str.3:                               ; @.str.3
	.asciz	"dmar%d: enabled translation\n"

l_.str.4:                               ; @.str.4
	.asciz	"dmar%d: enabling translation failed, error %d\n"

	.no_dead_strip	_dmar_get_ctx_for_dev1
.subsections_via_symbols
