	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_ng_btsocket_l2cap_raw_attach   ## -- Begin function ng_btsocket_l2cap_raw_attach
	.p2align	4, 0x90
_ng_btsocket_l2cap_raw_attach:          ## @ng_btsocket_l2cap_raw_attach
	.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	%rdx, %r14
	movq	%rdi, %r15
	callq	_so2l2cap_raw_pcb
	testq	%rax, %rax
	je	LBB0_4
## %bb.1:
	movq	_EISCONN@GOTPCREL(%rip), %rax
LBB0_2:
	movl	(%rax), %ebx
LBB0_3:
	movl	%ebx, %eax
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_4:
	movq	_ng_btsocket_l2cap_raw_node@GOTPCREL(%rip), %rax
	cmpq	$0, (%rax)
	je	LBB0_11
## %bb.5:
	movq	(%r15), %rax
	movq	_SOCK_RAW@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_12
## %bb.6:
	movq	_NG_BTSOCKET_L2CAP_RAW_SENDSPACE@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	_NG_BTSOCKET_L2CAP_RAW_RECVSPACE@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	%r15, %rdi
	callq	_soreserve
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	LBB0_3
## %bb.7:
	movq	_M_NETGRAPH_BTSOCKET_L2CAP_RAW@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	_M_NOWAIT@GOTPCREL(%rip), %rax
	movq	_M_ZERO@GOTPCREL(%rip), %rcx
	movl	(%rcx), %edx
	orl	(%rax), %edx
	movl	$16, %edi
	callq	_malloc
	testq	%rax, %rax
	je	LBB0_13
## %bb.8:
	movq	%rax, %r12
	movq	%rax, 8(%r15)
	movq	%r15, 8(%rax)
	movq	_PRIV_NETBLUETOOTH_RAW@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r14, %rdi
	callq	_priv_check
	testq	%rax, %rax
	jne	LBB0_10
## %bb.9:
	movq	_NG_BTSOCKET_L2CAP_RAW_PRIVILEGED@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	orl	%eax, 4(%r12)
LBB0_10:
	movq	_MTX_DEF@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	leaq	L_.str(%rip), %rsi
	xorl	%ebx, %ebx
	movq	%r12, %rdi
	xorl	%edx, %edx
	callq	_mtx_init
	movq	_ng_btsocket_l2cap_raw_sockets_mtx@GOTPCREL(%rip), %r14
	movq	%r14, %rdi
	callq	_mtx_lock
	movq	_next@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	_ng_btsocket_l2cap_raw_sockets@GOTPCREL(%rip), %rdi
	movq	%r12, %rsi
	callq	_LIST_INSERT_HEAD
	movq	%r14, %rdi
	callq	_mtx_unlock
	jmp	LBB0_3
LBB0_11:
	movq	_EPROTONOSUPPORT@GOTPCREL(%rip), %rax
	jmp	LBB0_2
LBB0_12:
	movq	_ESOCKTNOSUPPORT@GOTPCREL(%rip), %rax
	jmp	LBB0_2
LBB0_13:
	movq	_ENOMEM@GOTPCREL(%rip), %rax
	jmp	LBB0_2
	.cfi_endproc
                                        ## -- End function
	.comm	_EISCONN,4,2                    ## @EISCONN
	.comm	_ng_btsocket_l2cap_raw_node,8,3 ## @ng_btsocket_l2cap_raw_node
	.comm	_EPROTONOSUPPORT,4,2            ## @EPROTONOSUPPORT
	.comm	_SOCK_RAW,8,3                   ## @SOCK_RAW
	.comm	_ESOCKTNOSUPPORT,4,2            ## @ESOCKTNOSUPPORT
	.comm	_NG_BTSOCKET_L2CAP_RAW_SENDSPACE,4,2 ## @NG_BTSOCKET_L2CAP_RAW_SENDSPACE
	.comm	_NG_BTSOCKET_L2CAP_RAW_RECVSPACE,4,2 ## @NG_BTSOCKET_L2CAP_RAW_RECVSPACE
	.comm	_M_NETGRAPH_BTSOCKET_L2CAP_RAW,4,2 ## @M_NETGRAPH_BTSOCKET_L2CAP_RAW
	.comm	_M_NOWAIT,4,2                   ## @M_NOWAIT
	.comm	_M_ZERO,4,2                     ## @M_ZERO
	.comm	_ENOMEM,4,2                     ## @ENOMEM
	.comm	_PRIV_NETBLUETOOTH_RAW,4,2      ## @PRIV_NETBLUETOOTH_RAW
	.comm	_NG_BTSOCKET_L2CAP_RAW_PRIVILEGED,4,2 ## @NG_BTSOCKET_L2CAP_RAW_PRIVILEGED
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"btsocks_l2cap_raw_pcb_mtx"

	.comm	_MTX_DEF,4,2                    ## @MTX_DEF
	.comm	_ng_btsocket_l2cap_raw_sockets_mtx,4,2 ## @ng_btsocket_l2cap_raw_sockets_mtx
	.comm	_ng_btsocket_l2cap_raw_sockets,4,2 ## @ng_btsocket_l2cap_raw_sockets
	.comm	_next,4,2                       ## @next
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_ng_btsocket_l2cap_raw_attach   ; -- Begin function ng_btsocket_l2cap_raw_attach
	.p2align	2
_ng_btsocket_l2cap_raw_attach:          ; @ng_btsocket_l2cap_raw_attach
	.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, x2
	mov	x20, x0
	bl	_so2l2cap_raw_pcb
	cbz	x0, LBB0_4
; %bb.1:
Lloh0:
	adrp	x8, _EISCONN@GOTPAGE
Lloh1:
	ldr	x8, [x8, _EISCONN@GOTPAGEOFF]
LBB0_2:
	ldr	w0, [x8]
LBB0_3:
	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
LBB0_4:
Lloh2:
	adrp	x8, _ng_btsocket_l2cap_raw_node@GOTPAGE
Lloh3:
	ldr	x8, [x8, _ng_btsocket_l2cap_raw_node@GOTPAGEOFF]
Lloh4:
	ldr	x8, [x8]
	cbz	x8, LBB0_11
; %bb.5:
	ldr	x8, [x20]
Lloh5:
	adrp	x9, _SOCK_RAW@GOTPAGE
Lloh6:
	ldr	x9, [x9, _SOCK_RAW@GOTPAGEOFF]
Lloh7:
	ldr	x9, [x9]
	cmp	x8, x9
	b.ne	LBB0_12
; %bb.6:
Lloh8:
	adrp	x8, _NG_BTSOCKET_L2CAP_RAW_SENDSPACE@GOTPAGE
Lloh9:
	ldr	x8, [x8, _NG_BTSOCKET_L2CAP_RAW_SENDSPACE@GOTPAGEOFF]
Lloh10:
	ldr	w1, [x8]
Lloh11:
	adrp	x8, _NG_BTSOCKET_L2CAP_RAW_RECVSPACE@GOTPAGE
Lloh12:
	ldr	x8, [x8, _NG_BTSOCKET_L2CAP_RAW_RECVSPACE@GOTPAGEOFF]
Lloh13:
	ldr	w2, [x8]
	mov	x0, x20
	bl	_soreserve
	cbnz	w0, LBB0_3
; %bb.7:
Lloh14:
	adrp	x8, _M_NETGRAPH_BTSOCKET_L2CAP_RAW@GOTPAGE
Lloh15:
	ldr	x8, [x8, _M_NETGRAPH_BTSOCKET_L2CAP_RAW@GOTPAGEOFF]
Lloh16:
	adrp	x9, _M_NOWAIT@GOTPAGE
Lloh17:
	ldr	x9, [x9, _M_NOWAIT@GOTPAGEOFF]
Lloh18:
	ldr	w1, [x8]
Lloh19:
	ldr	w8, [x9]
Lloh20:
	adrp	x9, _M_ZERO@GOTPAGE
Lloh21:
	ldr	x9, [x9, _M_ZERO@GOTPAGEOFF]
Lloh22:
	ldr	w9, [x9]
	orr	w2, w9, w8
	mov	w0, #16
	bl	_malloc
	cbz	x0, LBB0_13
; %bb.8:
	mov	x21, x0
	str	x0, [x20, #8]
	str	x20, [x0, #8]
Lloh23:
	adrp	x8, _PRIV_NETBLUETOOTH_RAW@GOTPAGE
Lloh24:
	ldr	x8, [x8, _PRIV_NETBLUETOOTH_RAW@GOTPAGEOFF]
Lloh25:
	ldr	w1, [x8]
	mov	x0, x19
	bl	_priv_check
	cbnz	x0, LBB0_10
; %bb.9:
Lloh26:
	adrp	x8, _NG_BTSOCKET_L2CAP_RAW_PRIVILEGED@GOTPAGE
Lloh27:
	ldr	x8, [x8, _NG_BTSOCKET_L2CAP_RAW_PRIVILEGED@GOTPAGEOFF]
Lloh28:
	ldr	w8, [x8]
	ldr	w9, [x21, #4]
	orr	w8, w9, w8
	str	w8, [x21, #4]
LBB0_10:
Lloh29:
	adrp	x8, _MTX_DEF@GOTPAGE
Lloh30:
	ldr	x8, [x8, _MTX_DEF@GOTPAGEOFF]
Lloh31:
	ldr	w3, [x8]
Lloh32:
	adrp	x1, l_.str@PAGE
Lloh33:
	add	x1, x1, l_.str@PAGEOFF
	mov	x0, x21
	mov	x2, #0
	bl	_mtx_init
Lloh34:
	adrp	x19, _ng_btsocket_l2cap_raw_sockets_mtx@GOTPAGE
Lloh35:
	ldr	x19, [x19, _ng_btsocket_l2cap_raw_sockets_mtx@GOTPAGEOFF]
	mov	x0, x19
	bl	_mtx_lock
Lloh36:
	adrp	x8, _next@GOTPAGE
Lloh37:
	ldr	x8, [x8, _next@GOTPAGEOFF]
Lloh38:
	ldr	w2, [x8]
Lloh39:
	adrp	x0, _ng_btsocket_l2cap_raw_sockets@GOTPAGE
Lloh40:
	ldr	x0, [x0, _ng_btsocket_l2cap_raw_sockets@GOTPAGEOFF]
	mov	x1, x21
	bl	_LIST_INSERT_HEAD
	mov	x0, x19
	bl	_mtx_unlock
	mov	w0, #0
	b	LBB0_3
LBB0_11:
Lloh41:
	adrp	x8, _EPROTONOSUPPORT@GOTPAGE
Lloh42:
	ldr	x8, [x8, _EPROTONOSUPPORT@GOTPAGEOFF]
	b	LBB0_2
LBB0_12:
Lloh43:
	adrp	x8, _ESOCKTNOSUPPORT@GOTPAGE
Lloh44:
	ldr	x8, [x8, _ESOCKTNOSUPPORT@GOTPAGEOFF]
	b	LBB0_2
LBB0_13:
Lloh45:
	adrp	x8, _ENOMEM@GOTPAGE
Lloh46:
	ldr	x8, [x8, _ENOMEM@GOTPAGEOFF]
	b	LBB0_2
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpLdrGotLdr	Lloh20, Lloh21, Lloh22
	.loh AdrpLdrGotLdr	Lloh16, Lloh17, Lloh19
	.loh AdrpLdrGotLdr	Lloh14, Lloh15, Lloh18
	.loh AdrpLdrGotLdr	Lloh23, Lloh24, Lloh25
	.loh AdrpLdrGotLdr	Lloh26, Lloh27, Lloh28
	.loh AdrpLdrGot	Lloh39, Lloh40
	.loh AdrpLdrGotLdr	Lloh36, Lloh37, Lloh38
	.loh AdrpLdrGot	Lloh34, Lloh35
	.loh AdrpAdd	Lloh32, Lloh33
	.loh AdrpLdrGotLdr	Lloh29, Lloh30, Lloh31
	.loh AdrpLdrGot	Lloh41, Lloh42
	.loh AdrpLdrGot	Lloh43, Lloh44
	.loh AdrpLdrGot	Lloh45, Lloh46
	.cfi_endproc
                                        ; -- End function
	.comm	_EISCONN,4,2                    ; @EISCONN
	.comm	_ng_btsocket_l2cap_raw_node,8,3 ; @ng_btsocket_l2cap_raw_node
	.comm	_EPROTONOSUPPORT,4,2            ; @EPROTONOSUPPORT
	.comm	_SOCK_RAW,8,3                   ; @SOCK_RAW
	.comm	_ESOCKTNOSUPPORT,4,2            ; @ESOCKTNOSUPPORT
	.comm	_NG_BTSOCKET_L2CAP_RAW_SENDSPACE,4,2 ; @NG_BTSOCKET_L2CAP_RAW_SENDSPACE
	.comm	_NG_BTSOCKET_L2CAP_RAW_RECVSPACE,4,2 ; @NG_BTSOCKET_L2CAP_RAW_RECVSPACE
	.comm	_M_NETGRAPH_BTSOCKET_L2CAP_RAW,4,2 ; @M_NETGRAPH_BTSOCKET_L2CAP_RAW
	.comm	_M_NOWAIT,4,2                   ; @M_NOWAIT
	.comm	_M_ZERO,4,2                     ; @M_ZERO
	.comm	_ENOMEM,4,2                     ; @ENOMEM
	.comm	_PRIV_NETBLUETOOTH_RAW,4,2      ; @PRIV_NETBLUETOOTH_RAW
	.comm	_NG_BTSOCKET_L2CAP_RAW_PRIVILEGED,4,2 ; @NG_BTSOCKET_L2CAP_RAW_PRIVILEGED
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"btsocks_l2cap_raw_pcb_mtx"

	.comm	_MTX_DEF,4,2                    ; @MTX_DEF
	.comm	_ng_btsocket_l2cap_raw_sockets_mtx,4,2 ; @ng_btsocket_l2cap_raw_sockets_mtx
	.comm	_ng_btsocket_l2cap_raw_sockets,4,2 ; @ng_btsocket_l2cap_raw_sockets
	.comm	_next,4,2                       ; @next
.subsections_via_symbols
