	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_ng_btsocket_sco_detach         ## -- Begin function ng_btsocket_sco_detach
	.p2align	4, 0x90
_ng_btsocket_sco_detach:                ## @ng_btsocket_sco_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	%rbx
	pushq	%rax
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdi, %r14
	callq	_so2sco_pcb
	movq	%rax, %rbx
	xorl	%edi, %edi
	testq	%rax, %rax
	setne	%dil
	leaq	L_.str(%rip), %rsi
	callq	_KASSERT
	movq	_ng_btsocket_sco_node@GOTPCREL(%rip), %rax
	cmpq	$0, (%rax)
	je	LBB0_6
## %bb.1:
	movq	_ng_btsocket_sco_sockets_mtx@GOTPCREL(%rip), %rdi
	callq	_mtx_lock
	movq	%rbx, %r15
	addq	$16, %r15
	movq	%r15, %rdi
	callq	_mtx_lock
	movq	_NG_BTSOCKET_SCO_TIMO@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	testl	%eax, (%rbx)
	je	LBB0_3
## %bb.2:
	movq	%rbx, %rdi
	callq	_ng_btsocket_sco_untimeout
LBB0_3:
	movq	8(%rbx), %rax
	movq	_NG_BTSOCKET_SCO_OPEN@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_5
## %bb.4:
	movq	%rbx, %rdi
	callq	_ng_btsocket_sco_send_lp_discon_req
LBB0_5:
	movq	_NG_BTSOCKET_SCO_CLOSED@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	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_sco_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_SCO@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%rbx, %rdi
	callq	_free
	movq	%r14, %rdi
	callq	_soisdisconnected
	movq	$0, (%r14)
LBB0_6:
	addq	$8, %rsp
	popq	%rbx
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"ng_btsocket_sco_detach: pcb == NULL"

	.comm	_ng_btsocket_sco_node,8,3       ## @ng_btsocket_sco_node
	.comm	_ng_btsocket_sco_sockets_mtx,4,2 ## @ng_btsocket_sco_sockets_mtx
	.comm	_NG_BTSOCKET_SCO_TIMO,4,2       ## @NG_BTSOCKET_SCO_TIMO
	.comm	_NG_BTSOCKET_SCO_OPEN,8,3       ## @NG_BTSOCKET_SCO_OPEN
	.comm	_NG_BTSOCKET_SCO_CLOSED,8,3     ## @NG_BTSOCKET_SCO_CLOSED
	.comm	_next,4,2                       ## @next
	.comm	_M_NETGRAPH_BTSOCKET_SCO,4,2    ## @M_NETGRAPH_BTSOCKET_SCO
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_ng_btsocket_sco_detach         ; -- Begin function ng_btsocket_sco_detach
	.p2align	2
_ng_btsocket_sco_detach:                ; @ng_btsocket_sco_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	_so2sco_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_sco_node@GOTPAGE
Lloh3:
	ldr	x8, [x8, _ng_btsocket_sco_node@GOTPAGEOFF]
Lloh4:
	ldr	x8, [x8]
	cbz	x8, LBB0_6
; %bb.1:
Lloh5:
	adrp	x0, _ng_btsocket_sco_sockets_mtx@GOTPAGE
Lloh6:
	ldr	x0, [x0, _ng_btsocket_sco_sockets_mtx@GOTPAGEOFF]
	bl	_mtx_lock
	add	x21, x20, #16
	mov	x0, x21
	bl	_mtx_lock
	ldr	w8, [x20]
Lloh7:
	adrp	x9, _NG_BTSOCKET_SCO_TIMO@GOTPAGE
Lloh8:
	ldr	x9, [x9, _NG_BTSOCKET_SCO_TIMO@GOTPAGEOFF]
Lloh9:
	ldr	w9, [x9]
	tst	w9, w8
	b.eq	LBB0_3
; %bb.2:
	mov	x0, x20
	bl	_ng_btsocket_sco_untimeout
LBB0_3:
	ldr	x8, [x20, #8]
Lloh10:
	adrp	x9, _NG_BTSOCKET_SCO_OPEN@GOTPAGE
Lloh11:
	ldr	x9, [x9, _NG_BTSOCKET_SCO_OPEN@GOTPAGEOFF]
Lloh12:
	ldr	x9, [x9]
	cmp	x8, x9
	b.ne	LBB0_5
; %bb.4:
	mov	x0, x20
	bl	_ng_btsocket_sco_send_lp_discon_req
LBB0_5:
Lloh13:
	adrp	x8, _NG_BTSOCKET_SCO_CLOSED@GOTPAGE
Lloh14:
	ldr	x8, [x8, _NG_BTSOCKET_SCO_CLOSED@GOTPAGEOFF]
Lloh15:
	ldr	x8, [x8]
	str	x8, [x20, #8]
Lloh16:
	adrp	x8, _next@GOTPAGE
Lloh17:
	ldr	x8, [x8, _next@GOTPAGEOFF]
Lloh18:
	ldr	w1, [x8]
	mov	x0, x20
	bl	_LIST_REMOVE
	mov	x0, x21
	bl	_mtx_unlock
Lloh19:
	adrp	x0, _ng_btsocket_sco_sockets_mtx@GOTPAGE
Lloh20:
	ldr	x0, [x0, _ng_btsocket_sco_sockets_mtx@GOTPAGEOFF]
	bl	_mtx_unlock
	mov	x0, x21
	bl	_mtx_destroy
	mov	x0, x20
	mov	w1, #24
	bl	_bzero
Lloh21:
	adrp	x8, _M_NETGRAPH_BTSOCKET_SCO@GOTPAGE
Lloh22:
	ldr	x8, [x8, _M_NETGRAPH_BTSOCKET_SCO@GOTPAGEOFF]
Lloh23:
	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	Lloh10, Lloh11, Lloh12
	.loh AdrpLdrGotLdr	Lloh21, Lloh22, Lloh23
	.loh AdrpLdrGot	Lloh19, Lloh20
	.loh AdrpLdrGotLdr	Lloh16, Lloh17, Lloh18
	.loh AdrpLdrGotLdr	Lloh13, Lloh14, Lloh15
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"ng_btsocket_sco_detach: pcb == NULL"

	.comm	_ng_btsocket_sco_node,8,3       ; @ng_btsocket_sco_node
	.comm	_ng_btsocket_sco_sockets_mtx,4,2 ; @ng_btsocket_sco_sockets_mtx
	.comm	_NG_BTSOCKET_SCO_TIMO,4,2       ; @NG_BTSOCKET_SCO_TIMO
	.comm	_NG_BTSOCKET_SCO_OPEN,8,3       ; @NG_BTSOCKET_SCO_OPEN
	.comm	_NG_BTSOCKET_SCO_CLOSED,8,3     ; @NG_BTSOCKET_SCO_CLOSED
	.comm	_next,4,2                       ; @next
	.comm	_M_NETGRAPH_BTSOCKET_SCO,4,2    ; @M_NETGRAPH_BTSOCKET_SCO
.subsections_via_symbols
