	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_dmar_free_ctx_locked           ## -- Begin function dmar_free_ctx_locked
	.p2align	4, 0x90
_dmar_free_ctx_locked:                  ## @dmar_free_ctx_locked
	.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	%r12
	pushq	%rbx
	subq	$16, %rsp
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rsi, %rbx
	movq	%rdi, %r14
	callq	_DMAR_ASSERT_LOCKED
	movslq	(%rbx), %rsi
	xorl	%edi, %edi
	testq	%rsi, %rsi
	setg	%dil
	callq	_KASSERT
	movl	(%rbx), %eax
	cmpl	$2, %eax
	jl	LBB0_1
## %bb.9:
	decl	%eax
	movl	%eax, (%rbx)
	movq	%r14, %rdi
	addq	$16, %rsp
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	jmp	_DMAR_UNLOCK                    ## TAILCALL
LBB0_1:
	movq	_DMAR_CTX_DISABLED@GOTPCREL(%rip), %r12
	movl	(%r12), %eax
	xorl	%edi, %edi
	andl	4(%rbx), %eax
	sete	%dil
	movq	%rbx, %rsi
	callq	_KASSERT
	movq	%r14, %rdi
	callq	_DMAR_UNLOCK
	leaq	-40(%rbp), %rsi
	movq	%rbx, %rdi
	callq	_dmar_map_ctx_entry
	movq	%rax, %r15
	movq	%r14, %rdi
	callq	_DMAR_LOCK
	movslq	(%rbx), %rsi
	xorl	%edi, %edi
	testq	%rsi, %rsi
	setg	%dil
	callq	_KASSERT
	movl	(%rbx), %eax
	cmpl	$2, %eax
	jl	LBB0_3
## %bb.2:
	decl	%eax
	movl	%eax, (%rbx)
	movq	%r14, %rdi
	callq	_DMAR_UNLOCK
	movq	-40(%rbp), %rdi
	callq	_dmar_unmap_pgtbl
	jmp	LBB0_8
LBB0_3:
	movl	(%r12), %eax
	xorl	%edi, %edi
	andl	4(%rbx), %eax
	sete	%dil
	movq	%rbx, %rsi
	callq	_KASSERT
	movq	%r15, %rdi
	addq	$8, %rdi
	callq	_dmar_pte_clear
	movq	$0, (%r15)
	movq	%r14, %rdi
	movq	%r15, %rsi
	callq	_dmar_flush_ctx_to_ram
	movq	%r14, %rdi
	callq	_dmar_inv_ctx_glob
	movq	_DMAR_ECAP_DI@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	testl	%eax, (%r14)
	je	LBB0_7
## %bb.4:
	cmpq	$0, 8(%r14)
	je	LBB0_6
## %bb.5:
	movq	%r14, %rdi
	callq	_dmar_qi_invalidate_iotlb_glob_locked
	jmp	LBB0_7
LBB0_6:
	movq	%r14, %rdi
	callq	_dmar_inv_iotlb_glob
LBB0_7:
	movq	-40(%rbp), %rdi
	callq	_dmar_unmap_pgtbl
	movq	8(%rbx), %r15
	movq	%rbx, %rdi
	callq	_dmar_ctx_unlink
	movq	_M_DMAR_CTX@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%rbx, %rdi
	callq	_free
	movq	%r14, %rdi
	movq	%r15, %rsi
	callq	_dmar_unref_domain_locked
LBB0_8:
	addq	$16, %rsp
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_DMAR_CTX_DISABLED,4,2          ## @DMAR_CTX_DISABLED
	.comm	_TD_PREP_PINNED_ASSERT,4,2      ## @TD_PREP_PINNED_ASSERT
	.comm	_TD_PINNED_ASSERT,4,2           ## @TD_PINNED_ASSERT
	.comm	_DMAR_ECAP_DI,4,2               ## @DMAR_ECAP_DI
	.comm	_M_DMAR_CTX,4,2                 ## @M_DMAR_CTX
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_dmar_free_ctx_locked           ; -- Begin function dmar_free_ctx_locked
	.p2align	2
_dmar_free_ctx_locked:                  ; @dmar_free_ctx_locked
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #64
	.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
	mov	x20, x1
	mov	x19, x0
	bl	_DMAR_ASSERT_LOCKED
	ldrsw	x1, [x20]
	cmp	x1, #0
	cset	w0, gt
	bl	_KASSERT
	ldr	w8, [x20]
	cmp	w8, #2
	b.lt	LBB0_2
; %bb.1:
	sub	w8, w8, #1
	str	w8, [x20]
	mov	x0, x19
	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
	add	sp, sp, #64
	b	_DMAR_UNLOCK
LBB0_2:
	ldr	w8, [x20, #4]
Lloh0:
	adrp	x22, _DMAR_CTX_DISABLED@GOTPAGE
Lloh1:
	ldr	x22, [x22, _DMAR_CTX_DISABLED@GOTPAGEOFF]
	ldr	w9, [x22]
	tst	w9, w8
	cset	w0, eq
	mov	x1, x20
	bl	_KASSERT
	mov	x0, x19
	bl	_DMAR_UNLOCK
	add	x1, sp, #8
	mov	x0, x20
	bl	_dmar_map_ctx_entry
	mov	x21, x0
	mov	x0, x19
	bl	_DMAR_LOCK
	ldrsw	x1, [x20]
	cmp	x1, #0
	cset	w0, gt
	bl	_KASSERT
	ldr	w8, [x20]
	cmp	w8, #2
	b.lt	LBB0_4
; %bb.3:
	sub	w8, w8, #1
	str	w8, [x20]
	mov	x0, x19
	bl	_DMAR_UNLOCK
	ldr	x0, [sp, #8]
	bl	_dmar_unmap_pgtbl
	b	LBB0_9
LBB0_4:
	ldr	w8, [x20, #4]
	ldr	w9, [x22]
	tst	w9, w8
	cset	w0, eq
	mov	x1, x20
	bl	_KASSERT
	add	x0, x21, #8
	bl	_dmar_pte_clear
	str	xzr, [x21]
	mov	x0, x19
	mov	x1, x21
	bl	_dmar_flush_ctx_to_ram
	mov	x0, x19
	bl	_dmar_inv_ctx_glob
	ldr	w8, [x19]
Lloh2:
	adrp	x9, _DMAR_ECAP_DI@GOTPAGE
Lloh3:
	ldr	x9, [x9, _DMAR_ECAP_DI@GOTPAGEOFF]
Lloh4:
	ldr	w9, [x9]
	tst	w9, w8
	b.eq	LBB0_8
; %bb.5:
	ldr	x8, [x19, #8]
	cbz	x8, LBB0_7
; %bb.6:
	mov	x0, x19
	bl	_dmar_qi_invalidate_iotlb_glob_locked
	b	LBB0_8
LBB0_7:
	mov	x0, x19
	bl	_dmar_inv_iotlb_glob
LBB0_8:
	ldr	x0, [sp, #8]
	bl	_dmar_unmap_pgtbl
	ldr	x21, [x20, #8]
	mov	x0, x20
	bl	_dmar_ctx_unlink
Lloh5:
	adrp	x8, _M_DMAR_CTX@GOTPAGE
Lloh6:
	ldr	x8, [x8, _M_DMAR_CTX@GOTPAGEOFF]
Lloh7:
	ldr	w1, [x8]
	mov	x0, x20
	bl	_free
	mov	x0, x19
	mov	x1, x21
	bl	_dmar_unref_domain_locked
LBB0_9:
	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
	add	sp, sp, #64
	ret
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh7
	.cfi_endproc
                                        ; -- End function
	.comm	_DMAR_CTX_DISABLED,4,2          ; @DMAR_CTX_DISABLED
	.comm	_TD_PREP_PINNED_ASSERT,4,2      ; @TD_PREP_PINNED_ASSERT
	.comm	_TD_PINNED_ASSERT,4,2           ; @TD_PINNED_ASSERT
	.comm	_DMAR_ECAP_DI,4,2               ; @DMAR_ECAP_DI
	.comm	_M_DMAR_CTX,4,2                 ; @M_DMAR_CTX
.subsections_via_symbols
