	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function cosa_net_open
_cosa_net_open:                         ## @cosa_net_open
	.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	_dev_to_chan
	movq	%rax, %r15
	movq	8(%rax), %rdi
	movl	(%rdi), %edx
	movq	_COSA_FW_START@GOTPCREL(%rip), %rax
	testl	%edx, (%rax)
	je	LBB0_1
## %bb.3:
	addq	$4, %rdi
	callq	_spin_lock_irqsave
	movl	(%r15), %edx
	testl	%edx, %edx
	je	LBB0_5
## %bb.4:
	movl	28(%r15), %esi
	leaq	L_.str.1(%rip), %rdi
	callq	_pr_warn
	movq	8(%r15), %rdi
	addq	$4, %rdi
	callq	_spin_unlock_irqrestore
	movq	_EBUSY@GOTPCREL(%rip), %rax
	jmp	LBB0_2
LBB0_1:
	movl	12(%rdi), %esi
	leaq	L_.str(%rip), %rdi
	callq	_pr_notice
	movq	_EPERM@GOTPCREL(%rip), %rax
LBB0_2:
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
LBB0_8:
	movl	%ebx, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_5:
	movq	_cosa_net_setup_rx@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, 24(%r15)
	movq	_cosa_net_tx_done@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, 20(%r15)
	movq	_cosa_net_rx_done@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, 16(%r15)
	movl	$-1, (%r15)
	movq	8(%r15), %rdi
	incl	8(%rdi)
	addq	$4, %rdi
	callq	_spin_unlock_irqrestore
	movq	%r14, %rdi
	callq	_hdlc_open
	testl	%eax, %eax
	je	LBB0_7
## %bb.6:
	movl	%eax, %ebx
	movq	8(%r15), %rdi
	addq	$4, %rdi
	callq	_spin_lock_irqsave
	movl	$0, (%r15)
	movq	8(%r15), %rdi
	decl	8(%rdi)
	addq	$4, %rdi
	callq	_spin_unlock_irqrestore
	jmp	LBB0_8
LBB0_7:
	movq	%r14, %rdi
	callq	_netif_start_queue
	movq	%r15, %rdi
	callq	_cosa_enable_rx
	xorl	%ebx, %ebx
	jmp	LBB0_8
	.cfi_endproc
                                        ## -- End function
	.comm	_COSA_FW_START,4,2              ## @COSA_FW_START
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"%s: start the firmware first (status %d)\n"

	.comm	_EPERM,4,2                      ## @EPERM
L_.str.1:                               ## @.str.1
	.asciz	"%s: cosa_net_open called with usage count %d\n"

	.comm	_EBUSY,4,2                      ## @EBUSY
	.comm	_cosa_net_setup_rx,4,2          ## @cosa_net_setup_rx
	.comm	_cosa_net_tx_done,4,2           ## @cosa_net_tx_done
	.comm	_cosa_net_rx_done,4,2           ## @cosa_net_rx_done
	.no_dead_strip	_cosa_net_open
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function cosa_net_open
_cosa_net_open:                         ; @cosa_net_open
	.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	x20, x0
	bl	_dev_to_chan
	ldr	x8, [x0, #8]
	ldr	w2, [x8]
Lloh0:
	adrp	x9, _COSA_FW_START@GOTPAGE
Lloh1:
	ldr	x9, [x9, _COSA_FW_START@GOTPAGEOFF]
Lloh2:
	ldr	w9, [x9]
	tst	w9, w2
	b.eq	LBB0_3
; %bb.1:
	mov	x19, x0
	add	x0, x8, #4
	bl	_spin_lock_irqsave
	ldr	w2, [x19]
	cbz	w2, LBB0_6
; %bb.2:
	ldr	w1, [x19, #28]
Lloh3:
	adrp	x0, l_.str.1@PAGE
Lloh4:
	add	x0, x0, l_.str.1@PAGEOFF
	bl	_pr_warn
	ldr	x8, [x19, #8]
	add	x0, x8, #4
	bl	_spin_unlock_irqrestore
Lloh5:
	adrp	x8, _EBUSY@GOTPAGE
Lloh6:
	ldr	x8, [x8, _EBUSY@GOTPAGEOFF]
	b	LBB0_4
LBB0_3:
	ldr	w1, [x8, #12]
Lloh7:
	adrp	x0, l_.str@PAGE
Lloh8:
	add	x0, x0, l_.str@PAGEOFF
	bl	_pr_notice
Lloh9:
	adrp	x8, _EPERM@GOTPAGE
Lloh10:
	ldr	x8, [x8, _EPERM@GOTPAGEOFF]
LBB0_4:
	ldr	w8, [x8]
	neg	w21, w8
LBB0_5:
	mov	x0, x21
	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_6:
Lloh11:
	adrp	x8, _cosa_net_setup_rx@GOTPAGE
Lloh12:
	ldr	x8, [x8, _cosa_net_setup_rx@GOTPAGEOFF]
Lloh13:
	ldr	w8, [x8]
	str	w8, [x19, #24]
Lloh14:
	adrp	x8, _cosa_net_tx_done@GOTPAGE
Lloh15:
	ldr	x8, [x8, _cosa_net_tx_done@GOTPAGEOFF]
Lloh16:
	ldr	w8, [x8]
Lloh17:
	adrp	x9, _cosa_net_rx_done@GOTPAGE
Lloh18:
	ldr	x9, [x9, _cosa_net_rx_done@GOTPAGEOFF]
Lloh19:
	ldr	w9, [x9]
	stp	w9, w8, [x19, #16]
	mov	w8, #-1
	str	w8, [x19]
	ldr	x8, [x19, #8]
	ldr	w9, [x8, #8]
	add	w9, w9, #1
	str	w9, [x8, #8]
	add	x0, x8, #4
	bl	_spin_unlock_irqrestore
	mov	x0, x20
	bl	_hdlc_open
	mov	x21, x0
	cbz	w0, LBB0_8
; %bb.7:
	ldr	x8, [x19, #8]
	add	x0, x8, #4
	bl	_spin_lock_irqsave
	str	wzr, [x19]
	ldr	x8, [x19, #8]
	ldr	w9, [x8, #8]
	sub	w9, w9, #1
	str	w9, [x8, #8]
	add	x0, x8, #4
	bl	_spin_unlock_irqrestore
	b	LBB0_5
LBB0_8:
	mov	x0, x20
	bl	_netif_start_queue
	mov	x0, x19
	bl	_cosa_enable_rx
	b	LBB0_5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGot	Lloh5, Lloh6
	.loh AdrpAdd	Lloh3, Lloh4
	.loh AdrpLdrGot	Lloh9, Lloh10
	.loh AdrpAdd	Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh17, Lloh18, Lloh19
	.loh AdrpLdrGotLdr	Lloh14, Lloh15, Lloh16
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.cfi_endproc
                                        ; -- End function
	.comm	_COSA_FW_START,4,2              ; @COSA_FW_START
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"%s: start the firmware first (status %d)\n"

	.comm	_EPERM,4,2                      ; @EPERM
l_.str.1:                               ; @.str.1
	.asciz	"%s: cosa_net_open called with usage count %d\n"

	.comm	_EBUSY,4,2                      ; @EBUSY
	.comm	_cosa_net_setup_rx,4,2          ; @cosa_net_setup_rx
	.comm	_cosa_net_tx_done,4,2           ; @cosa_net_tx_done
	.comm	_cosa_net_rx_done,4,2           ; @cosa_net_rx_done
	.no_dead_strip	_cosa_net_open
.subsections_via_symbols
