	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_ng_btsocket_l2cap_detach       ## -- Begin function ng_btsocket_l2cap_detach
	.p2align	4, 0x90
_ng_btsocket_l2cap_detach:              ## @ng_btsocket_l2cap_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, %r14
	callq	_so2l2cap_pcb
	movq	%rax, %rbx
	xorl	%edi, %edi
	testq	%rax, %rax
	setne	%dil
	leaq	L_.str(%rip), %rsi
	callq	_KASSERT
	movq	_ng_btsocket_l2cap_node@GOTPCREL(%rip), %rax
	cmpq	$0, (%rax)
	je	LBB0_7
## %bb.1:
	movq	_ng_btsocket_l2cap_sockets_mtx@GOTPCREL(%rip), %rdi
	callq	_mtx_lock
	movq	%rbx, %r15
	addq	$16, %r15
	movq	%r15, %rdi
	callq	_mtx_lock
	movq	_NG_BTSOCKET_L2CAP_TIMO@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	testl	%eax, (%rbx)
	je	LBB0_3
## %bb.2:
	movq	%rbx, %rdi
	callq	_ng_btsocket_l2cap_untimeout
LBB0_3:
	movq	8(%rbx), %rcx
	movq	_NG_BTSOCKET_L2CAP_CLOSED@GOTPCREL(%rip), %r12
	movq	(%r12), %rax
	cmpq	%rax, %rcx
	je	LBB0_6
## %bb.4:
	movq	_NG_BTSOCKET_L2CAP_DISCONNECTING@GOTPCREL(%rip), %rdx
	cmpq	(%rdx), %rcx
	je	LBB0_6
## %bb.5:
	xorl	%edi, %edi
	movq	%rbx, %rsi
	callq	_ng_btsocket_l2cap_send_l2ca_discon_req
	movq	(%r12), %rax
LBB0_6:
	movq	%rax, 8(%rbx)
	movq	_next@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%rbx, %rdi
	callq	_LIST_REMOVE
	movq	%r15, %rdi
	callq	_mtx_unlock
	movq	_ng_btsocket_l2cap_sockets_mtx@GOTPCREL(%rip), %rdi
	callq	_mtx_unlock
	movq	%r15, %rdi
	callq	_mtx_destroy
	movq	%rbx, %rdi
	movl	$24, %esi
	callq	_bzero
	movq	_M_NETGRAPH_BTSOCKET_L2CAP@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%rbx, %rdi
	callq	_free
	movq	%r14, %rdi
	callq	_soisdisconnected
	movq	$0, (%r14)
LBB0_7:
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"ng_btsocket_l2cap_detach: pcb == NULL"

	.comm	_ng_btsocket_l2cap_node,8,3     ## @ng_btsocket_l2cap_node
	.comm	_ng_btsocket_l2cap_sockets_mtx,4,2 ## @ng_btsocket_l2cap_sockets_mtx
	.comm	_NG_BTSOCKET_L2CAP_TIMO,4,2     ## @NG_BTSOCKET_L2CAP_TIMO
	.comm	_NG_BTSOCKET_L2CAP_CLOSED,8,3   ## @NG_BTSOCKET_L2CAP_CLOSED
	.comm	_NG_BTSOCKET_L2CAP_DISCONNECTING,8,3 ## @NG_BTSOCKET_L2CAP_DISCONNECTING
	.comm	_next,4,2                       ## @next
	.comm	_M_NETGRAPH_BTSOCKET_L2CAP,4,2  ## @M_NETGRAPH_BTSOCKET_L2CAP
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_ng_btsocket_l2cap_detach       ; -- Begin function ng_btsocket_l2cap_detach
	.p2align	2
_ng_btsocket_l2cap_detach:              ; @ng_btsocket_l2cap_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
	bl	_so2l2cap_pcb
	mov	x20, x0
	cmp	x0, #0
	cset	w0, ne
Lloh0:
	adrp	x1, l_.str@PAGE
Lloh1:
	add	x1, x1, l_.str@PAGEOFF
	bl	_KASSERT
Lloh2:
	adrp	x8, _ng_btsocket_l2cap_node@GOTPAGE
Lloh3:
	ldr	x8, [x8, _ng_btsocket_l2cap_node@GOTPAGEOFF]
Lloh4:
	ldr	x8, [x8]
	cbz	x8, LBB0_6
; %bb.1:
Lloh5:
	adrp	x0, _ng_btsocket_l2cap_sockets_mtx@GOTPAGE
Lloh6:
	ldr	x0, [x0, _ng_btsocket_l2cap_sockets_mtx@GOTPAGEOFF]
	bl	_mtx_lock
	add	x21, x20, #16
	mov	x0, x21
	bl	_mtx_lock
	ldr	w8, [x20]
Lloh7:
	adrp	x9, _NG_BTSOCKET_L2CAP_TIMO@GOTPAGE
Lloh8:
	ldr	x9, [x9, _NG_BTSOCKET_L2CAP_TIMO@GOTPAGEOFF]
Lloh9:
	ldr	w9, [x9]
	tst	w9, w8
	b.eq	LBB0_3
; %bb.2:
	mov	x0, x20
	bl	_ng_btsocket_l2cap_untimeout
LBB0_3:
	ldr	x9, [x20, #8]
Lloh10:
	adrp	x22, _NG_BTSOCKET_L2CAP_CLOSED@GOTPAGE
Lloh11:
	ldr	x22, [x22, _NG_BTSOCKET_L2CAP_CLOSED@GOTPAGEOFF]
	ldr	x8, [x22]
Lloh12:
	adrp	x10, _NG_BTSOCKET_L2CAP_DISCONNECTING@GOTPAGE
Lloh13:
	ldr	x10, [x10, _NG_BTSOCKET_L2CAP_DISCONNECTING@GOTPAGEOFF]
Lloh14:
	ldr	x10, [x10]
	cmp	x9, x8
	ccmp	x9, x10, #4, ne
	b.eq	LBB0_5
; %bb.4:
	mov	w0, #0
	mov	x1, x20
	bl	_ng_btsocket_l2cap_send_l2ca_discon_req
	ldr	x8, [x22]
LBB0_5:
	str	x8, [x20, #8]
Lloh15:
	adrp	x8, _next@GOTPAGE
Lloh16:
	ldr	x8, [x8, _next@GOTPAGEOFF]
Lloh17:
	ldr	w1, [x8]
	mov	x0, x20
	bl	_LIST_REMOVE
	mov	x0, x21
	bl	_mtx_unlock
Lloh18:
	adrp	x0, _ng_btsocket_l2cap_sockets_mtx@GOTPAGE
Lloh19:
	ldr	x0, [x0, _ng_btsocket_l2cap_sockets_mtx@GOTPAGEOFF]
	bl	_mtx_unlock
	mov	x0, x21
	bl	_mtx_destroy
	mov	x0, x20
	mov	w1, #24
	bl	_bzero
Lloh20:
	adrp	x8, _M_NETGRAPH_BTSOCKET_L2CAP@GOTPAGE
Lloh21:
	ldr	x8, [x8, _M_NETGRAPH_BTSOCKET_L2CAP@GOTPAGEOFF]
Lloh22:
	ldr	w1, [x8]
	mov	x0, x20
	bl	_free
	mov	x0, x19
	bl	_soisdisconnected
	str	xzr, [x19]
LBB0_6:
	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	Lloh2, Lloh3, Lloh4
	.loh AdrpAdd	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh7, Lloh8, Lloh9
	.loh AdrpLdrGot	Lloh5, Lloh6
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGot	Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh20, Lloh21, Lloh22
	.loh AdrpLdrGot	Lloh18, Lloh19
	.loh AdrpLdrGotLdr	Lloh15, Lloh16, Lloh17
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"ng_btsocket_l2cap_detach: pcb == NULL"

	.comm	_ng_btsocket_l2cap_node,8,3     ; @ng_btsocket_l2cap_node
	.comm	_ng_btsocket_l2cap_sockets_mtx,4,2 ; @ng_btsocket_l2cap_sockets_mtx
	.comm	_NG_BTSOCKET_L2CAP_TIMO,4,2     ; @NG_BTSOCKET_L2CAP_TIMO
	.comm	_NG_BTSOCKET_L2CAP_CLOSED,8,3   ; @NG_BTSOCKET_L2CAP_CLOSED
	.comm	_NG_BTSOCKET_L2CAP_DISCONNECTING,8,3 ; @NG_BTSOCKET_L2CAP_DISCONNECTING
	.comm	_next,4,2                       ; @next
	.comm	_M_NETGRAPH_BTSOCKET_L2CAP,4,2  ; @M_NETGRAPH_BTSOCKET_L2CAP
.subsections_via_symbols
