	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function amdgpu_amdkfd_reserve_mem_limit
_amdgpu_amdkfd_reserve_mem_limit:       ## @amdgpu_amdkfd_reserve_mem_limit
	.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	$24, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	%ecx, %r13d
	movq	%rdx, %r15
	movq	%rsi, %rbx
	movq	_amdgpu_amdkfd_total_mem_size@GOTPCREL(%rip), %rax
	movl	(%rax), %r12d
	movq	%rdi, -56(%rbp)                 ## 8-byte Spill
	addq	$16, %rdi
	movl	$4, %edx
	callq	_ttm_bo_dma_acc_size
	movq	%rax, %r14
	movq	_AMDGPU_GEM_DOMAIN_GTT@GOTPCREL(%rip), %rax
	cmpq	%r15, (%rax)
	movl	%r12d, -44(%rbp)                ## 4-byte Spill
	jne	LBB0_2
## %bb.1:
	addq	%rbx, %r14
	xorl	%r13d, %r13d
	jmp	LBB0_6
LBB0_2:
	testl	%r13d, %r13d
	jne	LBB0_5
## %bb.3:
	movq	_AMDGPU_GEM_DOMAIN_CPU@GOTPCREL(%rip), %rax
	cmpq	%r15, (%rax)
	jne	LBB0_5
## %bb.4:
	movq	%r14, %r12
	addq	%rbx, %r12
	xorl	%r13d, %r13d
	jmp	LBB0_7
LBB0_5:
	movq	_AMDGPU_GEM_DOMAIN_VRAM@GOTPCREL(%rip), %rax
	xorl	%r13d, %r13d
	cmpq	%r15, (%rax)
	cmoveq	%rbx, %r13
LBB0_6:
	movq	%r14, %r12
LBB0_7:
	movq	_kfd_mem_limit@GOTPCREL(%rip), %rbx
	leaq	32(%rbx), %r15
	movq	%r15, %rdi
	callq	_spin_lock
	addq	(%rbx), %r12
	cmpq	8(%rbx), %r12
	ja	LBB0_10
## %bb.8:
	addq	16(%rbx), %r14
	cmpq	24(%rbx), %r14
	ja	LBB0_10
## %bb.9:
	movl	-44(%rbp), %eax                 ## 4-byte Reload
	sarl	$9, %eax
	movq	-56(%rbp), %rcx                 ## 8-byte Reload
	addq	(%rcx), %r13
	cltq
	movq	8(%rcx), %rcx
	subq	%rax, %rcx
	cmpq	%rcx, %r13
	jbe	LBB0_11
LBB0_10:
	movq	_ENOMEM@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
LBB0_12:
	movq	%r15, %rdi
	callq	_spin_unlock
	movl	%ebx, %eax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_11:
	movq	%r12, (%rbx)
	movq	%r14, 16(%rbx)
	movq	-56(%rbp), %rax                 ## 8-byte Reload
	movq	%r13, (%rax)
	xorl	%ebx, %ebx
	jmp	LBB0_12
	.cfi_endproc
                                        ## -- End function
	.comm	_amdgpu_amdkfd_total_mem_size,4,2 ## @amdgpu_amdkfd_total_mem_size
	.comm	_AMDGPU_GEM_DOMAIN_GTT,8,3      ## @AMDGPU_GEM_DOMAIN_GTT
	.comm	_AMDGPU_GEM_DOMAIN_CPU,8,3      ## @AMDGPU_GEM_DOMAIN_CPU
	.comm	_AMDGPU_GEM_DOMAIN_VRAM,8,3     ## @AMDGPU_GEM_DOMAIN_VRAM
	.comm	_kfd_mem_limit,40,3             ## @kfd_mem_limit
	.comm	_ENOMEM,4,2                     ## @ENOMEM
	.no_dead_strip	_amdgpu_amdkfd_reserve_mem_limit
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function amdgpu_amdkfd_reserve_mem_limit
_amdgpu_amdkfd_reserve_mem_limit:       ; @amdgpu_amdkfd_reserve_mem_limit
	.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	x23, x3
	mov	x22, x2
	mov	x21, x1
	mov	x19, x0
Lloh0:
	adrp	x8, _amdgpu_amdkfd_total_mem_size@GOTPAGE
Lloh1:
	ldr	x8, [x8, _amdgpu_amdkfd_total_mem_size@GOTPAGEOFF]
Lloh2:
	ldr	w24, [x8]
	add	x0, x0, #16
	mov	w2, #4
	bl	_ttm_bo_dma_acc_size
	mov	x20, x0
Lloh3:
	adrp	x8, _AMDGPU_GEM_DOMAIN_GTT@GOTPAGE
Lloh4:
	ldr	x8, [x8, _AMDGPU_GEM_DOMAIN_GTT@GOTPAGEOFF]
Lloh5:
	ldr	x8, [x8]
	cmp	x8, x22
	b.ne	LBB0_2
; %bb.1:
	mov	x22, #0
	add	x20, x20, x21
	b	LBB0_6
LBB0_2:
	cbnz	w23, LBB0_5
; %bb.3:
Lloh6:
	adrp	x8, _AMDGPU_GEM_DOMAIN_CPU@GOTPAGE
Lloh7:
	ldr	x8, [x8, _AMDGPU_GEM_DOMAIN_CPU@GOTPAGEOFF]
Lloh8:
	ldr	x8, [x8]
	cmp	x8, x22
	b.ne	LBB0_5
; %bb.4:
	mov	x22, #0
	add	x23, x20, x21
	b	LBB0_7
LBB0_5:
Lloh9:
	adrp	x8, _AMDGPU_GEM_DOMAIN_VRAM@GOTPAGE
Lloh10:
	ldr	x8, [x8, _AMDGPU_GEM_DOMAIN_VRAM@GOTPAGEOFF]
Lloh11:
	ldr	x8, [x8]
	cmp	x8, x22
	csel	x22, x21, xzr, eq
LBB0_6:
	mov	x23, x20
LBB0_7:
Lloh12:
	adrp	x21, _kfd_mem_limit@GOTPAGE
Lloh13:
	ldr	x21, [x21, _kfd_mem_limit@GOTPAGEOFF]
	add	x0, x21, #32
	bl	_spin_lock
	ldp	x8, x9, [x21]
	add	x8, x8, x23
	cmp	x8, x9
	b.hi	LBB0_10
; %bb.8:
	ldp	x9, x10, [x21, #16]
	add	x9, x9, x20
	cmp	x9, x10
	b.hi	LBB0_10
; %bb.9:
	sbfx	x11, x24, #9, #23
	ldp	x10, x12, [x19]
	add	x10, x10, x22
	sub	x11, x12, x11
	cmp	x10, x11
	b.ls	LBB0_12
LBB0_10:
Lloh14:
	adrp	x8, _ENOMEM@GOTPAGE
Lloh15:
	ldr	x8, [x8, _ENOMEM@GOTPAGEOFF]
Lloh16:
	ldr	w8, [x8]
	neg	w20, w8
LBB0_11:
	add	x0, x21, #32
	bl	_spin_unlock
	mov	x0, x20
	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
LBB0_12:
	mov	w20, #0
	str	x8, [x21]
	str	x9, [x21, #16]
	str	x10, [x19]
	b	LBB0_11
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGot	Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh14, Lloh15, Lloh16
	.cfi_endproc
                                        ; -- End function
	.comm	_amdgpu_amdkfd_total_mem_size,4,2 ; @amdgpu_amdkfd_total_mem_size
	.comm	_AMDGPU_GEM_DOMAIN_GTT,8,3      ; @AMDGPU_GEM_DOMAIN_GTT
	.comm	_AMDGPU_GEM_DOMAIN_CPU,8,3      ; @AMDGPU_GEM_DOMAIN_CPU
	.comm	_AMDGPU_GEM_DOMAIN_VRAM,8,3     ; @AMDGPU_GEM_DOMAIN_VRAM
	.comm	_kfd_mem_limit,40,3             ; @kfd_mem_limit
	.comm	_ENOMEM,4,2                     ; @ENOMEM
	.no_dead_strip	_amdgpu_amdkfd_reserve_mem_limit
.subsections_via_symbols
