	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function mtk_hsdma_free_rooms_in_ring
_mtk_hsdma_free_rooms_in_ring:          ## @mtk_hsdma_free_rooms_in_ring
	.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	$56, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdi, %r13
	movq	_MTK_DMA_SIZE@GOTPCREL(%rip), %r14
	movl	(%r14), %r15d
	movq	_MTK_HSDMA_INT_STATUS@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	callq	_mtk_dma_read
	movl	%eax, %ebx
	movq	_MTK_HSDMA_INT_RXDONE@GOTPCREL(%rip), %rax
	xorl	%edi, %edi
	movl	(%rax), %eax
	andl	%ebx, %eax
	sete	%dil
	callq	_unlikely
	testq	%rax, %rax
	jne	LBB0_17
## %bb.1:
	movl	%ebx, -48(%rbp)                 ## 4-byte Spill
	movq	24(%r13), %rbx
	movl	%r15d, -44(%rbp)                ## 4-byte Spill
	testl	%r15d, %r15d
	je	LBB0_12
## %bb.2:
	movq	%r13, -64(%rbp)                 ## 8-byte Spill
	movq	%rbx, -56(%rbp)                 ## 8-byte Spill
	jmp	LBB0_3
	.p2align	4, 0x90
LBB0_10:                                ##   in Loop: Header=BB0_3 Depth=1
	addq	%r13, %rbx
	addq	$8, %rbx
	movq	-80(%rbp), %rdi                 ## 8-byte Reload
	callq	_spin_unlock
	movq	$0, (%rbx)
	movq	-88(%rbp), %r15                 ## 8-byte Reload
LBB0_11:                                ##   in Loop: Header=BB0_3 Depth=1
	movq	$0, (%r15)
	movq	-72(%rbp), %rbx                 ## 8-byte Reload
	movl	4(%rbx,%r12,8), %edi
	xorl	%esi, %esi
	callq	_WRITE_ONCE
	movl	(%rbx,%r12,8), %edi
	xorl	%esi, %esi
	callq	_WRITE_ONCE
	movq	-56(%rbp), %rbx                 ## 8-byte Reload
	movq	%r12, 8(%rbx)
	movq	%rbx, %rdi
	callq	_atomic_inc
	cmpl	$0, -44(%rbp)                   ## 4-byte Folded Reload
	movq	-64(%rbp), %r13                 ## 8-byte Reload
	movq	_MTK_DMA_SIZE@GOTPCREL(%rip), %r14
	je	LBB0_12
LBB0_3:                                 ## =>This Inner Loop Header: Depth=1
	movq	8(%rbx), %rdi
	movl	(%r14), %esi
	callq	_MTK_HSDMA_NEXT_DESP_IDX
	movq	%rax, %r12
	movq	24(%rbx), %rax
	movq	%rax, -72(%rbp)                 ## 8-byte Spill
	movl	(%rax,%r12,8), %edi
	callq	_READ_ONCE
	movq	16(%r13), %rcx
	testl	%eax, (%rcx)
	je	LBB0_12
## %bb.4:                               ##   in Loop: Header=BB0_3 Depth=1
	movq	16(%rbx), %r13
	movq	%r12, %rbx
	shlq	$4, %rbx
	xorl	%edi, %edi
	cmpq	$0, (%r13,%rbx)
	sete	%dil
	callq	_unlikely
	testq	%rax, %rax
	jne	LBB0_5
## %bb.6:                               ##   in Loop: Header=BB0_3 Depth=1
	decl	-44(%rbp)                       ## 4-byte Folded Spill
	leaq	(%rbx,%r13), %r15
	movq	(%r15), %rdi
	callq	_to_hsdma_vdesc
	movq	%rax, %r14
	movq	-72(%rbp), %rax                 ## 8-byte Reload
	movl	(%rax,%r12,8), %edi
	callq	_MTK_HSDMA_DESC_PLEN_GET
	subl	%eax, (%r14)
	movq	8(%r13,%rbx), %rdi
	callq	_IS_MTK_HSDMA_VDESC_FINISHED
	testq	%rax, %rax
	je	LBB0_11
## %bb.7:                               ##   in Loop: Header=BB0_3 Depth=1
	movq	(%r15), %rax
	movl	4(%rax), %edi
	callq	_to_hsdma_vchan
	movq	%rax, %r14
	leaq	4(%rax), %rdi
	movq	%rdi, -80(%rbp)                 ## 8-byte Spill
	callq	_spin_lock
	movq	(%r15), %rdi
	callq	_list_del
	movq	%r15, -88(%rbp)                 ## 8-byte Spill
	movq	(%r15), %rdi
	callq	_vchan_cookie_complete
	cmpl	$0, (%r14)
	je	LBB0_10
## %bb.8:                               ##   in Loop: Header=BB0_3 Depth=1
	leaq	12(%r14), %rdi
	callq	_list_empty
	testq	%rax, %rax
	je	LBB0_10
## %bb.9:                               ##   in Loop: Header=BB0_3 Depth=1
	movq	%r14, %rdi
	addq	$8, %rdi
	callq	_complete
	movl	$0, (%r14)
	jmp	LBB0_10
LBB0_5:
	movq	-64(%rbp), %r13                 ## 8-byte Reload
	movq	%r13, %rdi
	callq	_hsdma2dev
	leaq	L_.str(%rip), %rsi
	movl	%eax, %edi
	callq	_dev_err
	movq	-56(%rbp), %rbx                 ## 8-byte Reload
LBB0_12:
	xorl	%eax, %eax
	callq	_wmb
	movq	_MTK_HSDMA_RX_CPU@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movl	8(%rbx), %edx
	movq	%r13, %rdi
	callq	_mtk_dma_write
	movq	%rbx, %rdi
	callq	_atomic_read
	movl	(%r14), %ecx
	decl	%ecx
	cmpl	%ecx, %eax
	jl	LBB0_14
## %bb.13:
	movq	_MTK_HSDMA_INT_STATUS@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r13, %rdi
	movl	-48(%rbp), %edx                 ## 4-byte Reload
	callq	_mtk_dma_write
LBB0_14:
	cmpl	$0, (%r13)
	jle	LBB0_17
## %bb.15:
	xorl	%r15d, %r15d
	xorl	%r12d, %r12d
	.p2align	4, 0x90
LBB0_16:                                ## =>This Inner Loop Header: Depth=1
	movq	8(%r13), %rbx
	leaq	(%rbx,%r15), %r14
	addq	$4, %r14
	addq	%r15, %rbx
	movq	%r14, %rdi
	callq	_spin_lock
	movq	%r13, %rdi
	movq	%rbx, %rsi
	callq	_mtk_hsdma_issue_vchan_pending
	movq	%r14, %rdi
	callq	_spin_unlock
	incq	%r12
	movslq	(%r13), %rax
	addq	$16, %r15
	cmpq	%rax, %r12
	jl	LBB0_16
LBB0_17:
	movq	_MTK_HSDMA_INT_ENABLE@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	_MTK_HSDMA_INT_RXDONE@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	%r13, %rdi
	addq	$56, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	jmp	_mtk_dma_set                    ## TAILCALL
	.cfi_endproc
                                        ## -- End function
	.comm	_MTK_DMA_SIZE,4,2               ## @MTK_DMA_SIZE
	.comm	_MTK_HSDMA_INT_STATUS,4,2       ## @MTK_HSDMA_INT_STATUS
	.comm	_MTK_HSDMA_INT_RXDONE,4,2       ## @MTK_HSDMA_INT_RXDONE
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"cb->vd cannot be null\n"

	.comm	_MTK_HSDMA_RX_CPU,4,2           ## @MTK_HSDMA_RX_CPU
	.comm	_MTK_HSDMA_INT_ENABLE,4,2       ## @MTK_HSDMA_INT_ENABLE
	.no_dead_strip	_mtk_hsdma_free_rooms_in_ring
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function mtk_hsdma_free_rooms_in_ring
_mtk_hsdma_free_rooms_in_ring:          ; @mtk_hsdma_free_rooms_in_ring
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #112
	.cfi_def_cfa_offset 112
	stp	x28, x27, [sp, #16]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #32]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #48]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #64]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #80]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #96]             ; 16-byte Folded Spill
	add	x29, sp, #96
	.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
	.cfi_offset w27, -88
	.cfi_offset w28, -96
	mov	x19, x0
Lloh0:
	adrp	x22, _MTK_DMA_SIZE@GOTPAGE
Lloh1:
	ldr	x22, [x22, _MTK_DMA_SIZE@GOTPAGEOFF]
	ldr	w28, [x22]
Lloh2:
	adrp	x8, _MTK_HSDMA_INT_STATUS@GOTPAGE
Lloh3:
	ldr	x8, [x8, _MTK_HSDMA_INT_STATUS@GOTPAGEOFF]
Lloh4:
	ldr	w1, [x8]
	bl	_mtk_dma_read
	mov	x20, x0
Lloh5:
	adrp	x24, _MTK_HSDMA_INT_RXDONE@GOTPAGE
Lloh6:
	ldr	x24, [x24, _MTK_HSDMA_INT_RXDONE@GOTPAGEOFF]
	ldr	w8, [x24]
	tst	w8, w0
	cset	w0, eq
	bl	_unlikely
	cbnz	x0, LBB0_16
; %bb.1:
	str	w20, [sp, #12]                  ; 4-byte Folded Spill
	ldr	x21, [x19, #24]
	mov	x24, x22
	cbnz	w28, LBB0_4
	b	LBB0_11
LBB0_2:                                 ;   in Loop: Header=BB0_4 Depth=1
	mov	x0, x23
	bl	_spin_unlock
	str	xzr, [x27]
Lloh7:
	adrp	x24, _MTK_DMA_SIZE@GOTPAGE
Lloh8:
	ldr	x24, [x24, _MTK_DMA_SIZE@GOTPAGEOFF]
LBB0_3:                                 ;   in Loop: Header=BB0_4 Depth=1
	str	xzr, [x20]
	add	x8, x25, x22, lsl #3
	ldr	w0, [x8, #4]
	mov	w1, #0
	bl	_WRITE_ONCE
	ldr	w0, [x26]
	mov	w1, #0
	bl	_WRITE_ONCE
	str	x22, [x21, #8]
	mov	x0, x21
	bl	_atomic_inc
	cbz	w28, LBB0_11
LBB0_4:                                 ; =>This Inner Loop Header: Depth=1
	ldr	x0, [x21, #8]
	ldr	w1, [x24]
	bl	_MTK_HSDMA_NEXT_DESP_IDX
	mov	x22, x0
	ldr	x25, [x21, #24]
	add	x26, x25, x0, lsl #3
	ldr	w0, [x26]
	bl	_READ_ONCE
	ldr	x8, [x19, #16]
	ldr	w8, [x8]
	tst	w8, w0
	b.eq	LBB0_11
; %bb.5:                                ;   in Loop: Header=BB0_4 Depth=1
	ldr	x8, [x21, #16]
	add	x20, x8, x22, lsl #4
	ldr	x8, [x20]
	cmp	x8, #0
	cset	w0, eq
	bl	_unlikely
	cbnz	x0, LBB0_10
; %bb.6:                                ;   in Loop: Header=BB0_4 Depth=1
	sub	w28, w28, #1
	ldr	x0, [x20]
	bl	_to_hsdma_vdesc
	mov	x23, x0
	ldr	w0, [x26]
	bl	_MTK_HSDMA_DESC_PLEN_GET
	ldr	w8, [x23]
	sub	w8, w8, w0
	str	w8, [x23]
	mov	x27, x20
	ldr	x0, [x27, #8]!
	bl	_IS_MTK_HSDMA_VDESC_FINISHED
	cbz	x0, LBB0_3
; %bb.7:                                ;   in Loop: Header=BB0_4 Depth=1
	ldr	x8, [x20]
	ldr	w0, [x8, #4]
	bl	_to_hsdma_vchan
	mov	x24, x0
	add	x23, x0, #4
	mov	x0, x23
	bl	_spin_lock
	ldr	x0, [x20]
	bl	_list_del
	ldr	x0, [x20]
	bl	_vchan_cookie_complete
	ldr	w8, [x24]
	cbz	w8, LBB0_2
; %bb.8:                                ;   in Loop: Header=BB0_4 Depth=1
	add	x0, x24, #12
	bl	_list_empty
	cbz	x0, LBB0_2
; %bb.9:                                ;   in Loop: Header=BB0_4 Depth=1
	add	x0, x24, #8
	bl	_complete
	str	wzr, [x24]
	b	LBB0_2
LBB0_10:
	mov	x0, x19
	bl	_hsdma2dev
Lloh9:
	adrp	x1, l_.str@PAGE
Lloh10:
	add	x1, x1, l_.str@PAGEOFF
	bl	_dev_err
LBB0_11:
	bl	_wmb
Lloh11:
	adrp	x8, _MTK_HSDMA_RX_CPU@GOTPAGE
Lloh12:
	ldr	x8, [x8, _MTK_HSDMA_RX_CPU@GOTPAGEOFF]
Lloh13:
	ldr	w1, [x8]
	ldr	w2, [x21, #8]
	mov	x0, x19
	bl	_mtk_dma_write
	mov	x0, x21
	bl	_atomic_read
	ldr	w8, [x24]
	sub	w8, w8, #1
	cmp	w0, w8
	b.lt	LBB0_13
; %bb.12:
Lloh14:
	adrp	x8, _MTK_HSDMA_INT_STATUS@GOTPAGE
Lloh15:
	ldr	x8, [x8, _MTK_HSDMA_INT_STATUS@GOTPAGEOFF]
Lloh16:
	ldr	w1, [x8]
	mov	x0, x19
	ldr	w2, [sp, #12]                   ; 4-byte Folded Reload
	bl	_mtk_dma_write
LBB0_13:
	ldr	w8, [x19]
	cmp	w8, #1
Lloh17:
	adrp	x24, _MTK_HSDMA_INT_RXDONE@GOTPAGE
Lloh18:
	ldr	x24, [x24, _MTK_HSDMA_INT_RXDONE@GOTPAGEOFF]
	b.lt	LBB0_16
; %bb.14:
	mov	x22, #0
	mov	x23, #0
LBB0_15:                                ; =>This Inner Loop Header: Depth=1
	ldr	x8, [x19, #8]
	add	x20, x8, x22
	add	x21, x20, #4
	mov	x0, x21
	bl	_spin_lock
	mov	x0, x19
	mov	x1, x20
	bl	_mtk_hsdma_issue_vchan_pending
	mov	x0, x21
	bl	_spin_unlock
	add	x23, x23, #1
	ldrsw	x8, [x19]
	add	x22, x22, #16
	cmp	x23, x8
	b.lt	LBB0_15
LBB0_16:
Lloh19:
	adrp	x8, _MTK_HSDMA_INT_ENABLE@GOTPAGE
Lloh20:
	ldr	x8, [x8, _MTK_HSDMA_INT_ENABLE@GOTPAGEOFF]
Lloh21:
	ldr	w1, [x8]
	ldr	w2, [x24]
	mov	x0, x19
	ldp	x29, x30, [sp, #96]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #80]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #64]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #48]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #32]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #112
	b	_mtk_dma_set
	.loh AdrpLdrGot	Lloh5, Lloh6
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGot	Lloh7, Lloh8
	.loh AdrpAdd	Lloh9, Lloh10
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh14, Lloh15, Lloh16
	.loh AdrpLdrGot	Lloh17, Lloh18
	.loh AdrpLdrGotLdr	Lloh19, Lloh20, Lloh21
	.cfi_endproc
                                        ; -- End function
	.comm	_MTK_DMA_SIZE,4,2               ; @MTK_DMA_SIZE
	.comm	_MTK_HSDMA_INT_STATUS,4,2       ; @MTK_HSDMA_INT_STATUS
	.comm	_MTK_HSDMA_INT_RXDONE,4,2       ; @MTK_HSDMA_INT_RXDONE
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"cb->vd cannot be null\n"

	.comm	_MTK_HSDMA_RX_CPU,4,2           ; @MTK_HSDMA_RX_CPU
	.comm	_MTK_HSDMA_INT_ENABLE,4,2       ; @MTK_HSDMA_INT_ENABLE
	.no_dead_strip	_mtk_hsdma_free_rooms_in_ring
.subsections_via_symbols
