	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function mtk_desc_ring_alloc
_mtk_desc_ring_alloc:                   ## @mtk_desc_ring_alloc
	.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	_MTK_RING_MAX@GOTPCREL(%rip), %rax
	cmpl	$0, (%rax)
	jle	LBB0_11
## %bb.1:
	movq	%rdi, %r15
	movq	8(%rdi), %r12
	movq	_ENOMEM@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, -44(%rbp)                 ## 4-byte Spill
	xorl	%ebx, %ebx
	movq	_GFP_KERNEL@GOTPCREL(%rip), %r13
	xorl	%r14d, %r14d
	.p2align	4, 0x90
LBB0_2:                                 ## =>This Inner Loop Header: Depth=1
	movl	(%r13), %esi
	movl	$48, %edi
	callq	_kzalloc
	movq	%rax, (%r12,%r14,8)
	testq	%rax, %rax
	je	LBB0_7
## %bb.3:                               ##   in Loop: Header=BB0_2 Depth=1
	movl	(%r15), %edi
	movq	_MTK_DESC_RING_SZ@GOTPCREL(%rip), %rcx
	movl	(%rcx), %esi
	movl	(%r13), %ecx
	movq	%rax, %rdx
	callq	_dma_alloc_coherent
	movq	(%r12,%r14,8), %rcx
	movq	%rax, 8(%rcx)
	movq	(%r12,%r14,8), %rdx
	cmpq	$0, 8(%rdx)
	je	LBB0_7
## %bb.4:                               ##   in Loop: Header=BB0_2 Depth=1
	movl	(%r15), %edi
	movq	_MTK_DESC_RING_SZ@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	addq	$16, %rdx
	movl	(%r13), %ecx
	callq	_dma_alloc_coherent
	movq	(%r12,%r14,8), %rcx
	movq	%rax, 24(%rcx)
	movq	(%r12,%r14,8), %rax
	cmpq	$0, 24(%rax)
	je	LBB0_7
## %bb.5:                               ##   in Loop: Header=BB0_2 Depth=1
	movq	8(%rax), %rcx
	movq	%rcx, 40(%rax)
	movq	(%r12,%r14,8), %rax
	movq	24(%rax), %rcx
	movq	%rcx, 32(%rax)
	incq	%r14
	movq	_MTK_RING_MAX@GOTPCREL(%rip), %rax
	movslq	(%rax), %rax
	addq	$-8, %rbx
	cmpq	%rax, %r14
	jl	LBB0_2
LBB0_11:
	xorl	%eax, %eax
	jmp	LBB0_12
LBB0_7:
	testl	%r14d, %r14d
	je	LBB0_10
## %bb.8:
	negq	%rbx
	movq	_MTK_DESC_RING_SZ@GOTPCREL(%rip), %r14
	.p2align	4, 0x90
LBB0_9:                                 ## =>This Inner Loop Header: Depth=1
	movl	(%r15), %edi
	movl	(%r14), %esi
	movq	-8(%r12,%rbx), %rax
	movq	24(%rax), %rdx
	movl	16(%rax), %ecx
	callq	_dma_free_coherent
	movl	(%r15), %edi
	movl	(%r14), %esi
	movq	-8(%r12,%rbx), %rax
	movq	8(%rax), %rdx
	movl	(%rax), %ecx
	callq	_dma_free_coherent
	movq	-8(%r12,%rbx), %rdi
	callq	_kfree
	addq	$-8, %rbx
	jne	LBB0_9
LBB0_10:
	movl	-44(%rbp), %eax                 ## 4-byte Reload
LBB0_12:
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_ENOMEM,4,2                     ## @ENOMEM
	.comm	_MTK_RING_MAX,4,2               ## @MTK_RING_MAX
	.comm	_GFP_KERNEL,4,2                 ## @GFP_KERNEL
	.comm	_MTK_DESC_RING_SZ,4,2           ## @MTK_DESC_RING_SZ
	.no_dead_strip	_mtk_desc_ring_alloc
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function mtk_desc_ring_alloc
_mtk_desc_ring_alloc:                   ; @mtk_desc_ring_alloc
	.cfi_startproc
; %bb.0:
	stp	x28, x27, [sp, #-96]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 96
	stp	x26, x25, [sp, #16]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #32]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #48]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #64]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #80]             ; 16-byte Folded Spill
	add	x29, sp, #80
	.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
Lloh0:
	adrp	x23, _MTK_RING_MAX@GOTPAGE
Lloh1:
	ldr	x23, [x23, _MTK_RING_MAX@GOTPAGEOFF]
	ldr	w8, [x23]
	cmp	w8, #1
	b.lt	LBB0_6
; %bb.1:
	mov	x20, x0
	mov	x22, #0
	mov	x25, #0
Lloh2:
	adrp	x8, _ENOMEM@GOTPAGE
Lloh3:
	ldr	x8, [x8, _ENOMEM@GOTPAGEOFF]
	ldr	x24, [x0, #8]
Lloh4:
	ldr	w19, [x8]
Lloh5:
	adrp	x26, _GFP_KERNEL@GOTPAGE
Lloh6:
	ldr	x26, [x26, _GFP_KERNEL@GOTPAGEOFF]
Lloh7:
	adrp	x21, _MTK_DESC_RING_SZ@GOTPAGE
Lloh8:
	ldr	x21, [x21, _MTK_DESC_RING_SZ@GOTPAGEOFF]
LBB0_2:                                 ; =>This Inner Loop Header: Depth=1
	ldr	w1, [x26]
	mov	w0, #48
	bl	_kzalloc
	str	x0, [x24, x25, lsl #3]
	cbz	x0, LBB0_7
; %bb.3:                                ;   in Loop: Header=BB0_2 Depth=1
	mov	x2, x0
	ldr	w0, [x20]
	ldr	w1, [x21]
	ldr	w3, [x26]
	bl	_dma_alloc_coherent
	lsl	x27, x25, #3
	ldr	x8, [x24, x27]
	str	x0, [x8, #8]
	ldr	x8, [x24, x27]
	ldr	x9, [x8, #8]
	cbz	x9, LBB0_7
; %bb.4:                                ;   in Loop: Header=BB0_2 Depth=1
	ldr	w0, [x20]
	ldr	w1, [x21]
	add	x2, x8, #16
	ldr	w3, [x26]
	bl	_dma_alloc_coherent
	ldr	x8, [x24, x27]
	str	x0, [x8, #24]
	ldr	x8, [x24, x27]
	ldr	x9, [x8, #24]
	cbz	x9, LBB0_7
; %bb.5:                                ;   in Loop: Header=BB0_2 Depth=1
	ldr	x9, [x8, #8]
	str	x9, [x8, #40]
	ldr	x8, [x24, x25, lsl #3]
	ldr	x9, [x8, #24]
	str	x9, [x8, #32]
	add	x25, x25, #1
	ldrsw	x8, [x23]
	sub	x22, x22, #8
	cmp	x25, x8
	b.lt	LBB0_2
LBB0_6:
	mov	w19, #0
	b	LBB0_10
LBB0_7:
	cbz	w25, LBB0_10
; %bb.8:
	neg	x22, x22
	sub	x23, x24, #8
LBB0_9:                                 ; =>This Inner Loop Header: Depth=1
	ldr	w0, [x20]
	ldr	w1, [x21]
	ldr	x8, [x23, x22]
	ldr	x2, [x8, #24]
	ldr	w3, [x8, #16]
	bl	_dma_free_coherent
	ldr	w0, [x20]
	ldr	w1, [x21]
	ldr	x8, [x23, x22]
	ldr	x2, [x8, #8]
	ldr	w3, [x8]
	bl	_dma_free_coherent
	ldr	x0, [x23, x22]
	bl	_kfree
	subs	x22, x22, #8
	b.ne	LBB0_9
LBB0_10:
	mov	x0, x19
	ldp	x29, x30, [sp, #80]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #64]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #48]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #32]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #16]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp], #96             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGot	Lloh7, Lloh8
	.loh AdrpLdrGot	Lloh5, Lloh6
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.cfi_endproc
                                        ; -- End function
	.comm	_ENOMEM,4,2                     ; @ENOMEM
	.comm	_MTK_RING_MAX,4,2               ; @MTK_RING_MAX
	.comm	_GFP_KERNEL,4,2                 ; @GFP_KERNEL
	.comm	_MTK_DESC_RING_SZ,4,2           ; @MTK_DESC_RING_SZ
	.no_dead_strip	_mtk_desc_ring_alloc
.subsections_via_symbols
