	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function create_queue_cpsch
_create_queue_cpsch:                    ## @create_queue_cpsch
	.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	%rsi, %r12
	movq	(%rdi), %rsi
	movq	_max_num_of_queues_per_device@GOTPCREL(%rip), %rax
	cmpq	(%rax), %rsi
	jge	LBB0_1
## %bb.2:
	movq	%rdx, %r15
	movq	%rdi, %r14
	movq	(%r12), %rax
	movq	_KFD_QUEUE_TYPE_SDMA@GOTPCREL(%rip), %r13
	cmpq	(%r13), %rax
	je	LBB0_4
## %bb.3:
	movq	_KFD_QUEUE_TYPE_SDMA_XGMI@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_5
LBB0_4:
	movq	%r14, %rdi
	callq	_dqm_lock
	movq	%r14, %rdi
	movq	%r12, %rsi
	callq	_allocate_sdma_queue
	movl	%eax, %ebx
	movq	%r14, %rdi
	callq	_dqm_unlock
	testl	%ebx, %ebx
	jne	LBB0_23
LBB0_5:
	movq	%r15, %rdi
	movq	%r12, %rsi
	callq	_allocate_doorbell
	movl	%eax, %ebx
	testl	%eax, %eax
	je	LBB0_6
LBB0_11:
	movq	(%r12), %rax
	cmpq	(%r13), %rax
	je	LBB0_13
## %bb.12:
	movq	_KFD_QUEUE_TYPE_SDMA_XGMI@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_23
LBB0_13:
	movq	%r14, %rdi
	callq	_dqm_lock
	movq	%r14, %rdi
	movq	%r12, %rsi
	callq	_deallocate_sdma_queue
	jmp	LBB0_22
LBB0_1:
	leaq	L_.str(%rip), %rdi
	callq	_pr_warn
	movq	_EPERM@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
	jmp	LBB0_23
LBB0_6:
	movq	32(%r14), %rbx
	movq	(%r12), %rdi
	callq	_get_mqd_type_from_queue_type
	movq	(%rbx,%rax,8), %rbx
	movq	(%r12), %rax
	cmpq	(%r13), %rax
	je	LBB0_8
## %bb.7:
	movq	_KFD_QUEUE_TYPE_SDMA_XGMI@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_9
LBB0_8:
	movq	%r14, %rdi
	movq	%r12, %rsi
	movq	%r15, %rdx
	callq	*24(%r14)
LBB0_9:
	movl	16(%r15), %eax
	movl	%eax, 28(%r12)
	movl	12(%r15), %eax
	movl	%eax, 24(%r12)
	movl	8(%rbx), %edi
	movq	%r12, %rsi
	callq	*16(%rbx)
	movl	%eax, 40(%r12)
	testl	%eax, %eax
	je	LBB0_10
## %bb.14:
	movq	%r14, %rdi
	callq	_dqm_lock
	xorl	%eax, %eax
	cmpl	$0, 8(%r15)
	setne	%al
	movl	%eax, 8(%r12)
	leaq	44(%r12), %rsi
	movl	40(%r12), %edx
	leaq	36(%r12), %rcx
	movq	%rbx, %rdi
	movq	%r12, %r8
	callq	*(%rbx)
	leaq	32(%r12), %rdi
	leaq	4(%r15), %rsi
	callq	_list_add
	incl	(%r15)
	cmpq	$0, 16(%r12)
	je	LBB0_15
## %bb.16:
	incl	16(%r14)
	movq	_KFD_UNMAP_QUEUES_FILTER_DYNAMIC_QUEUES@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r14, %rdi
	xorl	%edx, %edx
	callq	_execute_queues_cpsch
	movl	%eax, %ebx
	jmp	LBB0_17
LBB0_10:
	movq	_ENOMEM@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
	movq	%r15, %rdi
	movq	%r12, %rsi
	callq	_deallocate_doorbell
	jmp	LBB0_11
LBB0_15:
	xorl	%ebx, %ebx
LBB0_17:
	movq	(%r12), %rax
	cmpq	(%r13), %rax
	jne	LBB0_19
## %bb.18:
	incl	12(%r14)
	jmp	LBB0_21
LBB0_19:
	movq	_KFD_QUEUE_TYPE_SDMA_XGMI@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_21
## %bb.20:
	incl	8(%r14)
LBB0_21:
	movq	(%r14), %rsi
	incq	%rsi
	movq	%rsi, (%r14)
	leaq	L_.str.1(%rip), %rdi
	callq	_pr_debug
LBB0_22:
	movq	%r14, %rdi
	callq	_dqm_unlock
LBB0_23:
	movl	%ebx, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_max_num_of_queues_per_device,8,3 ## @max_num_of_queues_per_device
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Can't create new usermode queue because %d queues were already created\n"

	.comm	_EPERM,4,2                      ## @EPERM
	.comm	_KFD_QUEUE_TYPE_SDMA,8,3        ## @KFD_QUEUE_TYPE_SDMA
	.comm	_KFD_QUEUE_TYPE_SDMA_XGMI,8,3   ## @KFD_QUEUE_TYPE_SDMA_XGMI
	.comm	_ENOMEM,4,2                     ## @ENOMEM
	.comm	_KFD_UNMAP_QUEUES_FILTER_DYNAMIC_QUEUES,4,2 ## @KFD_UNMAP_QUEUES_FILTER_DYNAMIC_QUEUES
L_.str.1:                               ## @.str.1
	.asciz	"Total of %d queues are accountable so far\n"

	.no_dead_strip	_create_queue_cpsch
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function create_queue_cpsch
_create_queue_cpsch:                    ; @create_queue_cpsch
	.cfi_startproc
; %bb.0:
	stp	x24, x23, [sp, #-64]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 64
	stp	x22, x21, [sp, #16]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #32]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #48]             ; 16-byte Folded Spill
	add	x29, sp, #48
	.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
	mov	x20, x1
	ldr	x1, [x0]
Lloh0:
	adrp	x8, _max_num_of_queues_per_device@GOTPAGE
Lloh1:
	ldr	x8, [x8, _max_num_of_queues_per_device@GOTPAGEOFF]
Lloh2:
	ldr	x8, [x8]
	cmp	x1, x8
	b.ge	LBB0_6
; %bb.1:
	mov	x21, x2
	mov	x19, x0
	ldr	x8, [x20]
Lloh3:
	adrp	x24, _KFD_QUEUE_TYPE_SDMA@GOTPAGE
Lloh4:
	ldr	x24, [x24, _KFD_QUEUE_TYPE_SDMA@GOTPAGEOFF]
	ldr	x9, [x24]
Lloh5:
	adrp	x23, _KFD_QUEUE_TYPE_SDMA_XGMI@GOTPAGE
Lloh6:
	ldr	x23, [x23, _KFD_QUEUE_TYPE_SDMA_XGMI@GOTPAGEOFF]
	ldr	x10, [x23]
	cmp	x8, x9
	ccmp	x8, x10, #4, ne
	b.ne	LBB0_3
; %bb.2:
	mov	x0, x19
	bl	_dqm_lock
	mov	x0, x19
	mov	x1, x20
	bl	_allocate_sdma_queue
	mov	x22, x0
	mov	x0, x19
	bl	_dqm_unlock
	cbnz	w22, LBB0_20
LBB0_3:
	mov	x0, x21
	mov	x1, x20
	bl	_allocate_doorbell
	mov	x22, x0
	cbz	w0, LBB0_7
LBB0_4:
	ldr	x8, [x20]
	ldr	x9, [x24]
	ldr	x10, [x23]
	cmp	x8, x9
	ccmp	x8, x10, #4, ne
	b.ne	LBB0_20
; %bb.5:
	mov	x0, x19
	bl	_dqm_lock
	mov	x0, x19
	mov	x1, x20
	bl	_deallocate_sdma_queue
	b	LBB0_19
LBB0_6:
Lloh7:
	adrp	x0, l_.str@PAGE
Lloh8:
	add	x0, x0, l_.str@PAGEOFF
	bl	_pr_warn
Lloh9:
	adrp	x8, _EPERM@GOTPAGE
Lloh10:
	ldr	x8, [x8, _EPERM@GOTPAGEOFF]
Lloh11:
	ldr	w8, [x8]
	neg	w22, w8
	b	LBB0_20
LBB0_7:
	ldr	x22, [x19, #32]
	ldr	x0, [x20]
	bl	_get_mqd_type_from_queue_type
	ldr	x22, [x22, x0, lsl #3]
	ldr	x8, [x20]
	ldr	x9, [x24]
	ldr	x10, [x23]
	cmp	x8, x9
	ccmp	x8, x10, #4, ne
	b.ne	LBB0_9
; %bb.8:
	ldr	x8, [x19, #24]
	mov	x0, x19
	mov	x1, x20
	mov	x2, x21
	blr	x8
LBB0_9:
	ldur	d0, [x21, #12]
	str	d0, [x20, #24]
	ldr	x8, [x22, #16]
	ldr	w0, [x22, #8]
	mov	x1, x20
	blr	x8
	str	w0, [x20, #40]
	cbz	w0, LBB0_12
; %bb.10:
	mov	x0, x19
	bl	_dqm_lock
	ldr	w8, [x21, #8]
	cmp	w8, #0
	cset	w8, ne
	str	w8, [x20, #8]
	ldr	x8, [x22]
	add	x1, x20, #44
	ldr	w2, [x20, #40]
	add	x3, x20, #36
	mov	x0, x22
	mov	x4, x20
	blr	x8
	add	x0, x20, #32
	add	x1, x21, #4
	bl	_list_add
	ldr	w8, [x21]
	add	w8, w8, #1
	str	w8, [x21]
	ldr	x8, [x20, #16]
	cbz	x8, LBB0_13
; %bb.11:
	ldr	w8, [x19, #16]
	add	w8, w8, #1
	str	w8, [x19, #16]
Lloh12:
	adrp	x8, _KFD_UNMAP_QUEUES_FILTER_DYNAMIC_QUEUES@GOTPAGE
Lloh13:
	ldr	x8, [x8, _KFD_UNMAP_QUEUES_FILTER_DYNAMIC_QUEUES@GOTPAGEOFF]
Lloh14:
	ldr	w1, [x8]
	mov	x0, x19
	mov	w2, #0
	bl	_execute_queues_cpsch
	mov	x22, x0
	b	LBB0_14
LBB0_12:
Lloh15:
	adrp	x8, _ENOMEM@GOTPAGE
Lloh16:
	ldr	x8, [x8, _ENOMEM@GOTPAGEOFF]
Lloh17:
	ldr	w8, [x8]
	neg	w22, w8
	mov	x0, x21
	mov	x1, x20
	bl	_deallocate_doorbell
	b	LBB0_4
LBB0_13:
	mov	w22, #0
LBB0_14:
	ldr	x8, [x20]
	ldr	x9, [x24]
	cmp	x8, x9
	b.ne	LBB0_16
; %bb.15:
	ldr	w8, [x19, #12]
	add	w8, w8, #1
	str	w8, [x19, #12]
	b	LBB0_18
LBB0_16:
	ldr	x9, [x23]
	cmp	x8, x9
	b.ne	LBB0_18
; %bb.17:
	ldr	w8, [x19, #8]
	add	w8, w8, #1
	str	w8, [x19, #8]
LBB0_18:
	ldr	x8, [x19]
	add	x1, x8, #1
	str	x1, [x19]
Lloh18:
	adrp	x0, l_.str.1@PAGE
Lloh19:
	add	x0, x0, l_.str.1@PAGEOFF
	bl	_pr_debug
LBB0_19:
	mov	x0, x19
	bl	_dqm_unlock
LBB0_20:
	mov	x0, x22
	ldp	x29, x30, [sp, #48]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #32]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #16]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp], #64             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGot	Lloh5, Lloh6
	.loh AdrpLdrGot	Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpAdd	Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh15, Lloh16, Lloh17
	.loh AdrpAdd	Lloh18, Lloh19
	.cfi_endproc
                                        ; -- End function
	.comm	_max_num_of_queues_per_device,8,3 ; @max_num_of_queues_per_device
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Can't create new usermode queue because %d queues were already created\n"

	.comm	_EPERM,4,2                      ; @EPERM
	.comm	_KFD_QUEUE_TYPE_SDMA,8,3        ; @KFD_QUEUE_TYPE_SDMA
	.comm	_KFD_QUEUE_TYPE_SDMA_XGMI,8,3   ; @KFD_QUEUE_TYPE_SDMA_XGMI
	.comm	_ENOMEM,4,2                     ; @ENOMEM
	.comm	_KFD_UNMAP_QUEUES_FILTER_DYNAMIC_QUEUES,4,2 ; @KFD_UNMAP_QUEUES_FILTER_DYNAMIC_QUEUES
l_.str.1:                               ; @.str.1
	.asciz	"Total of %d queues are accountable so far\n"

	.no_dead_strip	_create_queue_cpsch
.subsections_via_symbols
