	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function vp8_enc_alloc_work_buf
_vp8_enc_alloc_work_buf:                ## @vp8_enc_alloc_work_buf
	.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
	pushq	%rax
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdi, %r14
	movq	16(%rdi), %rax
	movq	(%rax), %r13
	callq	_mtk_vcodec_debug_enter
	movq	_VENC_VP8_VPU_WORK_BUF_MAX@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	jle	LBB0_11
## %bb.1:
	xorl	%r15d, %r15d
	xorl	%ebx, %ebx
	jmp	LBB0_2
	.p2align	4, 0x90
LBB0_8:                                 ##   in Loop: Header=BB0_2 Depth=1
	movl	8(%r14), %edi
	movl	12(%r13,%r15), %esi
	callq	_vpu_mapping_dm_addr
	movq	(%r14), %rcx
	movl	12(%rcx,%r15), %edi
	movq	(%r13,%r15), %rdx
	movq	%rax, %rsi
	callq	_memcpy
LBB0_9:                                 ##   in Loop: Header=BB0_2 Depth=1
	movq	(%r14), %rax
	leaq	(%rax,%r15), %r8
	addq	$8, %r8
	movl	8(%rax,%r15), %ecx
	movl	%ecx, 8(%r13,%r15)
	movl	12(%rax,%r15), %ecx
	movq	(%rax,%r15), %r9
	movq	%r14, %rdi
	leaq	L_.str.1(%rip), %rsi
	movl	%ebx, %edx
	callq	_mtk_vcodec_debug
	movq	_VENC_VP8_VPU_WORK_BUF_MAX@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
LBB0_10:                                ##   in Loop: Header=BB0_2 Depth=1
	incq	%rbx
	movslq	%eax, %rcx
	addq	$16, %r15
	cmpq	%rcx, %rbx
	jge	LBB0_11
LBB0_2:                                 ## =>This Inner Loop Header: Depth=1
	movq	(%r13,%r15), %rcx
	testq	%rcx, %rcx
	je	LBB0_10
## %bb.3:                               ##   in Loop: Header=BB0_2 Depth=1
	movq	(%r14), %rsi
	movq	%rcx, (%rsi,%r15)
	addq	%r15, %rsi
	movl	12(%r14), %edi
	callq	_mtk_vcodec_mem_alloc
	testl	%eax, %eax
	jne	LBB0_4
## %bb.5:                               ##   in Loop: Header=BB0_2 Depth=1
	movq	_VENC_VP8_VPU_WORK_BUF_RC_CODE@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	cmpq	%rax, %rbx
	je	LBB0_8
## %bb.6:                               ##   in Loop: Header=BB0_2 Depth=1
	movq	_VENC_VP8_VPU_WORK_BUF_RC_CODE2@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	cmpq	%rax, %rbx
	je	LBB0_8
## %bb.7:                               ##   in Loop: Header=BB0_2 Depth=1
	movq	_VENC_VP8_VPU_WORK_BUF_RC_CODE3@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	cmpq	%rax, %rbx
	jne	LBB0_9
	jmp	LBB0_8
LBB0_11:
	movq	%r14, %rdi
	callq	_mtk_vcodec_debug_leave
	xorl	%r12d, %r12d
	jmp	LBB0_12
LBB0_4:
	movl	%eax, %r12d
	leaq	L_.str(%rip), %rsi
	movq	%r14, %rdi
	movl	%ebx, %edx
	callq	_mtk_vcodec_err
	movq	%r14, %rdi
	callq	_vp8_enc_free_work_buf
LBB0_12:
	movl	%r12d, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_VENC_VP8_VPU_WORK_BUF_MAX,4,2  ## @VENC_VP8_VPU_WORK_BUF_MAX
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"cannot alloc work_bufs[%d]"

	.comm	_VENC_VP8_VPU_WORK_BUF_RC_CODE,4,2 ## @VENC_VP8_VPU_WORK_BUF_RC_CODE
	.comm	_VENC_VP8_VPU_WORK_BUF_RC_CODE2,4,2 ## @VENC_VP8_VPU_WORK_BUF_RC_CODE2
	.comm	_VENC_VP8_VPU_WORK_BUF_RC_CODE3,4,2 ## @VENC_VP8_VPU_WORK_BUF_RC_CODE3
L_.str.1:                               ## @.str.1
	.asciz	"work_bufs[%d] va=0x%p,iova=%pad,size=%zu"

	.no_dead_strip	_vp8_enc_alloc_work_buf
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function vp8_enc_alloc_work_buf
_vp8_enc_alloc_work_buf:                ; @vp8_enc_alloc_work_buf
	.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	x8, [x0, #16]
	ldr	x23, [x8]
	bl	_mtk_vcodec_debug_enter
Lloh0:
	adrp	x24, _VENC_VP8_VPU_WORK_BUF_MAX@GOTPAGE
Lloh1:
	ldr	x24, [x24, _VENC_VP8_VPU_WORK_BUF_MAX@GOTPAGEOFF]
	ldr	w8, [x24]
	cmp	w8, #1
	b.lt	LBB0_8
; %bb.1:
	mov	x25, #0
	mov	x20, #0
Lloh2:
	adrp	x26, _VENC_VP8_VPU_WORK_BUF_RC_CODE@GOTPAGE
Lloh3:
	ldr	x26, [x26, _VENC_VP8_VPU_WORK_BUF_RC_CODE@GOTPAGEOFF]
Lloh4:
	adrp	x27, _VENC_VP8_VPU_WORK_BUF_RC_CODE2@GOTPAGE
Lloh5:
	ldr	x27, [x27, _VENC_VP8_VPU_WORK_BUF_RC_CODE2@GOTPAGEOFF]
Lloh6:
	adrp	x28, _VENC_VP8_VPU_WORK_BUF_RC_CODE3@GOTPAGE
Lloh7:
	ldr	x28, [x28, _VENC_VP8_VPU_WORK_BUF_RC_CODE3@GOTPAGEOFF]
Lloh8:
	adrp	x21, l_.str.1@PAGE
Lloh9:
	add	x21, x21, l_.str.1@PAGEOFF
	b	LBB0_4
LBB0_2:                                 ;   in Loop: Header=BB0_4 Depth=1
	ldr	x8, [x19]
	add	x4, x8, x25
	ldr	w3, [x4, #12]
	ldr	x5, [x4]
	ldr	w8, [x4, #8]!
	add	x9, x23, x25
	str	w8, [x9, #8]
	mov	x0, x19
	mov	x1, x21
	mov	x2, x20
	bl	_mtk_vcodec_debug
	ldr	w8, [x24]
LBB0_3:                                 ;   in Loop: Header=BB0_4 Depth=1
	add	x20, x20, #1
	add	x25, x25, #16
	cmp	x20, w8, sxtw
	b.ge	LBB0_8
LBB0_4:                                 ; =>This Inner Loop Header: Depth=1
	ldr	x9, [x23, x25]
	cbz	x9, LBB0_3
; %bb.5:                                ;   in Loop: Header=BB0_4 Depth=1
	ldr	x8, [x19]
	add	x1, x8, x25
	str	x9, [x1]
	ldr	w0, [x19, #12]
	bl	_mtk_vcodec_mem_alloc
	cbnz	w0, LBB0_9
; %bb.6:                                ;   in Loop: Header=BB0_4 Depth=1
	ldr	w8, [x26]
	ldr	w9, [x27]
	ldr	w10, [x28]
	cmp	x20, x8
	ccmp	x20, x9, #4, ne
	ccmp	x20, x10, #4, ne
	b.ne	LBB0_2
; %bb.7:                                ;   in Loop: Header=BB0_4 Depth=1
	ldr	w0, [x19, #8]
	add	x22, x23, x25
	ldr	w1, [x22, #12]
	bl	_vpu_mapping_dm_addr
	mov	x1, x0
	ldr	x8, [x19]
	add	x8, x8, x25
	ldr	w0, [x8, #12]
	ldr	x2, [x22]
	bl	_memcpy
	b	LBB0_2
LBB0_8:
	mov	x0, x19
	bl	_mtk_vcodec_debug_leave
	mov	w22, #0
	b	LBB0_10
LBB0_9:
	mov	x22, x0
Lloh10:
	adrp	x1, l_.str@PAGE
Lloh11:
	add	x1, x1, l_.str@PAGEOFF
	mov	x0, x19
	mov	x2, x20
	bl	_mtk_vcodec_err
	mov	x0, x19
	bl	_vp8_enc_free_work_buf
LBB0_10:
	mov	x0, x22
	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 AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpAdd	Lloh8, Lloh9
	.loh AdrpLdrGot	Lloh6, Lloh7
	.loh AdrpLdrGot	Lloh4, Lloh5
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpAdd	Lloh10, Lloh11
	.cfi_endproc
                                        ; -- End function
	.comm	_VENC_VP8_VPU_WORK_BUF_MAX,4,2  ; @VENC_VP8_VPU_WORK_BUF_MAX
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"cannot alloc work_bufs[%d]"

	.comm	_VENC_VP8_VPU_WORK_BUF_RC_CODE,4,2 ; @VENC_VP8_VPU_WORK_BUF_RC_CODE
	.comm	_VENC_VP8_VPU_WORK_BUF_RC_CODE2,4,2 ; @VENC_VP8_VPU_WORK_BUF_RC_CODE2
	.comm	_VENC_VP8_VPU_WORK_BUF_RC_CODE3,4,2 ; @VENC_VP8_VPU_WORK_BUF_RC_CODE3
l_.str.1:                               ; @.str.1
	.asciz	"work_bufs[%d] va=0x%p,iova=%pad,size=%zu"

	.no_dead_strip	_vp8_enc_alloc_work_buf
.subsections_via_symbols
