	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_via_mem_alloc                  ## -- Begin function via_mem_alloc
	.p2align	4, 0x90
_via_mem_alloc:                         ## @via_mem_alloc
	.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
	movq	(%rsi), %rax
	movq	_VIA_MEM_AGP@GOTPCREL(%rip), %r14
	cmpq	(%r14), %rax
	jle	LBB0_3
## %bb.1:
	leaq	L_.str(%rip), %rdi
	callq	_DRM_ERROR
	jmp	LBB0_2
LBB0_3:
	movq	%rsi, %r13
	movq	%rdi, %rbx
	movq	8(%rdi), %r12
	movq	(%rdx), %r15
	callq	_mutex_lock
	movq	(%r13), %rax
	movq	_VIA_MEM_VIDEO@GOTPCREL(%rip), %rdx
	xorl	%ecx, %ecx
	cmpq	(%rdx), %rax
	setne	%cl
	cmpq	$0, (%r12,%rcx,8)
	je	LBB0_4
## %bb.5:
	movq	%rbx, -56(%rbp)                 ## 8-byte Spill
	movq	%r15, -72(%rbp)                 ## 8-byte Spill
	movq	_GFP_KERNEL@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movl	$16, %edi
	callq	_kzalloc
	movq	%rax, %r15
	testq	%rax, %rax
	je	LBB0_6
## %bb.7:
	movq	_VIA_MM_ALIGN_MASK@GOTPCREL(%rip), %rax
	movq	(%rax), %rdx
	addq	8(%r13), %rdx
	movq	_VIA_MM_ALIGN_SHIFT@GOTPCREL(%rip), %rax
	movb	(%rax), %cl
	shrq	%cl, %rdx
	movq	(%r13), %rax
	xorl	%ecx, %ecx
	cmpq	(%r14), %rax
	sete	%cl
	leaq	(%r12,%rcx,4), %rdi
	addq	$36, %rdi
	movq	%r15, %rsi
	xorl	%ecx, %ecx
	callq	_drm_mm_insert_node
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	LBB0_12
## %bb.8:
	movq	%r12, -64(%rbp)                 ## 8-byte Spill
	addq	$32, %r12
	movq	_VIA_MM_ALIGN_SHIFT@GOTPCREL(%rip), %r14
	.p2align	4, 0x90
LBB0_9:                                 ## =>This Inner Loop Header: Depth=1
	movq	_GFP_KERNEL@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r12, %rdi
	callq	_idr_pre_get
	testq	%rax, %rax
	je	LBB0_10
## %bb.13:                              ##   in Loop: Header=BB0_9 Depth=1
	movq	%r12, %rdi
	movq	%r15, %rsi
	movl	$1, %edx
	leaq	-44(%rbp), %rcx
	callq	_idr_get_new_above
	movl	%eax, %ebx
	movq	_EAGAIN@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	addl	%ebx, %eax
	je	LBB0_9
## %bb.14:
	testl	%ebx, %ebx
	jne	LBB0_11
## %bb.15:
	movq	%r15, %rdi
	addq	$8, %rdi
	movq	-72(%rbp), %rsi                 ## 8-byte Reload
	callq	_list_add
	movq	-56(%rbp), %rdi                 ## 8-byte Reload
	callq	_mutex_unlock
	movq	(%r13), %rax
	xorl	%edx, %edx
	movq	_VIA_MEM_VIDEO@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	sete	%dl
	movq	(%r15), %rax
	movb	(%r14), %cl
	shlq	%cl, %rax
	movq	-64(%rbp), %rcx                 ## 8-byte Reload
	addq	16(%rcx,%rdx,8), %rax
	movq	%rax, 24(%r13)
	movl	-44(%rbp), %eax
	movl	%eax, 16(%r13)
	xorl	%ebx, %ebx
	jmp	LBB0_16
LBB0_4:
	leaq	L_.str.1(%rip), %rdi
	callq	_DRM_ERROR
	movq	%rbx, %rdi
	callq	_mutex_unlock
LBB0_2:
	movq	_EINVAL@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
	jmp	LBB0_16
LBB0_6:
	movq	_ENOMEM@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
	jmp	LBB0_12
LBB0_10:
	movq	_ENOMEM@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
LBB0_11:
	movq	%r15, %rdi
	callq	_drm_mm_remove_node
LBB0_12:
	movq	%r15, %rdi
	callq	_kfree
	movq	-56(%rbp), %rdi                 ## 8-byte Reload
	callq	_mutex_unlock
	movq	$0, 24(%r13)
	movq	$0, 8(%r13)
	movl	$0, 16(%r13)
	leaq	L_.str.2(%rip), %rdi
	callq	_DRM_DEBUG
LBB0_16:
	movl	%ebx, %eax
	addq	$40, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_VIA_MEM_AGP,8,3                ## @VIA_MEM_AGP
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Unknown memory type allocation\n"

	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_VIA_MEM_VIDEO,8,3              ## @VIA_MEM_VIDEO
L_.str.1:                               ## @.str.1
	.asciz	"Attempt to allocate from uninitialized memory manager.\n"

	.comm	_GFP_KERNEL,4,2                 ## @GFP_KERNEL
	.comm	_ENOMEM,4,2                     ## @ENOMEM
	.comm	_VIA_MM_ALIGN_MASK,8,3          ## @VIA_MM_ALIGN_MASK
	.comm	_VIA_MM_ALIGN_SHIFT,8,3         ## @VIA_MM_ALIGN_SHIFT
	.comm	_EAGAIN,4,2                     ## @EAGAIN
L_.str.2:                               ## @.str.2
	.asciz	"Video memory allocation failed\n"

.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_via_mem_alloc                  ; -- Begin function via_mem_alloc
	.p2align	2
_via_mem_alloc:                         ; @via_mem_alloc
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #112
	.cfi_def_cfa_offset 112
	stp	x28, x27, [sp, #16]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #32]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #48]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #64]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #80]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #96]             ; 16-byte Folded Spill
	add	x29, sp, #96
	.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
	ldr	x8, [x1]
Lloh0:
	adrp	x23, _VIA_MEM_AGP@GOTPAGE
Lloh1:
	ldr	x23, [x23, _VIA_MEM_AGP@GOTPAGEOFF]
	ldr	x9, [x23]
	cmp	x8, x9
	b.le	LBB0_2
; %bb.1:
Lloh2:
	adrp	x0, l_.str@PAGE
Lloh3:
	add	x0, x0, l_.str@PAGEOFF
	bl	_DRM_ERROR
	b	LBB0_11
LBB0_2:
	mov	x19, x1
	mov	x20, x0
	ldr	x25, [x0, #8]
	ldr	x22, [x2]
	bl	_mutex_lock
Lloh4:
	adrp	x26, _VIA_MEM_VIDEO@GOTPAGE
Lloh5:
	ldr	x26, [x26, _VIA_MEM_VIDEO@GOTPAGEOFF]
	ldr	x8, [x19]
	ldr	x9, [x26]
	cmp	x8, x9
	cset	w8, ne
	ldr	x8, [x25, w8, uxtw #3]
	cbz	x8, LBB0_10
; %bb.3:
Lloh6:
	adrp	x28, _GFP_KERNEL@GOTPAGE
Lloh7:
	ldr	x28, [x28, _GFP_KERNEL@GOTPAGEOFF]
	ldr	w1, [x28]
	mov	w0, #16
	bl	_kzalloc
	mov	x21, x0
	cbz	x0, LBB0_12
; %bb.4:
Lloh8:
	adrp	x8, _VIA_MM_ALIGN_MASK@GOTPAGE
Lloh9:
	ldr	x8, [x8, _VIA_MM_ALIGN_MASK@GOTPAGEOFF]
Lloh10:
	ldr	x8, [x8]
	ldp	x10, x9, [x19]
	add	x8, x8, x9
Lloh11:
	adrp	x9, _VIA_MM_ALIGN_SHIFT@GOTPAGE
Lloh12:
	ldr	x9, [x9, _VIA_MM_ALIGN_SHIFT@GOTPAGEOFF]
Lloh13:
	ldr	x9, [x9]
	lsr	x2, x8, x9
	ldr	x8, [x23]
	add	x9, x25, #36
	add	x11, x25, #40
	cmp	x10, x8
	csel	x0, x11, x9, eq
	mov	x1, x21
	mov	w3, #0
	bl	_drm_mm_insert_node
	mov	x23, x0
	cbnz	w0, LBB0_15
; %bb.5:
	add	x24, x25, #32
Lloh14:
	adrp	x27, _EAGAIN@GOTPAGE
Lloh15:
	ldr	x27, [x27, _EAGAIN@GOTPAGEOFF]
LBB0_6:                                 ; =>This Inner Loop Header: Depth=1
	ldr	w1, [x28]
	mov	x0, x24
	bl	_idr_pre_get
	cbz	x0, LBB0_13
; %bb.7:                                ;   in Loop: Header=BB0_6 Depth=1
	add	x3, sp, #12
	mov	x0, x24
	mov	x1, x21
	mov	w2, #1
	bl	_idr_get_new_above
	ldr	w8, [x27]
	cmn	w0, w8
	b.eq	LBB0_6
; %bb.8:
	mov	x23, x0
	cbnz	w0, LBB0_14
; %bb.9:
	add	x0, x21, #8
	mov	x1, x22
	bl	_list_add
	mov	x0, x20
	bl	_mutex_unlock
	ldr	x8, [x19]
	ldr	x9, [x26]
	mov	w10, #16
	mov	w11, #24
	cmp	x8, x9
	csel	x8, x11, x10, eq
	ldr	x8, [x25, x8]
	ldr	x9, [x21]
Lloh16:
	adrp	x10, _VIA_MM_ALIGN_SHIFT@GOTPAGE
Lloh17:
	ldr	x10, [x10, _VIA_MM_ALIGN_SHIFT@GOTPAGEOFF]
Lloh18:
	ldr	x10, [x10]
	lsl	x9, x9, x10
	add	x8, x9, x8
	str	x8, [x19, #24]
	ldr	w8, [sp, #12]
	str	w8, [x19, #16]
	b	LBB0_16
LBB0_10:
Lloh19:
	adrp	x0, l_.str.1@PAGE
Lloh20:
	add	x0, x0, l_.str.1@PAGEOFF
	bl	_DRM_ERROR
	mov	x0, x20
	bl	_mutex_unlock
LBB0_11:
Lloh21:
	adrp	x8, _EINVAL@GOTPAGE
Lloh22:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh23:
	ldr	w8, [x8]
	neg	w23, w8
	b	LBB0_16
LBB0_12:
Lloh24:
	adrp	x8, _ENOMEM@GOTPAGE
Lloh25:
	ldr	x8, [x8, _ENOMEM@GOTPAGEOFF]
Lloh26:
	ldr	w8, [x8]
	neg	w23, w8
	b	LBB0_15
LBB0_13:
Lloh27:
	adrp	x8, _ENOMEM@GOTPAGE
Lloh28:
	ldr	x8, [x8, _ENOMEM@GOTPAGEOFF]
Lloh29:
	ldr	w8, [x8]
	neg	w23, w8
LBB0_14:
	mov	x0, x21
	bl	_drm_mm_remove_node
LBB0_15:
	mov	x0, x21
	bl	_kfree
	mov	x0, x20
	bl	_mutex_unlock
	str	xzr, [x19, #24]
	str	xzr, [x19, #8]
	str	wzr, [x19, #16]
Lloh30:
	adrp	x0, l_.str.2@PAGE
Lloh31:
	add	x0, x0, l_.str.2@PAGEOFF
	bl	_DRM_DEBUG
LBB0_16:
	mov	x0, x23
	ldp	x29, x30, [sp, #96]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #80]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #64]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #48]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #32]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #112
	ret
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpAdd	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh4, Lloh5
	.loh AdrpLdrGot	Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpLdrGot	Lloh14, Lloh15
	.loh AdrpLdrGotLdr	Lloh16, Lloh17, Lloh18
	.loh AdrpAdd	Lloh19, Lloh20
	.loh AdrpLdrGotLdr	Lloh21, Lloh22, Lloh23
	.loh AdrpLdrGotLdr	Lloh24, Lloh25, Lloh26
	.loh AdrpLdrGotLdr	Lloh27, Lloh28, Lloh29
	.loh AdrpAdd	Lloh30, Lloh31
	.cfi_endproc
                                        ; -- End function
	.comm	_VIA_MEM_AGP,8,3                ; @VIA_MEM_AGP
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Unknown memory type allocation\n"

	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_VIA_MEM_VIDEO,8,3              ; @VIA_MEM_VIDEO
l_.str.1:                               ; @.str.1
	.asciz	"Attempt to allocate from uninitialized memory manager.\n"

	.comm	_GFP_KERNEL,4,2                 ; @GFP_KERNEL
	.comm	_ENOMEM,4,2                     ; @ENOMEM
	.comm	_VIA_MM_ALIGN_MASK,8,3          ; @VIA_MM_ALIGN_MASK
	.comm	_VIA_MM_ALIGN_SHIFT,8,3         ; @VIA_MM_ALIGN_SHIFT
	.comm	_EAGAIN,4,2                     ; @EAGAIN
l_.str.2:                               ; @.str.2
	.asciz	"Video memory allocation failed\n"

.subsections_via_symbols
