	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function h264_enc_alloc_work_buf
_h264_enc_alloc_work_buf:               ## @h264_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	48(%rdi), %rax
	movq	(%rax), %r13
	callq	_mtk_vcodec_debug_enter
	movq	_VENC_H264_VPU_WORK_BUF_MAX@GOTPCREL(%rip), %r12
	cmpl	$0, (%r12)
	jle	LBB0_9
## %bb.1:
	xorl	%r15d, %r15d
	xorl	%ebx, %ebx
	jmp	LBB0_2
	.p2align	4, 0x90
LBB0_3:                                 ##   in Loop: Header=BB0_2 Depth=1
	movl	40(%r14), %edi
	movl	16(%r13,%r15), %esi
	callq	_vpu_mapping_dm_addr
	movq	32(%r14), %rcx
	movq	%rax, 16(%rcx,%r15)
	movq	$0, 8(%rcx,%r15)
LBB0_8:                                 ##   in Loop: Header=BB0_2 Depth=1
	movq	32(%r14), %rax
	leaq	(%rax,%r15), %r8
	addq	$8, %r8
	movq	8(%rax,%r15), %rcx
	movq	%rcx, 8(%r13,%r15)
	movq	16(%rax,%r15), %rcx
	movl	(%rax,%r15), %r9d
	movq	%r14, %rdi
	leaq	L_.str.1(%rip), %rsi
	movl	%ebx, %edx
	callq	_mtk_vcodec_debug
	incq	%rbx
	movslq	(%r12), %rax
	addq	$24, %r15
	cmpq	%rax, %rbx
	jge	LBB0_9
LBB0_2:                                 ## =>This Inner Loop Header: Depth=1
	movl	(%r13,%r15), %eax
	movq	32(%r14), %rsi
	movl	%eax, (%rsi,%r15)
	movq	_VENC_H264_VPU_WORK_BUF_SKIP_FRAME@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	cmpq	%rax, %rbx
	je	LBB0_3
## %bb.4:                               ##   in Loop: Header=BB0_2 Depth=1
	movl	24(%r14), %edi
	addq	%r15, %rsi
	callq	_mtk_vcodec_mem_alloc
	testl	%eax, %eax
	jne	LBB0_5
## %bb.6:                               ##   in Loop: Header=BB0_2 Depth=1
	movq	_VENC_H264_VPU_WORK_BUF_RC_CODE@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	cmpq	%rax, %rbx
	jne	LBB0_8
## %bb.7:                               ##   in Loop: Header=BB0_2 Depth=1
	movl	40(%r14), %edi
	movl	16(%r13,%r15), %esi
	callq	_vpu_mapping_dm_addr
	movq	32(%r14), %rcx
	movq	16(%rcx,%r15), %rdi
	movl	(%r13,%r15), %edx
	movq	%rax, %rsi
	callq	_memcpy
	jmp	LBB0_8
LBB0_9:
	movl	$128, (%r14)
	movl	24(%r14), %edi
	movq	%r14, %rsi
	callq	_mtk_vcodec_mem_alloc
	testl	%eax, %eax
	je	LBB0_13
## %bb.10:
	movl	%eax, %r15d
	leaq	L_.str.2(%rip), %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	callq	_mtk_vcodec_err
	jmp	LBB0_11
LBB0_13:
	movq	%r14, %rdi
	callq	_mtk_vcodec_debug_leave
	xorl	%eax, %eax
	jmp	LBB0_12
LBB0_5:
	movl	%eax, %r15d
	leaq	L_.str(%rip), %rsi
	movq	%r14, %rdi
	movl	%ebx, %edx
	xorl	%eax, %eax
	callq	_mtk_vcodec_err
LBB0_11:
	movq	%r14, %rdi
	callq	_h264_enc_free_work_buf
	movl	%r15d, %eax
LBB0_12:
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_VENC_H264_VPU_WORK_BUF_MAX,4,2 ## @VENC_H264_VPU_WORK_BUF_MAX
	.comm	_VENC_H264_VPU_WORK_BUF_SKIP_FRAME,4,2 ## @VENC_H264_VPU_WORK_BUF_SKIP_FRAME
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"cannot allocate buf %d"

	.comm	_VENC_H264_VPU_WORK_BUF_RC_CODE,4,2 ## @VENC_H264_VPU_WORK_BUF_RC_CODE
L_.str.1:                               ## @.str.1
	.asciz	"work_buf[%d] va=0x%p iova=%pad size=%zu"

L_.str.2:                               ## @.str.2
	.asciz	"cannot allocate pps_buf"

	.no_dead_strip	_h264_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 h264_enc_alloc_work_buf
_h264_enc_alloc_work_buf:               ; @h264_enc_alloc_work_buf
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #112
	.cfi_def_cfa_offset 112
	stp	x28, x27, [sp, #16]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #32]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #48]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #64]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #80]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #96]             ; 16-byte Folded Spill
	add	x29, sp, #96
	.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, #48]
	ldr	x23, [x8]
	bl	_mtk_vcodec_debug_enter
Lloh0:
	adrp	x24, _VENC_H264_VPU_WORK_BUF_MAX@GOTPAGE
Lloh1:
	ldr	x24, [x24, _VENC_H264_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_H264_VPU_WORK_BUF_SKIP_FRAME@GOTPAGE
Lloh3:
	ldr	x26, [x26, _VENC_H264_VPU_WORK_BUF_SKIP_FRAME@GOTPAGEOFF]
Lloh4:
	adrp	x27, _VENC_H264_VPU_WORK_BUF_RC_CODE@GOTPAGE
Lloh5:
	ldr	x27, [x27, _VENC_H264_VPU_WORK_BUF_RC_CODE@GOTPAGEOFF]
Lloh6:
	adrp	x21, l_.str.1@PAGE
Lloh7:
	add	x21, x21, l_.str.1@PAGEOFF
	b	LBB0_4
LBB0_2:                                 ;   in Loop: Header=BB0_4 Depth=1
	ldr	w0, [x19, #40]
	add	x8, x23, x25
	ldr	w1, [x8, #16]
	bl	_vpu_mapping_dm_addr
	ldr	x8, [x19, #32]
	add	x8, x8, x25
	stp	xzr, x0, [x8, #8]
LBB0_3:                                 ;   in Loop: Header=BB0_4 Depth=1
	ldr	x8, [x19, #32]
	add	x4, x8, x25
	ldr	x3, [x4, #16]
	ldr	w5, [x4]
	ldr	x8, [x4, #8]!
	add	x9, x23, x25
	str	x8, [x9, #8]
	mov	x0, x19
	mov	x1, x21
	mov	x2, x20
	bl	_mtk_vcodec_debug
	add	x20, x20, #1
	ldrsw	x8, [x24]
	add	x25, x25, #24
	cmp	x20, x8
	b.ge	LBB0_8
LBB0_4:                                 ; =>This Inner Loop Header: Depth=1
	ldr	w9, [x23, x25]
	ldr	x8, [x19, #32]
	str	w9, [x8, x25]
	ldr	w9, [x26]
	cmp	x20, x9
	b.eq	LBB0_2
; %bb.5:                                ;   in Loop: Header=BB0_4 Depth=1
	ldr	w0, [x19, #24]
	add	x1, x8, x25
	bl	_mtk_vcodec_mem_alloc
	cbnz	w0, LBB0_11
; %bb.6:                                ;   in Loop: Header=BB0_4 Depth=1
	ldr	w8, [x27]
	cmp	x20, x8
	b.ne	LBB0_3
; %bb.7:                                ;   in Loop: Header=BB0_4 Depth=1
	ldr	w0, [x19, #40]
	add	x22, x23, x25
	ldr	w1, [x22, #16]
	bl	_vpu_mapping_dm_addr
	mov	x1, x0
	ldr	x8, [x19, #32]
	add	x8, x8, x25
	ldr	x0, [x8, #16]
	ldr	w2, [x22]
	bl	_memcpy
	b	LBB0_3
LBB0_8:
	mov	w8, #128
	str	w8, [x19]
	ldr	w0, [x19, #24]
	mov	x1, x19
	bl	_mtk_vcodec_mem_alloc
	mov	x22, x0
	cbz	w0, LBB0_10
; %bb.9:
Lloh8:
	adrp	x1, l_.str.2@PAGE
Lloh9:
	add	x1, x1, l_.str.2@PAGEOFF
	b	LBB0_12
LBB0_10:
	mov	x0, x19
	bl	_mtk_vcodec_debug_leave
	b	LBB0_13
LBB0_11:
	mov	x22, x0
	str	x20, [sp]
Lloh10:
	adrp	x1, l_.str@PAGE
Lloh11:
	add	x1, x1, l_.str@PAGEOFF
LBB0_12:
	mov	x0, x19
	bl	_mtk_vcodec_err
	mov	x0, x19
	bl	_h264_enc_free_work_buf
LBB0_13:
	mov	x0, x22
	ldp	x29, x30, [sp, #96]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #80]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #64]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #48]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #32]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #112
	ret
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpAdd	Lloh6, Lloh7
	.loh AdrpLdrGot	Lloh4, Lloh5
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpAdd	Lloh8, Lloh9
	.loh AdrpAdd	Lloh10, Lloh11
	.cfi_endproc
                                        ; -- End function
	.comm	_VENC_H264_VPU_WORK_BUF_MAX,4,2 ; @VENC_H264_VPU_WORK_BUF_MAX
	.comm	_VENC_H264_VPU_WORK_BUF_SKIP_FRAME,4,2 ; @VENC_H264_VPU_WORK_BUF_SKIP_FRAME
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"cannot allocate buf %d"

	.comm	_VENC_H264_VPU_WORK_BUF_RC_CODE,4,2 ; @VENC_H264_VPU_WORK_BUF_RC_CODE
l_.str.1:                               ; @.str.1
	.asciz	"work_buf[%d] va=0x%p iova=%pad size=%zu"

l_.str.2:                               ; @.str.2
	.asciz	"cannot allocate pps_buf"

	.no_dead_strip	_h264_enc_alloc_work_buf
.subsections_via_symbols
