	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_etnaviv_cmdbuf_init            ## -- Begin function etnaviv_cmdbuf_init
	.p2align	4, 0x90
_etnaviv_cmdbuf_init:                   ## @etnaviv_cmdbuf_init
	.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	%rdi, %r13
	movq	%rdi, 24(%rsi)
	movq	%rsi, -48(%rbp)                 ## 8-byte Spill
	movl	%edx, 16(%rsi)
	movq	_SUBALLOC_GRANULE@GOTPCREL(%rip), %rbx
	movl	(%rbx), %esi
	movl	%edx, %edi
	callq	_ALIGN
	cltd
	idivl	(%rbx)
	movl	%eax, %edi
	callq	_order_base_2
	movl	%eax, %r12d
	leaq	8(%r13), %r15
	.p2align	4, 0x90
LBB0_1:                                 ## =>This Inner Loop Header: Depth=1
	movq	%r15, %rdi
	callq	_mutex_lock
	movl	28(%r13), %edi
	movq	_SUBALLOC_GRANULES@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movl	%r12d, %edx
	callq	_bitmap_find_free_region
	testl	%eax, %eax
	jns	LBB0_4
## %bb.2:                               ##   in Loop: Header=BB0_1 Depth=1
	movq	$0, 16(%r13)
	movq	%r15, %rdi
	callq	_mutex_unlock
	movl	24(%r13), %ebx
	movq	16(%r13), %r14
	movl	$10000, %edi                    ## imm = 0x2710
	callq	_msecs_to_jiffies
	movl	%ebx, %edi
	movq	%r14, %rsi
	movl	%eax, %edx
	callq	_wait_event_interruptible_timeout
	testl	%eax, %eax
	jne	LBB0_1
## %bb.3:
	movl	12(%r13), %edi
	leaq	L_.str(%rip), %rsi
	callq	_dev_err
	movq	_ETIMEDOUT@GOTPCREL(%rip), %rcx
	xorl	%eax, %eax
	subl	(%rcx), %eax
	jmp	LBB0_5
LBB0_4:
	movl	%eax, %ebx
	movq	%r15, %rdi
	callq	_mutex_unlock
	movq	_SUBALLOC_GRANULE@GOTPCREL(%rip), %rax
	movslq	(%rax), %rax
	movslq	%ebx, %rcx
	imulq	%rax, %rcx
	movq	-48(%rbp), %rax                 ## 8-byte Reload
	movl	%ecx, (%rax)
	addq	(%r13), %rcx
	movq	%rcx, 8(%rax)
	xorl	%eax, %eax
LBB0_5:
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_SUBALLOC_GRANULE,4,2           ## @SUBALLOC_GRANULE
	.comm	_SUBALLOC_GRANULES,4,2          ## @SUBALLOC_GRANULES
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Timeout waiting for cmdbuf space\n"

	.comm	_ETIMEDOUT,4,2                  ## @ETIMEDOUT
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_etnaviv_cmdbuf_init            ; -- Begin function etnaviv_cmdbuf_init
	.p2align	2
_etnaviv_cmdbuf_init:                   ; @etnaviv_cmdbuf_init
	.cfi_startproc
; %bb.0:
	stp	x26, x25, [sp, #-80]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 80
	stp	x24, x23, [sp, #16]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #32]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #48]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #64]             ; 16-byte Folded Spill
	add	x29, sp, #64
	.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
	mov	x19, x1
	mov	x20, x0
	str	x0, [x1, #24]
	str	w2, [x1, #16]
Lloh0:
	adrp	x25, _SUBALLOC_GRANULE@GOTPAGE
Lloh1:
	ldr	x25, [x25, _SUBALLOC_GRANULE@GOTPAGEOFF]
	ldr	w1, [x25]
	mov	x0, x2
	bl	_ALIGN
	ldr	w8, [x25]
	sdiv	w0, w0, w8
	bl	_order_base_2
	mov	x22, x0
	add	x21, x20, #8
Lloh2:
	adrp	x26, _SUBALLOC_GRANULES@GOTPAGE
Lloh3:
	ldr	x26, [x26, _SUBALLOC_GRANULES@GOTPAGEOFF]
LBB0_1:                                 ; =>This Inner Loop Header: Depth=1
	mov	x0, x21
	bl	_mutex_lock
	ldr	w0, [x20, #28]
	ldr	w1, [x26]
	mov	x2, x22
	bl	_bitmap_find_free_region
	tbz	w0, #31, LBB0_4
; %bb.2:                                ;   in Loop: Header=BB0_1 Depth=1
	str	xzr, [x20, #16]
	mov	x0, x21
	bl	_mutex_unlock
	ldr	w23, [x20, #24]
	ldr	x24, [x20, #16]
	mov	w0, #10000
	bl	_msecs_to_jiffies
	mov	x2, x0
	mov	x0, x23
	mov	x1, x24
	bl	_wait_event_interruptible_timeout
	cbnz	w0, LBB0_1
; %bb.3:
	ldr	w0, [x20, #12]
Lloh4:
	adrp	x1, l_.str@PAGE
Lloh5:
	add	x1, x1, l_.str@PAGEOFF
	bl	_dev_err
Lloh6:
	adrp	x8, _ETIMEDOUT@GOTPAGE
Lloh7:
	ldr	x8, [x8, _ETIMEDOUT@GOTPAGEOFF]
Lloh8:
	ldr	w8, [x8]
	neg	w0, w8
	b	LBB0_5
LBB0_4:
	mov	x23, x0
	mov	x0, x21
	bl	_mutex_unlock
	mov	w0, #0
	ldrsw	x8, [x25]
	sxtw	x9, w23
	mul	x8, x8, x9
	str	w8, [x19]
	ldr	x9, [x20]
	add	x8, x9, x8
	str	x8, [x19, #8]
LBB0_5:
	ldp	x29, x30, [sp, #64]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #48]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #32]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #16]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp], #80             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpAdd	Lloh4, Lloh5
	.cfi_endproc
                                        ; -- End function
	.comm	_SUBALLOC_GRANULE,4,2           ; @SUBALLOC_GRANULE
	.comm	_SUBALLOC_GRANULES,4,2          ; @SUBALLOC_GRANULES
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Timeout waiting for cmdbuf space\n"

	.comm	_ETIMEDOUT,4,2                  ; @ETIMEDOUT
.subsections_via_symbols
