	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_etnaviv_iommuv2_context_alloc  ## -- Begin function etnaviv_iommuv2_context_alloc
	.p2align	4, 0x90
_etnaviv_iommuv2_context_alloc:         ## @etnaviv_iommuv2_context_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	%r12
	pushq	%rbx
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdi, %r14
	movl	$40, %edi
	callq	_vzalloc
	testq	%rax, %rax
	je	LBB0_6
## %bb.1:
	movq	%rax, %rbx
	leaq	20(%r14), %r15
	movq	%r15, %rdi
	callq	_mutex_lock
	movl	(%r14), %edi
	movq	_ETNAVIV_PTA_ENTRIES@GOTPCREL(%rip), %r12
	movq	(%r12), %rsi
	callq	_find_first_zero_bit
	movq	%rax, (%rbx)
	cmpq	(%r12), %rax
	jae	LBB0_8
## %bb.2:
	movl	(%r14), %esi
	movq	%rax, %rdi
	callq	_set_bit
	movq	%r15, %rdi
	callq	_mutex_unlock
	movl	16(%r14), %edi
	movq	_SZ_4K@GOTPCREL(%rip), %r12
	movq	(%r12), %rsi
	leaq	32(%rbx), %rdx
	movq	_GFP_KERNEL@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	callq	_dma_alloc_wc
	movl	%eax, 36(%rbx)
	testl	%eax, %eax
	je	LBB0_4
## %bb.3:
	movq	_MMUv2_PTE_EXCEPTION@GOTPCREL(%rip), %rcx
	movl	(%rcx), %esi
	movq	_MMUv2_MAX_STLB_ENTRIES@GOTPCREL(%rip), %rcx
	movl	(%rcx), %edx
	movl	%eax, %edi
	callq	_memset32
	movl	32(%rbx), %eax
	movq	8(%r14), %rcx
	movq	(%rbx), %rdx
	movl	%eax, (%rcx,%rdx,4)
	leaq	8(%rbx), %r15
	movq	%r14, 24(%rbx)
	leaq	20(%rbx), %rdi
	callq	_kref_init
	leaq	16(%rbx), %rdi
	callq	_mutex_init
	addq	$12, %rbx
	movq	%rbx, %rdi
	callq	_INIT_LIST_HEAD
	movq	(%r12), %rsi
	movq	_SZ_1G@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	shll	$2, %eax
	movslq	%eax, %rdx
	subq	%rsi, %rdx
	movq	%r15, %rdi
	callq	_drm_mm_init
	jmp	LBB0_7
LBB0_8:
	movq	%r15, %rdi
	callq	_mutex_unlock
	jmp	LBB0_5
LBB0_4:
	movq	(%rbx), %rdi
	movl	(%r14), %esi
	callq	_clear_bit
LBB0_5:
	movq	%rbx, %rdi
	callq	_vfree
LBB0_6:
	xorl	%r15d, %r15d
LBB0_7:
	movq	%r15, %rax
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_ETNAVIV_PTA_ENTRIES,8,3        ## @ETNAVIV_PTA_ENTRIES
	.comm	_SZ_4K,8,3                      ## @SZ_4K
	.comm	_GFP_KERNEL,4,2                 ## @GFP_KERNEL
	.comm	_MMUv2_PTE_EXCEPTION,4,2        ## @MMUv2_PTE_EXCEPTION
	.comm	_MMUv2_MAX_STLB_ENTRIES,4,2     ## @MMUv2_MAX_STLB_ENTRIES
	.comm	_SZ_1G,8,3                      ## @SZ_1G
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_etnaviv_iommuv2_context_alloc  ; -- Begin function etnaviv_iommuv2_context_alloc
	.p2align	2
_etnaviv_iommuv2_context_alloc:         ; @etnaviv_iommuv2_context_alloc
	.cfi_startproc
; %bb.0:
	stp	x22, x21, [sp, #-48]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 48
	stp	x20, x19, [sp, #16]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #32]             ; 16-byte Folded Spill
	add	x29, sp, #32
	.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
	mov	x20, x0
	mov	w0, #40
	bl	_vzalloc
	cbz	x0, LBB0_7
; %bb.1:
	mov	x19, x0
	add	x21, x20, #20
	mov	x0, x21
	bl	_mutex_lock
	ldr	w0, [x20]
Lloh0:
	adrp	x22, _ETNAVIV_PTA_ENTRIES@GOTPAGE
Lloh1:
	ldr	x22, [x22, _ETNAVIV_PTA_ENTRIES@GOTPAGEOFF]
	ldr	x1, [x22]
	bl	_find_first_zero_bit
	str	x0, [x19]
	ldr	x8, [x22]
	cmp	x0, x8
	b.hs	LBB0_4
; %bb.2:
	ldr	w1, [x20]
	bl	_set_bit
	mov	x0, x21
	bl	_mutex_unlock
Lloh2:
	adrp	x22, _SZ_4K@GOTPAGE
Lloh3:
	ldr	x22, [x22, _SZ_4K@GOTPAGEOFF]
	ldr	w0, [x20, #16]
	ldr	x1, [x22]
	add	x2, x19, #32
Lloh4:
	adrp	x8, _GFP_KERNEL@GOTPAGE
Lloh5:
	ldr	x8, [x8, _GFP_KERNEL@GOTPAGEOFF]
Lloh6:
	ldr	w3, [x8]
	bl	_dma_alloc_wc
	str	w0, [x19, #36]
	cbz	w0, LBB0_5
; %bb.3:
Lloh7:
	adrp	x8, _MMUv2_PTE_EXCEPTION@GOTPAGE
Lloh8:
	ldr	x8, [x8, _MMUv2_PTE_EXCEPTION@GOTPAGEOFF]
Lloh9:
	ldr	w1, [x8]
Lloh10:
	adrp	x8, _MMUv2_MAX_STLB_ENTRIES@GOTPAGE
Lloh11:
	ldr	x8, [x8, _MMUv2_MAX_STLB_ENTRIES@GOTPAGEOFF]
Lloh12:
	ldr	w2, [x8]
	bl	_memset32
	ldr	w8, [x19, #32]
	ldr	x9, [x20, #8]
	ldr	x10, [x19]
	str	w8, [x9, x10, lsl #2]
	add	x21, x19, #8
	str	x20, [x19, #24]
	add	x0, x19, #20
	bl	_kref_init
	add	x0, x19, #16
	bl	_mutex_init
	add	x0, x19, #12
	bl	_INIT_LIST_HEAD
	ldr	x1, [x22]
Lloh13:
	adrp	x8, _SZ_1G@GOTPAGE
Lloh14:
	ldr	x8, [x8, _SZ_1G@GOTPAGEOFF]
Lloh15:
	ldr	w8, [x8]
	lsl	w8, w8, #2
	sxtw	x8, w8
	sub	x2, x8, x1
	mov	x0, x21
	bl	_drm_mm_init
	b	LBB0_8
LBB0_4:
	mov	x0, x21
	bl	_mutex_unlock
	b	LBB0_6
LBB0_5:
	ldr	x0, [x19]
	ldr	w1, [x20]
	bl	_clear_bit
LBB0_6:
	mov	x0, x19
	bl	_vfree
LBB0_7:
	mov	x21, #0
LBB0_8:
	mov	x0, x21
	ldp	x29, x30, [sp, #32]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #16]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp], #48             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh4, Lloh5, Lloh6
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpLdrGotLdr	Lloh13, Lloh14, Lloh15
	.loh AdrpLdrGotLdr	Lloh10, Lloh11, Lloh12
	.loh AdrpLdrGotLdr	Lloh7, Lloh8, Lloh9
	.cfi_endproc
                                        ; -- End function
	.comm	_ETNAVIV_PTA_ENTRIES,8,3        ; @ETNAVIV_PTA_ENTRIES
	.comm	_SZ_4K,8,3                      ; @SZ_4K
	.comm	_GFP_KERNEL,4,2                 ; @GFP_KERNEL
	.comm	_MMUv2_PTE_EXCEPTION,4,2        ; @MMUv2_PTE_EXCEPTION
	.comm	_MMUv2_MAX_STLB_ENTRIES,4,2     ; @MMUv2_MAX_STLB_ENTRIES
	.comm	_SZ_1G,8,3                      ; @SZ_1G
.subsections_via_symbols
