	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function mtk_iommu_map
_mtk_iommu_map:                         ## @mtk_iommu_map
	.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	%rcx, %r15
	movl	%edx, %ebx
	movq	%rsi, %r14
	callq	_to_mtk_domain
	movq	_MT2701_IOMMU_PAGE_SHIFT@GOTPCREL(%rip), %rcx
	movb	(%rcx), %cl
	movq	%r15, -56(%rbp)                 ## 8-byte Spill
	shrq	%cl, %r15
	movq	%rax, %r12
	movq	%r14, -48(%rbp)                 ## 8-byte Spill
	shrq	%cl, %r14
	shlq	$2, %r14
	addq	(%rax), %r14
	movq	%rax, %r13
	addq	$12, %r13
	movq	%r13, %rdi
	callq	_spin_lock_irqsave
	testl	%r15d, %r15d
	je	LBB0_1
## %bb.2:
	movq	_MT2701_IOMMU_PAGE_SIZE@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movl	%r15d, %ecx
	shlq	$2, %rcx
	xorl	%edx, %edx
	movq	_F_DESC_VALID@GOTPCREL(%rip), %r8
	movq	_F_DESC_NONSEC@GOTPCREL(%rip), %rdi
	xorl	%r15d, %r15d
	.p2align	4, 0x90
LBB0_3:                                 ## =>This Inner Loop Header: Depth=1
	cmpl	$0, (%r14,%rdx)
	jne	LBB0_4
## %bb.5:                               ##   in Loop: Header=BB0_3 Depth=1
	movl	(%r8), %esi
	orl	%ebx, %esi
	orl	(%rdi), %esi
	movl	%esi, (%r14,%rdx)
	addl	%eax, %ebx
	addl	%eax, %r15d
	movslq	%r15d, %r15
	addq	$4, %rdx
	cmpq	%rdx, %rcx
	jne	LBB0_3
	jmp	LBB0_6
LBB0_1:
	xorl	%r15d, %r15d
	jmp	LBB0_6
LBB0_4:
	movq	%r14, %rdi
	xorl	%esi, %esi
                                        ## kill: def $edx killed $edx killed $rdx
	callq	_memset
LBB0_6:
	movq	%r13, %rdi
	callq	_spin_unlock_irqrestore
	movl	8(%r12), %edi
	movq	-48(%rbp), %rsi                 ## 8-byte Reload
	movq	-56(%rbp), %rbx                 ## 8-byte Reload
	movq	%rbx, %rdx
	callq	_mtk_iommu_tlb_flush_range
	movq	_EEXIST@GOTPCREL(%rip), %rcx
	xorl	%eax, %eax
	subl	(%rcx), %eax
	cmpq	%rbx, %r15
	movl	$0, %ecx
	cmovel	%ecx, %eax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_MT2701_IOMMU_PAGE_SHIFT,8,3    ## @MT2701_IOMMU_PAGE_SHIFT
	.comm	_F_DESC_VALID,4,2               ## @F_DESC_VALID
	.comm	_F_DESC_NONSEC,4,2              ## @F_DESC_NONSEC
	.comm	_MT2701_IOMMU_PAGE_SIZE,8,3     ## @MT2701_IOMMU_PAGE_SIZE
	.comm	_EEXIST,4,2                     ## @EEXIST
	.no_dead_strip	_mtk_iommu_map
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function mtk_iommu_map
_mtk_iommu_map:                         ; @mtk_iommu_map
	.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, x3
	mov	x23, x2
	mov	x20, x1
	bl	_to_mtk_domain
	mov	x21, x0
Lloh0:
	adrp	x8, _MT2701_IOMMU_PAGE_SHIFT@GOTPAGE
Lloh1:
	ldr	x8, [x8, _MT2701_IOMMU_PAGE_SHIFT@GOTPAGEOFF]
Lloh2:
	ldr	x26, [x8]
	lsr	x25, x19, x26
	mov	x22, x0
	ldr	x27, [x22], #12
	mov	x0, x22
	bl	_spin_lock_irqsave
	cbz	w25, LBB0_4
; %bb.1:
	mov	x2, #0
	mov	x24, #0
	lsr	x8, x20, x26
	add	x0, x27, x8, lsl #2
Lloh3:
	adrp	x8, _MT2701_IOMMU_PAGE_SIZE@GOTPAGE
Lloh4:
	ldr	x8, [x8, _MT2701_IOMMU_PAGE_SIZE@GOTPAGEOFF]
Lloh5:
	ldr	x8, [x8]
	and	x9, x25, #0xffffffff
	lsl	x9, x9, #2
Lloh6:
	adrp	x10, _F_DESC_VALID@GOTPAGE
Lloh7:
	ldr	x10, [x10, _F_DESC_VALID@GOTPAGEOFF]
Lloh8:
	adrp	x11, _F_DESC_NONSEC@GOTPAGE
Lloh9:
	ldr	x11, [x11, _F_DESC_NONSEC@GOTPAGEOFF]
LBB0_2:                                 ; =>This Inner Loop Header: Depth=1
	ldr	w12, [x0, x2]
	cbnz	w12, LBB0_5
; %bb.3:                                ;   in Loop: Header=BB0_2 Depth=1
	ldr	w12, [x10]
	orr	w12, w12, w23
	ldr	w13, [x11]
	orr	w12, w12, w13
	str	w12, [x0, x2]
	add	w23, w23, w8
	add	w12, w8, w24
	sxtw	x24, w12
	add	x2, x2, #4
	cmp	x9, x2
	b.ne	LBB0_2
	b	LBB0_6
LBB0_4:
	mov	x24, #0
	b	LBB0_6
LBB0_5:
	mov	w1, #0
                                        ; kill: def $w2 killed $w2 killed $x2
	bl	_memset
LBB0_6:
	mov	x0, x22
	bl	_spin_unlock_irqrestore
	ldr	w0, [x21, #8]
	mov	x1, x20
	mov	x2, x19
	bl	_mtk_iommu_tlb_flush_range
Lloh10:
	adrp	x8, _EEXIST@GOTPAGE
Lloh11:
	ldr	x8, [x8, _EEXIST@GOTPAGEOFF]
Lloh12:
	ldr	w8, [x8]
	cmp	x24, x19
	csneg	w0, wzr, w8, eq
	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	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGot	Lloh8, Lloh9
	.loh AdrpLdrGot	Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh10, Lloh11, Lloh12
	.cfi_endproc
                                        ; -- End function
	.comm	_MT2701_IOMMU_PAGE_SHIFT,8,3    ; @MT2701_IOMMU_PAGE_SHIFT
	.comm	_F_DESC_VALID,4,2               ; @F_DESC_VALID
	.comm	_F_DESC_NONSEC,4,2              ; @F_DESC_NONSEC
	.comm	_MT2701_IOMMU_PAGE_SIZE,8,3     ; @MT2701_IOMMU_PAGE_SIZE
	.comm	_EEXIST,4,2                     ; @EEXIST
	.no_dead_strip	_mtk_iommu_map
.subsections_via_symbols
