	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_ocxl_context_detach            ## -- Begin function ocxl_context_detach
	.p2align	4, 0x90
_ocxl_context_detach:                   ## @ocxl_context_detach
	.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
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdi, %r12
	leaq	16(%rdi), %rbx
	movq	%rbx, %rdi
	callq	_mutex_lock
	movl	(%r12), %r14d
	movq	_CLOSED@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, (%r12)
	movq	%rbx, %rdi
	callq	_mutex_unlock
	movq	_ATTACHED@GOTPCREL(%rip), %rax
	cmpl	(%rax), %r14d
	jne	LBB0_5
## %bb.1:
	movq	8(%r12), %rax
	movq	(%rax), %rax
	movl	4(%rax), %edi
	callq	_to_pci_dev
	movq	%rax, %r14
	movq	8(%r12), %rdi
	movl	12(%rdi), %ebx
	addq	$8, %rdi
	callq	_mutex_lock
	movl	4(%r12), %edx
	movq	%r14, %rdi
	movl	%ebx, %esi
	callq	_ocxl_config_terminate_pasid
	movl	%eax, %r15d
	movq	8(%r12), %rdi
	addq	$8, %rdi
	callq	_mutex_unlock
	movl	4(%r12), %edi
	movl	%r15d, %esi
	callq	_trace_ocxl_terminate_pasid
	testl	%r15d, %r15d
	je	LBB0_3
## %bb.2:
	movq	_EBUSY@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	addl	%r15d, %eax
	je	LBB0_6
LBB0_3:
	movq	8(%r12), %rax
	movq	(%rax), %rax
	movl	(%rax), %edi
	movl	4(%r12), %esi
	callq	_ocxl_link_remove_pe
	testl	%eax, %eax
	je	LBB0_5
## %bb.4:
	leaq	L_.str(%rip), %rsi
	movq	%r14, %rdi
	movl	%eax, %edx
	callq	_dev_warn
LBB0_5:
	xorl	%r15d, %r15d
LBB0_6:
	movl	%r15d, %eax
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_CLOSED,4,2                     ## @CLOSED
	.comm	_ATTACHED,4,2                   ## @ATTACHED
	.comm	_EBUSY,4,2                      ## @EBUSY
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Couldn't remove PE entry cleanly: %d\n"

.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_ocxl_context_detach            ; -- Begin function ocxl_context_detach
	.p2align	2
_ocxl_context_detach:                   ; @ocxl_context_detach
	.cfi_startproc
; %bb.0:
	stp	x22, x21, [sp, #-48]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 48
	stp	x20, x19, [sp, #16]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #32]             ; 16-byte Folded Spill
	add	x29, sp, #32
	.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	x19, x0
	add	x20, x0, #16
	mov	x0, x20
	bl	_mutex_lock
	ldr	w21, [x19]
Lloh0:
	adrp	x8, _CLOSED@GOTPAGE
Lloh1:
	ldr	x8, [x8, _CLOSED@GOTPAGEOFF]
Lloh2:
	ldr	w8, [x8]
	str	w8, [x19]
	mov	x0, x20
	bl	_mutex_unlock
Lloh3:
	adrp	x8, _ATTACHED@GOTPAGE
Lloh4:
	ldr	x8, [x8, _ATTACHED@GOTPAGEOFF]
Lloh5:
	ldr	w8, [x8]
	cmp	w21, w8
	b.ne	LBB0_5
; %bb.1:
	ldr	x8, [x19, #8]
	ldr	x8, [x8]
	ldr	w0, [x8, #4]
	bl	_to_pci_dev
	mov	x20, x0
	ldr	x8, [x19, #8]
	ldr	w21, [x8, #12]
	add	x0, x8, #8
	bl	_mutex_lock
	ldr	w2, [x19, #4]
	mov	x0, x20
	mov	x1, x21
	bl	_ocxl_config_terminate_pasid
	mov	x21, x0
	ldr	x8, [x19, #8]
	add	x0, x8, #8
	bl	_mutex_unlock
	ldr	w0, [x19, #4]
	mov	x1, x21
	bl	_trace_ocxl_terminate_pasid
	cbz	w21, LBB0_3
; %bb.2:
Lloh6:
	adrp	x8, _EBUSY@GOTPAGE
Lloh7:
	ldr	x8, [x8, _EBUSY@GOTPAGEOFF]
Lloh8:
	ldr	w8, [x8]
	cmn	w21, w8
	b.eq	LBB0_6
LBB0_3:
	ldr	x8, [x19, #8]
	ldr	x8, [x8]
	ldr	w0, [x8]
	ldr	w1, [x19, #4]
	bl	_ocxl_link_remove_pe
	cbz	w0, LBB0_5
; %bb.4:
	mov	x2, x0
Lloh9:
	adrp	x1, l_.str@PAGE
Lloh10:
	add	x1, x1, l_.str@PAGEOFF
	mov	x0, x20
	bl	_dev_warn
LBB0_5:
	mov	w21, #0
LBB0_6:
	mov	x0, x21
	ldp	x29, x30, [sp, #32]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #16]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp], #48             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpAdd	Lloh9, Lloh10
	.cfi_endproc
                                        ; -- End function
	.comm	_CLOSED,4,2                     ; @CLOSED
	.comm	_ATTACHED,4,2                   ; @ATTACHED
	.comm	_EBUSY,4,2                      ; @EBUSY
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Couldn't remove PE entry cleanly: %d\n"

.subsections_via_symbols
