	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_ng_btsocket_rfcomm_connect     ## -- Begin function ng_btsocket_rfcomm_connect
	.p2align	4, 0x90
_ng_btsocket_rfcomm_connect:            ## @ng_btsocket_rfcomm_connect
	.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	%r13
	pushq	%r12
	pushq	%rbx
	subq	$24, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdx, %r12
	movq	%rsi, %rbx
	callq	_so2rfcomm_pcb
	movq	$0, -56(%rbp)
	testq	%rax, %rax
	je	LBB0_5
## %bb.1:
	testq	%rbx, %rbx
	je	LBB0_5
## %bb.2:
	movq	%rax, %r14
	movq	(%rbx), %rax
	movq	_AF_BLUETOOTH@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_6
## %bb.3:
	cmpl	$24, 8(%rbx)
	jne	LBB0_5
## %bb.4:
	movl	12(%rbx), %eax
	cmpl	$31, %eax
	jl	LBB0_9
LBB0_5:
	movq	_EINVAL@GOTPCREL(%rip), %rax
	jmp	LBB0_7
LBB0_6:
	movq	_EAFNOSUPPORT@GOTPCREL(%rip), %rax
LBB0_7:
	movl	(%rax), %r15d
LBB0_8:
	movl	%r15d, %eax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_9:
	testl	%eax, %eax
	je	LBB0_16
## %bb.10:
	leaq	16(%rbx), %r13
	movq	_NG_HCI_BDADDR_ANY@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r13, %rdi
	movl	$4, %edx
	callq	_bcmp
	testq	%rax, %rax
	je	LBB0_16
## %bb.11:
	movq	_PF_BLUETOOTH@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movq	_SOCK_SEQPACKET@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	_BLUETOOTH_PROTO_L2CAP@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	movl	(%r12), %r8d
	leaq	-56(%rbp), %rsi
	movq	%r12, %r9
	callq	_socreate
	movl	%eax, %r15d
	movq	_ng_btsocket_rfcomm_sessions_mtx@GOTPCREL(%rip), %rdi
	callq	_mtx_lock
	leaq	16(%r14), %rdi
	movq	%rdi, -64(%rbp)                 ## 8-byte Spill
	movq	%r13, %rsi
	callq	_ng_btsocket_rfcomm_session_by_addr
	movq	%rax, -48(%rbp)
	movq	-56(%rbp), %rsi
	testq	%rax, %rax
	je	LBB0_17
## %bb.12:
	movq	%rax, %r13
	testq	%rsi, %rsi
	je	LBB0_14
## %bb.13:
	movq	%rsi, %rdi
	callq	_soclose
LBB0_14:
	addq	$4, %r13
	movq	%r13, %rdi
	callq	_mtx_lock
	leaq	8(%r14), %r12
	movq	%r12, %rdi
	callq	_mtx_lock
	movq	-48(%rbp), %rdi
	callq	_INITIATOR
	xorl	%edi, %edi
	testl	%eax, %eax
	sete	%dil
	movl	12(%rbx), %esi
	callq	_RFCOMM_MKDLCI
	movl	%eax, %r13d
	movq	-48(%rbp), %rdi
	movl	%eax, %esi
	callq	_ng_btsocket_rfcomm_pcb_by_dlci
	testq	%rax, %rax
	je	LBB0_20
## %bb.15:
	movq	%r12, %rdi
	callq	_mtx_unlock
	movq	-48(%rbp), %rdi
	addq	$4, %rdi
	callq	_mtx_unlock
	movq	_ng_btsocket_rfcomm_sessions_mtx@GOTPCREL(%rip), %rdi
	callq	_mtx_unlock
	movq	_EBUSY@GOTPCREL(%rip), %rax
	jmp	LBB0_7
LBB0_16:
	movq	_EDESTADDRREQ@GOTPCREL(%rip), %rax
	jmp	LBB0_7
LBB0_17:
	movq	-64(%rbp), %rdx                 ## 8-byte Reload
	testq	%rsi, %rsi
	je	LBB0_28
## %bb.18:
	movq	%r13, %rcx
	leaq	-48(%rbp), %rdi
	movq	%r12, %r8
	callq	_ng_btsocket_rfcomm_session_create
	testl	%eax, %eax
	je	LBB0_25
## %bb.19:
	movl	%eax, %r15d
	movq	_ng_btsocket_rfcomm_sessions_mtx@GOTPCREL(%rip), %rdi
	callq	_mtx_unlock
	movq	-56(%rbp), %rdi
	callq	_soclose
	jmp	LBB0_8
LBB0_20:
	movq	-48(%rbp), %rdi
	movl	(%rdi), %eax
	addl	$-128, %eax
	cmpl	$2, %eax
	ja	LBB0_24
## %bb.21:
	movl	16(%rbx), %eax
	movl	%eax, 40(%r14)
	movl	12(%rbx), %eax
	movl	%eax, (%r14)
	movl	%r13d, 4(%r14)
	addq	$16, %rdi
	movq	_session_next@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	%r14, %rsi
	callq	_LIST_INSERT_HEAD
	movq	-48(%rbp), %rax
	movq	%rax, 32(%r14)
	movq	%r14, %rdi
	callq	_ng_btsocket_rfcomm_timeout
	movl	24(%r14), %edi
	callq	_soisconnecting
	movq	-48(%rbp), %rax
	cmpl	$128, (%rax)
	jne	LBB0_26
## %bb.22:
	movl	12(%rax), %ecx
	movl	%ecx, 20(%r14)
	movl	8(%rax), %edi
	callq	_so2l2cap_pcb
	movl	(%rax), %eax
	movl	%eax, 16(%r14)
	movq	_NG_BTSOCKET_RFCOMM_DLC_CONFIGURING@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, 12(%r14)
	movq	%r14, %rdi
	callq	_ng_btsocket_rfcomm_send_pn
	movl	%eax, %r15d
	testl	%eax, %eax
	jne	LBB0_27
## %bb.23:
	xorl	%eax, %eax
	callq	_ng_btsocket_rfcomm_task_wakeup
	movl	%eax, %r15d
	jmp	LBB0_27
LBB0_24:
	movq	_ECONNRESET@GOTPCREL(%rip), %rax
	movl	(%rax), %r15d
	jmp	LBB0_27
LBB0_25:
	xorl	%r15d, %r15d
	movq	-48(%rbp), %r13
	jmp	LBB0_14
LBB0_26:
	movq	_NG_BTSOCKET_RFCOMM_DLC_W4_CONNECT@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, 12(%r14)
LBB0_27:
	movq	%r12, %rdi
	callq	_mtx_unlock
	movq	-48(%rbp), %rdi
	addq	$4, %rdi
	callq	_mtx_unlock
LBB0_28:
	movq	_ng_btsocket_rfcomm_sessions_mtx@GOTPCREL(%rip), %rdi
	callq	_mtx_unlock
	jmp	LBB0_8
	.cfi_endproc
                                        ## -- End function
	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_AF_BLUETOOTH,8,3               ## @AF_BLUETOOTH
	.comm	_EAFNOSUPPORT,4,2               ## @EAFNOSUPPORT
	.comm	_NG_HCI_BDADDR_ANY,4,2          ## @NG_HCI_BDADDR_ANY
	.comm	_EDESTADDRREQ,4,2               ## @EDESTADDRREQ
	.comm	_PF_BLUETOOTH,4,2               ## @PF_BLUETOOTH
	.comm	_SOCK_SEQPACKET,4,2             ## @SOCK_SEQPACKET
	.comm	_BLUETOOTH_PROTO_L2CAP,4,2      ## @BLUETOOTH_PROTO_L2CAP
	.comm	_ng_btsocket_rfcomm_sessions_mtx,4,2 ## @ng_btsocket_rfcomm_sessions_mtx
	.comm	_EBUSY,4,2                      ## @EBUSY
	.comm	_session_next,4,2               ## @session_next
	.comm	_NG_BTSOCKET_RFCOMM_DLC_CONFIGURING,4,2 ## @NG_BTSOCKET_RFCOMM_DLC_CONFIGURING
	.comm	_NG_BTSOCKET_RFCOMM_DLC_W4_CONNECT,4,2 ## @NG_BTSOCKET_RFCOMM_DLC_W4_CONNECT
	.comm	_ECONNRESET,4,2                 ## @ECONNRESET
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_ng_btsocket_rfcomm_connect     ; -- Begin function ng_btsocket_rfcomm_connect
	.p2align	2
_ng_btsocket_rfcomm_connect:            ; @ng_btsocket_rfcomm_connect
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #96
	.cfi_def_cfa_offset 96
	stp	x26, x25, [sp, #16]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #32]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #48]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #64]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #80]             ; 16-byte Folded Spill
	add	x29, sp, #80
	.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
	.cfi_offset w23, -56
	.cfi_offset w24, -64
	.cfi_offset w25, -72
	.cfi_offset w26, -80
	mov	x22, x2
	mov	x21, x1
	bl	_so2rfcomm_pcb
	str	xzr, [sp]
	cbz	x0, LBB0_5
; %bb.1:
	cbz	x21, LBB0_5
; %bb.2:
	ldr	x8, [x21]
Lloh0:
	adrp	x9, _AF_BLUETOOTH@GOTPAGE
Lloh1:
	ldr	x9, [x9, _AF_BLUETOOTH@GOTPAGEOFF]
Lloh2:
	ldr	x9, [x9]
	cmp	x8, x9
	b.ne	LBB0_6
; %bb.3:
	ldr	w8, [x21, #8]
	cmp	w8, #24
	b.ne	LBB0_5
; %bb.4:
	ldr	w8, [x21, #12]
	cmp	w8, #31
	b.lt	LBB0_9
LBB0_5:
Lloh3:
	adrp	x8, _EINVAL@GOTPAGE
Lloh4:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
	b	LBB0_7
LBB0_6:
Lloh5:
	adrp	x8, _EAFNOSUPPORT@GOTPAGE
Lloh6:
	ldr	x8, [x8, _EAFNOSUPPORT@GOTPAGEOFF]
LBB0_7:
	ldr	w20, [x8]
LBB0_8:
	mov	x0, x20
	ldp	x29, x30, [sp, #80]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #64]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #48]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #32]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #96
	ret
LBB0_9:
	cbz	w8, LBB0_16
; %bb.10:
	mov	x19, x0
	add	x23, x21, #16
Lloh7:
	adrp	x8, _NG_HCI_BDADDR_ANY@GOTPAGE
Lloh8:
	ldr	x8, [x8, _NG_HCI_BDADDR_ANY@GOTPAGEOFF]
Lloh9:
	ldr	w1, [x8]
	mov	x0, x23
	mov	w2, #4
	bl	_bcmp
	cbz	x0, LBB0_16
; %bb.11:
Lloh10:
	adrp	x8, _PF_BLUETOOTH@GOTPAGE
Lloh11:
	ldr	x8, [x8, _PF_BLUETOOTH@GOTPAGEOFF]
Lloh12:
	adrp	x9, _SOCK_SEQPACKET@GOTPAGE
Lloh13:
	ldr	x9, [x9, _SOCK_SEQPACKET@GOTPAGEOFF]
Lloh14:
	ldr	w0, [x8]
Lloh15:
	ldr	w2, [x9]
Lloh16:
	adrp	x8, _BLUETOOTH_PROTO_L2CAP@GOTPAGE
Lloh17:
	ldr	x8, [x8, _BLUETOOTH_PROTO_L2CAP@GOTPAGEOFF]
Lloh18:
	ldr	w3, [x8]
	ldr	w4, [x22]
	mov	x1, sp
	mov	x5, x22
	bl	_socreate
	mov	x20, x0
Lloh19:
	adrp	x0, _ng_btsocket_rfcomm_sessions_mtx@GOTPAGE
Lloh20:
	ldr	x0, [x0, _ng_btsocket_rfcomm_sessions_mtx@GOTPAGEOFF]
	bl	_mtx_lock
	add	x25, x19, #16
	mov	x0, x25
	mov	x1, x23
	bl	_ng_btsocket_rfcomm_session_by_addr
	str	x0, [sp, #8]
	ldr	x1, [sp]
	cbz	x0, LBB0_17
; %bb.12:
	mov	x24, x0
	cbz	x1, LBB0_14
; %bb.13:
	mov	x0, x1
	bl	_soclose
LBB0_14:
	add	x0, x24, #4
	bl	_mtx_lock
	add	x22, x19, #8
	mov	x0, x22
	bl	_mtx_lock
	ldr	x0, [sp, #8]
	bl	_INITIATOR
	cmp	w0, #0
	cset	w0, eq
	ldr	w1, [x21, #12]
	bl	_RFCOMM_MKDLCI
	mov	x23, x0
	ldr	x0, [sp, #8]
	mov	x1, x23
	bl	_ng_btsocket_rfcomm_pcb_by_dlci
	cbz	x0, LBB0_20
; %bb.15:
	mov	x0, x22
	bl	_mtx_unlock
	ldr	x8, [sp, #8]
	add	x0, x8, #4
	bl	_mtx_unlock
Lloh21:
	adrp	x0, _ng_btsocket_rfcomm_sessions_mtx@GOTPAGE
Lloh22:
	ldr	x0, [x0, _ng_btsocket_rfcomm_sessions_mtx@GOTPAGEOFF]
	bl	_mtx_unlock
Lloh23:
	adrp	x8, _EBUSY@GOTPAGE
Lloh24:
	ldr	x8, [x8, _EBUSY@GOTPAGEOFF]
	b	LBB0_7
LBB0_16:
Lloh25:
	adrp	x8, _EDESTADDRREQ@GOTPAGE
Lloh26:
	ldr	x8, [x8, _EDESTADDRREQ@GOTPAGEOFF]
	b	LBB0_7
LBB0_17:
	cbz	x1, LBB0_28
; %bb.18:
	add	x0, sp, #8
	mov	x2, x25
	mov	x3, x23
	mov	x4, x22
	bl	_ng_btsocket_rfcomm_session_create
	mov	x20, x0
	cbz	w0, LBB0_25
; %bb.19:
Lloh27:
	adrp	x0, _ng_btsocket_rfcomm_sessions_mtx@GOTPAGE
Lloh28:
	ldr	x0, [x0, _ng_btsocket_rfcomm_sessions_mtx@GOTPAGEOFF]
	bl	_mtx_unlock
	ldr	x0, [sp]
	bl	_soclose
	b	LBB0_8
LBB0_20:
	ldr	x8, [sp, #8]
	ldr	w9, [x8]
	sub	w9, w9, #128
	cmp	w9, #2
	b.hi	LBB0_24
; %bb.21:
	ldr	w9, [x21, #16]
	str	w9, [x19, #40]
	ldr	w9, [x21, #12]
	stp	w9, w23, [x19]
	add	x0, x8, #16
Lloh29:
	adrp	x8, _session_next@GOTPAGE
Lloh30:
	ldr	x8, [x8, _session_next@GOTPAGEOFF]
Lloh31:
	ldr	w2, [x8]
	mov	x1, x19
	bl	_LIST_INSERT_HEAD
	ldr	x8, [sp, #8]
	str	x8, [x19, #32]
	mov	x0, x19
	bl	_ng_btsocket_rfcomm_timeout
	ldr	w0, [x19, #24]
	bl	_soisconnecting
	ldr	x8, [sp, #8]
	ldr	w9, [x8]
	cmp	w9, #128
	b.ne	LBB0_26
; %bb.22:
	ldr	w9, [x8, #12]
	str	w9, [x19, #20]
	ldr	w0, [x8, #8]
	bl	_so2l2cap_pcb
	ldr	w8, [x0]
Lloh32:
	adrp	x9, _NG_BTSOCKET_RFCOMM_DLC_CONFIGURING@GOTPAGE
Lloh33:
	ldr	x9, [x9, _NG_BTSOCKET_RFCOMM_DLC_CONFIGURING@GOTPAGEOFF]
Lloh34:
	ldr	w9, [x9]
	stp	w9, w8, [x19, #12]
	mov	x0, x19
	bl	_ng_btsocket_rfcomm_send_pn
	mov	x20, x0
	cbnz	w0, LBB0_27
; %bb.23:
	bl	_ng_btsocket_rfcomm_task_wakeup
	mov	x20, x0
	b	LBB0_27
LBB0_24:
Lloh35:
	adrp	x8, _ECONNRESET@GOTPAGE
Lloh36:
	ldr	x8, [x8, _ECONNRESET@GOTPAGEOFF]
Lloh37:
	ldr	w20, [x8]
	b	LBB0_27
LBB0_25:
	ldr	x24, [sp, #8]
	b	LBB0_14
LBB0_26:
Lloh38:
	adrp	x8, _NG_BTSOCKET_RFCOMM_DLC_W4_CONNECT@GOTPAGE
Lloh39:
	ldr	x8, [x8, _NG_BTSOCKET_RFCOMM_DLC_W4_CONNECT@GOTPAGEOFF]
Lloh40:
	ldr	w8, [x8]
	str	w8, [x19, #12]
LBB0_27:
	mov	x0, x22
	bl	_mtx_unlock
	ldr	x8, [sp, #8]
	add	x0, x8, #4
	bl	_mtx_unlock
LBB0_28:
Lloh41:
	adrp	x0, _ng_btsocket_rfcomm_sessions_mtx@GOTPAGE
Lloh42:
	ldr	x0, [x0, _ng_btsocket_rfcomm_sessions_mtx@GOTPAGEOFF]
	bl	_mtx_unlock
	b	LBB0_8
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGot	Lloh3, Lloh4
	.loh AdrpLdrGot	Lloh5, Lloh6
	.loh AdrpLdrGotLdr	Lloh7, Lloh8, Lloh9
	.loh AdrpLdrGot	Lloh19, Lloh20
	.loh AdrpLdrGotLdr	Lloh16, Lloh17, Lloh18
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh15
	.loh AdrpLdrGotLdr	Lloh10, Lloh11, Lloh14
	.loh AdrpLdrGot	Lloh23, Lloh24
	.loh AdrpLdrGot	Lloh21, Lloh22
	.loh AdrpLdrGot	Lloh25, Lloh26
	.loh AdrpLdrGot	Lloh27, Lloh28
	.loh AdrpLdrGotLdr	Lloh29, Lloh30, Lloh31
	.loh AdrpLdrGotLdr	Lloh32, Lloh33, Lloh34
	.loh AdrpLdrGotLdr	Lloh35, Lloh36, Lloh37
	.loh AdrpLdrGotLdr	Lloh38, Lloh39, Lloh40
	.loh AdrpLdrGot	Lloh41, Lloh42
	.cfi_endproc
                                        ; -- End function
	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_AF_BLUETOOTH,8,3               ; @AF_BLUETOOTH
	.comm	_EAFNOSUPPORT,4,2               ; @EAFNOSUPPORT
	.comm	_NG_HCI_BDADDR_ANY,4,2          ; @NG_HCI_BDADDR_ANY
	.comm	_EDESTADDRREQ,4,2               ; @EDESTADDRREQ
	.comm	_PF_BLUETOOTH,4,2               ; @PF_BLUETOOTH
	.comm	_SOCK_SEQPACKET,4,2             ; @SOCK_SEQPACKET
	.comm	_BLUETOOTH_PROTO_L2CAP,4,2      ; @BLUETOOTH_PROTO_L2CAP
	.comm	_ng_btsocket_rfcomm_sessions_mtx,4,2 ; @ng_btsocket_rfcomm_sessions_mtx
	.comm	_EBUSY,4,2                      ; @EBUSY
	.comm	_session_next,4,2               ; @session_next
	.comm	_NG_BTSOCKET_RFCOMM_DLC_CONFIGURING,4,2 ; @NG_BTSOCKET_RFCOMM_DLC_CONFIGURING
	.comm	_NG_BTSOCKET_RFCOMM_DLC_W4_CONNECT,4,2 ; @NG_BTSOCKET_RFCOMM_DLC_W4_CONNECT
	.comm	_ECONNRESET,4,2                 ; @ECONNRESET
.subsections_via_symbols
