	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function map_device_va
_map_device_va:                         ## @map_device_va
	.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	$72, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdx, %r15
	movq	%rsi, %r14
	movq	%rdi, %r13
	movq	32(%rdi), %r12
	movq	$0, -80(%rbp)
	movq	_HL_MEM_USERPTR@GOTPCREL(%rip), %rax
	movl	(%rax), %ebx
	andl	(%rsi), %ebx
	movq	$0, (%rdx)
	je	LBB0_6
## %bb.1:
	movq	%r15, -72(%rbp)                 ## 8-byte Spill
	leaq	-80(%rbp), %rdx
	movq	%r12, %rdi
	movq	%r14, %rsi
	callq	_get_userptr_from_host_va
	testl	%eax, %eax
	je	LBB0_3
## %bb.2:
	movl	%eax, %r15d
	movl	(%r12), %edi
	leaq	L_.str(%rip), %rsi
	xorl	%eax, %eax
	callq	_dev_err
	jmp	LBB0_26
LBB0_6:
	movq	%r13, -72(%rbp)                 ## 8-byte Spill
	movl	%ebx, -44(%rbp)                 ## 4-byte Spill
	movl	16(%r14), %edi
	callq	_lower_32_bits
	movl	%eax, %r13d
	leaq	16(%r12), %rbx
	movq	%rbx, %rdi
	callq	_spin_lock
	leaq	20(%r12), %rdi
	movl	%r13d, %esi
	callq	_idr_find
	movq	%rax, -56(%rbp)
	testq	%rax, %rax
	je	LBB0_7
## %bb.8:
	movl	%r13d, -48(%rbp)                ## 4-byte Spill
	movq	%r12, -64(%rbp)                 ## 8-byte Spill
	movq	%rax, %r12
	addq	$16, %r12
	movq	%r12, %rdi
	movq	%rax, -88(%rbp)                 ## 8-byte Spill
	callq	_atomic_inc
	movq	%rbx, %rdi
	callq	_spin_unlock
	movq	-88(%rbp), %rcx                 ## 8-byte Reload
	movq	8(%r14), %rbx
	movq	_HL_MEM_SHARED@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	testl	%eax, (%rcx)
	je	LBB0_10
## %bb.9:
	movq	-64(%rbp), %r12                 ## 8-byte Reload
	movq	-72(%rbp), %r13                 ## 8-byte Reload
	jmp	LBB0_14
LBB0_3:
	movq	-80(%rbp), %rsi
	leaq	-56(%rbp), %rdx
	movq	%r13, %rdi
	callq	_init_phys_pg_pack_from_userptr
	testl	%eax, %eax
	je	LBB0_13
## %bb.4:
	movl	%eax, %r15d
	movl	(%r12), %edi
	movl	32(%r14), %edx
	leaq	L_.str.1(%rip), %rsi
	xorl	%eax, %eax
	callq	_dev_err
	jmp	LBB0_5
LBB0_7:
	movq	%rbx, %rdi
	callq	_spin_unlock
	movl	(%r12), %edi
	leaq	L_.str.2(%rip), %rsi
	xorl	%r15d, %r15d
	movl	%r13d, %edx
	xorl	%eax, %eax
	callq	_dev_err
	movq	_EINVAL@GOTPCREL(%rip), %rax
	subl	(%rax), %r15d
	jmp	LBB0_26
LBB0_10:
	movq	8(%rcx), %rax
	movq	-72(%rbp), %r13                 ## 8-byte Reload
	cmpq	(%r13), %rax
	jne	LBB0_12
## %bb.11:
	movq	-64(%rbp), %r12                 ## 8-byte Reload
	jmp	LBB0_14
LBB0_13:
	movl	%ebx, -44(%rbp)                 ## 4-byte Spill
	movq	-80(%rbp), %rax
	movq	%rax, -88(%rbp)                 ## 8-byte Spill
	movq	24(%r14), %rbx
	movl	$0, -48(%rbp)                   ## 4-byte Folded Spill
	movq	-72(%rbp), %r15                 ## 8-byte Reload
LBB0_14:
	movq	_GFP_KERNEL@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movl	$24, %edi
	callq	_kzalloc
	testq	%rax, %rax
	je	LBB0_15
## %bb.18:
	movq	%rax, -96(%rbp)                 ## 8-byte Spill
	xorl	%eax, %eax
	movl	-44(%rbp), %r8d                 ## 4-byte Reload
	testl	%r8d, %r8d
	setne	%al
	leaq	8(%r13,%rax,4), %rsi
	movq	-56(%rbp), %rax
	movq	24(%rax), %rdx
	movq	%r12, %rdi
	movq	%rsi, -104(%rbp)                ## 8-byte Spill
	movq	%rbx, %rcx
	callq	_get_va_block
	testq	%rax, %rax
	je	LBB0_19
## %bb.20:
	movq	%rax, %r14
	movq	%r15, -72(%rbp)                 ## 8-byte Spill
	movq	%r12, -64(%rbp)                 ## 8-byte Spill
	leaq	24(%r13), %r12
	movq	%r12, %rdi
	callq	_mutex_lock
	movq	-56(%rbp), %rdx
	movq	%r13, %rdi
	movq	%r14, %rsi
	callq	_map_phys_page_pack
	testl	%eax, %eax
	je	LBB0_24
## %bb.21:
	movl	%eax, %r15d
	movq	%r12, %rdi
	callq	_mutex_unlock
	movq	-64(%rbp), %r12                 ## 8-byte Reload
	movl	(%r12), %edi
	leaq	L_.str.5(%rip), %rsi
	movl	-48(%rbp), %ebx                 ## 4-byte Reload
	movl	%ebx, %edx
	xorl	%eax, %eax
	callq	_dev_err
	movq	-56(%rbp), %rax
	movq	24(%rax), %rax
	leaq	(%r14,%rax), %rcx
	decq	%rcx
	movq	%r12, %rdi
	movq	-104(%rbp), %rsi                ## 8-byte Reload
	movq	%r14, %rdx
	callq	_add_va_block
	testq	%rax, %rax
	je	LBB0_23
## %bb.22:
	movl	(%r12), %edi
	leaq	L_.str.6(%rip), %rsi
	movl	%ebx, %edx
	movq	%r14, %rcx
	callq	_dev_warn
	jmp	LBB0_23
LBB0_15:
	movq	_ENOMEM@GOTPCREL(%rip), %rax
	xorl	%r15d, %r15d
	subl	(%rax), %r15d
	movl	-44(%rbp), %ebx                 ## 4-byte Reload
	jmp	LBB0_16
LBB0_19:
	movl	(%r12), %edi
	leaq	L_.str.4(%rip), %rsi
	xorl	%r15d, %r15d
	movl	-48(%rbp), %edx                 ## 4-byte Reload
	xorl	%eax, %eax
	callq	_dev_err
	movq	_ENOMEM@GOTPCREL(%rip), %rax
	subl	(%rax), %r15d
LBB0_23:
	movl	-44(%rbp), %ebx                 ## 4-byte Reload
	movq	-96(%rbp), %rdi                 ## 8-byte Reload
	callq	_kfree
LBB0_16:
	movq	-56(%rbp), %rdi
	addq	$16, %rdi
	callq	_atomic_dec
	testl	%ebx, %ebx
	je	LBB0_26
## %bb.17:
	movq	-56(%rbp), %rsi
	movq	%r12, %rdi
	callq	_free_phys_pg_pack
LBB0_5:
	movq	-80(%rbp), %rsi
	movq	%r12, %rdi
	callq	_free_userptr
LBB0_26:
	movl	%r15d, %eax
	addq	$72, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_12:
	movq	-64(%rbp), %rax                 ## 8-byte Reload
	movl	(%rax), %edi
	leaq	L_.str.3(%rip), %rsi
	xorl	%r15d, %r15d
	movl	-48(%rbp), %edx                 ## 4-byte Reload
	xorl	%eax, %eax
	callq	_dev_err
	movq	_EPERM@GOTPCREL(%rip), %rax
	subl	(%rax), %r15d
	movq	%r12, %rdi
	callq	_atomic_dec
	jmp	LBB0_26
LBB0_24:
	movq	-64(%rbp), %rdi                 ## 8-byte Reload
	movq	8(%rdi), %rax
	xorl	%r15d, %r15d
	xorl	%esi, %esi
	callq	*(%rax)
	movq	%r12, %rdi
	callq	_mutex_unlock
	movq	-56(%rbp), %rax
	movq	32(%rax), %r12
	addq	%r14, %r12
	movq	-96(%rbp), %rbx                 ## 8-byte Reload
	movq	-88(%rbp), %rax                 ## 8-byte Reload
	movq	%rax, (%rbx)
	movq	%r12, 16(%rbx)
	leaq	16(%r13), %r14
	movq	%r14, %rdi
	callq	_mutex_lock
	movl	20(%r13), %edi
	addq	$8, %rbx
	movq	%rbx, %rsi
	movq	%r12, %rdx
	callq	_hash_add
	movq	%r14, %rdi
	callq	_mutex_unlock
	movq	-72(%rbp), %rax                 ## 8-byte Reload
	movq	%r12, (%rax)
	cmpl	$0, -44(%rbp)                   ## 4-byte Folded Reload
	je	LBB0_26
## %bb.25:
	movq	-56(%rbp), %rsi
	movq	-64(%rbp), %rdi                 ## 8-byte Reload
	callq	_free_phys_pg_pack
	jmp	LBB0_26
	.cfi_endproc
                                        ## -- End function
	.comm	_HL_MEM_USERPTR,4,2             ## @HL_MEM_USERPTR
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"failed to get userptr from va\n"

L_.str.1:                               ## @.str.1
	.asciz	"unable to init page pack for vaddr 0x%llx\n"

L_.str.2:                               ## @.str.2
	.asciz	"no match for handle %u\n"

	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_HL_MEM_SHARED,4,2              ## @HL_MEM_SHARED
L_.str.3:                               ## @.str.3
	.asciz	"Failed to map memory, handle %u is not shared\n"

	.comm	_EPERM,4,2                      ## @EPERM
	.comm	_GFP_KERNEL,4,2                 ## @GFP_KERNEL
	.comm	_ENOMEM,4,2                     ## @ENOMEM
L_.str.4:                               ## @.str.4
	.asciz	"no available va block for handle %u\n"

L_.str.5:                               ## @.str.5
	.asciz	"mapping page pack failed for handle %u\n"

L_.str.6:                               ## @.str.6
	.asciz	"release va block failed for handle 0x%x, vaddr: 0x%llx\n"

	.no_dead_strip	_map_device_va
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function map_device_va
_map_device_va:                         ; @map_device_va
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #128
	.cfi_def_cfa_offset 128
	stp	x28, x27, [sp, #32]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #48]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #64]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #80]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #96]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #112]            ; 16-byte Folded Spill
	add	x29, sp, #112
	.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	x21, x2
	mov	x25, x1
	mov	x22, x0
	ldr	x19, [x0, #32]
	str	xzr, [sp, #16]
	ldr	w8, [x1]
Lloh0:
	adrp	x9, _HL_MEM_USERPTR@GOTPAGE
Lloh1:
	ldr	x9, [x9, _HL_MEM_USERPTR@GOTPAGEOFF]
Lloh2:
	ldr	w9, [x9]
	str	xzr, [x2]
	ands	w20, w9, w8
	b.eq	LBB0_3
; %bb.1:
	add	x2, sp, #16
	mov	x0, x19
	mov	x1, x25
	bl	_get_userptr_from_host_va
	cbz	w0, LBB0_7
; %bb.2:
	mov	x24, x0
	ldr	w0, [x19]
Lloh3:
	adrp	x1, l_.str@PAGE
Lloh4:
	add	x1, x1, l_.str@PAGEOFF
	bl	_dev_err
	b	LBB0_22
LBB0_3:
	ldr	w0, [x25, #16]
	bl	_lower_32_bits
	mov	x23, x0
	add	x24, x19, #16
	mov	x0, x24
	bl	_spin_lock
	add	x0, x19, #20
	mov	x1, x23
	bl	_idr_find
	str	x0, [sp, #24]
	cbz	x0, LBB0_9
; %bb.4:
	mov	x26, x0
	add	x27, x0, #16
	mov	x0, x27
	bl	_atomic_inc
	mov	x0, x24
	bl	_spin_unlock
	ldr	x24, [x25, #8]
	ldr	w8, [x26]
Lloh5:
	adrp	x9, _HL_MEM_SHARED@GOTPAGE
Lloh6:
	ldr	x9, [x9, _HL_MEM_SHARED@GOTPAGEOFF]
Lloh7:
	ldr	w9, [x9]
	tst	w9, w8
	b.ne	LBB0_11
; %bb.5:
	ldr	x8, [x26, #8]
	ldr	x9, [x22]
	cmp	x8, x9
	b.eq	LBB0_11
; %bb.6:
	ldr	w0, [x19]
                                        ; kill: def $w23 killed $w23 killed $x23 def $x23
	str	x23, [sp]
Lloh8:
	adrp	x1, l_.str.3@PAGE
Lloh9:
	add	x1, x1, l_.str.3@PAGEOFF
	bl	_dev_err
Lloh10:
	adrp	x8, _EPERM@GOTPAGE
Lloh11:
	ldr	x8, [x8, _EPERM@GOTPAGEOFF]
Lloh12:
	ldr	w8, [x8]
	neg	w24, w8
	mov	x0, x27
	bl	_atomic_dec
	b	LBB0_22
LBB0_7:
	ldr	x1, [sp, #16]
	add	x2, sp, #24
	mov	x0, x22
	bl	_init_phys_pg_pack_from_userptr
	cbz	w0, LBB0_10
; %bb.8:
	mov	x24, x0
	ldr	w0, [x19]
	ldr	w8, [x25, #32]
	str	x8, [sp]
Lloh13:
	adrp	x1, l_.str.1@PAGE
Lloh14:
	add	x1, x1, l_.str.1@PAGEOFF
	bl	_dev_err
	b	LBB0_21
LBB0_9:
	mov	x0, x24
	bl	_spin_unlock
	ldr	w0, [x19]
                                        ; kill: def $w23 killed $w23 killed $x23 def $x23
	str	x23, [sp]
Lloh15:
	adrp	x1, l_.str.2@PAGE
Lloh16:
	add	x1, x1, l_.str.2@PAGEOFF
	bl	_dev_err
Lloh17:
	adrp	x8, _EINVAL@GOTPAGE
Lloh18:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh19:
	ldr	w8, [x8]
	neg	w24, w8
	b	LBB0_22
LBB0_10:
	mov	w23, #0
	ldr	x26, [sp, #16]
	ldr	x24, [x25, #24]
LBB0_11:
Lloh20:
	adrp	x8, _GFP_KERNEL@GOTPAGE
Lloh21:
	ldr	x8, [x8, _GFP_KERNEL@GOTPAGEOFF]
Lloh22:
	ldr	w1, [x8]
	mov	w0, #24
	bl	_kzalloc
	cbz	x0, LBB0_16
; %bb.12:
	mov	x25, x0
	add	x8, x22, #12
	add	x9, x22, #8
	cmp	w20, #0
	csel	x28, x9, x8, eq
	ldr	x8, [sp, #24]
	ldr	x2, [x8, #24]
	mov	x0, x19
	mov	x1, x28
	mov	x3, x24
	mov	x4, x20
	bl	_get_va_block
	cbz	x0, LBB0_17
; %bb.13:
	mov	x27, x0
	str	x28, [sp, #8]                   ; 8-byte Folded Spill
	add	x28, x22, #24
	mov	x0, x28
	bl	_mutex_lock
	ldr	x2, [sp, #24]
	mov	x0, x22
	mov	x1, x27
	bl	_map_phys_page_pack
	cbz	w0, LBB0_23
; %bb.14:
	mov	x24, x0
	mov	x0, x28
	bl	_mutex_unlock
	ldr	w0, [x19]
	str	x23, [sp]
Lloh23:
	adrp	x1, l_.str.5@PAGE
Lloh24:
	add	x1, x1, l_.str.5@PAGEOFF
	bl	_dev_err
	ldr	x8, [sp, #24]
	ldr	x8, [x8, #24]
	add	x8, x27, x8
	sub	x3, x8, #1
	mov	x0, x19
	ldr	x1, [sp, #8]                    ; 8-byte Folded Reload
	mov	x2, x27
	bl	_add_va_block
	cbz	x0, LBB0_18
; %bb.15:
	ldr	w0, [x19]
Lloh25:
	adrp	x1, l_.str.6@PAGE
Lloh26:
	add	x1, x1, l_.str.6@PAGEOFF
	mov	x2, x23
	mov	x3, x27
	bl	_dev_warn
	b	LBB0_18
LBB0_16:
Lloh27:
	adrp	x8, _ENOMEM@GOTPAGE
Lloh28:
	ldr	x8, [x8, _ENOMEM@GOTPAGEOFF]
Lloh29:
	ldr	w8, [x8]
	neg	w24, w8
	b	LBB0_19
LBB0_17:
	ldr	w0, [x19]
                                        ; kill: def $w23 killed $w23 killed $x23 def $x23
	str	x23, [sp]
Lloh30:
	adrp	x1, l_.str.4@PAGE
Lloh31:
	add	x1, x1, l_.str.4@PAGEOFF
	bl	_dev_err
Lloh32:
	adrp	x8, _ENOMEM@GOTPAGE
Lloh33:
	ldr	x8, [x8, _ENOMEM@GOTPAGEOFF]
Lloh34:
	ldr	w8, [x8]
	neg	w24, w8
LBB0_18:
	mov	x0, x25
	bl	_kfree
LBB0_19:
	ldr	x8, [sp, #24]
	add	x0, x8, #16
	bl	_atomic_dec
	cbz	w20, LBB0_22
; %bb.20:
	ldr	x1, [sp, #24]
	mov	x0, x19
	bl	_free_phys_pg_pack
LBB0_21:
	ldr	x1, [sp, #16]
	mov	x0, x19
	bl	_free_userptr
LBB0_22:
	mov	x0, x24
	ldp	x29, x30, [sp, #112]            ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #96]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #80]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #64]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #48]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #32]             ; 16-byte Folded Reload
	add	sp, sp, #128
	ret
LBB0_23:
	ldr	x8, [x19, #8]
	ldr	x8, [x8]
	mov	x0, x19
	mov	w1, #0
	blr	x8
	mov	x0, x28
	bl	_mutex_unlock
	ldr	x8, [sp, #24]
	ldr	x8, [x8, #32]
	add	x23, x8, x27
	str	x26, [x25]
	str	x23, [x25, #16]
	add	x24, x22, #16
	mov	x0, x24
	bl	_mutex_lock
	ldr	w0, [x22, #20]
	add	x1, x25, #8
	mov	x2, x23
	bl	_hash_add
	mov	x0, x24
	bl	_mutex_unlock
	str	x23, [x21]
	cbz	w20, LBB0_25
; %bb.24:
	ldr	x1, [sp, #24]
	mov	x0, x19
	bl	_free_phys_pg_pack
LBB0_25:
	mov	w24, #0
	b	LBB0_22
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpAdd	Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh10, Lloh11, Lloh12
	.loh AdrpAdd	Lloh8, Lloh9
	.loh AdrpAdd	Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh17, Lloh18, Lloh19
	.loh AdrpAdd	Lloh15, Lloh16
	.loh AdrpLdrGotLdr	Lloh20, Lloh21, Lloh22
	.loh AdrpAdd	Lloh23, Lloh24
	.loh AdrpAdd	Lloh25, Lloh26
	.loh AdrpLdrGotLdr	Lloh27, Lloh28, Lloh29
	.loh AdrpLdrGotLdr	Lloh32, Lloh33, Lloh34
	.loh AdrpAdd	Lloh30, Lloh31
	.cfi_endproc
                                        ; -- End function
	.comm	_HL_MEM_USERPTR,4,2             ; @HL_MEM_USERPTR
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"failed to get userptr from va\n"

l_.str.1:                               ; @.str.1
	.asciz	"unable to init page pack for vaddr 0x%llx\n"

l_.str.2:                               ; @.str.2
	.asciz	"no match for handle %u\n"

	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_HL_MEM_SHARED,4,2              ; @HL_MEM_SHARED
l_.str.3:                               ; @.str.3
	.asciz	"Failed to map memory, handle %u is not shared\n"

	.comm	_EPERM,4,2                      ; @EPERM
	.comm	_GFP_KERNEL,4,2                 ; @GFP_KERNEL
	.comm	_ENOMEM,4,2                     ; @ENOMEM
l_.str.4:                               ; @.str.4
	.asciz	"no available va block for handle %u\n"

l_.str.5:                               ; @.str.5
	.asciz	"mapping page pack failed for handle %u\n"

l_.str.6:                               ; @.str.6
	.asciz	"release va block failed for handle 0x%x, vaddr: 0x%llx\n"

	.no_dead_strip	_map_device_va
.subsections_via_symbols
