	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function amdgpu_vram_mgr_new
_amdgpu_vram_mgr_new:                   ## @amdgpu_vram_mgr_new
	.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	$104, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rcx, %r14
	movq	%rdx, %rbx
	movq	%rdi, %r12
	movl	16(%rdi), %edi
	callq	_amdgpu_ttm_adev
	movq	%rax, %r13
	movq	8(%r12), %r15
	movq	%rbx, -64(%rbp)                 ## 8-byte Spill
	movq	(%rbx), %rax
	movq	%rax, -72(%rbp)                 ## 8-byte Spill
	testq	%rax, %rax
	jne	LBB0_2
## %bb.1:
	movq	(%r12), %rax
	movq	%rax, -72(%rbp)                 ## 8-byte Spill
LBB0_2:
	movq	(%r14), %rbx
	movq	_PAGE_SHIFT@GOTPCREL(%rip), %r12
	movb	(%r12), %cl
	shlq	%cl, %rbx
	movq	%rbx, %rdi
	movq	%r15, %rsi
	callq	_atomic64_add_return
	cmpq	(%r13), %rax
	jle	LBB0_4
## %bb.3:
	movq	%rbx, %rdi
	movq	%r15, %rsi
	callq	_atomic64_sub
	movq	$0, 16(%r14)
	jmp	LBB0_27
LBB0_4:
	movq	_TTM_PL_FLAG_CONTIGUOUS@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movq	-64(%rbp), %rcx                 ## 8-byte Reload
	testl	%eax, 8(%rcx)
	je	LBB0_6
## %bb.5:
	movq	$-1, %r12
	movl	$1, %edi
	jmp	LBB0_7
LBB0_6:
	movb	$20, %cl
	subb	(%r12), %cl
	movl	$2, %edi
	shlq	%cl, %rdi
	movq	8(%r14), %rsi
	callq	_max
	movq	%rax, %r12
	movq	(%r14), %rdi
	movq	%rax, %rsi
	callq	_DIV_ROUND_UP
	movq	%rax, %rdi
LBB0_7:
	movq	_GFP_KERNEL@GOTPCREL(%rip), %rax
	movq	___GFP_ZERO@GOTPCREL(%rip), %rcx
	movl	(%rcx), %edx
	orl	(%rax), %edx
	movl	$4, %esi
	callq	_kvmalloc_array
	movq	%rax, -48(%rbp)                 ## 8-byte Spill
	testq	%rax, %rax
	je	LBB0_8
## %bb.9:
	movq	_TTM_PL_FLAG_TOPDOWN@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movq	-64(%rbp), %rcx                 ## 8-byte Reload
	andl	8(%rcx), %eax
	movq	%r13, -104(%rbp)                ## 8-byte Spill
	jne	LBB0_10
## %bb.11:
	movq	_DRM_MM_INSERT_BEST@GOTPCREL(%rip), %rax
	jmp	LBB0_12
LBB0_8:
	movq	%rbx, %rdi
	movq	%r15, %rsi
	callq	_atomic64_sub
	movq	_ENOMEM@GOTPCREL(%rip), %rcx
	xorl	%eax, %eax
	subl	(%rcx), %eax
	jmp	LBB0_28
LBB0_10:
	movq	_DRM_MM_INSERT_HIGH@GOTPCREL(%rip), %rax
LBB0_12:
	leaq	12(%r15), %rcx
	movq	%rcx, -120(%rbp)                ## 8-byte Spill
	movl	(%rax), %eax
	movq	%rax, -112(%rbp)                ## 8-byte Spill
	movq	$0, 24(%r14)
	movq	%r14, -56(%rbp)                 ## 8-byte Spill
	movq	(%r14), %rbx
	movq	%r15, -96(%rbp)                 ## 8-byte Spill
	leaq	4(%r15), %rdi
	movq	%rdi, -88(%rbp)                 ## 8-byte Spill
	callq	_spin_lock
	movq	%r12, -80(%rbp)                 ## 8-byte Spill
	cmpq	%r12, %rbx
	jae	LBB0_14
## %bb.13:
	xorl	%r12d, %r12d
	xorl	%r13d, %r13d
	jmp	LBB0_17
LBB0_14:
	xorl	%r13d, %r13d
	xorl	%r12d, %r12d
	.p2align	4, 0x90
LBB0_15:                                ## =>This Inner Loop Header: Depth=1
	movq	%rbx, %rdi
	callq	_rounddown_pow_of_two
	movq	%rax, %r14
	movl	%r13d, %eax
	movq	-48(%rbp), %rcx                 ## 8-byte Reload
	leaq	(%rcx,%rax,4), %r15
	movq	-64(%rbp), %rax                 ## 8-byte Reload
	movl	12(%rax), %r9d
	movq	-120(%rbp), %rdi                ## 8-byte Reload
	movq	%r15, %rsi
	movq	%r14, %rdx
	movq	-80(%rbp), %rcx                 ## 8-byte Reload
	xorl	%r8d, %r8d
	pushq	-112(%rbp)                      ## 8-byte Folded Reload
	pushq	-72(%rbp)                       ## 8-byte Folded Reload
	callq	_drm_mm_insert_node_in_range
	addq	$16, %rsp
	movl	%eax, %edi
	callq	_unlikely
	testq	%rax, %rax
	jne	LBB0_17
## %bb.16:                              ##   in Loop: Header=BB0_15 Depth=1
	movq	-104(%rbp), %rdi                ## 8-byte Reload
	movq	%r15, %rsi
	callq	_amdgpu_vram_mgr_vis_size
	addq	%rax, %r12
	movq	-56(%rbp), %rdi                 ## 8-byte Reload
	movq	%r15, %rsi
	callq	_amdgpu_vram_mgr_virt_start
	subq	%r14, %rbx
	incl	%r13d
	cmpq	-80(%rbp), %rbx                 ## 8-byte Folded Reload
	jae	LBB0_15
LBB0_17:
	testq	%rbx, %rbx
	je	LBB0_26
	.p2align	4, 0x90
LBB0_18:                                ## =>This Inner Loop Header: Depth=1
	movq	%r12, -136(%rbp)                ## 8-byte Spill
	movq	%rbx, -128(%rbp)                ## 8-byte Spill
	movq	%rbx, %rdi
	movq	-80(%rbp), %rbx                 ## 8-byte Reload
	movq	%rbx, %rsi
	callq	_min
	movq	%rax, %r12
	movq	%rbx, %rcx
	cmpq	%rbx, %rax
	je	LBB0_20
## %bb.19:                              ##   in Loop: Header=BB0_18 Depth=1
	movq	-56(%rbp), %rax                 ## 8-byte Reload
	movq	8(%rax), %rcx
LBB0_20:                                ##   in Loop: Header=BB0_18 Depth=1
	movl	%r13d, %ebx
	movq	-48(%rbp), %rax                 ## 8-byte Reload
	leaq	(%rax,%rbx,4), %r14
	movq	-64(%rbp), %rax                 ## 8-byte Reload
	movl	12(%rax), %r9d
	movq	-120(%rbp), %rdi                ## 8-byte Reload
	movq	%r14, %rsi
	movq	%r12, %rdx
	xorl	%r8d, %r8d
	pushq	-112(%rbp)                      ## 8-byte Folded Reload
	pushq	-72(%rbp)                       ## 8-byte Folded Reload
	callq	_drm_mm_insert_node_in_range
	addq	$16, %rsp
	movl	%eax, %r15d
	movl	%eax, %edi
	callq	_unlikely
	testq	%rax, %rax
	jne	LBB0_21
## %bb.25:                              ##   in Loop: Header=BB0_18 Depth=1
	movq	-104(%rbp), %rdi                ## 8-byte Reload
	movq	%r14, %rsi
	callq	_amdgpu_vram_mgr_vis_size
	movq	%r12, %r15
	movq	-136(%rbp), %r12                ## 8-byte Reload
	addq	%rax, %r12
	movq	-56(%rbp), %rdi                 ## 8-byte Reload
	movq	%r14, %rsi
	callq	_amdgpu_vram_mgr_virt_start
	incl	%r13d
	movq	-128(%rbp), %rbx                ## 8-byte Reload
	subq	%r15, %rbx
	jne	LBB0_18
LBB0_26:
	movq	-88(%rbp), %rdi                 ## 8-byte Reload
	callq	_spin_unlock
	movq	-96(%rbp), %rsi                 ## 8-byte Reload
	addq	$8, %rsi
	movq	%r12, %rdi
	callq	_atomic64_add
	movq	-56(%rbp), %rax                 ## 8-byte Reload
	movq	-48(%rbp), %rcx                 ## 8-byte Reload
	movq	%rcx, 16(%rax)
LBB0_27:
	xorl	%eax, %eax
LBB0_28:
	addq	$104, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_21:
	testl	%r13d, %r13d
	je	LBB0_24
## %bb.22:
	shlq	$2, %rbx
	movq	-48(%rbp), %r14                 ## 8-byte Reload
	addq	$-4, %r14
	.p2align	4, 0x90
LBB0_23:                                ## =>This Inner Loop Header: Depth=1
	leaq	(%r14,%rbx), %rdi
	callq	_drm_mm_remove_node
	addq	$-4, %rbx
	jne	LBB0_23
LBB0_24:
	movq	-88(%rbp), %rdi                 ## 8-byte Reload
	callq	_spin_unlock
	movq	-56(%rbp), %rax                 ## 8-byte Reload
	movq	(%rax), %rdi
	movq	_PAGE_SHIFT@GOTPCREL(%rip), %rax
	movb	(%rax), %cl
	shlq	%cl, %rdi
	movq	-96(%rbp), %rsi                 ## 8-byte Reload
	callq	_atomic64_sub
	movq	-48(%rbp), %rdi                 ## 8-byte Reload
	callq	_kvfree
	movq	_ENOSPC@GOTPCREL(%rip), %rax
	xorl	%ecx, %ecx
	movl	(%rax), %edx
	movl	%r15d, %eax
	addl	%r15d, %edx
	cmovel	%ecx, %eax
	jmp	LBB0_28
	.cfi_endproc
                                        ## -- End function
	.comm	_PAGE_SHIFT,8,3                 ## @PAGE_SHIFT
	.comm	_TTM_PL_FLAG_CONTIGUOUS,4,2     ## @TTM_PL_FLAG_CONTIGUOUS
	.comm	_GFP_KERNEL,4,2                 ## @GFP_KERNEL
	.comm	___GFP_ZERO,4,2                 ## @__GFP_ZERO
	.comm	_ENOMEM,4,2                     ## @ENOMEM
	.comm	_DRM_MM_INSERT_BEST,4,2         ## @DRM_MM_INSERT_BEST
	.comm	_TTM_PL_FLAG_TOPDOWN,4,2        ## @TTM_PL_FLAG_TOPDOWN
	.comm	_DRM_MM_INSERT_HIGH,4,2         ## @DRM_MM_INSERT_HIGH
	.comm	_ENOSPC,4,2                     ## @ENOSPC
	.comm	_HPAGE_PMD_NR,8,3               ## @HPAGE_PMD_NR
	.no_dead_strip	_amdgpu_vram_mgr_new
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function amdgpu_vram_mgr_new
_amdgpu_vram_mgr_new:                   ; @amdgpu_vram_mgr_new
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #160
	.cfi_def_cfa_offset 160
	stp	x28, x27, [sp, #64]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #80]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #96]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #112]            ; 16-byte Folded Spill
	stp	x20, x19, [sp, #128]            ; 16-byte Folded Spill
	stp	x29, x30, [sp, #144]            ; 16-byte Folded Spill
	add	x29, sp, #144
	.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, x3
	mov	x24, x2
	mov	x20, x0
	ldr	w0, [x0, #16]
	bl	_amdgpu_ttm_adev
	mov	x27, x0
	ldr	x21, [x20, #8]
	ldr	x28, [x24]
	cbnz	x28, LBB0_2
; %bb.1:
	ldr	x28, [x20]
LBB0_2:
	ldr	x8, [x19]
Lloh0:
	adrp	x22, _PAGE_SHIFT@GOTPAGE
Lloh1:
	ldr	x22, [x22, _PAGE_SHIFT@GOTPAGEOFF]
	ldr	x9, [x22]
	lsl	x20, x8, x9
	mov	x0, x20
	mov	x1, x21
	bl	_atomic64_add_return
	ldr	x8, [x27]
	cmp	x0, x8
	b.le	LBB0_4
; %bb.3:
	mov	x0, x20
	mov	x1, x21
	bl	_atomic64_sub
	mov	w0, #0
	str	xzr, [x19, #16]
	b	LBB0_24
LBB0_4:
	ldr	w8, [x24, #8]
Lloh2:
	adrp	x9, _TTM_PL_FLAG_CONTIGUOUS@GOTPAGE
Lloh3:
	ldr	x9, [x9, _TTM_PL_FLAG_CONTIGUOUS@GOTPAGEOFF]
Lloh4:
	ldr	w9, [x9]
	tst	w9, w8
	b.eq	LBB0_6
; %bb.5:
	mov	x25, #-1
	mov	w0, #1
	b	LBB0_7
LBB0_6:
	ldr	x8, [x22]
	mov	w9, #20
	sub	x8, x9, x8
	mov	w9, #2
	lsl	x0, x9, x8
	ldr	x1, [x19, #8]
	bl	_max
	mov	x25, x0
	ldr	x0, [x19]
	mov	x1, x25
	bl	_DIV_ROUND_UP
LBB0_7:
Lloh5:
	adrp	x8, _GFP_KERNEL@GOTPAGE
Lloh6:
	ldr	x8, [x8, _GFP_KERNEL@GOTPAGEOFF]
Lloh7:
	ldr	w8, [x8]
Lloh8:
	adrp	x9, ___GFP_ZERO@GOTPAGE
Lloh9:
	ldr	x9, [x9, ___GFP_ZERO@GOTPAGEOFF]
Lloh10:
	ldr	w9, [x9]
	orr	w2, w9, w8
	mov	w1, #4
	bl	_kvmalloc_array
	str	x0, [sp, #56]                   ; 8-byte Folded Spill
	cbz	x0, LBB0_10
; %bb.8:
	add	x8, x21, #12
	str	x8, [sp, #48]                   ; 8-byte Folded Spill
Lloh11:
	adrp	x8, _TTM_PL_FLAG_TOPDOWN@GOTPAGE
Lloh12:
	ldr	x8, [x8, _TTM_PL_FLAG_TOPDOWN@GOTPAGEOFF]
	ldr	w9, [x24, #8]
Lloh13:
	ldr	w8, [x8]
Lloh14:
	adrp	x10, _DRM_MM_INSERT_BEST@GOTPAGE
Lloh15:
	ldr	x10, [x10, _DRM_MM_INSERT_BEST@GOTPAGEOFF]
Lloh16:
	adrp	x11, _DRM_MM_INSERT_HIGH@GOTPAGE
Lloh17:
	ldr	x11, [x11, _DRM_MM_INSERT_HIGH@GOTPAGEOFF]
	tst	w8, w9
	csel	x8, x10, x11, eq
	ldr	w8, [x8]
	str	w8, [sp, #44]                   ; 4-byte Folded Spill
	str	xzr, [x19, #24]
	ldr	x26, [x19]
	add	x0, x21, #4
	stp	x0, x21, [sp, #8]               ; 16-byte Folded Spill
	bl	_spin_lock
	cmp	x26, x25
	b.hs	LBB0_11
; %bb.9:
	mov	x20, #0
	mov	w21, #0
	b	LBB0_14
LBB0_10:
	mov	x0, x20
	mov	x1, x21
	bl	_atomic64_sub
Lloh18:
	adrp	x8, _ENOMEM@GOTPAGE
Lloh19:
	ldr	x8, [x8, _ENOMEM@GOTPAGEOFF]
Lloh20:
	ldr	w8, [x8]
	neg	w0, w8
	b	LBB0_24
LBB0_11:
	mov	w21, #0
	mov	x20, #0
LBB0_12:                                ; =>This Inner Loop Header: Depth=1
	mov	x0, x26
	bl	_rounddown_pow_of_two
	mov	x22, x0
	ldp	x0, x8, [sp, #48]               ; 16-byte Folded Reload
	add	x23, x8, w21, uxtw #2
	ldr	w5, [x24, #12]
	mov	x1, x23
	mov	x2, x22
	mov	x3, x25
	mov	w4, #0
	mov	x6, x28
	ldr	w7, [sp, #44]                   ; 4-byte Folded Reload
	bl	_drm_mm_insert_node_in_range
	bl	_unlikely
	cbnz	x0, LBB0_14
; %bb.13:                               ;   in Loop: Header=BB0_12 Depth=1
	mov	x0, x27
	mov	x1, x23
	bl	_amdgpu_vram_mgr_vis_size
	add	x20, x0, x20
	mov	x0, x19
	mov	x1, x23
	bl	_amdgpu_vram_mgr_virt_start
	add	w21, w21, #1
	sub	x26, x26, x22
	cmp	x26, x25
	b.hs	LBB0_12
LBB0_14:
	str	x19, [sp, #24]                  ; 8-byte Folded Spill
	cbz	x26, LBB0_18
; %bb.15:
	str	x27, [sp, #32]                  ; 8-byte Folded Spill
	mov	x27, x24
	ldr	x19, [sp, #24]                  ; 8-byte Folded Reload
LBB0_16:                                ; =>This Inner Loop Header: Depth=1
	mov	x0, x26
	mov	x1, x25
	bl	_min
	mov	x24, x0
	ldr	x8, [x19, #8]
	cmp	x0, x25
	csel	x3, x25, x8, eq
	ldp	x0, x8, [sp, #48]               ; 16-byte Folded Reload
	add	x23, x8, w21, uxtw #2
	ldr	w5, [x27, #12]
	mov	x1, x23
	mov	x2, x24
	mov	w4, #0
	mov	x6, x28
	ldr	w7, [sp, #44]                   ; 4-byte Folded Reload
	bl	_drm_mm_insert_node_in_range
	mov	x22, x0
	bl	_unlikely
	cbnz	x0, LBB0_20
; %bb.17:                               ;   in Loop: Header=BB0_16 Depth=1
	ldr	x0, [sp, #32]                   ; 8-byte Folded Reload
	mov	x1, x23
	bl	_amdgpu_vram_mgr_vis_size
	add	x20, x0, x20
	mov	x0, x19
	mov	x1, x23
	bl	_amdgpu_vram_mgr_virt_start
	add	w21, w21, #1
	subs	x26, x26, x24
	b.ne	LBB0_16
	b	LBB0_19
LBB0_18:
	ldr	x19, [sp, #24]                  ; 8-byte Folded Reload
LBB0_19:
	ldr	x0, [sp, #8]                    ; 8-byte Folded Reload
	bl	_spin_unlock
	ldr	x8, [sp, #16]                   ; 8-byte Folded Reload
	add	x1, x8, #8
	mov	x0, x20
	bl	_atomic64_add
	mov	w0, #0
	ldr	x8, [sp, #56]                   ; 8-byte Folded Reload
	str	x8, [x19, #16]
	b	LBB0_24
LBB0_20:
	cbz	w21, LBB0_23
; %bb.21:
	mov	w8, w21
	lsl	x20, x8, #2
	ldr	x8, [sp, #56]                   ; 8-byte Folded Reload
	sub	x21, x8, #4
LBB0_22:                                ; =>This Inner Loop Header: Depth=1
	add	x0, x21, x20
	bl	_drm_mm_remove_node
	subs	x20, x20, #4
	b.ne	LBB0_22
LBB0_23:
	ldr	x0, [sp, #8]                    ; 8-byte Folded Reload
	bl	_spin_unlock
	ldp	x1, x8, [sp, #16]               ; 16-byte Folded Reload
	ldr	x8, [x8]
Lloh21:
	adrp	x9, _PAGE_SHIFT@GOTPAGE
Lloh22:
	ldr	x9, [x9, _PAGE_SHIFT@GOTPAGEOFF]
Lloh23:
	ldr	x9, [x9]
	lsl	x0, x8, x9
	bl	_atomic64_sub
	ldr	x0, [sp, #56]                   ; 8-byte Folded Reload
	bl	_kvfree
Lloh24:
	adrp	x8, _ENOSPC@GOTPAGE
Lloh25:
	ldr	x8, [x8, _ENOSPC@GOTPAGEOFF]
Lloh26:
	ldr	w8, [x8]
	cmn	w22, w8
	csel	w0, wzr, w22, eq
LBB0_24:
	ldp	x29, x30, [sp, #144]            ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #128]            ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #112]            ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #96]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #80]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #64]             ; 16-byte Folded Reload
	add	sp, sp, #160
	ret
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh7
	.loh AdrpLdrGot	Lloh16, Lloh17
	.loh AdrpLdrGot	Lloh14, Lloh15
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh18, Lloh19, Lloh20
	.loh AdrpLdrGotLdr	Lloh24, Lloh25, Lloh26
	.loh AdrpLdrGotLdr	Lloh21, Lloh22, Lloh23
	.cfi_endproc
                                        ; -- End function
	.comm	_PAGE_SHIFT,8,3                 ; @PAGE_SHIFT
	.comm	_TTM_PL_FLAG_CONTIGUOUS,4,2     ; @TTM_PL_FLAG_CONTIGUOUS
	.comm	_GFP_KERNEL,4,2                 ; @GFP_KERNEL
	.comm	___GFP_ZERO,4,2                 ; @__GFP_ZERO
	.comm	_ENOMEM,4,2                     ; @ENOMEM
	.comm	_DRM_MM_INSERT_BEST,4,2         ; @DRM_MM_INSERT_BEST
	.comm	_TTM_PL_FLAG_TOPDOWN,4,2        ; @TTM_PL_FLAG_TOPDOWN
	.comm	_DRM_MM_INSERT_HIGH,4,2         ; @DRM_MM_INSERT_HIGH
	.comm	_ENOSPC,4,2                     ; @ENOSPC
	.comm	_HPAGE_PMD_NR,8,3               ; @HPAGE_PMD_NR
	.no_dead_strip	_amdgpu_vram_mgr_new
.subsections_via_symbols
