	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function tun_destroy
_tun_destroy:                           ## @tun_destroy
	.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	%rbx
	pushq	%rax
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdi, %r15
	callq	_TUN_LOCK
	movq	_TUN_DYING@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	orl	%eax, (%r15)
	cmpq	$0, 8(%r15)
	je	LBB0_2
## %bb.1:
	leaq	16(%r15), %rdi
	leaq	20(%r15), %rsi
	callq	_cv_wait_unlock
	jmp	LBB0_3
LBB0_2:
	movq	%r15, %rdi
	callq	_TUN_UNLOCK
LBB0_3:
	movq	%r15, %rdi
	callq	_TUN2IFP
	movl	16(%rax), %edi
	callq	_CURVNET_SET
	movl	36(%r15), %edi
	callq	_destroy_dev
	leaq	32(%r15), %r14
	movq	%r14, %rdi
	callq	_seldrain
	movq	%r14, %rdi
	xorl	%esi, %esi
	callq	_knlist_clear
	movq	%r14, %rdi
	callq	_knlist_destroy
	movq	_TUN_L2@GOTPCREL(%rip), %rax
	movl	(%rax), %ebx
	andl	(%r15), %ebx
	movq	%r15, %rdi
	callq	_TUN2IFP
	movq	%rax, %rdi
	testl	%ebx, %ebx
	je	LBB0_5
## %bb.4:
	callq	_ether_ifdetach
	jmp	LBB0_6
LBB0_5:
	callq	_bpfdetach
	movq	%r15, %rdi
	callq	_TUN2IFP
	movq	%rax, %rdi
	callq	_if_detach
LBB0_6:
	movq	_tun_ioctl_sx@GOTPCREL(%rip), %r14
	movq	%r14, %rdi
	callq	_sx_xlock
	movq	%r15, %rdi
	callq	_TUN2IFP
	movq	$0, 8(%rax)
	movq	%r14, %rdi
	callq	_sx_xunlock
	movq	24(%r15), %rax
	movl	(%rax), %r14d
	movq	%r15, %rdi
	callq	_TUN2IFP
	movl	(%rax), %esi
	movl	%r14d, %edi
	callq	_free_unr
	movq	%r15, %rdi
	callq	_TUN2IFP
	movq	%rax, %rdi
	callq	_if_free
	leaq	20(%r15), %rdi
	callq	_mtx_destroy
	leaq	16(%r15), %rdi
	callq	_cv_destroy
	movq	_M_TUN@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r15, %rdi
	callq	_free
	xorl	%eax, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r14
	popq	%r15
	popq	%rbp
	jmp	_CURVNET_RESTORE                ## TAILCALL
	.cfi_endproc
                                        ## -- End function
	.comm	_TUN_DYING,4,2                  ## @TUN_DYING
	.comm	_TUN_L2,4,2                     ## @TUN_L2
	.comm	_tun_ioctl_sx,4,2               ## @tun_ioctl_sx
	.comm	_M_TUN,4,2                      ## @M_TUN
	.no_dead_strip	_tun_destroy
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function tun_destroy
_tun_destroy:                           ; @tun_destroy
	.cfi_startproc
; %bb.0:
	stp	x20, x19, [sp, #-32]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 32
	stp	x29, x30, [sp, #16]             ; 16-byte Folded Spill
	add	x29, sp, #16
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
	.cfi_offset w19, -24
	.cfi_offset w20, -32
	mov	x19, x0
	bl	_TUN_LOCK
Lloh0:
	adrp	x8, _TUN_DYING@GOTPAGE
Lloh1:
	ldr	x8, [x8, _TUN_DYING@GOTPAGEOFF]
Lloh2:
	ldr	w8, [x8]
	ldr	w9, [x19]
	orr	w8, w9, w8
	str	w8, [x19]
	ldr	x8, [x19, #8]
	cbz	x8, LBB0_2
; %bb.1:
	add	x0, x19, #16
	add	x1, x19, #20
	bl	_cv_wait_unlock
	b	LBB0_3
LBB0_2:
	mov	x0, x19
	bl	_TUN_UNLOCK
LBB0_3:
	mov	x0, x19
	bl	_TUN2IFP
	ldr	w0, [x0, #16]
	bl	_CURVNET_SET
	ldr	w0, [x19, #36]
	bl	_destroy_dev
	add	x20, x19, #32
	mov	x0, x20
	bl	_seldrain
	mov	x0, x20
	mov	w1, #0
	bl	_knlist_clear
	mov	x0, x20
	bl	_knlist_destroy
	ldr	w8, [x19]
Lloh3:
	adrp	x9, _TUN_L2@GOTPAGE
Lloh4:
	ldr	x9, [x9, _TUN_L2@GOTPAGEOFF]
Lloh5:
	ldr	w9, [x9]
	and	w20, w9, w8
	mov	x0, x19
	bl	_TUN2IFP
	cbz	w20, LBB0_5
; %bb.4:
	bl	_ether_ifdetach
	b	LBB0_6
LBB0_5:
	bl	_bpfdetach
	mov	x0, x19
	bl	_TUN2IFP
	bl	_if_detach
LBB0_6:
Lloh6:
	adrp	x20, _tun_ioctl_sx@GOTPAGE
Lloh7:
	ldr	x20, [x20, _tun_ioctl_sx@GOTPAGEOFF]
	mov	x0, x20
	bl	_sx_xlock
	mov	x0, x19
	bl	_TUN2IFP
	str	xzr, [x0, #8]
	mov	x0, x20
	bl	_sx_xunlock
	ldr	x8, [x19, #24]
	ldr	w20, [x8]
	mov	x0, x19
	bl	_TUN2IFP
	ldr	w1, [x0]
	mov	x0, x20
	bl	_free_unr
	mov	x0, x19
	bl	_TUN2IFP
	bl	_if_free
	add	x0, x19, #20
	bl	_mtx_destroy
	add	x0, x19, #16
	bl	_cv_destroy
Lloh8:
	adrp	x8, _M_TUN@GOTPAGE
Lloh9:
	ldr	x8, [x8, _M_TUN@GOTPAGEOFF]
Lloh10:
	ldr	w1, [x8]
	mov	x0, x19
	bl	_free
	ldp	x29, x30, [sp, #16]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp], #32             ; 16-byte Folded Reload
	b	_CURVNET_RESTORE
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpLdrGot	Lloh6, Lloh7
	.cfi_endproc
                                        ; -- End function
	.comm	_TUN_DYING,4,2                  ; @TUN_DYING
	.comm	_TUN_L2,4,2                     ; @TUN_L2
	.comm	_tun_ioctl_sx,4,2               ; @tun_ioctl_sx
	.comm	_M_TUN,4,2                      ; @M_TUN
	.no_dead_strip	_tun_destroy
.subsections_via_symbols
