	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function allocate_hqd
_allocate_hqd:                          ## @allocate_hqd
	.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
	movq	%rsi, %r15
	movq	%rdi, %r14
	movl	(%rdi), %ebx
	callq	_get_pipes_per_mec
	testl	%eax, %eax
	jle	LBB0_5
## %bb.1:
	xorl	%r12d, %r12d
	jmp	LBB0_2
	.p2align	4, 0x90
LBB0_4:                                 ##   in Loop: Header=BB0_2 Depth=1
	incl	%ebx
	movq	%r14, %rdi
	callq	_get_pipes_per_mec
	movl	%eax, %ecx
	movl	%ebx, %eax
	cltd
	idivl	%ecx
	incl	%r12d
	movl	%edx, %ebx
	movq	%r14, %rdi
	callq	_get_pipes_per_mec
	cmpl	%eax, %r12d
	jge	LBB0_5
LBB0_2:                                 ## =>This Inner Loop Header: Depth=1
	movq	%r14, %rdi
	xorl	%esi, %esi
	movl	%ebx, %edx
	callq	_is_pipe_enabled
	testl	%eax, %eax
	je	LBB0_4
## %bb.3:                               ##   in Loop: Header=BB0_2 Depth=1
	movq	8(%r14), %rax
	movslq	%ebx, %rcx
	movl	(%rax,%rcx,4), %esi
	testl	%esi, %esi
	je	LBB0_4
## %bb.6:
	bsfl	%esi, %edx
	btrl	%edx, %esi
	movl	%esi, (%rax,%rcx,4)
	movl	%ebx, (%r15)
	movl	%edx, 4(%r15)
	leaq	L_.str(%rip), %rdi
	movl	%ebx, %esi
	callq	_pr_debug
	incl	%ebx
	movq	%r14, %rdi
	callq	_get_pipes_per_mec
	movl	%eax, %ecx
	movl	%ebx, %eax
	cltd
	idivl	%ecx
	movl	%edx, (%r14)
	xorl	%eax, %eax
	jmp	LBB0_7
LBB0_5:
	movq	_EBUSY@GOTPCREL(%rip), %rcx
	xorl	%eax, %eax
	subl	(%rcx), %eax
LBB0_7:
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_EBUSY,4,2                      ## @EBUSY
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"hqd slot - pipe %d, queue %d\n"

	.no_dead_strip	_allocate_hqd
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function allocate_hqd
_allocate_hqd:                          ; @allocate_hqd
	.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
	mov	x20, x1
	mov	x19, x0
	ldr	w21, [x0]
	bl	_get_pipes_per_mec
	cmp	w0, #1
	b.lt	LBB0_6
; %bb.1:
	mov	w22, #0
	b	LBB0_3
LBB0_2:                                 ;   in Loop: Header=BB0_3 Depth=1
	add	w21, w21, #1
	mov	x0, x19
	bl	_get_pipes_per_mec
	sdiv	w8, w21, w0
	msub	w21, w8, w0, w21
	add	w22, w22, #1
	mov	x0, x19
	bl	_get_pipes_per_mec
	cmp	w22, w0
	b.ge	LBB0_6
LBB0_3:                                 ; =>This Inner Loop Header: Depth=1
	mov	x0, x19
	mov	w1, #0
	mov	x2, x21
	bl	_is_pipe_enabled
	cbz	w0, LBB0_2
; %bb.4:                                ;   in Loop: Header=BB0_3 Depth=1
	ldr	x8, [x19, #8]
	ldr	w9, [x8, w21, sxtw #2]
	cbz	w9, LBB0_2
; %bb.5:
	sxtw	x10, w21
	rbit	w11, w9
	clz	w2, w11
	mov	w11, #1
	lsl	w11, w11, w2
	bic	w9, w9, w11
	str	w9, [x8, x10, lsl #2]
	stp	w21, w2, [x20]
Lloh0:
	adrp	x0, l_.str@PAGE
Lloh1:
	add	x0, x0, l_.str@PAGEOFF
	mov	x1, x21
	bl	_pr_debug
	add	w20, w21, #1
	mov	x0, x19
	bl	_get_pipes_per_mec
	mov	x8, x0
	mov	w0, #0
	sdiv	w9, w20, w8
	msub	w8, w9, w8, w20
	str	w8, [x19]
	b	LBB0_7
LBB0_6:
Lloh2:
	adrp	x8, _EBUSY@GOTPAGE
Lloh3:
	ldr	x8, [x8, _EBUSY@GOTPAGEOFF]
Lloh4:
	ldr	w8, [x8]
	neg	w0, w8
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 AdrpAdd	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.cfi_endproc
                                        ; -- End function
	.comm	_EBUSY,4,2                      ; @EBUSY
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"hqd slot - pipe %d, queue %d\n"

	.no_dead_strip	_allocate_hqd
.subsections_via_symbols
