	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function alloc_surface
_alloc_surface:                         ## @alloc_surface
	.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	%rbx
	pushq	%rax
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	(%rdi), %r15d
	movl	4(%rdi), %r11d
	leal	(%r11,%r15), %r9d
	decl	%r9d
	cmpl	%r9d, %r15d
	jge	LBB0_30
## %bb.1:
	movq	8(%rdi), %r8
	testq	%r8, %r8
	je	LBB0_30
## %bb.2:
	testl	%r11d, %r11d
	je	LBB0_30
## %bb.3:
	movq	_RADEON_SURF_ADDRESS_FIXED_MASK@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	movl	%r9d, %eax
	notl	%eax
	testl	%eax, %ecx
	jne	LBB0_30
## %bb.4:
	andl	%r15d, %ecx
	jne	LBB0_30
## %bb.5:
	movq	_RADEON_MAX_SURFACES@GOTPCREL(%rip), %rax
	movl	(%rax), %r10d
	testl	%r10d, %r10d
	jle	LBB0_15
## %bb.6:
	movq	(%rsi), %rdi
	leaq	(,%r10,8), %rax
	leaq	(%rax,%rax,2), %rbx
	xorl	%ecx, %ecx
	jmp	LBB0_9
	.p2align	4, 0x90
LBB0_7:                                 ##   in Loop: Header=BB0_9 Depth=1
	cmpl	%eax, %r9d
	jg	LBB0_30
LBB0_8:                                 ##   in Loop: Header=BB0_9 Depth=1
	addq	$24, %rcx
	cmpq	%rcx, %rbx
	je	LBB0_12
LBB0_9:                                 ## =>This Inner Loop Header: Depth=1
	cmpl	$0, (%rdi,%rcx)
	je	LBB0_8
## %bb.10:                              ##   in Loop: Header=BB0_9 Depth=1
	movl	4(%rdi,%rcx), %eax
	cmpl	%eax, %r15d
	jl	LBB0_7
## %bb.11:                              ##   in Loop: Header=BB0_9 Depth=1
	cmpl	8(%rdi,%rcx), %r15d
	jge	LBB0_8
	jmp	LBB0_30
LBB0_12:
	leal	(%r10,%r10), %edi
	movq	8(%rsi), %rbx
	cmpl	$2, %edi
	movl	$1, %r14d
	cmovgel	%edi, %r14d
	addq	$24, %rbx
	xorl	%ecx, %ecx
	.p2align	4, 0x90
LBB0_13:                                ## =>This Inner Loop Header: Depth=1
	cmpq	$0, (%rbx)
	je	LBB0_17
## %bb.14:                              ##   in Loop: Header=BB0_13 Depth=1
	incq	%rcx
	addq	$32, %rbx
	cmpq	%rcx, %r14
	jne	LBB0_13
	jmp	LBB0_16
LBB0_15:
	leal	(%r10,%r10), %edi
	xorl	%r14d, %r14d
LBB0_16:
	cmpl	%edi, %r14d
	jne	LBB0_18
	jmp	LBB0_30
LBB0_17:
	movl	%ecx, %r14d
	cmpl	%edi, %r14d
	je	LBB0_30
LBB0_18:
	testl	%r10d, %r10d
	jle	LBB0_30
## %bb.19:
	addl	%r15d, %r11d
	movq	(%rsi), %rbx
	xorl	%edi, %edi
	jmp	LBB0_21
	.p2align	4, 0x90
LBB0_20:                                ##   in Loop: Header=BB0_21 Depth=1
	incq	%rdi
	addq	$24, %rbx
	cmpq	%rdi, %r10
	je	LBB0_26
LBB0_21:                                ## =>This Inner Loop Header: Depth=1
	cmpl	$1, (%rbx)
	jne	LBB0_20
## %bb.22:                              ##   in Loop: Header=BB0_21 Depth=1
	cmpq	16(%rbx), %r8
	jne	LBB0_20
## %bb.23:                              ##   in Loop: Header=BB0_21 Depth=1
	cmpl	4(%rbx), %r11d
	je	LBB0_33
## %bb.24:                              ##   in Loop: Header=BB0_21 Depth=1
	movl	8(%rbx), %eax
	incl	%eax
	cmpl	%eax, %r15d
	jne	LBB0_20
## %bb.25:
	movq	8(%rsi), %rax
	movl	%r14d, %ecx
	shlq	$5, %rcx
	movl	%edi, (%rax,%rcx)
	movl	%r15d, 4(%rax,%rcx)
	movl	%r9d, 8(%rax,%rcx)
	movq	%r8, 16(%rax,%rcx)
	movq	%rdx, 24(%rax,%rcx)
	movl	$2, (%rbx)
	movl	%r9d, 8(%rbx)
	jmp	LBB0_34
LBB0_26:
	testl	%r10d, %r10d
	jle	LBB0_30
## %bb.27:
	movq	(%rsi), %rcx
	xorl	%edi, %edi
	.p2align	4, 0x90
LBB0_28:                                ## =>This Inner Loop Header: Depth=1
	cmpl	$0, (%rcx)
	je	LBB0_32
## %bb.29:                              ##   in Loop: Header=BB0_28 Depth=1
	incq	%rdi
	addq	$24, %rcx
	cmpq	%rdi, %r10
	jne	LBB0_28
LBB0_30:
	movl	$-1, %r14d
LBB0_31:
	movl	%r14d, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_32:
	movq	8(%rsi), %rax
	movl	%r14d, %ebx
	shlq	$5, %rbx
	movl	%edi, (%rax,%rbx)
	movl	%r15d, 4(%rax,%rbx)
	movl	%r9d, 8(%rax,%rbx)
	movq	%r8, 16(%rax,%rbx)
	movq	%rdx, 24(%rax,%rbx)
	movl	$1, (%rcx)
	movl	%r15d, 4(%rcx)
	movl	%r9d, 8(%rcx)
	movq	%r8, 16(%rcx)
	jmp	LBB0_34
LBB0_33:
	movq	8(%rsi), %rax
	movl	%r14d, %ecx
	shlq	$5, %rcx
	movl	%edi, (%rax,%rcx)
	movl	%r15d, 4(%rax,%rcx)
	movl	%r9d, 8(%rax,%rcx)
	movq	%r8, 16(%rax,%rcx)
	movq	%rdx, 24(%rax,%rcx)
	movl	$2, (%rbx)
	movl	%r15d, 4(%rbx)
LBB0_34:
                                        ## kill: def $edi killed $edi killed $rdi
	callq	_radeon_apply_surface_regs
	jmp	LBB0_31
	.cfi_endproc
                                        ## -- End function
	.comm	_RADEON_SURF_ADDRESS_FIXED_MASK,4,2 ## @RADEON_SURF_ADDRESS_FIXED_MASK
	.comm	_RADEON_MAX_SURFACES,4,2        ## @RADEON_MAX_SURFACES
	.no_dead_strip	_alloc_surface
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function alloc_surface
_alloc_surface:                         ; @alloc_surface
	.cfi_startproc
; %bb.0:
	stp	x20, x19, [sp, #-32]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 32
	stp	x29, x30, [sp, #16]             ; 16-byte Folded Spill
	add	x29, sp, #16
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
	.cfi_offset w19, -24
	.cfi_offset w20, -32
	ldp	w8, w11, [x0]
	add	w12, w11, w8
	sub	w9, w12, #1
	cmp	w8, w9
	b.ge	LBB0_3
; %bb.1:
	ldr	x10, [x0, #8]
	cmp	x10, #0
	ccmp	w11, #0, #4, ne
	b.eq	LBB0_3
; %bb.2:
Lloh0:
	adrp	x11, _RADEON_SURF_ADDRESS_FIXED_MASK@GOTPAGE
Lloh1:
	ldr	x11, [x11, _RADEON_SURF_ADDRESS_FIXED_MASK@GOTPAGEOFF]
Lloh2:
	ldr	w11, [x11]
	bic	w13, w11, w9
	and	w11, w11, w8
	cmp	w13, #0
	ccmp	w11, #0, #0, eq
	b.eq	LBB0_5
LBB0_3:
	mov	w0, #-1
LBB0_4:
	ldp	x29, x30, [sp, #16]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp], #32             ; 16-byte Folded Reload
	ret
LBB0_5:
Lloh3:
	adrp	x11, _RADEON_MAX_SURFACES@GOTPAGE
Lloh4:
	ldr	x11, [x11, _RADEON_MAX_SURFACES@GOTPAGEOFF]
Lloh5:
	ldr	w11, [x11]
	cmp	w11, #0
	b.le	LBB0_15
; %bb.6:
	ldr	x13, [x1]
	add	x13, x13, #4
	mov	x14, x11
	b	LBB0_9
LBB0_7:                                 ;   in Loop: Header=BB0_9 Depth=1
	ldr	w15, [x13, #4]
	cmp	w8, w15
	b.lt	LBB0_3
LBB0_8:                                 ;   in Loop: Header=BB0_9 Depth=1
	add	x13, x13, #24
	subs	x14, x14, #1
	b.eq	LBB0_12
LBB0_9:                                 ; =>This Inner Loop Header: Depth=1
	ldur	w15, [x13, #-4]
	cbz	w15, LBB0_8
; %bb.10:                               ;   in Loop: Header=BB0_9 Depth=1
	ldr	w15, [x13]
	cmp	w8, w15
	b.ge	LBB0_7
; %bb.11:                               ;   in Loop: Header=BB0_9 Depth=1
	cmp	w9, w15
	b.le	LBB0_8
	b	LBB0_3
LBB0_12:
	lsl	w13, w11, #1
	ldr	x15, [x1, #8]
	cmp	w13, #1
	csinc	w19, w13, wzr, gt
	add	x15, x15, #24
LBB0_13:                                ; =>This Inner Loop Header: Depth=1
	ldr	x16, [x15]
	cbz	x16, LBB0_16
; %bb.14:                               ;   in Loop: Header=BB0_13 Depth=1
	add	x14, x14, #1
	add	x15, x15, #32
	cmp	x19, x14
	b.ne	LBB0_13
	b	LBB0_17
LBB0_15:
	mov	w19, #0
	lsl	w13, w11, #1
	b	LBB0_17
LBB0_16:
	mov	x19, x14
LBB0_17:
	mov	w0, #-1
	cmp	w19, w13
	b.eq	LBB0_4
; %bb.18:
	cmp	w11, #1
	b.lt	LBB0_4
; %bb.19:
	mov	x0, #0
	ldr	x13, [x1]
	add	x13, x13, #8
	b	LBB0_21
LBB0_20:                                ;   in Loop: Header=BB0_21 Depth=1
	add	x0, x0, #1
	add	x13, x13, #24
	cmp	x11, x0
	b.eq	LBB0_26
LBB0_21:                                ; =>This Inner Loop Header: Depth=1
	ldur	w14, [x13, #-8]
	cmp	w14, #1
	b.ne	LBB0_20
; %bb.22:                               ;   in Loop: Header=BB0_21 Depth=1
	ldr	x14, [x13, #8]
	cmp	x10, x14
	b.ne	LBB0_20
; %bb.23:                               ;   in Loop: Header=BB0_21 Depth=1
	ldur	w14, [x13, #-4]
	cmp	w12, w14
	b.eq	LBB0_31
; %bb.24:                               ;   in Loop: Header=BB0_21 Depth=1
	ldr	w14, [x13]
	add	w14, w14, #1
	cmp	w8, w14
	b.ne	LBB0_20
; %bb.25:
	ldr	x11, [x1, #8]
	mov	w12, w19
	add	x11, x11, x12, lsl #5
	stp	w0, w8, [x11]
	str	w9, [x11, #8]
	stp	x10, x2, [x11, #16]
	mov	w8, #2
	stur	w8, [x13, #-8]
	str	w9, [x13]
	b	LBB0_32
LBB0_26:
	cmp	w11, #1
	b.lt	LBB0_3
; %bb.27:
	mov	x12, #0
	ldr	x13, [x1]
	mov	w0, #-1
LBB0_28:                                ; =>This Inner Loop Header: Depth=1
	ldr	w14, [x13]
	cbz	w14, LBB0_30
; %bb.29:                               ;   in Loop: Header=BB0_28 Depth=1
	add	x12, x12, #1
	add	x13, x13, #24
	cmp	x11, x12
	b.ne	LBB0_28
	b	LBB0_4
LBB0_30:
	ldr	x11, [x1, #8]
	mov	w14, w19
	add	x11, x11, x14, lsl #5
	stp	w12, w8, [x11]
	str	w9, [x11, #8]
	stp	x10, x2, [x11, #16]
	mov	w11, #1
	stp	w11, w8, [x13]
	str	w9, [x13, #8]
	str	x10, [x13, #16]
	mov	x0, x12
	b	LBB0_32
LBB0_31:
	ldr	x11, [x1, #8]
	mov	w12, w19
	add	x11, x11, x12, lsl #5
	stp	w0, w8, [x11]
	str	w9, [x11, #8]
	stp	x10, x2, [x11, #16]
	mov	w9, #2
	stp	w9, w8, [x13, #-8]
LBB0_32:
                                        ; kill: def $w0 killed $w0 killed $x0
	bl	_radeon_apply_surface_regs
	mov	x0, x19
	b	LBB0_4
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.cfi_endproc
                                        ; -- End function
	.comm	_RADEON_SURF_ADDRESS_FIXED_MASK,4,2 ; @RADEON_SURF_ADDRESS_FIXED_MASK
	.comm	_RADEON_MAX_SURFACES,4,2        ; @RADEON_MAX_SURFACES
	.no_dead_strip	_alloc_surface
.subsections_via_symbols
