	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function vpu_alloc_ext_mem
_vpu_alloc_ext_mem:                     ## @vpu_alloc_ext_mem
	.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
	movl	%esi, %r12d
	movq	%rdi, %rbx
	movq	16(%rdi), %r15
	testl	%esi, %esi
	jne	LBB0_1
## %bb.2:
	movq	_VPU_EXT_P_SIZE@GOTPCREL(%rip), %rax
	jmp	LBB0_3
LBB0_1:
	movq	_VPU_EXT_D_SIZE@GOTPCREL(%rip), %rax
LBB0_3:
	movq	8(%rbx), %rcx
	movq	%rcx, -72(%rbp)                 ## 8-byte Spill
	movq	(%rax), %rsi
	movq	_VPU_DMEM_EXT0_ADDR@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, -52(%rbp)                 ## 4-byte Spill
	movq	_VPU_PMEM_EXT0_ADDR@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, -48(%rbp)                 ## 4-byte Spill
	movq	_VPU_DMEM_EXT1_ADDR@GOTPCREL(%rip), %rax
	movl	(%rax), %r13d
	movq	_VPU_PMEM_EXT1_ADDR@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, -44(%rbp)                 ## 4-byte Spill
	movslq	%r12d, %r14
	leaq	(,%r14,8), %rdx
	addq	(%rbx), %rdx
	movq	_GFP_KERNEL@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	movq	%r15, %rdi
	callq	_dma_alloc_coherent
	movq	(%rbx), %rcx
	movl	%eax, 4(%rcx,%r14,8)
	testl	%eax, %eax
	je	LBB0_4
## %bb.5:
	movq	%r15, -64(%rbp)                 ## 8-byte Spill
	xorl	%r15d, %r15d
	cmpq	$0, -72(%rbp)                   ## 8-byte Folded Reload
	setne	%r15b
	shll	$30, %r15d
	testl	%r12d, %r12d
	cmovel	-44(%rbp), %r13d                ## 4-byte Folded Reload
	movl	-52(%rbp), %edx                 ## 4-byte Reload
	cmovel	-48(%rbp), %edx                 ## 4-byte Folded Reload
	leaq	L_.str.3(%rip), %rax
	leaq	L_.str.2(%rip), %r12
	cmoveq	%rax, %r12
	movq	%rbx, %rdi
	movl	$1, %esi
	callq	_vpu_cfg_writel
	movq	(%rbx), %rax
	movl	$-4096, %esi                    ## imm = 0xF000
	andl	(%rax,%r14,8), %esi
	addl	%r15d, %esi
	movq	%rbx, %rdi
	movl	%r13d, %edx
	callq	_vpu_cfg_writel
	movq	(%rbx), %rax
	movslq	(%rax,%r14,8), %rcx
	movl	4(%rax,%r14,8), %r8d
	leaq	L_.str.1(%rip), %rsi
	movq	-64(%rbp), %rdi                 ## 8-byte Reload
	movq	%r12, %rdx
	callq	_dev_info
	xorl	%eax, %eax
	jmp	LBB0_6
LBB0_4:
	leaq	L_.str(%rip), %rsi
	movq	%r15, %rdi
	callq	_dev_err
	movq	_ENOMEM@GOTPCREL(%rip), %rcx
	xorl	%eax, %eax
	subl	(%rcx), %eax
LBB0_6:
	addq	$40, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_VPU_EXT_D_SIZE,8,3             ## @VPU_EXT_D_SIZE
	.comm	_VPU_EXT_P_SIZE,8,3             ## @VPU_EXT_P_SIZE
	.comm	_VPU_DMEM_EXT0_ADDR,4,2         ## @VPU_DMEM_EXT0_ADDR
	.comm	_VPU_PMEM_EXT0_ADDR,4,2         ## @VPU_PMEM_EXT0_ADDR
	.comm	_VPU_DMEM_EXT1_ADDR,4,2         ## @VPU_DMEM_EXT1_ADDR
	.comm	_VPU_PMEM_EXT1_ADDR,4,2         ## @VPU_PMEM_EXT1_ADDR
	.comm	_GFP_KERNEL,4,2                 ## @GFP_KERNEL
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Failed to allocate the extended program memory\n"

	.comm	_ENOMEM,4,2                     ## @ENOMEM
L_.str.1:                               ## @.str.1
	.asciz	"%s extend memory phy=0x%llx virt=0x%p\n"

L_.str.2:                               ## @.str.2
	.asciz	"Data"

L_.str.3:                               ## @.str.3
	.asciz	"Program"

	.no_dead_strip	_vpu_alloc_ext_mem
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function vpu_alloc_ext_mem
_vpu_alloc_ext_mem:                     ; @vpu_alloc_ext_mem
	.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	x21, x1
	mov	x20, x0
	ldp	x26, x19, [x0, #8]
Lloh0:
	adrp	x8, _VPU_EXT_D_SIZE@GOTPAGE
Lloh1:
	ldr	x8, [x8, _VPU_EXT_D_SIZE@GOTPAGEOFF]
Lloh2:
	adrp	x9, _VPU_EXT_P_SIZE@GOTPAGE
Lloh3:
	ldr	x9, [x9, _VPU_EXT_P_SIZE@GOTPAGEOFF]
	cmp	w1, #0
	csel	x8, x9, x8, eq
Lloh4:
	adrp	x9, _VPU_DMEM_EXT0_ADDR@GOTPAGE
Lloh5:
	ldr	x9, [x9, _VPU_DMEM_EXT0_ADDR@GOTPAGEOFF]
	ldr	x1, [x8]
Lloh6:
	ldr	w22, [x9]
Lloh7:
	adrp	x8, _VPU_PMEM_EXT0_ADDR@GOTPAGE
Lloh8:
	ldr	x8, [x8, _VPU_PMEM_EXT0_ADDR@GOTPAGEOFF]
Lloh9:
	adrp	x9, _VPU_DMEM_EXT1_ADDR@GOTPAGE
Lloh10:
	ldr	x9, [x9, _VPU_DMEM_EXT1_ADDR@GOTPAGEOFF]
Lloh11:
	ldr	w23, [x8]
Lloh12:
	ldr	w24, [x9]
Lloh13:
	adrp	x8, _VPU_PMEM_EXT1_ADDR@GOTPAGE
Lloh14:
	ldr	x8, [x8, _VPU_PMEM_EXT1_ADDR@GOTPAGEOFF]
Lloh15:
	ldr	w25, [x8]
	ldr	x8, [x0]
	sbfiz	x27, x21, #3, #32
	add	x2, x8, x27
Lloh16:
	adrp	x8, _GFP_KERNEL@GOTPAGE
Lloh17:
	ldr	x8, [x8, _GFP_KERNEL@GOTPAGEOFF]
Lloh18:
	ldr	w3, [x8]
	mov	x0, x19
	bl	_dma_alloc_coherent
	ldr	x8, [x20]
	add	x8, x8, x27
	str	w0, [x8, #4]
	cbz	w0, LBB0_2
; %bb.1:
	sxtw	x27, w21
	cmp	x26, #0
	cset	w26, ne
	cmp	w21, #0
	csel	w21, w25, w24, eq
	csel	w2, w23, w22, eq
Lloh19:
	adrp	x8, l_.str.2@PAGE
Lloh20:
	add	x8, x8, l_.str.2@PAGEOFF
Lloh21:
	adrp	x9, l_.str.3@PAGE
Lloh22:
	add	x9, x9, l_.str.3@PAGEOFF
	csel	x22, x9, x8, eq
	mov	x0, x20
	mov	w1, #1
	bl	_vpu_cfg_writel
	ldr	x8, [x20]
	lsl	x23, x27, #3
	ldr	w8, [x8, x23]
	and	w8, w8, #0xfffff000
	add	w1, w8, w26, lsl #30
	mov	x0, x20
	mov	x2, x21
	bl	_vpu_cfg_writel
	ldr	x8, [x20]
	add	x8, x8, x23
	ldp	w3, w4, [x8]
                                        ; kill: def $w3 killed $w3 def $x3
	sxtw	x3, w3
Lloh23:
	adrp	x1, l_.str.1@PAGE
Lloh24:
	add	x1, x1, l_.str.1@PAGEOFF
	mov	x0, x19
	mov	x2, x22
	bl	_dev_info
	mov	w0, #0
	b	LBB0_3
LBB0_2:
Lloh25:
	adrp	x1, l_.str@PAGE
Lloh26:
	add	x1, x1, l_.str@PAGEOFF
	mov	x0, x19
	bl	_dev_err
Lloh27:
	adrp	x8, _ENOMEM@GOTPAGE
Lloh28:
	ldr	x8, [x8, _ENOMEM@GOTPAGEOFF]
Lloh29:
	ldr	w8, [x8]
	neg	w0, w8
LBB0_3:
	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	Lloh16, Lloh17, Lloh18
	.loh AdrpLdrGotLdr	Lloh13, Lloh14, Lloh15
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh12
	.loh AdrpLdrGotLdr	Lloh7, Lloh8, Lloh11
	.loh AdrpLdrGotLdr	Lloh4, Lloh5, Lloh6
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpAdd	Lloh23, Lloh24
	.loh AdrpAdd	Lloh21, Lloh22
	.loh AdrpAdd	Lloh19, Lloh20
	.loh AdrpLdrGotLdr	Lloh27, Lloh28, Lloh29
	.loh AdrpAdd	Lloh25, Lloh26
	.cfi_endproc
                                        ; -- End function
	.comm	_VPU_EXT_D_SIZE,8,3             ; @VPU_EXT_D_SIZE
	.comm	_VPU_EXT_P_SIZE,8,3             ; @VPU_EXT_P_SIZE
	.comm	_VPU_DMEM_EXT0_ADDR,4,2         ; @VPU_DMEM_EXT0_ADDR
	.comm	_VPU_PMEM_EXT0_ADDR,4,2         ; @VPU_PMEM_EXT0_ADDR
	.comm	_VPU_DMEM_EXT1_ADDR,4,2         ; @VPU_DMEM_EXT1_ADDR
	.comm	_VPU_PMEM_EXT1_ADDR,4,2         ; @VPU_PMEM_EXT1_ADDR
	.comm	_GFP_KERNEL,4,2                 ; @GFP_KERNEL
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Failed to allocate the extended program memory\n"

	.comm	_ENOMEM,4,2                     ; @ENOMEM
l_.str.1:                               ; @.str.1
	.asciz	"%s extend memory phy=0x%llx virt=0x%p\n"

l_.str.2:                               ; @.str.2
	.asciz	"Data"

l_.str.3:                               ; @.str.3
	.asciz	"Program"

	.no_dead_strip	_vpu_alloc_ext_mem
.subsections_via_symbols
