	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function mtk_cqdma_alloc_chan_resources
_mtk_cqdma_alloc_chan_resources:        ## @mtk_cqdma_alloc_chan_resources
	.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, %r14
	callq	_to_cqdma_dev
	movq	%rax, %r12
	movq	%r14, %rdi
	callq	_to_cqdma_vchan
	cmpq	$0, (%r12)
	je	LBB0_6
## %bb.1:
	movq	%rax, %r14
	movq	_U32_MAX@GOTPCREL(%rip), %rax
	movq	(%rax), %r13
	xorl	%ebx, %ebx
	xorl	%r15d, %r15d
	jmp	LBB0_2
	.p2align	4, 0x90
LBB0_4:                                 ##   in Loop: Header=BB0_2 Depth=1
	incq	%rbx
	cmpq	(%r12), %rbx
	jae	LBB0_5
LBB0_2:                                 ## =>This Inner Loop Header: Depth=1
	movq	8(%r12), %rax
	movq	(%rax,%rbx,8), %rdi
	addq	$4, %rdi
	callq	_refcount_read
	cmpq	%r13, %rax
	jae	LBB0_4
## %bb.3:                               ##   in Loop: Header=BB0_2 Depth=1
	movq	8(%r12), %rcx
	movq	(%rcx,%rbx,8), %r15
	movq	%rax, %r13
	jmp	LBB0_4
LBB0_5:
	testq	%r15, %r15
	je	LBB0_6
## %bb.7:
	movq	%r15, %rdi
	callq	_spin_lock_irqsave
	leaq	4(%r15), %rbx
	movq	%rbx, %rdi
	callq	_refcount_read
	testq	%rax, %rax
	je	LBB0_8
## %bb.9:
	movq	%rbx, %rdi
	callq	_refcount_inc
	jmp	LBB0_10
LBB0_6:
	movq	_ENOSPC@GOTPCREL(%rip), %rcx
	xorl	%eax, %eax
	subl	(%rcx), %eax
	jmp	LBB0_11
LBB0_8:
	movq	%r15, %rdi
	callq	_mtk_cqdma_hard_reset
	movq	_MTK_CQDMA_INT_EN@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	_MTK_CQDMA_INT_EN_BIT@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	%r15, %rdi
	callq	_mtk_dma_set
	movq	%rbx, %rdi
	movl	$1, %esi
	callq	_refcount_set
LBB0_10:
	movq	%r15, %rdi
	callq	_spin_unlock_irqrestore
	movq	%r15, (%r14)
	xorl	%eax, %eax
LBB0_11:
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_U32_MAX,8,3                    ## @U32_MAX
	.comm	_ENOSPC,4,2                     ## @ENOSPC
	.comm	_MTK_CQDMA_INT_EN,4,2           ## @MTK_CQDMA_INT_EN
	.comm	_MTK_CQDMA_INT_EN_BIT,4,2       ## @MTK_CQDMA_INT_EN_BIT
	.no_dead_strip	_mtk_cqdma_alloc_chan_resources
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function mtk_cqdma_alloc_chan_resources
_mtk_cqdma_alloc_chan_resources:        ; @mtk_cqdma_alloc_chan_resources
	.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
	mov	x19, x0
	bl	_to_cqdma_dev
	mov	x21, x0
	mov	x0, x19
	bl	_to_cqdma_vchan
	ldr	x8, [x21]
	cbz	x8, LBB0_8
; %bb.1:
	mov	x19, x0
	mov	x22, #0
	mov	x20, #0
Lloh0:
	adrp	x8, _U32_MAX@GOTPAGE
Lloh1:
	ldr	x8, [x8, _U32_MAX@GOTPAGEOFF]
Lloh2:
	ldr	x23, [x8]
	b	LBB0_3
LBB0_2:                                 ;   in Loop: Header=BB0_3 Depth=1
	add	x22, x22, #1
	ldr	x8, [x21]
	cmp	x22, x8
	b.hs	LBB0_5
LBB0_3:                                 ; =>This Inner Loop Header: Depth=1
	ldr	x8, [x21, #8]
	ldr	x8, [x8, x22, lsl #3]
	add	x0, x8, #4
	bl	_refcount_read
	cmp	x0, x23
	b.hs	LBB0_2
; %bb.4:                                ;   in Loop: Header=BB0_3 Depth=1
	ldr	x8, [x21, #8]
	ldr	x20, [x8, x22, lsl #3]
	mov	x23, x0
	b	LBB0_2
LBB0_5:
	cbz	x20, LBB0_8
; %bb.6:
	mov	x0, x20
	bl	_spin_lock_irqsave
	add	x21, x20, #4
	mov	x0, x21
	bl	_refcount_read
	cbz	x0, LBB0_9
; %bb.7:
	mov	x0, x21
	bl	_refcount_inc
	b	LBB0_10
LBB0_8:
Lloh3:
	adrp	x8, _ENOSPC@GOTPAGE
Lloh4:
	ldr	x8, [x8, _ENOSPC@GOTPAGEOFF]
Lloh5:
	ldr	w8, [x8]
	neg	w0, w8
	b	LBB0_11
LBB0_9:
	mov	x0, x20
	bl	_mtk_cqdma_hard_reset
Lloh6:
	adrp	x8, _MTK_CQDMA_INT_EN@GOTPAGE
Lloh7:
	ldr	x8, [x8, _MTK_CQDMA_INT_EN@GOTPAGEOFF]
Lloh8:
	ldr	w1, [x8]
Lloh9:
	adrp	x8, _MTK_CQDMA_INT_EN_BIT@GOTPAGE
Lloh10:
	ldr	x8, [x8, _MTK_CQDMA_INT_EN_BIT@GOTPAGEOFF]
Lloh11:
	ldr	w2, [x8]
	mov	x0, x20
	bl	_mtk_dma_set
	mov	x0, x21
	mov	w1, #1
	bl	_refcount_set
LBB0_10:
	mov	x0, x20
	bl	_spin_unlock_irqrestore
	mov	w0, #0
	str	x20, [x19]
LBB0_11:
	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	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.cfi_endproc
                                        ; -- End function
	.comm	_U32_MAX,8,3                    ; @U32_MAX
	.comm	_ENOSPC,4,2                     ; @ENOSPC
	.comm	_MTK_CQDMA_INT_EN,4,2           ; @MTK_CQDMA_INT_EN
	.comm	_MTK_CQDMA_INT_EN_BIT,4,2       ; @MTK_CQDMA_INT_EN_BIT
	.no_dead_strip	_mtk_cqdma_alloc_chan_resources
.subsections_via_symbols
