	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_radeon_ring_alloc              ## -- Begin function radeon_ring_alloc
	.p2align	4, 0x90
_radeon_ring_alloc:                     ## @radeon_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	%r12
	pushq	%rbx
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	(%rsi), %eax
	leal	3(%rax), %ecx
	testl	%eax, %eax
	cmovnsl	%eax, %ecx
	sarl	$2, %ecx
	cmpl	%edx, %ecx
	jae	LBB0_2
## %bb.1:
	movq	_ENOMEM@GOTPCREL(%rip), %rcx
	xorl	%eax, %eax
	subl	(%rcx), %eax
	jmp	LBB0_7
LBB0_2:
	movl	%edx, %r15d
	movq	%rsi, %rbx
	movq	%rdi, %r14
	callq	_radeon_ring_free_size
	movl	4(%rbx), %r12d
	addl	%r12d, %r15d
	notl	%r12d
	andl	%r15d, %r12d
	.p2align	4, 0x90
LBB0_3:                                 ## =>This Inner Loop Header: Depth=1
	movl	8(%rbx), %eax
	decl	%eax
	cmpl	%eax, %r12d
	jbe	LBB0_6
## %bb.4:                               ##   in Loop: Header=BB0_3 Depth=1
	movq	%r14, %rdi
	movq	%rbx, %rsi
	callq	_radeon_ring_free_size
	cmpl	8(%rbx), %r12d
	jb	LBB0_6
## %bb.5:                               ##   in Loop: Header=BB0_3 Depth=1
	movl	24(%rbx), %esi
	movq	%r14, %rdi
	callq	_radeon_fence_wait_next
	testl	%eax, %eax
	je	LBB0_3
	jmp	LBB0_7
LBB0_6:
	movl	%r12d, 12(%rbx)
	movl	16(%rbx), %eax
	movl	%eax, 20(%rbx)
	xorl	%eax, %eax
LBB0_7:
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_ENOMEM,4,2                     ## @ENOMEM
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_radeon_ring_alloc              ; -- Begin function radeon_ring_alloc
	.p2align	2
_radeon_ring_alloc:                     ; @radeon_ring_alloc
	.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
	ldr	w8, [x1]
	add	w9, w8, #3
	cmp	w8, #0
	csel	w8, w9, w8, lt
	cmp	w2, w8, asr #2
	b.ls	LBB0_2
; %bb.1:
Lloh0:
	adrp	x8, _ENOMEM@GOTPAGE
Lloh1:
	ldr	x8, [x8, _ENOMEM@GOTPAGEOFF]
Lloh2:
	ldr	w8, [x8]
	neg	w0, w8
	b	LBB0_7
LBB0_2:
	mov	x21, x2
	mov	x19, x1
	mov	x20, x0
	bl	_radeon_ring_free_size
	ldr	w8, [x19, #4]
	add	w9, w8, w21
	bic	w21, w9, w8
LBB0_3:                                 ; =>This Inner Loop Header: Depth=1
	ldr	w8, [x19, #8]
	sub	w8, w8, #1
	cmp	w21, w8
	b.ls	LBB0_6
; %bb.4:                                ;   in Loop: Header=BB0_3 Depth=1
	mov	x0, x20
	mov	x1, x19
	bl	_radeon_ring_free_size
	ldr	w8, [x19, #8]
	cmp	w21, w8
	b.lo	LBB0_6
; %bb.5:                                ;   in Loop: Header=BB0_3 Depth=1
	ldr	w1, [x19, #24]
	mov	x0, x20
	bl	_radeon_fence_wait_next
	cbz	w0, LBB0_3
	b	LBB0_7
LBB0_6:
	mov	w0, #0
	str	w21, [x19, #12]
	ldr	w8, [x19, #16]
	str	w8, [x19, #20]
LBB0_7:
	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
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.cfi_endproc
                                        ; -- End function
	.comm	_ENOMEM,4,2                     ; @ENOMEM
.subsections_via_symbols
