	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_nvc0_grctx_fini                ## -- Begin function nvc0_grctx_fini
	.p2align	4, 0x90
_nvc0_grctx_fini:                       ## @nvc0_grctx_fini
	.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	%rdi, %r14
	movq	8(%rdi), %r12
	xorl	%r15d, %r15d
	movq	%r12, %rdi
	movl	$4233988, %esi                  ## imm = 0x409B04
	movl	$-2147483648, %edx              ## imm = 0x80000000
	xorl	%ecx, %ecx
	callq	_nv_mask
	movq	%r12, %rdi
	movl	$4231168, %esi                  ## imm = 0x409000
	movl	$256, %edx                      ## imm = 0x100
	callq	_nv_wr32
	movq	%r12, %rdi
	movl	$4233984, %esi                  ## imm = 0x409B00
	movl	$-2147483648, %edx              ## imm = 0x80000000
	xorl	%ecx, %ecx
	callq	_nv_wait
	testl	%eax, %eax
	je	LBB0_1
## %bb.2:
	movl	(%r12), %edi
	movq	_GFP_KERNEL@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	callq	_kmalloc
	movq	%rax, 8(%r12)
	testq	%rax, %rax
	je	LBB0_6
## %bb.3:
	cmpl	$0, (%r12)
	jle	LBB0_6
## %bb.4:
	xorl	%ebx, %ebx
	.p2align	4, 0x90
LBB0_5:                                 ## =>This Inner Loop Header: Depth=1
	movl	(%r14), %edi
	leal	524288(%rbx), %esi
	callq	_nv_ro32
	movq	8(%r12), %rcx
	movl	%eax, (%rcx,%rbx)
	addq	$4, %rbx
	cmpl	%ebx, (%r12)
	jg	LBB0_5
LBB0_6:
	xorl	%ebx, %ebx
	xorl	%edi, %edi
	movq	%r14, %rsi
	callq	_nouveau_gpuobj_ref
	movq	_ENOMEM@GOTPCREL(%rip), %rax
	xorl	%r15d, %r15d
	subl	(%rax), %r15d
	cmpq	$0, 8(%r12)
	cmovnel	%ebx, %r15d
	jmp	LBB0_7
LBB0_1:
	leaq	L_.str(%rip), %rsi
	movq	%r12, %rdi
	callq	_nv_error
	movq	_EBUSY@GOTPCREL(%rip), %rax
	subl	(%rax), %r15d
LBB0_7:
	movl	%r15d, %eax
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"grctx template channel unload timeout\n"

	.comm	_EBUSY,4,2                      ## @EBUSY
	.comm	_GFP_KERNEL,4,2                 ## @GFP_KERNEL
	.comm	_ENOMEM,4,2                     ## @ENOMEM
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_nvc0_grctx_fini                ; -- Begin function nvc0_grctx_fini
	.p2align	2
_nvc0_grctx_fini:                       ; @nvc0_grctx_fini
	.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, x0
	ldr	x19, [x0, #8]
	mov	w8, #2820
	mov	w21, #36864
	movk	w21, #64, lsl #16
	orr	w1, w21, w8
	mov	x0, x19
	mov	w2, #-2147483648
	mov	w3, #0
	bl	_nv_mask
	mov	x0, x19
	mov	w1, #36864
	movk	w1, #64, lsl #16
	mov	w2, #256
	bl	_nv_wr32
	mov	w8, #2816
	orr	w1, w21, w8
	mov	x0, x19
	mov	w2, #-2147483648
	mov	w3, #0
	bl	_nv_wait
	cbz	w0, LBB0_6
; %bb.1:
	ldr	w0, [x19]
Lloh0:
	adrp	x8, _GFP_KERNEL@GOTPAGE
Lloh1:
	ldr	x8, [x8, _GFP_KERNEL@GOTPAGEOFF]
Lloh2:
	ldr	w1, [x8]
	bl	_kmalloc
	str	x0, [x19, #8]
	cbz	x0, LBB0_5
; %bb.2:
	ldr	w8, [x19]
	cmp	w8, #1
	b.lt	LBB0_5
; %bb.3:
	mov	x21, #0
LBB0_4:                                 ; =>This Inner Loop Header: Depth=1
	ldr	w0, [x20]
	add	w1, w21, #128, lsl #12          ; =524288
	bl	_nv_ro32
	ldr	x8, [x19, #8]
	str	w0, [x8, x21]
	add	x21, x21, #4
	ldr	w8, [x19]
	cmp	w8, w21
	b.gt	LBB0_4
LBB0_5:
	mov	x0, #0
	mov	x1, x20
	bl	_nouveau_gpuobj_ref
	ldr	x8, [x19, #8]
Lloh3:
	adrp	x9, _ENOMEM@GOTPAGE
Lloh4:
	ldr	x9, [x9, _ENOMEM@GOTPAGEOFF]
Lloh5:
	ldr	w9, [x9]
	cmp	x8, #0
	csneg	w0, wzr, w9, ne
	b	LBB0_7
LBB0_6:
Lloh6:
	adrp	x1, l_.str@PAGE
Lloh7:
	add	x1, x1, l_.str@PAGEOFF
	mov	x0, x19
	bl	_nv_error
Lloh8:
	adrp	x8, _EBUSY@GOTPAGE
Lloh9:
	ldr	x8, [x8, _EBUSY@GOTPAGEOFF]
Lloh10:
	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 AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpAdd	Lloh6, Lloh7
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"grctx template channel unload timeout\n"

	.comm	_EBUSY,4,2                      ; @EBUSY
	.comm	_GFP_KERNEL,4,2                 ; @GFP_KERNEL
	.comm	_ENOMEM,4,2                     ; @ENOMEM
.subsections_via_symbols
