	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function sgx_unload
_sgx_unload:                            ## @sgx_unload
	.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	_sgx_sc@GOTPCREL(%rip), %rbx
	movq	_SGX_STATE_RUNNING@GOTPCREL(%rip), %r12
	movl	(%r12), %eax
	xorl	%r14d, %r14d
	testl	%eax, (%rbx)
	je	LBB0_4
## %bb.1:
	leaq	4(%rbx), %r15
	movq	%r15, %rdi
	callq	_mtx_lock
	leaq	20(%rbx), %rdi
	callq	_TAILQ_EMPTY
	testl	%eax, %eax
	je	LBB0_2
## %bb.3:
	movl	(%r12), %eax
	notl	%eax
	andl	%eax, (%rbx)
	movq	%r15, %rdi
	callq	_mtx_unlock
	movl	16(%rbx), %edi
	callq	_destroy_dev
	movl	12(%rbx), %edi
	callq	_vmem_destroy
	movq	%rbx, %rdi
	callq	_sgx_put_epc_area
	addq	$8, %rbx
	movq	%rbx, %rdi
	callq	_mtx_destroy
	movq	%r15, %rdi
	callq	_mtx_destroy
	jmp	LBB0_4
LBB0_2:
	movq	%r15, %rdi
	callq	_mtx_unlock
	movq	_EBUSY@GOTPCREL(%rip), %rax
	movl	(%rax), %r14d
LBB0_4:
	movl	%r14d, %eax
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_sgx_sc,24,2                    ## @sgx_sc
	.comm	_SGX_STATE_RUNNING,4,2          ## @SGX_STATE_RUNNING
	.comm	_EBUSY,4,2                      ## @EBUSY
	.no_dead_strip	_sgx_unload
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function sgx_unload
_sgx_unload:                            ; @sgx_unload
	.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
Lloh0:
	adrp	x19, _sgx_sc@GOTPAGE
Lloh1:
	ldr	x19, [x19, _sgx_sc@GOTPAGEOFF]
	ldr	w8, [x19]
Lloh2:
	adrp	x21, _SGX_STATE_RUNNING@GOTPAGE
Lloh3:
	ldr	x21, [x21, _SGX_STATE_RUNNING@GOTPAGEOFF]
	ldr	w9, [x21]
	tst	w9, w8
	b.eq	LBB0_3
; %bb.1:
	add	x20, x19, #4
	mov	x0, x20
	bl	_mtx_lock
	add	x0, x19, #20
	bl	_TAILQ_EMPTY
	cbz	w0, LBB0_4
; %bb.2:
	ldr	w8, [x21]
	ldr	w9, [x19]
	bic	w8, w9, w8
	str	w8, [x19]
	mov	x0, x20
	bl	_mtx_unlock
	ldr	w0, [x19, #16]
	bl	_destroy_dev
	ldr	w0, [x19, #12]
	bl	_vmem_destroy
	mov	x0, x19
	bl	_sgx_put_epc_area
	add	x0, x19, #8
	bl	_mtx_destroy
	mov	x0, x20
	bl	_mtx_destroy
LBB0_3:
	mov	w0, #0
	b	LBB0_5
LBB0_4:
	mov	x0, x20
	bl	_mtx_unlock
Lloh4:
	adrp	x8, _EBUSY@GOTPAGE
Lloh5:
	ldr	x8, [x8, _EBUSY@GOTPAGEOFF]
Lloh6:
	ldr	w0, [x8]
LBB0_5:
	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 AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh4, Lloh5, Lloh6
	.cfi_endproc
                                        ; -- End function
	.comm	_sgx_sc,24,2                    ; @sgx_sc
	.comm	_SGX_STATE_RUNNING,4,2          ; @SGX_STATE_RUNNING
	.comm	_EBUSY,4,2                      ; @EBUSY
	.no_dead_strip	_sgx_unload
.subsections_via_symbols
