	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_l2ca_datawrite                 ## -- Begin function l2ca_datawrite
	.p2align	4, 0x90
_l2ca_datawrite:                        ## @l2ca_datawrite
	.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
	pushq	%rax
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	(%rdi), %rax
	movq	_L2CAP_OPEN@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_1
## %bb.2:
	movq	%rsi, %r15
	movq	%rdi, %rbx
	movq	_PBUF_RAW@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movq	_L2CAP_HDR_LEN@GOTPCREL(%rip), %r12
	movq	(%r12), %rsi
	movq	_PBUF_RAM@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	callq	_btpbuf_alloc
	testq	%rax, %rax
	je	LBB0_3
## %bb.4:
	movq	%rax, %r14
	movq	%rax, %rdi
	movq	%r15, %rsi
	callq	_btpbuf_chain
	movq	8(%r14), %r13
	movq	8(%rbx), %rdi
	callq	_htole16
	movq	%rax, 8(%r13)
	movq	(%r15), %rdi
	movq	24(%rbx), %rax
	cmpq	%rax, %rdi
	jle	LBB0_7
## %bb.5:
	movq	%rax, %rdi
	callq	_htole16
	movq	%rax, (%r13)
	movq	(%r12), %rdx
	addq	24(%rbx), %rdx
	addq	$16, %rbx
	movq	%rbx, %rdi
	movq	%r14, %rsi
	callq	_l2cap_write
	movl	%eax, %ebx
	movq	_ERR_OK@GOTPCREL(%rip), %rax
	cmpl	(%rax), %ebx
	jne	LBB0_8
## %bb.6:
	movq	_ERR_BUF@GOTPCREL(%rip), %rax
	movl	(%rax), %ebx
	jmp	LBB0_8
LBB0_1:
	leaq	L_.str(%rip), %rdi
	callq	_ERROR
	movq	_ERR_CONN@GOTPCREL(%rip), %rax
	movl	(%rax), %ebx
	jmp	LBB0_9
LBB0_3:
	leaq	L_.str.1(%rip), %rdi
	callq	_ERROR
	movq	_ERR_MEM@GOTPCREL(%rip), %rax
	movl	(%rax), %ebx
	jmp	LBB0_9
LBB0_7:
	callq	_htole16
	movq	%rax, (%r13)
	addq	$16, %rbx
	movq	(%r14), %rdx
	movq	%rbx, %rdi
	movq	%r14, %rsi
	callq	_l2cap_write
	movl	%eax, %ebx
LBB0_8:
	movq	%r14, %rdi
	callq	_btpbuf_dechain
	movq	%r14, %rdi
	callq	_btpbuf_free
LBB0_9:
	movl	%ebx, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_L2CAP_OPEN,8,3                 ## @L2CAP_OPEN
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"l2cap_datawrite: State != L2CAP_OPEN. Dropping data\n"

	.comm	_ERR_CONN,4,2                   ## @ERR_CONN
	.comm	_PBUF_RAW,4,2                   ## @PBUF_RAW
	.comm	_L2CAP_HDR_LEN,8,3              ## @L2CAP_HDR_LEN
	.comm	_PBUF_RAM,4,2                   ## @PBUF_RAM
L_.str.1:                               ## @.str.1
	.asciz	"l2cap_datawrite: Could not allocate memory for pbuf\n"

	.comm	_ERR_MEM,4,2                    ## @ERR_MEM
	.comm	_ERR_OK,4,2                     ## @ERR_OK
	.comm	_ERR_BUF,4,2                    ## @ERR_BUF
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_l2ca_datawrite                 ; -- Begin function l2ca_datawrite
	.p2align	2
_l2ca_datawrite:                        ; @l2ca_datawrite
	.cfi_startproc
; %bb.0:
	stp	x24, x23, [sp, #-64]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 64
	stp	x22, x21, [sp, #16]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #32]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #48]             ; 16-byte Folded Spill
	add	x29, sp, #48
	.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
	ldr	x8, [x0]
Lloh0:
	adrp	x9, _L2CAP_OPEN@GOTPAGE
Lloh1:
	ldr	x9, [x9, _L2CAP_OPEN@GOTPAGEOFF]
Lloh2:
	ldr	x9, [x9]
	cmp	x8, x9
	b.ne	LBB0_4
; %bb.1:
	mov	x21, x1
	mov	x20, x0
Lloh3:
	adrp	x8, _PBUF_RAW@GOTPAGE
Lloh4:
	ldr	x8, [x8, _PBUF_RAW@GOTPAGEOFF]
Lloh5:
	ldr	w0, [x8]
Lloh6:
	adrp	x22, _L2CAP_HDR_LEN@GOTPAGE
Lloh7:
	ldr	x22, [x22, _L2CAP_HDR_LEN@GOTPAGEOFF]
	ldr	x1, [x22]
Lloh8:
	adrp	x8, _PBUF_RAM@GOTPAGE
Lloh9:
	ldr	x8, [x8, _PBUF_RAM@GOTPAGEOFF]
Lloh10:
	ldr	w2, [x8]
	bl	_btpbuf_alloc
	cbz	x0, LBB0_5
; %bb.2:
	mov	x19, x0
	mov	x1, x21
	bl	_btpbuf_chain
	ldr	x23, [x19, #8]
	ldr	x0, [x20, #8]
	bl	_htole16
	str	x0, [x23, #8]
	ldr	x0, [x21]
	ldr	x8, [x20, #24]
	cmp	x0, x8
	b.le	LBB0_6
; %bb.3:
	mov	x0, x8
	bl	_htole16
	str	x0, [x23]
	add	x0, x20, #16
	ldr	x8, [x20, #24]
	ldr	x9, [x22]
	add	x2, x9, x8
	mov	x1, x19
	bl	_l2cap_write
Lloh11:
	adrp	x8, _ERR_OK@GOTPAGE
Lloh12:
	ldr	x8, [x8, _ERR_OK@GOTPAGEOFF]
Lloh13:
	ldr	w8, [x8]
Lloh14:
	adrp	x9, _ERR_BUF@GOTPAGE
Lloh15:
	ldr	x9, [x9, _ERR_BUF@GOTPAGEOFF]
Lloh16:
	ldr	w9, [x9]
	cmp	w0, w8
	csel	w20, w9, w0, eq
	b	LBB0_7
LBB0_4:
Lloh17:
	adrp	x0, l_.str@PAGE
Lloh18:
	add	x0, x0, l_.str@PAGEOFF
	bl	_ERROR
Lloh19:
	adrp	x8, _ERR_CONN@GOTPAGE
Lloh20:
	ldr	x8, [x8, _ERR_CONN@GOTPAGEOFF]
Lloh21:
	ldr	w20, [x8]
	b	LBB0_8
LBB0_5:
Lloh22:
	adrp	x0, l_.str.1@PAGE
Lloh23:
	add	x0, x0, l_.str.1@PAGEOFF
	bl	_ERROR
Lloh24:
	adrp	x8, _ERR_MEM@GOTPAGE
Lloh25:
	ldr	x8, [x8, _ERR_MEM@GOTPAGEOFF]
Lloh26:
	ldr	w20, [x8]
	b	LBB0_8
LBB0_6:
	bl	_htole16
	str	x0, [x23]
	add	x0, x20, #16
	ldr	x2, [x19]
	mov	x1, x19
	bl	_l2cap_write
	mov	x20, x0
LBB0_7:
	mov	x0, x19
	bl	_btpbuf_dechain
	mov	x0, x19
	bl	_btpbuf_free
LBB0_8:
	mov	x0, x20
	ldp	x29, x30, [sp, #48]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #32]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #16]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp], #64             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpLdrGot	Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh14, Lloh15, Lloh16
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh19, Lloh20, Lloh21
	.loh AdrpAdd	Lloh17, Lloh18
	.loh AdrpLdrGotLdr	Lloh24, Lloh25, Lloh26
	.loh AdrpAdd	Lloh22, Lloh23
	.cfi_endproc
                                        ; -- End function
	.comm	_L2CAP_OPEN,8,3                 ; @L2CAP_OPEN
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"l2cap_datawrite: State != L2CAP_OPEN. Dropping data\n"

	.comm	_ERR_CONN,4,2                   ; @ERR_CONN
	.comm	_PBUF_RAW,4,2                   ; @PBUF_RAW
	.comm	_L2CAP_HDR_LEN,8,3              ; @L2CAP_HDR_LEN
	.comm	_PBUF_RAM,4,2                   ; @PBUF_RAM
l_.str.1:                               ; @.str.1
	.asciz	"l2cap_datawrite: Could not allocate memory for pbuf\n"

	.comm	_ERR_MEM,4,2                    ; @ERR_MEM
	.comm	_ERR_OK,4,2                     ; @ERR_OK
	.comm	_ERR_BUF,4,2                    ; @ERR_BUF
.subsections_via_symbols
