	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function radeon_ttm_tt_pin_userptr
_radeon_ttm_tt_pin_userptr:             ## @radeon_ttm_tt_pin_userptr
	.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
	movq	%rdi, %r12
	movl	24(%rdi), %edi
	callq	_radeon_get_rdev
	movq	%rax, %r13
	movl	(%r12), %r15d
	movq	_RADEON_GEM_USERPTR_READONLY@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, -48(%rbp)                 ## 4-byte Spill
	testl	%r15d, %eax
	jne	LBB0_1
## %bb.2:
	movq	_DMA_BIDIRECTIONAL@GOTPCREL(%rip), %rax
	jmp	LBB0_3
LBB0_1:
	movq	_DMA_TO_DEVICE@GOTPCREL(%rip), %rax
LBB0_3:
	movq	_current@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rcx
	movq	(%rcx), %rdi
	cmpq	8(%r12), %rdi
	jne	LBB0_4
## %bb.5:
	movl	(%rax), %eax
	movl	%eax, -44(%rbp)                 ## 4-byte Spill
	movq	_RADEON_GEM_USERPTR_ANONONLY@GOTPCREL(%rip), %rcx
	movl	%r15d, %eax
	testl	%r15d, (%rcx)
	je	LBB0_10
## %bb.6:
	movl	16(%r12), %r14d
	movq	_PAGE_SIZE@GOTPCREL(%rip), %rax
	movl	(%rax), %ebx
	imull	%r15d, %ebx
	movl	%r14d, %esi
	callq	_find_vma
	testq	%rax, %rax
	je	LBB0_4
## %bb.7:
	cmpq	$0, 8(%rax)
	jne	LBB0_4
## %bb.8:
	addl	%r14d, %ebx
	cmpq	%rbx, (%rax)
	jae	LBB0_9
LBB0_4:
	movq	_EPERM@GOTPCREL(%rip), %rax
	xorl	%r13d, %r13d
	subl	(%rax), %r13d
	jmp	LBB0_21
LBB0_9:
	movl	(%r12), %eax
LBB0_10:
	movq	%r13, -56(%rbp)                 ## 8-byte Spill
	xorl	%r14d, %r14d
	.p2align	4, 0x90
LBB0_11:                                ## =>This Inner Loop Header: Depth=1
	subl	%r14d, %eax
	movq	_PAGE_SIZE@GOTPCREL(%rip), %rcx
	movl	(%rcx), %edi
	imull	%r14d, %edi
	addl	16(%r12), %edi
	movl	%r14d, %ecx
	shlq	$3, %rcx
	addq	8(%r12), %rcx
	movl	$0, %edx
	testl	%r15d, -48(%rbp)                ## 4-byte Folded Reload
	jne	LBB0_13
## %bb.12:                              ##   in Loop: Header=BB0_11 Depth=1
	movq	_FOLL_WRITE@GOTPCREL(%rip), %rdx
	movl	(%rdx), %edx
LBB0_13:                                ##   in Loop: Header=BB0_11 Depth=1
	movl	%eax, %esi
	xorl	%r8d, %r8d
	callq	_get_user_pages
	movl	%eax, %r13d
	leal	(%r14,%r13), %ecx
	movl	%r14d, %ebx
	testl	%eax, %eax
	cmovnsl	%ecx, %ebx
	js	LBB0_18
## %bb.14:                              ##   in Loop: Header=BB0_11 Depth=1
	movl	(%r12), %eax
	movl	%ecx, %r14d
	cmpl	%eax, %ebx
	jb	LBB0_11
## %bb.15:
	movq	_PAGE_SHIFT@GOTPCREL(%rip), %rcx
	movb	(%rcx), %cl
	movl	%eax, %r8d
	shll	%cl, %r8d
	movq	8(%r12), %rsi
	movq	16(%r12), %rdi
	movq	_GFP_KERNEL@GOTPCREL(%rip), %rcx
	movl	(%rcx), %r9d
	xorl	%r13d, %r13d
	movl	%eax, %edx
	xorl	%ecx, %ecx
	callq	_sg_alloc_table_from_pages
	testl	%eax, %eax
	je	LBB0_19
## %bb.16:
	movq	16(%r12), %rdi
	movl	%eax, %r13d
	jmp	LBB0_17
LBB0_19:
	movq	_ENOMEM@GOTPCREL(%rip), %rax
	subl	(%rax), %r13d
	movq	-56(%rbp), %rax                 ## 8-byte Reload
	movl	(%rax), %edi
	movq	16(%r12), %rax
	movl	(%rax), %edx
	movl	4(%rax), %esi
	movl	-44(%rbp), %ecx                 ## 4-byte Reload
	callq	_dma_map_sg
	movq	16(%r12), %rdi
	cmpl	(%rdi), %eax
	jne	LBB0_17
## %bb.20:
	movq	%rdi, %rdx
	shrq	$32, %rdx
	movq	8(%r12), %rsi
	movl	(%r12), %ecx
                                        ## kill: def $edx killed $edx killed $rdx
	callq	_drm_prime_sg_to_page_addr_arrays
	xorl	%r13d, %r13d
	jmp	LBB0_21
LBB0_17:
	callq	_kfree
LBB0_18:
	movq	8(%r12), %rdi
	movl	%ebx, %esi
	callq	_release_pages
LBB0_21:
	movl	%r13d, %eax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_RADEON_GEM_USERPTR_READONLY,4,2 ## @RADEON_GEM_USERPTR_READONLY
	.comm	_DMA_BIDIRECTIONAL,4,2          ## @DMA_BIDIRECTIONAL
	.comm	_DMA_TO_DEVICE,4,2              ## @DMA_TO_DEVICE
	.comm	_current,8,3                    ## @current
	.comm	_EPERM,4,2                      ## @EPERM
	.comm	_RADEON_GEM_USERPTR_ANONONLY,4,2 ## @RADEON_GEM_USERPTR_ANONONLY
	.comm	_PAGE_SIZE,4,2                  ## @PAGE_SIZE
	.comm	_FOLL_WRITE,4,2                 ## @FOLL_WRITE
	.comm	_PAGE_SHIFT,4,2                 ## @PAGE_SHIFT
	.comm	_GFP_KERNEL,4,2                 ## @GFP_KERNEL
	.comm	_ENOMEM,4,2                     ## @ENOMEM
	.no_dead_strip	_radeon_ttm_tt_pin_userptr
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function radeon_ttm_tt_pin_userptr
_radeon_ttm_tt_pin_userptr:             ; @radeon_ttm_tt_pin_userptr
	.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, x0
	ldr	w0, [x0, #24]
	bl	_radeon_get_rdev
	mov	x20, x0
	ldr	w23, [x19]
Lloh0:
	adrp	x8, _RADEON_GEM_USERPTR_READONLY@GOTPAGE
Lloh1:
	ldr	x8, [x8, _RADEON_GEM_USERPTR_READONLY@GOTPAGEOFF]
Lloh2:
	ldr	w8, [x8]
	ands	w24, w8, w23
Lloh3:
	adrp	x8, _DMA_BIDIRECTIONAL@GOTPAGE
Lloh4:
	ldr	x8, [x8, _DMA_BIDIRECTIONAL@GOTPAGEOFF]
Lloh5:
	adrp	x9, _DMA_TO_DEVICE@GOTPAGE
Lloh6:
	ldr	x9, [x9, _DMA_TO_DEVICE@GOTPAGEOFF]
	csel	x8, x8, x9, eq
Lloh7:
	adrp	x9, _current@GOTPAGE
Lloh8:
	ldr	x9, [x9, _current@GOTPAGEOFF]
Lloh9:
	ldr	x9, [x9]
	ldr	x0, [x9]
	ldr	x9, [x19, #8]
	cmp	x0, x9
	b.ne	LBB0_5
; %bb.1:
	ldr	w21, [x8]
Lloh10:
	adrp	x8, _RADEON_GEM_USERPTR_ANONONLY@GOTPAGE
Lloh11:
	ldr	x8, [x8, _RADEON_GEM_USERPTR_ANONONLY@GOTPAGEOFF]
Lloh12:
	ldr	w8, [x8]
Lloh13:
	adrp	x25, _PAGE_SIZE@GOTPAGE
Lloh14:
	ldr	x25, [x25, _PAGE_SIZE@GOTPAGEOFF]
	tst	w8, w23
	b.eq	LBB0_7
; %bb.2:
	ldr	w22, [x19, #16]
	ldr	w26, [x25]
	mov	x1, x22
	bl	_find_vma
	cbz	x0, LBB0_5
; %bb.3:
	ldr	x8, [x0, #8]
	cbnz	x8, LBB0_5
; %bb.4:
	madd	w8, w26, w23, w22
	ldr	x9, [x0]
	cmp	x9, x8
	b.hs	LBB0_6
LBB0_5:
Lloh15:
	adrp	x8, _EPERM@GOTPAGE
Lloh16:
	ldr	x8, [x8, _EPERM@GOTPAGEOFF]
Lloh17:
	ldr	w8, [x8]
	neg	w23, w8
	b	LBB0_18
LBB0_6:
	ldr	w23, [x19]
LBB0_7:
	mov	w27, #0
Lloh18:
	adrp	x26, _FOLL_WRITE@GOTPAGE
Lloh19:
	ldr	x26, [x26, _FOLL_WRITE@GOTPAGEOFF]
LBB0_8:                                 ; =>This Inner Loop Header: Depth=1
	sub	w1, w23, w27
	ldr	w8, [x19, #16]
	ldr	w9, [x25]
	madd	w0, w9, w27, w8
	ldr	x8, [x19, #8]
	add	x3, x8, w27, uxtw #3
	ldr	w8, [x26]
	cmp	w24, #0
	csel	w2, w8, wzr, eq
	mov	x4, #0
	bl	_get_user_pages
	add	w8, w0, w27
	cmp	w0, #0
	csel	w22, w27, w8, lt
	tbnz	w0, #31, LBB0_12
; %bb.9:                                ;   in Loop: Header=BB0_8 Depth=1
	ldr	w23, [x19]
	mov	x27, x8
	cmp	w22, w23
	b.lo	LBB0_8
; %bb.10:
Lloh20:
	adrp	x8, _PAGE_SHIFT@GOTPAGE
Lloh21:
	ldr	x8, [x8, _PAGE_SHIFT@GOTPAGEOFF]
	ldp	x1, x0, [x19, #8]
Lloh22:
	ldr	w8, [x8]
	lsl	w4, w23, w8
Lloh23:
	adrp	x8, _GFP_KERNEL@GOTPAGE
Lloh24:
	ldr	x8, [x8, _GFP_KERNEL@GOTPAGEOFF]
Lloh25:
	ldr	w5, [x8]
	mov	x2, x23
	mov	w3, #0
	bl	_sg_alloc_table_from_pages
	cbz	w0, LBB0_13
; %bb.11:
	mov	x23, x0
	ldr	x0, [x19, #16]
	b	LBB0_16
LBB0_12:
	mov	x23, x0
	b	LBB0_17
LBB0_13:
Lloh26:
	adrp	x8, _ENOMEM@GOTPAGE
Lloh27:
	ldr	x8, [x8, _ENOMEM@GOTPAGEOFF]
Lloh28:
	ldr	w23, [x8]
	ldr	w0, [x20]
	ldr	x8, [x19, #16]
	ldp	w2, w1, [x8]
	mov	x3, x21
	bl	_dma_map_sg
	mov	x8, x0
	ldr	x0, [x19, #16]
	ldr	w9, [x0]
	cmp	w8, w9
	b.ne	LBB0_15
; %bb.14:
	lsr	x2, x0, #32
	ldr	x1, [x19, #8]
	ldr	w3, [x19]
                                        ; kill: def $w2 killed $w2 killed $x2
	bl	_drm_prime_sg_to_page_addr_arrays
	mov	w23, #0
	b	LBB0_18
LBB0_15:
	neg	w23, w23
LBB0_16:
	bl	_kfree
LBB0_17:
	ldr	x0, [x19, #8]
	mov	x1, x22
	bl	_release_pages
LBB0_18:
	mov	x0, x23
	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
	.loh AdrpLdrGotLdr	Lloh7, Lloh8, Lloh9
	.loh AdrpLdrGot	Lloh5, Lloh6
	.loh AdrpLdrGot	Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGot	Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh10, Lloh11, Lloh12
	.loh AdrpLdrGotLdr	Lloh15, Lloh16, Lloh17
	.loh AdrpLdrGot	Lloh18, Lloh19
	.loh AdrpLdrGotLdr	Lloh23, Lloh24, Lloh25
	.loh AdrpLdrGotLdr	Lloh20, Lloh21, Lloh22
	.loh AdrpLdrGotLdr	Lloh26, Lloh27, Lloh28
	.cfi_endproc
                                        ; -- End function
	.comm	_RADEON_GEM_USERPTR_READONLY,4,2 ; @RADEON_GEM_USERPTR_READONLY
	.comm	_DMA_BIDIRECTIONAL,4,2          ; @DMA_BIDIRECTIONAL
	.comm	_DMA_TO_DEVICE,4,2              ; @DMA_TO_DEVICE
	.comm	_current,8,3                    ; @current
	.comm	_EPERM,4,2                      ; @EPERM
	.comm	_RADEON_GEM_USERPTR_ANONONLY,4,2 ; @RADEON_GEM_USERPTR_ANONONLY
	.comm	_PAGE_SIZE,4,2                  ; @PAGE_SIZE
	.comm	_FOLL_WRITE,4,2                 ; @FOLL_WRITE
	.comm	_PAGE_SHIFT,4,2                 ; @PAGE_SHIFT
	.comm	_GFP_KERNEL,4,2                 ; @GFP_KERNEL
	.comm	_ENOMEM,4,2                     ; @ENOMEM
	.no_dead_strip	_radeon_ttm_tt_pin_userptr
.subsections_via_symbols
