	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_hinic_wq_allocate              ## -- Begin function hinic_wq_allocate
	.p2align	4, 0x90
_hinic_wq_allocate:                     ## @hinic_wq_allocate
	.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	$56, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%r9, -96(%rbp)                  ## 8-byte Spill
	movq	%r8, -64(%rbp)                  ## 8-byte Spill
	movq	%rcx, %r14
	movq	%rdx, %r15
	movq	%rsi, %r12
	movq	%rdi, -56(%rbp)                 ## 8-byte Spill
	movq	(%rdi), %rbx
	movq	(%rbx), %r13
	movq	%rdx, %rdi
	callq	_is_power_of_2
	testl	%eax, %eax
	je	LBB0_6
## %bb.1:
	movq	%r13, -48(%rbp)                 ## 8-byte Spill
	testq	%r14, %r14
	je	LBB0_7
## %bb.2:
	movq	-64(%rbp), %rax                 ## 8-byte Reload
	leaq	-1(%rax), %r13
	testq	%r13, %rax
	jne	LBB0_8
## %bb.3:
	movq	%r12, -88(%rbp)                 ## 8-byte Spill
	movq	%r15, %rdi
	callq	_ilog2
	movq	%rax, %r12
	movq	%r14, %rdi
	movq	%r15, %rsi
	callq	_ALIGN
	movq	%r12, -80(%rbp)                 ## 8-byte Spill
	movl	%r12d, %ecx
	movq	%rax, %r12
	sarq	%cl, %r12
	movq	%r12, %rdi
	callq	_is_power_of_2
	testl	%eax, %eax
	je	LBB0_9
## %bb.4:
	movq	%r13, -72(%rbp)                 ## 8-byte Spill
	movq	-88(%rbp), %rdx                 ## 8-byte Reload
	movq	%rbx, 96(%rdx)
	leaq	4(%rdx), %rsi
	movq	-56(%rbp), %rdi                 ## 8-byte Reload
	movq	%rdx, %r13
	callq	_wqs_next_block
	testl	%eax, %eax
	je	LBB0_13
## %bb.5:
	movl	%eax, %ebx
	leaq	L_.str.4(%rip), %rsi
	movq	-48(%rbp), %rdi                 ## 8-byte Reload
	callq	_dev_err
	jmp	LBB0_12
LBB0_6:
	leaq	L_.str(%rip), %rsi
	movq	%r13, %rdi
	jmp	LBB0_11
LBB0_7:
	leaq	L_.str.1(%rip), %rsi
	jmp	LBB0_10
LBB0_8:
	leaq	L_.str.2(%rip), %rsi
	jmp	LBB0_10
LBB0_9:
	leaq	L_.str.3(%rip), %rsi
LBB0_10:
	movq	-48(%rbp), %rdi                 ## 8-byte Reload
LBB0_11:
	callq	_dev_err
	movq	_EINVAL@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
LBB0_12:
	movl	%ebx, %eax
	addq	$56, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_13:
	movq	%r15, 88(%r13)
	movq	%r14, 80(%r13)
	movq	-64(%rbp), %r15                 ## 8-byte Reload
	movq	%r15, 72(%r13)
	movq	-96(%rbp), %rax                 ## 8-byte Reload
	movq	%rax, 64(%r13)
	movq	%r12, 56(%r13)
	movq	%r12, %rdi
	callq	_ilog2
	movq	%rax, 48(%r13)
	movq	-80(%rbp), %rax                 ## 8-byte Reload
	movq	%rax, 40(%r13)
	movq	-56(%rbp), %r12                 ## 8-byte Reload
	movq	%r12, %rdi
	movq	%r13, %rsi
	callq	_WQ_BASE_VADDR
	movl	%eax, 36(%r13)
	movq	%r12, %rdi
	movq	%r13, %rsi
	callq	_WQ_BASE_ADDR
	movl	%eax, 32(%r13)
	movq	%r12, %rdi
	movq	%r13, %rsi
	callq	_WQ_BASE_PADDR
	movl	%eax, 28(%r13)
	movq	(%r12), %rsi
	movq	_WQ_MAX_PAGES@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	%r13, %rdi
	callq	_alloc_wq_pages
	testl	%eax, %eax
	je	LBB0_15
## %bb.14:
	movl	%eax, %ebx
	leaq	L_.str.5(%rip), %rsi
	movq	-48(%rbp), %rdi                 ## 8-byte Reload
	callq	_dev_err
	movl	(%r13), %edx
	movl	4(%r13), %esi
	movq	%r12, %rdi
	callq	_wqs_return_block
	jmp	LBB0_12
LBB0_15:
	leaq	24(%r13), %rdi
	xorl	%ebx, %ebx
	xorl	%esi, %esi
	callq	_atomic_set
	leaq	20(%r13), %rdi
	xorl	%esi, %esi
	callq	_atomic_set
	leaq	16(%r13), %rdi
	movq	%r15, %rsi
	callq	_atomic_set
	movq	-72(%rbp), %rax                 ## 8-byte Reload
	movq	%rax, 8(%r13)
	jmp	LBB0_12
	.cfi_endproc
                                        ## -- End function
	.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 get free wqs next block\n"

	.comm	_WQ_MAX_PAGES,4,2               ## @WQ_MAX_PAGES
L_.str.5:                               ## @.str.5
	.asciz	"Failed to allocate wq pages\n"

.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_hinic_wq_allocate              ; -- Begin function hinic_wq_allocate
	.p2align	2
_hinic_wq_allocate:                     ; @hinic_wq_allocate
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #112
	.cfi_def_cfa_offset 112
	stp	x28, x27, [sp, #16]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #32]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #48]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #64]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #80]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #96]             ; 16-byte Folded Spill
	add	x29, sp, #96
	.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	x23, x5
	mov	x20, x4
	mov	x24, x3
	mov	x25, x2
	mov	x19, x1
	mov	x22, x0
	ldr	x26, [x0]
	ldr	x21, [x26]
	mov	x0, x2
	bl	_is_power_of_2
	cbz	w0, LBB0_6
; %bb.1:
	cbz	x24, LBB0_7
; %bb.2:
	sub	x8, x20, #1
	tst	x20, x8
	b.ne	LBB0_8
; %bb.3:
	str	x8, [sp, #8]                    ; 8-byte Folded Spill
	mov	x0, x25
	bl	_ilog2
	mov	x27, x0
	mov	x0, x24
	mov	x1, x25
	bl	_ALIGN
	asr	x28, x0, x27
	mov	x0, x28
	bl	_is_power_of_2
	cbz	w0, LBB0_9
; %bb.4:
	str	x26, [x19, #96]
	add	x1, x19, #4
	mov	x0, x22
	mov	x2, x19
	bl	_wqs_next_block
	cbz	w0, LBB0_12
; %bb.5:
	mov	x26, 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	w26, w8
LBB0_11:
	mov	x0, x26
	ldp	x29, x30, [sp, #96]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #80]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #64]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #48]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #32]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #112
	ret
LBB0_12:
	stp	x24, x25, [x19, #80]
	stp	x23, x20, [x19, #64]
	str	x28, [x19, #56]
	mov	x0, x28
	bl	_ilog2
	stp	x27, x0, [x19, #40]
	mov	x0, x22
	mov	x1, x19
	bl	_WQ_BASE_VADDR
	str	w0, [x19, #36]
	mov	x0, x22
	mov	x1, x19
	bl	_WQ_BASE_ADDR
	str	w0, [x19, #32]
	mov	x0, x22
	mov	x1, x19
	bl	_WQ_BASE_PADDR
	str	w0, [x19, #28]
	ldr	x1, [x22]
Lloh13:
	adrp	x8, _WQ_MAX_PAGES@GOTPAGE
Lloh14:
	ldr	x8, [x8, _WQ_MAX_PAGES@GOTPAGEOFF]
Lloh15:
	ldr	w2, [x8]
	mov	x0, x19
	bl	_alloc_wq_pages
	mov	x26, x0
	cbz	w0, LBB0_14
; %bb.13:
Lloh16:
	adrp	x1, l_.str.5@PAGE
Lloh17:
	add	x1, x1, l_.str.5@PAGEOFF
	mov	x0, x21
	bl	_dev_err
	ldp	w2, w1, [x19]
	mov	x0, x22
	bl	_wqs_return_block
	b	LBB0_11
LBB0_14:
	add	x0, x19, #24
	mov	x1, #0
	bl	_atomic_set
	add	x0, x19, #20
	mov	x1, #0
	bl	_atomic_set
	add	x0, x19, #16
	mov	x1, x20
	bl	_atomic_set
	ldr	x8, [sp, #8]                    ; 8-byte Folded Reload
	str	x8, [x19, #8]
	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
	.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 get free wqs next block\n"

	.comm	_WQ_MAX_PAGES,4,2               ; @WQ_MAX_PAGES
l_.str.5:                               ; @.str.5
	.asciz	"Failed to allocate wq pages\n"

.subsections_via_symbols
