	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function vp9_alloc_work_buf
_vp9_alloc_work_buf:                    ## @vp9_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	%rbx
	pushq	%rax
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdi, %r15
	movq	(%rdi), %rax
	movq	56(%rdi), %rbx
	movq	(%rax), %rcx
	movq	_VCODEC_CAPABILITY_4K_DISABLED@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	andl	(%rcx), %eax
	jne	LBB0_1
## %bb.2:
	movq	_VCODEC_DEC_4K_CODED_WIDTH@GOTPCREL(%rip), %rdx
	jmp	LBB0_3
LBB0_1:
	movq	_MTK_VDEC_MAX_W@GOTPCREL(%rip), %rdx
LBB0_3:
	movl	(%rbx), %ecx
	cmpl	(%rdx), %ecx
	jbe	LBB0_5
## %bb.4:
	movl	4(%rbx), %r8d
	jmp	LBB0_9
LBB0_5:
	testl	%eax, %eax
	jne	LBB0_6
## %bb.7:
	movq	_VCODEC_DEC_4K_CODED_HEIGHT@GOTPCREL(%rip), %rax
	jmp	LBB0_8
LBB0_6:
	movq	_MTK_VDEC_MAX_H@GOTPCREL(%rip), %rax
LBB0_8:
	movl	4(%rbx), %r8d
	cmpl	(%rax), %r8d
	jbe	LBB0_10
LBB0_9:
	leaq	L_.str(%rip), %rsi
	xorl	%ebx, %ebx
	movq	%r15, %rdi
	movl	%ecx, %edx
	movl	%r8d, %ecx
	xorl	%eax, %eax
	callq	_mtk_vcodec_err
	jmp	LBB0_20
LBB0_10:
	movl	72(%rbx), %edx
	movl	8(%rbx), %r9d
	movl	12(%rbx), %eax
	movl	%eax, (%rsp)
	leaq	L_.str.1(%rip), %rsi
	movq	%r15, %rdi
	callq	_mtk_vcodec_debug
	leaq	32(%r15), %r14
	cmpq	$0, 48(%r15)
	je	LBB0_12
## %bb.11:
	movq	(%r15), %rdi
	movq	%r14, %rsi
	callq	_mtk_vcodec_mem_free
LBB0_12:
	movl	8(%rbx), %eax
	movl	12(%rbx), %ecx
	leal	63(%rax), %edx
	testl	%eax, %eax
	cmovnsl	%eax, %edx
	sarl	$6, %edx
	leal	63(%rcx), %eax
	testl	%ecx, %ecx
	cmovnsl	%ecx, %eax
	sarl	$6, %eax
	imull	%edx, %eax
	leal	(%rax,%rax,8), %eax
	shll	$6, %eax
	addl	$1152, %eax                     ## imm = 0x480
	movl	%eax, 32(%r15)
	movq	(%r15), %rdi
	movq	%r14, %rsi
	callq	_mtk_vcodec_mem_alloc
	testl	%eax, %eax
	je	LBB0_15
## %bb.13:
	movl	$0, 32(%r15)
	leaq	L_.str.2(%rip), %rsi
	jmp	LBB0_14
LBB0_15:
	movdqu	40(%r15), %xmm0
	pshufd	$78, %xmm0, %xmm0               ## xmm0 = xmm0[2,3,0,1]
	movdqu	%xmm0, 48(%rbx)
	movl	32(%r15), %eax
	movl	%eax, 64(%rbx)
	leaq	8(%r15), %r14
	cmpq	$0, 24(%r15)
	je	LBB0_17
## %bb.16:
	movq	(%r15), %rdi
	movq	%r14, %rsi
	callq	_mtk_vcodec_mem_free
LBB0_17:
	movq	_VP9_SEG_ID_SZ@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, 8(%r15)
	movq	(%r15), %rdi
	movq	%r14, %rsi
	callq	_mtk_vcodec_mem_alloc
	testl	%eax, %eax
	je	LBB0_19
## %bb.18:
	movl	$0, 8(%r15)
	leaq	L_.str.3(%rip), %rsi
LBB0_14:
	xorl	%ebx, %ebx
	movq	%r15, %rdi
	xorl	%eax, %eax
	callq	_mtk_vcodec_err
LBB0_20:
	movl	%ebx, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_19:
	movdqu	16(%r15), %xmm0
	pshufd	$78, %xmm0, %xmm0               ## xmm0 = xmm0[2,3,0,1]
	movdqu	%xmm0, 24(%rbx)
	movl	8(%r15), %eax
	movl	%eax, 40(%rbx)
	movq	%r15, %rdi
	callq	_vp9_free_all_sf_ref_fb
	movq	%r15, %rdi
	callq	_vp9_get_sf_ref_fb
	movl	%eax, 16(%rbx)
	movl	$1, %ebx
	jmp	LBB0_20
	.cfi_endproc
                                        ## -- End function
	.comm	_VCODEC_CAPABILITY_4K_DISABLED,4,2 ## @VCODEC_CAPABILITY_4K_DISABLED
	.comm	_VCODEC_DEC_4K_CODED_WIDTH,4,2  ## @VCODEC_DEC_4K_CODED_WIDTH
	.comm	_VCODEC_DEC_4K_CODED_HEIGHT,4,2 ## @VCODEC_DEC_4K_CODED_HEIGHT
	.comm	_MTK_VDEC_MAX_W,4,2             ## @MTK_VDEC_MAX_W
	.comm	_MTK_VDEC_MAX_H,4,2             ## @MTK_VDEC_MAX_H
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Invalid w/h %d/%d"

L_.str.1:                               ## @.str.1
	.asciz	"BUF CHG(%d): w/h/sb_w/sb_h=%d/%d/%d/%d"

L_.str.2:                               ## @.str.2
	.asciz	"Cannot allocate mv_buf"

	.comm	_VP9_SEG_ID_SZ,4,2              ## @VP9_SEG_ID_SZ
L_.str.3:                               ## @.str.3
	.asciz	"Cannot allocate seg_id_buf"

	.no_dead_strip	_vp9_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 vp9_alloc_work_buf
_vp9_alloc_work_buf:                    ; @vp9_alloc_work_buf
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #64
	.cfi_def_cfa_offset 64
	stp	x22, x21, [sp, #16]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #32]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #48]             ; 16-byte Folded Spill
	add	x29, sp, #48
	.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	x19, x0
	ldr	x21, [x0, #56]
	ldr	x8, [x0]
	ldr	x8, [x8]
	ldr	w8, [x8]
Lloh0:
	adrp	x9, _VCODEC_CAPABILITY_4K_DISABLED@GOTPAGE
Lloh1:
	ldr	x9, [x9, _VCODEC_CAPABILITY_4K_DISABLED@GOTPAGEOFF]
Lloh2:
	ldr	w9, [x9]
	ands	w8, w9, w8
Lloh3:
	adrp	x9, _VCODEC_DEC_4K_CODED_WIDTH@GOTPAGE
Lloh4:
	ldr	x9, [x9, _VCODEC_DEC_4K_CODED_WIDTH@GOTPAGEOFF]
Lloh5:
	adrp	x10, _MTK_VDEC_MAX_W@GOTPAGE
Lloh6:
	ldr	x10, [x10, _MTK_VDEC_MAX_W@GOTPAGEOFF]
	csel	x9, x9, x10, eq
	ldr	w9, [x9]
	ldr	w3, [x21]
	cmp	w3, w9
	b.ls	LBB0_2
; %bb.1:
	ldr	w4, [x21, #4]
	b	LBB0_3
LBB0_2:
Lloh7:
	adrp	x9, _VCODEC_DEC_4K_CODED_HEIGHT@GOTPAGE
Lloh8:
	ldr	x9, [x9, _VCODEC_DEC_4K_CODED_HEIGHT@GOTPAGEOFF]
Lloh9:
	adrp	x10, _MTK_VDEC_MAX_H@GOTPAGE
Lloh10:
	ldr	x10, [x10, _MTK_VDEC_MAX_H@GOTPAGEOFF]
	cmp	w8, #0
	csel	x8, x9, x10, eq
	ldr	w8, [x8]
	ldr	w4, [x21, #4]
	cmp	w4, w8
	b.ls	LBB0_6
LBB0_3:
	stp	x3, x4, [sp]
Lloh11:
	adrp	x1, l_.str@PAGE
Lloh12:
	add	x1, x1, l_.str@PAGEOFF
LBB0_4:
	mov	x0, x19
	bl	_mtk_vcodec_err
	mov	w0, #0
LBB0_5:
	ldp	x29, x30, [sp, #48]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #32]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #64
	ret
LBB0_6:
	ldr	w2, [x21, #72]
	ldp	w5, w6, [x21, #8]
Lloh13:
	adrp	x1, l_.str.1@PAGE
Lloh14:
	add	x1, x1, l_.str.1@PAGEOFF
	mov	x0, x19
                                        ; kill: def $w3 killed $w3 killed $x3
                                        ; kill: def $w4 killed $w4 killed $x4
	bl	_mtk_vcodec_debug
	add	x20, x19, #32
	ldr	x8, [x19, #48]
	cbz	x8, LBB0_8
; %bb.7:
	ldr	x0, [x19]
	mov	x1, x20
	bl	_mtk_vcodec_mem_free
LBB0_8:
	ldp	w8, w9, [x21, #8]
	add	w10, w8, #63
	cmp	w8, #0
	csel	w8, w10, w8, lt
	asr	w8, w8, #6
	add	w10, w9, #63
	cmp	w9, #0
	csel	w9, w10, w9, lt
	asr	w9, w9, #6
	mul	w8, w8, w9
	mov	w9, #576
	mul	w8, w8, w9
	add	w8, w8, #1152
	str	w8, [x19, #32]
	ldr	x0, [x19]
	mov	x1, x20
	bl	_mtk_vcodec_mem_alloc
	cbz	w0, LBB0_10
; %bb.9:
	str	wzr, [x19, #32]
Lloh15:
	adrp	x1, l_.str.2@PAGE
Lloh16:
	add	x1, x1, l_.str.2@PAGEOFF
	b	LBB0_4
LBB0_10:
	ldur	q0, [x19, #40]
	ext.16b	v0, v0, v0, #8
	str	q0, [x21, #48]
	ldr	w8, [x19, #32]
	str	w8, [x21, #64]
	add	x20, x19, #8
	ldr	x8, [x19, #24]
	cbz	x8, LBB0_12
; %bb.11:
	ldr	x0, [x19]
	mov	x1, x20
	bl	_mtk_vcodec_mem_free
LBB0_12:
Lloh17:
	adrp	x8, _VP9_SEG_ID_SZ@GOTPAGE
Lloh18:
	ldr	x8, [x8, _VP9_SEG_ID_SZ@GOTPAGEOFF]
Lloh19:
	ldr	w8, [x8]
	str	w8, [x19, #8]
	ldr	x0, [x19]
	mov	x1, x20
	bl	_mtk_vcodec_mem_alloc
	cbz	w0, LBB0_14
; %bb.13:
	str	wzr, [x19, #8]
Lloh20:
	adrp	x1, l_.str.3@PAGE
Lloh21:
	add	x1, x1, l_.str.3@PAGEOFF
	b	LBB0_4
LBB0_14:
	ldr	q0, [x19, #16]
	ext.16b	v0, v0, v0, #8
	stur	q0, [x21, #24]
	ldr	w8, [x19, #8]
	str	w8, [x21, #40]
	mov	x0, x19
	bl	_vp9_free_all_sf_ref_fb
	mov	x0, x19
	bl	_vp9_get_sf_ref_fb
	str	w0, [x21, #16]
	mov	w0, #1
	b	LBB0_5
	.loh AdrpLdrGot	Lloh5, Lloh6
	.loh AdrpLdrGot	Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGot	Lloh9, Lloh10
	.loh AdrpLdrGot	Lloh7, Lloh8
	.loh AdrpAdd	Lloh11, Lloh12
	.loh AdrpAdd	Lloh13, Lloh14
	.loh AdrpAdd	Lloh15, Lloh16
	.loh AdrpLdrGotLdr	Lloh17, Lloh18, Lloh19
	.loh AdrpAdd	Lloh20, Lloh21
	.cfi_endproc
                                        ; -- End function
	.comm	_VCODEC_CAPABILITY_4K_DISABLED,4,2 ; @VCODEC_CAPABILITY_4K_DISABLED
	.comm	_VCODEC_DEC_4K_CODED_WIDTH,4,2  ; @VCODEC_DEC_4K_CODED_WIDTH
	.comm	_VCODEC_DEC_4K_CODED_HEIGHT,4,2 ; @VCODEC_DEC_4K_CODED_HEIGHT
	.comm	_MTK_VDEC_MAX_W,4,2             ; @MTK_VDEC_MAX_W
	.comm	_MTK_VDEC_MAX_H,4,2             ; @MTK_VDEC_MAX_H
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Invalid w/h %d/%d"

l_.str.1:                               ; @.str.1
	.asciz	"BUF CHG(%d): w/h/sb_w/sb_h=%d/%d/%d/%d"

l_.str.2:                               ; @.str.2
	.asciz	"Cannot allocate mv_buf"

	.comm	_VP9_SEG_ID_SZ,4,2              ; @VP9_SEG_ID_SZ
l_.str.3:                               ; @.str.3
	.asciz	"Cannot allocate seg_id_buf"

	.no_dead_strip	_vp9_alloc_work_buf
.subsections_via_symbols
