	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_hinic_wqs_cmdq_alloc           ## -- Begin function hinic_wqs_cmdq_alloc
	.p2align	4, 0x90
_hinic_wqs_cmdq_alloc:                  ## @hinic_wqs_cmdq_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	%r13
	pushq	%r12
	pushq	%rbx
	subq	$88, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%r9, %r13
	movq	%r8, %r12
	movl	%ecx, -48(%rbp)                 ## 4-byte Spill
	movq	%rsi, %rbx
	movq	%rdi, %r14
	movq	%rdx, -64(%rbp)                 ## 8-byte Spill
	movq	(%rdx), %r15
	movq	%r8, %rdi
	callq	_is_power_of_2
	testl	%eax, %eax
	je	LBB0_1
## %bb.3:
	testq	%r13, %r13
	je	LBB0_4
## %bb.5:
	movq	16(%rbp), %rax
	leaq	-1(%rax), %rcx
	movq	%rcx, -120(%rbp)                ## 8-byte Spill
	testq	%rcx, %rax
	jne	LBB0_6
## %bb.7:
	movq	%r14, -80(%rbp)                 ## 8-byte Spill
	movq	%r12, %rdi
	callq	_ilog2
	movq	%rax, %r14
	movq	%r13, %rdi
	movq	%r12, %rsi
	callq	_ALIGN
	movq	%r14, -112(%rbp)                ## 8-byte Spill
	movl	%r14d, %ecx
	sarq	%cl, %rax
	movq	%rax, -56(%rbp)                 ## 8-byte Spill
	movq	%rax, %rdi
	callq	_is_power_of_2
	testl	%eax, %eax
	je	LBB0_8
## %bb.9:
	movq	%r12, -104(%rbp)                ## 8-byte Spill
	movq	-64(%rbp), %rax                 ## 8-byte Reload
	movq	-80(%rbp), %r14                 ## 8-byte Reload
	movq	%rax, (%r14)
	movq	%r14, %rdi
	callq	_cmdq_allocate_page
	testl	%eax, %eax
	je	LBB0_11
## %bb.10:
	movl	%eax, %r12d
	leaq	L_.str.4(%rip), %rsi
	movq	%r15, %rdi
	callq	_dev_err
	jmp	LBB0_18
LBB0_1:
	leaq	L_.str(%rip), %rsi
	jmp	LBB0_2
LBB0_4:
	leaq	L_.str.1(%rip), %rsi
	jmp	LBB0_2
LBB0_6:
	leaq	L_.str.2(%rip), %rsi
	jmp	LBB0_2
LBB0_8:
	leaq	L_.str.3(%rip), %rsi
LBB0_2:
	movq	%r15, %rdi
	callq	_dev_err
	movq	_EINVAL@GOTPCREL(%rip), %rax
	xorl	%r12d, %r12d
	subl	(%rax), %r12d
LBB0_18:
	movl	%r12d, %eax
	addq	$88, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_11:
	movq	-56(%rbp), %rdi                 ## 8-byte Reload
	callq	_ilog2
	movq	%rax, -96(%rbp)                 ## 8-byte Spill
	movl	-48(%rbp), %eax                 ## 4-byte Reload
	testl	%eax, %eax
	jle	LBB0_12
## %bb.13:
	movq	%r13, -88(%rbp)                 ## 8-byte Spill
	movq	%r15, -72(%rbp)                 ## 8-byte Spill
	movl	%eax, %eax
	imulq	$112, %rax, %rax
	movq	%rax, -48(%rbp)                 ## 8-byte Spill
	xorl	%r13d, %r13d
	xorl	%r15d, %r15d
	.p2align	4, 0x90
LBB0_14:                                ## =>This Inner Loop Header: Depth=1
	leaq	(%rbx,%r13), %r12
	movq	-64(%rbp), %rax                 ## 8-byte Reload
	movq	%rax, 104(%rbx,%r13)
	movq	$0, 96(%rbx,%r13)
	movl	%r15d, (%rbx,%r13)
	movq	-104(%rbp), %rax                ## 8-byte Reload
	movq	%rax, 88(%rbx,%r13)
	movq	-88(%rbp), %rax                 ## 8-byte Reload
	movq	%rax, 80(%rbx,%r13)
	movq	16(%rbp), %rax
	movq	%rax, 72(%rbx,%r13)
	movq	24(%rbp), %rax
	movq	%rax, 64(%rbx,%r13)
	movq	-56(%rbp), %rax                 ## 8-byte Reload
	movq	%rax, 56(%rbx,%r13)
	movq	-96(%rbp), %rax                 ## 8-byte Reload
	movq	%rax, 48(%rbx,%r13)
	movq	-112(%rbp), %rax                ## 8-byte Reload
	movq	%rax, 40(%rbx,%r13)
	movq	%r14, %rdi
	movq	%r12, %rsi
	callq	_CMDQ_BASE_VADDR
	movl	%eax, 36(%rbx,%r13)
	movq	%r14, %rdi
	movq	%r12, %rsi
	callq	_CMDQ_BASE_ADDR
	movl	%eax, 32(%rbx,%r13)
	movq	%r14, %rdi
	movq	%r12, %rsi
	callq	_CMDQ_BASE_PADDR
	movl	%eax, 28(%rbx,%r13)
	movq	(%r14), %rsi
	movq	_CMDQ_WQ_MAX_PAGES@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	%r12, %rdi
	callq	_alloc_wq_pages
	testl	%eax, %eax
	jne	LBB0_15
## %bb.19:                              ##   in Loop: Header=BB0_14 Depth=1
	leaq	(%rbx,%r13), %rdi
	addq	$24, %rdi
	xorl	%r12d, %r12d
	xorl	%esi, %esi
	callq	_atomic_set
	leaq	(%rbx,%r13), %rdi
	addq	$20, %rdi
	xorl	%esi, %esi
	callq	_atomic_set
	leaq	(%rbx,%r13), %rdi
	addq	$16, %rdi
	movq	16(%rbp), %rsi
	callq	_atomic_set
	movq	-120(%rbp), %rax                ## 8-byte Reload
	movq	%rax, 8(%rbx,%r13)
	incq	%r15
	addq	$112, %r13
	cmpq	%r13, -48(%rbp)                 ## 8-byte Folded Reload
	jne	LBB0_14
	jmp	LBB0_18
LBB0_12:
	xorl	%r12d, %r12d
	jmp	LBB0_18
LBB0_15:
	movl	%eax, %r12d
	leaq	L_.str.5(%rip), %rsi
	movq	-72(%rbp), %rdi                 ## 8-byte Reload
	callq	_dev_err
	testl	%r15d, %r15d
	je	LBB0_17
	.p2align	4, 0x90
LBB0_16:                                ## =>This Inner Loop Header: Depth=1
	movq	(%r14), %rsi
	movl	4(%rbx), %edx
	movq	%rbx, %rdi
	callq	_free_wq_pages
	addq	$112, %rbx
	decq	%r15
	jne	LBB0_16
LBB0_17:
	movq	%r14, %rdi
	callq	_cmdq_free_page
	jmp	LBB0_18
	.cfi_endproc
                                        ## -- End function
	.comm	_ENOMEM,4,2                     ## @ENOMEM
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"wqebb_size must be power of 2\n"

	.comm	_EINVAL,4,2                     ## @EINVAL
L_.str.1:                               ## @.str.1
	.asciz	"wq_page_size must be > 0\n"

L_.str.2:                               ## @.str.2
	.asciz	"WQ q_depth must be power of 2\n"

L_.str.3:                               ## @.str.3
	.asciz	"num wqebbs per page must be power of 2\n"

L_.str.4:                               ## @.str.4
	.asciz	"Failed to allocate CMDQ page\n"

	.comm	_CMDQ_WQ_MAX_PAGES,4,2          ## @CMDQ_WQ_MAX_PAGES
L_.str.5:                               ## @.str.5
	.asciz	"Failed to alloc CMDQ blocks\n"

.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_hinic_wqs_cmdq_alloc           ; -- Begin function hinic_wqs_cmdq_alloc
	.p2align	2
_hinic_wqs_cmdq_alloc:                  ; @hinic_wqs_cmdq_alloc
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #160
	.cfi_def_cfa_offset 160
	stp	x28, x27, [sp, #64]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #80]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #96]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #112]            ; 16-byte Folded Spill
	stp	x20, x19, [sp, #128]            ; 16-byte Folded Spill
	stp	x29, x30, [sp, #144]            ; 16-byte Folded Spill
	add	x29, sp, #144
	.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
	.cfi_offset w27, -88
	.cfi_offset w28, -96
	mov	x22, x7
	mov	x23, x6
	mov	x24, x5
	mov	x25, x4
	mov	x28, x3
	mov	x26, x2
	mov	x20, x1
	mov	x19, x0
	ldr	x21, [x2]
	mov	x0, x4
	bl	_is_power_of_2
	cbz	w0, LBB0_6
; %bb.1:
	cbz	x24, LBB0_7
; %bb.2:
	sub	x8, x23, #1
	str	x8, [sp, #56]                   ; 8-byte Folded Spill
	tst	x23, x8
	b.ne	LBB0_8
; %bb.3:
	mov	x0, x25
	bl	_ilog2
	mov	x27, x0
	mov	x0, x24
	mov	x1, x25
	bl	_ALIGN
	asr	x0, x0, x27
	stp	x27, x0, [sp, #40]              ; 16-byte Folded Spill
	bl	_is_power_of_2
	cbz	w0, LBB0_9
; %bb.4:
	str	x26, [x19]
	mov	x0, x19
	bl	_cmdq_allocate_page
	cbz	w0, LBB0_12
; %bb.5:
	mov	x27, x0
Lloh0:
	adrp	x1, l_.str.4@PAGE
Lloh1:
	add	x1, x1, l_.str.4@PAGEOFF
	mov	x0, x21
	bl	_dev_err
	b	LBB0_11
LBB0_6:
Lloh2:
	adrp	x1, l_.str@PAGE
Lloh3:
	add	x1, x1, l_.str@PAGEOFF
	b	LBB0_10
LBB0_7:
Lloh4:
	adrp	x1, l_.str.1@PAGE
Lloh5:
	add	x1, x1, l_.str.1@PAGEOFF
	b	LBB0_10
LBB0_8:
Lloh6:
	adrp	x1, l_.str.2@PAGE
Lloh7:
	add	x1, x1, l_.str.2@PAGEOFF
	b	LBB0_10
LBB0_9:
Lloh8:
	adrp	x1, l_.str.3@PAGE
Lloh9:
	add	x1, x1, l_.str.3@PAGEOFF
LBB0_10:
	mov	x0, x21
	bl	_dev_err
Lloh10:
	adrp	x8, _EINVAL@GOTPAGE
Lloh11:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh12:
	ldr	w8, [x8]
	neg	w27, w8
LBB0_11:
	mov	x0, x27
	ldp	x29, x30, [sp, #144]            ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #128]            ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #112]            ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #96]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #80]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #64]             ; 16-byte Folded Reload
	add	sp, sp, #160
	ret
LBB0_12:
	ldr	x0, [sp, #48]                   ; 8-byte Folded Reload
	bl	_ilog2
	str	x0, [sp, #32]                   ; 8-byte Folded Spill
	cmp	w28, #1
	b.lt	LBB0_16
; %bb.13:
	str	x22, [sp, #24]                  ; 8-byte Folded Spill
	str	x21, [sp, #8]                   ; 8-byte Folded Spill
	mov	x21, #0
	mov	x22, #0
	mov	w8, #112
	umull	x8, w28, w8
	str	x8, [sp, #16]                   ; 8-byte Folded Spill
LBB0_14:                                ; =>This Inner Loop Header: Depth=1
	add	x28, x20, x21
	stp	xzr, x26, [x28, #96]
	str	w22, [x28]
	stp	x24, x25, [x28, #80]
	ldr	x8, [sp, #24]                   ; 8-byte Folded Reload
	stp	x8, x23, [x28, #64]
	ldr	x9, [sp, #48]                   ; 8-byte Folded Reload
	ldr	x8, [sp, #32]                   ; 8-byte Folded Reload
	stp	x8, x9, [x28, #48]
	ldr	x8, [sp, #40]                   ; 8-byte Folded Reload
	str	x8, [x28, #40]
	mov	x0, x19
	mov	x1, x28
	bl	_CMDQ_BASE_VADDR
	str	w0, [x28, #36]
	mov	x0, x19
	mov	x1, x28
	bl	_CMDQ_BASE_ADDR
	str	w0, [x28, #32]
	mov	x0, x19
	mov	x1, x28
	bl	_CMDQ_BASE_PADDR
	str	w0, [x28, #28]
	ldr	x1, [x19]
Lloh13:
	adrp	x8, _CMDQ_WQ_MAX_PAGES@GOTPAGE
Lloh14:
	ldr	x8, [x8, _CMDQ_WQ_MAX_PAGES@GOTPAGEOFF]
Lloh15:
	ldr	w2, [x8]
	mov	x0, x28
	bl	_alloc_wq_pages
	mov	x27, x0
	cbnz	w0, LBB0_17
; %bb.15:                               ;   in Loop: Header=BB0_14 Depth=1
	add	x0, x28, #24
	mov	x1, #0
	bl	_atomic_set
	add	x0, x28, #20
	mov	x1, #0
	bl	_atomic_set
	add	x0, x28, #16
	mov	x1, x23
	bl	_atomic_set
	ldr	x8, [sp, #56]                   ; 8-byte Folded Reload
	str	x8, [x28, #8]
	add	x22, x22, #1
	add	x21, x21, #112
	ldr	x8, [sp, #16]                   ; 8-byte Folded Reload
	cmp	x8, x21
	b.ne	LBB0_14
	b	LBB0_11
LBB0_16:
	mov	w27, #0
	b	LBB0_11
LBB0_17:
Lloh16:
	adrp	x1, l_.str.5@PAGE
Lloh17:
	add	x1, x1, l_.str.5@PAGEOFF
	ldr	x0, [sp, #8]                    ; 8-byte Folded Reload
	bl	_dev_err
	cbz	w22, LBB0_19
LBB0_18:                                ; =>This Inner Loop Header: Depth=1
	ldr	x1, [x19]
	ldr	w2, [x20, #4]
	mov	x0, x20
	bl	_free_wq_pages
	add	x20, x20, #112
	subs	x22, x22, #1
	b.ne	LBB0_18
LBB0_19:
	mov	x0, x19
	bl	_cmdq_free_page
	b	LBB0_11
	.loh AdrpAdd	Lloh0, Lloh1
	.loh AdrpAdd	Lloh2, Lloh3
	.loh AdrpAdd	Lloh4, Lloh5
	.loh AdrpAdd	Lloh6, Lloh7
	.loh AdrpAdd	Lloh8, Lloh9
	.loh AdrpLdrGotLdr	Lloh10, Lloh11, Lloh12
	.loh AdrpLdrGotLdr	Lloh13, Lloh14, Lloh15
	.loh AdrpAdd	Lloh16, Lloh17
	.cfi_endproc
                                        ; -- End function
	.comm	_ENOMEM,4,2                     ; @ENOMEM
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"wqebb_size must be power of 2\n"

	.comm	_EINVAL,4,2                     ; @EINVAL
l_.str.1:                               ; @.str.1
	.asciz	"wq_page_size must be > 0\n"

l_.str.2:                               ; @.str.2
	.asciz	"WQ q_depth must be power of 2\n"

l_.str.3:                               ; @.str.3
	.asciz	"num wqebbs per page must be power of 2\n"

l_.str.4:                               ; @.str.4
	.asciz	"Failed to allocate CMDQ page\n"

	.comm	_CMDQ_WQ_MAX_PAGES,4,2          ; @CMDQ_WQ_MAX_PAGES
l_.str.5:                               ; @.str.5
	.asciz	"Failed to alloc CMDQ blocks\n"

.subsections_via_symbols
