	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function mtk_cqdma_prep_dma_memcpy
_mtk_cqdma_prep_dma_memcpy:             ## @mtk_cqdma_prep_dma_memcpy
	.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	%r8, -88(%rbp)                  ## 8-byte Spill
	movq	%rcx, %r15
	movq	%rdx, -56(%rbp)                 ## 8-byte Spill
	movq	%rsi, -48(%rbp)                 ## 8-byte Spill
	movq	%rdi, -80(%rbp)                 ## 8-byte Spill
	movq	_MTK_CQDMA_MAX_LEN@GOTPCREL(%rip), %rax
	movq	(%rax), %rsi
	movq	%rcx, %rdi
	callq	_DIV_ROUND_UP
	movq	%rax, %r12
	movq	_GFP_NOWAIT@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	%r12, %rdi
	movl	$8, %esi
	callq	_kcalloc
	testq	%rax, %rax
	je	LBB0_1
## %bb.2:
	movq	%rax, %rbx
	testq	%r12, %r12
	je	LBB0_12
## %bb.3:
	xorl	%r14d, %r14d
	xorl	%r13d, %r13d
	movq	%rbx, -72(%rbp)                 ## 8-byte Spill
	movq	%r12, -64(%rbp)                 ## 8-byte Spill
	jmp	LBB0_4
	.p2align	4, 0x90
LBB0_10:                                ##   in Loop: Header=BB0_4 Depth=1
	movq	%rax, (%r13)
	movq	(%rbx,%r14,8), %rcx
	movq	%r12, 24(%rcx)
	movq	(%rbx), %rdx
LBB0_11:                                ##   in Loop: Header=BB0_4 Depth=1
	movq	%rdx, 40(%rcx)
	addq	%r12, -56(%rbp)                 ## 8-byte Folded Spill
	addq	%r12, -48(%rbp)                 ## 8-byte Folded Spill
	subq	%r12, %r15
	incq	%r14
	movq	%rax, %r13
	movq	-64(%rbp), %r12                 ## 8-byte Reload
	cmpq	%r14, %r12
	movq	-72(%rbp), %rbx                 ## 8-byte Reload
	je	LBB0_12
LBB0_4:                                 ## =>This Inner Loop Header: Depth=1
	movq	_GFP_NOWAIT@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movl	$56, %edi
	callq	_kzalloc
	movq	%rax, (%rbx,%r14,8)
	testq	%rax, %rax
	je	LBB0_5
## %bb.8:                               ##   in Loop: Header=BB0_4 Depth=1
	movq	-80(%rbp), %rdi                 ## 8-byte Reload
	movq	%rdi, 48(%rax)
	movq	_MTK_CQDMA_MAX_LEN@GOTPCREL(%rip), %rax
	movq	(%rax), %r12
	cmpq	%r12, %r15
	cmovbq	%r15, %r12
	movq	(%rbx,%r14,8), %rax
	movq	%r12, (%rax)
	movq	-56(%rbp), %rcx                 ## 8-byte Reload
	movq	%rcx, 8(%rax)
	movq	-48(%rbp), %rcx                 ## 8-byte Reload
	movq	%rcx, 16(%rax)
	callq	_to_virt_chan
	movq	(%rbx,%r14,8), %rsi
	addq	$32, %rsi
	movl	%eax, %edi
	movq	-88(%rbp), %rdx                 ## 8-byte Reload
	callq	_vchan_tx_prep
	movq	$0, (%rax)
	testq	%r14, %r14
	jne	LBB0_10
## %bb.9:                               ##   in Loop: Header=BB0_4 Depth=1
	movq	(%rbx), %rdx
	movq	%r15, 24(%rdx)
	movq	(%rbx,%r14,8), %rcx
	jmp	LBB0_11
LBB0_12:
	movq	(%rbx), %r15
	addq	$32, %r15
	jmp	LBB0_13
LBB0_1:
	xorl	%r15d, %r15d
LBB0_13:
	movq	%r15, %rax
	addq	$56, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_5:
	xorl	%r15d, %r15d
	testq	%r14, %r14
	je	LBB0_13
	.p2align	4, 0x90
LBB0_7:                                 ## =>This Inner Loop Header: Depth=1
	movq	-8(%rbx,%r14,8), %rdi
	decq	%r14
	callq	_kfree
	testq	%r14, %r14
	jne	LBB0_7
	jmp	LBB0_13
	.cfi_endproc
                                        ## -- End function
	.comm	_MTK_CQDMA_MAX_LEN,8,3          ## @MTK_CQDMA_MAX_LEN
	.comm	_GFP_NOWAIT,4,2                 ## @GFP_NOWAIT
	.no_dead_strip	_mtk_cqdma_prep_dma_memcpy
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function mtk_cqdma_prep_dma_memcpy
_mtk_cqdma_prep_dma_memcpy:             ; @mtk_cqdma_prep_dma_memcpy
	.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
	str	x4, [sp, #8]                    ; 8-byte Folded Spill
	mov	x20, x3
	mov	x21, x2
	mov	x22, x1
	mov	x23, x0
Lloh0:
	adrp	x8, _MTK_CQDMA_MAX_LEN@GOTPAGE
Lloh1:
	ldr	x8, [x8, _MTK_CQDMA_MAX_LEN@GOTPAGEOFF]
Lloh2:
	ldr	x1, [x8]
	mov	x0, x3
	bl	_DIV_ROUND_UP
	mov	x24, x0
Lloh3:
	adrp	x8, _GFP_NOWAIT@GOTPAGE
Lloh4:
	ldr	x8, [x8, _GFP_NOWAIT@GOTPAGEOFF]
Lloh5:
	ldr	w2, [x8]
	mov	w1, #8
	bl	_kcalloc
	cbz	x0, LBB0_13
; %bb.1:
	mov	x25, x0
	cbz	x24, LBB0_8
; %bb.2:
	mov	x28, #0
	mov	x26, #0
	b	LBB0_5
LBB0_3:                                 ;   in Loop: Header=BB0_5 Depth=1
	ldr	x9, [x25]
	str	x20, [x9, #24]
	ldr	x8, [x25, x28, lsl #3]
LBB0_4:                                 ;   in Loop: Header=BB0_5 Depth=1
	str	x9, [x8, #40]
	add	x21, x27, x21
	add	x22, x27, x22
	sub	x20, x20, x27
	add	x28, x28, #1
	mov	x26, x0
	cmp	x24, x28
	b.eq	LBB0_8
LBB0_5:                                 ; =>This Inner Loop Header: Depth=1
Lloh6:
	adrp	x8, _GFP_NOWAIT@GOTPAGE
Lloh7:
	ldr	x8, [x8, _GFP_NOWAIT@GOTPAGEOFF]
Lloh8:
	ldr	w1, [x8]
	mov	w0, #56
	bl	_kzalloc
	str	x0, [x25, x28, lsl #3]
	cbz	x0, LBB0_9
; %bb.6:                                ;   in Loop: Header=BB0_5 Depth=1
	str	x23, [x0, #48]
Lloh9:
	adrp	x8, _MTK_CQDMA_MAX_LEN@GOTPAGE
Lloh10:
	ldr	x8, [x8, _MTK_CQDMA_MAX_LEN@GOTPAGEOFF]
Lloh11:
	ldr	x8, [x8]
	cmp	x20, x8
	csel	x27, x20, x8, lo
	lsl	x19, x28, #3
	ldr	x8, [x25, x19]
	stp	x27, x21, [x8]
	str	x22, [x8, #16]
	mov	x0, x23
	bl	_to_virt_chan
	ldr	x8, [x25, x19]
	add	x1, x8, #32
	ldr	x2, [sp, #8]                    ; 8-byte Folded Reload
	bl	_vchan_tx_prep
	str	xzr, [x0]
	cbz	x28, LBB0_3
; %bb.7:                                ;   in Loop: Header=BB0_5 Depth=1
	str	x0, [x26]
	ldr	x8, [x25, x28, lsl #3]
	str	x27, [x8, #24]
	ldr	x9, [x25]
	b	LBB0_4
LBB0_8:
	ldr	x8, [x25]
	add	x0, x8, #32
	b	LBB0_13
LBB0_9:
	cbz	x28, LBB0_12
; %bb.10:
	sub	x19, x25, #8
LBB0_11:                                ; =>This Inner Loop Header: Depth=1
	sub	x20, x28, #1
	ldr	x0, [x19, x28, lsl #3]
	bl	_kfree
	mov	x28, x20
	cbnz	x20, LBB0_11
LBB0_12:
	mov	x0, #0
LBB0_13:
	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
	ret
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.cfi_endproc
                                        ; -- End function
	.comm	_MTK_CQDMA_MAX_LEN,8,3          ; @MTK_CQDMA_MAX_LEN
	.comm	_GFP_NOWAIT,4,2                 ; @GFP_NOWAIT
	.no_dead_strip	_mtk_cqdma_prep_dma_memcpy
.subsections_via_symbols
