	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function free_surface
_free_surface:                          ## @free_surface
	.cfi_startproc
## %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	movq	_RADEON_MAX_SURFACES@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	testl	%ecx, %ecx
	jle	LBB0_13
## %bb.1:
	addl	%ecx, %ecx
	movq	8(%rsi), %r8
	cmpl	$2, %ecx
	movl	$1, %r9d
	cmovgel	%ecx, %r9d
	shlq	$5, %r9
	xorl	%ecx, %ecx
	jmp	LBB0_2
	.p2align	4, 0x90
LBB0_12:                                ##   in Loop: Header=BB0_2 Depth=1
	addq	$32, %rcx
	cmpq	%rcx, %r9
	je	LBB0_13
LBB0_2:                                 ## =>This Inner Loop Header: Depth=1
	movq	24(%r8,%rcx), %rax
	testq	%rax, %rax
	je	LBB0_12
## %bb.3:                               ##   in Loop: Header=BB0_2 Depth=1
	cmpl	%edx, (%r8,%rcx)
	jne	LBB0_12
## %bb.4:                               ##   in Loop: Header=BB0_2 Depth=1
	cmpq	%rdi, %rax
	jne	LBB0_12
## %bb.5:
	movq	(%rsi), %r9
	movq	8(%r8,%rcx), %rdi
	leaq	(%rdi,%rdi,2), %r11
	movl	16(%r8,%rcx), %r10d
	cmpl	%edx, (%r9,%r11,8)
	je	LBB0_6
## %bb.7:
	cmpl	%r10d, 4(%r9,%r11,8)
	je	LBB0_8
LBB0_9:
	decq	8(%r9,%r11,8)
	je	LBB0_10
LBB0_11:
	movq	$0, 24(%r8,%rcx)
	callq	_radeon_apply_surface_regs
	xorl	%eax, %eax
	popq	%rbp
	retq
LBB0_13:
	movl	$1, %eax
	popq	%rbp
	retq
LBB0_6:
	leaq	(%r9,%r11,8), %rax
	movl	%r10d, (%rax)
	cmpl	%r10d, 4(%r9,%r11,8)
	jne	LBB0_9
LBB0_8:
	leaq	(%r9,%r11,8), %rax
	addq	$4, %rax
	movl	%edx, (%rax)
	decq	8(%r9,%r11,8)
	jne	LBB0_11
LBB0_10:
	movq	$0, 16(%r9,%r11,8)
	jmp	LBB0_11
	.cfi_endproc
                                        ## -- End function
	.comm	_RADEON_MAX_SURFACES,4,2        ## @RADEON_MAX_SURFACES
	.no_dead_strip	_free_surface
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function free_surface
_free_surface:                          ; @free_surface
	.cfi_startproc
; %bb.0:
	stp	x29, x30, [sp, #-16]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 16
	mov	x29, sp
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
Lloh0:
	adrp	x8, _RADEON_MAX_SURFACES@GOTPAGE
Lloh1:
	ldr	x8, [x8, _RADEON_MAX_SURFACES@GOTPAGEOFF]
Lloh2:
	ldr	w8, [x8]
	cmp	w8, #1
	b.lt	LBB0_12
; %bb.1:
	lsl	w8, w8, #1
	ldr	x10, [x1, #8]
	cmp	w8, #1
	csinc	w9, w8, wzr, gt
	add	x8, x10, #24
	b	LBB0_3
LBB0_2:                                 ;   in Loop: Header=BB0_3 Depth=1
	add	x8, x8, #32
	subs	x9, x9, #1
	b.eq	LBB0_12
LBB0_3:                                 ; =>This Inner Loop Header: Depth=1
	ldr	x10, [x8]
	cbz	x10, LBB0_2
; %bb.4:                                ;   in Loop: Header=BB0_3 Depth=1
	ldur	w11, [x8, #-24]
	cmp	w11, w2
	ccmp	x10, x0, #0, eq
	b.ne	LBB0_2
; %bb.5:
	ldr	x9, [x1]
	ldur	x0, [x8, #-16]
	mov	w10, #24
	madd	x11, x0, x10, x9
	ldr	w12, [x11]
	ldur	w10, [x8, #-8]
	cmp	w12, w2
	b.ne	LBB0_7
; %bb.6:
	str	w10, [x11]
LBB0_7:
	mov	w11, #24
	madd	x11, x0, x11, x9
	ldr	w12, [x11, #4]!
	cmp	w12, w10
	b.ne	LBB0_9
; %bb.8:
	str	w2, [x11]
LBB0_9:
	mov	w10, #24
	madd	x10, x0, x10, x9
	ldr	x11, [x10, #8]
	subs	x11, x11, #1
	str	x11, [x10, #8]
	b.ne	LBB0_11
; %bb.10:
	mov	w10, #24
	madd	x9, x0, x10, x9
	str	xzr, [x9, #16]
LBB0_11:
	str	xzr, [x8]
	bl	_radeon_apply_surface_regs
	mov	w0, #0
	ldp	x29, x30, [sp], #16             ; 16-byte Folded Reload
	ret
LBB0_12:
	mov	w0, #1
	ldp	x29, x30, [sp], #16             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.cfi_endproc
                                        ; -- End function
	.comm	_RADEON_MAX_SURFACES,4,2        ; @RADEON_MAX_SURFACES
	.no_dead_strip	_free_surface
.subsections_via_symbols
