	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function amdgpu_cs_get_threshold_for_moves
_amdgpu_cs_get_threshold_for_moves:     ## @amdgpu_cs_get_threshold_for_moves
	.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	$40, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	cmpl	$0, 20(%rdi)
	je	LBB0_13
## %bb.1:
	movq	%rdi, %rbx
	movq	%rsi, -56(%rbp)                 ## 8-byte Spill
	movq	%rdx, -64(%rbp)                 ## 8-byte Spill
	leaq	32(%rdi), %rax
	movq	%rax, -48(%rbp)                 ## 8-byte Spill
	movl	32(%rdi), %r12d
	addq	$40, %rdi
	callq	_atomic64_read
	subl	%eax, %r12d
	movq	_TTM_PL_VRAM@GOTPCREL(%rip), %rax
	movq	(%rax), %rdi
	shlq	$2, %rdi
	addq	24(%rbx), %rdi
	callq	_amdgpu_vram_mgr_usage
	xorl	%r13d, %r13d
	movl	%r12d, %r15d
	subl	%eax, %r15d
	cmovlel	%r13d, %r15d
	leaq	16(%rbx), %rdi
	movq	%rdi, -72(%rbp)                 ## 8-byte Spill
	callq	_spin_lock
	xorl	%eax, %eax
	callq	_ktime_get
	movl	%eax, %edi
	callq	_ktime_to_us
	movl	%eax, %r14d
	subl	4(%rbx), %r14d
	movl	%eax, 4(%rbx)
	movl	8(%rbx), %edi
	addl	%r14d, %edi
	movl	$200000, %esi                   ## imm = 0x30D40
	callq	_min
	movl	%eax, 8(%rbx)
	leal	7(%r12), %ecx
	testl	%r12d, %r12d
	cmovnsl	%r12d, %ecx
	cmpl	$134217727, %r15d               ## imm = 0x7FFFFFF
	jg	LBB0_3
## %bb.2:
	sarl	$3, %ecx
	cmpl	%ecx, %r15d
	jl	LBB0_6
LBB0_3:
	movq	_AMD_IS_APU@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	testl	%ecx, (%rbx)
	jne	LBB0_5
## %bb.4:
	leal	3(%r15), %esi
	testl	%r15d, %r15d
	cmovnsl	%r15d, %esi
	sarl	$2, %esi
	movq	%rbx, %rdi
	callq	_bytes_to_us
	movl	%eax, %r13d
	movl	8(%rbx), %eax
LBB0_5:
	movl	%r13d, %edi
	movl	%eax, %esi
	callq	_max
	movl	%eax, 8(%rbx)
LBB0_6:
	movq	-64(%rbp), %r13                 ## 8-byte Reload
	movq	-56(%rbp), %r15                 ## 8-byte Reload
	movq	-48(%rbp), %r12                 ## 8-byte Reload
	movq	%rbx, %rdi
	movl	%eax, %esi
	callq	_us_to_bytes
	movl	%eax, (%r15)
	movq	%r12, %rdi
	callq	_amdgpu_gmc_vram_full_visible
	movl	%eax, %ecx
	xorl	%eax, %eax
	testl	%ecx, %ecx
	jne	LBB0_12
## %bb.7:
	movl	36(%rbx), %r15d
	movq	_TTM_PL_VRAM@GOTPCREL(%rip), %rax
	movq	(%rax), %rdi
	shlq	$2, %rdi
	addq	24(%rbx), %rdi
	callq	_amdgpu_vram_mgr_vis_usage
	movl	%r15d, %r12d
	subl	%eax, %r12d
	jle	LBB0_8
## %bb.9:
	addl	12(%rbx), %r14d
	movl	%r14d, %edi
	movl	$200000, %esi                   ## imm = 0x30D40
	callq	_min
	movq	%rax, %rsi
	movl	%esi, 12(%rbx)
	movl	%r15d, %eax
	shrl	$31, %eax
	addl	%r15d, %eax
	sarl	%eax
	cmpl	%eax, %r12d
	jl	LBB0_11
## %bb.10:
	movl	%r12d, %esi
	shrl	$31, %esi
	addl	%r12d, %esi
	sarl	%esi
	movq	%rbx, %rdi
	callq	_bytes_to_us
	movl	12(%rbx), %esi
	movl	%eax, %edi
	callq	_max
	movq	%rax, %rsi
	movl	%esi, 12(%rbx)
	jmp	LBB0_11
LBB0_13:
	movl	$0, (%rsi)
	movl	$0, (%rdx)
	addq	$40, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_8:
	movl	12(%rbx), %esi
LBB0_11:
	movq	%rbx, %rdi
                                        ## kill: def $esi killed $esi killed $rsi
	callq	_us_to_bytes
LBB0_12:
	movl	%eax, (%r13)
	movq	-72(%rbp), %rdi                 ## 8-byte Reload
	addq	$40, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	jmp	_spin_unlock                    ## TAILCALL
	.cfi_endproc
                                        ## -- End function
	.comm	_TTM_PL_VRAM,8,3                ## @TTM_PL_VRAM
	.comm	_AMD_IS_APU,4,2                 ## @AMD_IS_APU
	.no_dead_strip	_amdgpu_cs_get_threshold_for_moves
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function amdgpu_cs_get_threshold_for_moves
_amdgpu_cs_get_threshold_for_moves:     ; @amdgpu_cs_get_threshold_for_moves
	.cfi_startproc
; %bb.0:
	stp	x28, x27, [sp, #-96]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 96
	stp	x26, x25, [sp, #16]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #32]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #48]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #64]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #80]             ; 16-byte Folded Spill
	add	x29, sp, #80
	.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	x19, x2
	mov	x22, x1
	ldr	w8, [x0, #20]
	cbz	w8, LBB0_4
; %bb.1:
	mov	x20, x0
	mov	x23, x0
	ldr	w21, [x23, #32]!
	add	x0, x23, #8
	bl	_atomic64_read
	sub	w27, w21, w0
	ldur	x8, [x23, #-8]
Lloh0:
	adrp	x24, _TTM_PL_VRAM@GOTPAGE
Lloh1:
	ldr	x24, [x24, _TTM_PL_VRAM@GOTPAGEOFF]
	ldr	x9, [x24]
	add	x0, x8, x9, lsl #2
	bl	_amdgpu_vram_mgr_usage
	subs	w8, w27, w0
	csel	w26, w8, wzr, gt
	sub	x21, x23, #16
	mov	x0, x21
	bl	_spin_lock
	bl	_ktime_get
	bl	_ktime_to_us
	ldp	w8, w9, [x23, #-28]
	stur	w0, [x23, #-28]
	sub	w25, w0, w8
	add	w0, w9, w25
	mov	w1, #3392
	movk	w1, #3, lsl #16
	bl	_min
	mov	x1, x0
	stur	w1, [x23, #-24]
	add	w8, w27, #7
	cmp	w27, #0
	csel	w8, w8, w27, lt
	asr	w8, w8, #3
	mov	w9, #134217727
	cmp	w26, w9
	ccmp	w26, w8, #0, le
	b.lt	LBB0_7
; %bb.2:
	ldr	w8, [x20]
Lloh2:
	adrp	x9, _AMD_IS_APU@GOTPAGE
Lloh3:
	ldr	x9, [x9, _AMD_IS_APU@GOTPAGEOFF]
Lloh4:
	ldr	w9, [x9]
	tst	w9, w8
	b.eq	LBB0_5
; %bb.3:
	mov	w0, #0
	b	LBB0_6
LBB0_4:
	str	wzr, [x22]
	str	wzr, [x19]
	ldp	x29, x30, [sp, #80]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #64]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #48]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #32]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #16]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp], #96             ; 16-byte Folded Reload
	ret
LBB0_5:
	add	w8, w26, #3
	cmp	w26, #0
	csel	w8, w8, w26, lt
	asr	w1, w8, #2
	mov	x0, x20
	bl	_bytes_to_us
	ldr	w1, [x20, #8]
LBB0_6:
                                        ; kill: def $w1 killed $w1 killed $x1
	bl	_max
	str	w0, [x20, #8]
	mov	x1, x0
LBB0_7:
	mov	x0, x20
                                        ; kill: def $w1 killed $w1 killed $x1
	bl	_us_to_bytes
	str	w0, [x22]
	mov	x0, x23
	bl	_amdgpu_gmc_vram_full_visible
	cbz	w0, LBB0_9
; %bb.8:
	mov	w0, #0
	b	LBB0_14
LBB0_9:
	ldr	w22, [x20, #36]
	ldr	x8, [x20, #24]
	ldr	x9, [x24]
	add	x0, x8, x9, lsl #2
	bl	_amdgpu_vram_mgr_vis_usage
	subs	w23, w22, w0
	b.le	LBB0_12
; %bb.10:
	ldr	w8, [x20, #12]
	add	w0, w8, w25
	mov	w1, #3392
	movk	w1, #3, lsl #16
	bl	_min
	mov	x1, x0
	str	w1, [x20, #12]
	cmp	w22, #0
	cinc	w8, w22, lt
	cmp	w23, w8, asr #1
	b.lt	LBB0_13
; %bb.11:
	cmp	w23, #0
	cinc	w8, w23, lt
	asr	w1, w8, #1
	mov	x0, x20
	bl	_bytes_to_us
	ldr	w1, [x20, #12]
	bl	_max
	str	w0, [x20, #12]
	mov	x1, x0
	b	LBB0_13
LBB0_12:
	ldr	w1, [x20, #12]
LBB0_13:
	mov	x0, x20
                                        ; kill: def $w1 killed $w1 killed $x1
	bl	_us_to_bytes
LBB0_14:
	str	w0, [x19]
	mov	x0, x21
	ldp	x29, x30, [sp, #80]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #64]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #48]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #32]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #16]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp], #96             ; 16-byte Folded Reload
	b	_spin_unlock
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.cfi_endproc
                                        ; -- End function
	.comm	_TTM_PL_VRAM,8,3                ; @TTM_PL_VRAM
	.comm	_AMD_IS_APU,4,2                 ; @AMD_IS_APU
	.no_dead_strip	_amdgpu_cs_get_threshold_for_moves
.subsections_via_symbols
