	.file	"extr_roqvideoenc.c_generate_new_codebooks.c"
	.intel_syntax noprefix
	.text
	.p2align 4
	.type	generate_new_codebooks, @function
generate_new_codebooks:
.LFB0:
	.cfi_startproc
	endbr64
	push	r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	mov	r15, rsi
	push	r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	push	r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	push	r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	push	rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	push	rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	mov	rbx, rdi
	sub	rsp, 120
	.cfi_def_cfa_offset 176
	mov	ebp, DWORD PTR [rdi]
	imul	ebp, DWORD PTR 4[rdi]
	mov	rax, QWORD PTR fs:40
	mov	QWORD PTR 104[rsp], rax
	xor	eax, eax
	mov	edi, DWORD PTR MAX_CBS_4x4[rip]
	test	ebp, ebp
	lea	ecx, 15[rbp]
	cmovs	ebp, ecx
	sal	edi, 4
	call	av_malloc@PLT
	mov	esi, 96
	sar	ebp, 4
	mov	r14, rax
	mov	QWORD PTR 24[rsp], rax
	mov	edi, ebp
	call	av_malloc_array@PLT
	mov	esi, 96
	mov	edi, ebp
	mov	r13, rax
	mov	QWORD PTR 32[rsp], rax
	call	av_malloc_array@PLT
	test	r14, r14
	sete	dl
	test	r13, r13
	mov	QWORD PTR 16[rsp], rax
	mov	rcx, rax
	sete	al
	or	dl, al
	jne	.L29
	test	rcx, rcx
	je	.L29
	mov	r14, QWORD PTR 32[rsp]
	mov	edx, DWORD PTR 4[rbx]
	mov	edi, DWORD PTR 32[rbx]
	mov	esi, DWORD PTR [rbx]
	mov	rcx, r14
	call	create_clusters@PLT
	lea	eax, 0[rbp+rbp*2]
	sal	eax, 3
	test	eax, eax
	jle	.L5
	lea	ecx, -1[rax]
	mov	r9, QWORD PTR 16[rsp]
	mov	eax, 1
	mov	r8, r14
	add	rcx, 1
	mov	edx, 1
	mov	edi, 2863311531
	mov	esi, 1
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L10:
	mov	edx, eax
	mov	r10d, eax
	imul	rdx, rdi
	shr	rdx, 34
	lea	edx, [rdx+rdx*2]
	add	edx, edx
	sub	r10d, edx
	mov	edx, esi
	cmp	r10d, 3
	cmovg	edx, DWORD PTR CHROMA_BIAS[rip]
	add	rax, 1
.L6:
	imul	edx, DWORD PTR -4[r8+rax*4]
	mov	DWORD PTR -4[r9+rax*4], edx
	cmp	rax, rcx
	jne	.L10
.L5:
	mov	eax, DWORD PTR MAX_CBS_4x4[rip]
	cmp	QWORD PTR 24[rbx], 1
	mov	rsi, r15
	mov	ecx, ebp
	mov	rdi, rbx
	mov	r9d, 4
	adc	eax, -1
	sub	rsp, 8
	.cfi_def_cfa_offset 184
	push	rax
	.cfi_def_cfa_offset 192
	mov	r8, QWORD PTR 40[rsp]
	mov	rdx, QWORD PTR 32[rsp]
	call	generate_codebook@PLT
	mov	DWORD PTR 60[rsp], eax
	pop	rsi
	.cfi_def_cfa_offset 184
	pop	rdi
	.cfi_def_cfa_offset 176
	test	eax, eax
	js	.L4
	mov	eax, DWORD PTR MAX_CBS_4x4[rip]
	cmp	QWORD PTR 24[rbx], 1
	mov	esi, 16
	mov	edi, ebp
	adc	eax, -1
	mov	DWORD PTR 8[r15], eax
	call	av_malloc_array@PLT
	mov	QWORD PTR [r15], rax
	test	rax, rax
	je	.L29
	mov	eax, DWORD PTR MAX_CBS_2x2[rip]
	sub	rsp, 8
	.cfi_def_cfa_offset 184
	mov	rsi, r15
	mov	rdi, rbx
	mov	r8, QWORD PTR 8[rbx]
	lea	ecx, 0[0+rbp*4]
	mov	r9d, 2
	push	rax
	.cfi_def_cfa_offset 192
	mov	rdx, QWORD PTR 32[rsp]
	call	generate_codebook@PLT
	mov	DWORD PTR 60[rsp], eax
	pop	rdx
	.cfi_def_cfa_offset 184
	pop	rcx
	.cfi_def_cfa_offset 176
	test	eax, eax
	js	.L4
	mov	eax, DWORD PTR MAX_CBS_2x2[rip]
	xor	ebp, ebp
	mov	DWORD PTR 12[r15], eax
	test	eax, eax
	jle	.L15
	.p2align 4,,10
	.p2align 3
.L13:
	mov	rax, QWORD PTR 8[rbx]
	lea	rsi, 0[rbp+rbp*2]
	sal	rsi, 4
	add	rsi, QWORD PTR 16[r15]
	lea	rdi, [rax+rbp*4]
	add	rbp, 1
	call	unpack_roq_cell@PLT
	cmp	DWORD PTR 12[r15], ebp
	jg	.L13
.L15:
	mov	eax, DWORD PTR 8[r15]
	test	eax, eax
	jle	.L4
	mov	QWORD PTR 8[rsp], 0
	mov	r13, QWORD PTR 24[rsp]
	lea	rbp, 48[rsp]
	mov	QWORD PTR [rsp], 0
	.p2align 4,,10
	.p2align 3
.L17:
	mov	rax, QWORD PTR [rsp]
	xor	r14d, r14d
	lea	r12, 0[0+rax*8]
.L16:
	lea	rdi, 0[r13+r14]
	mov	rsi, rbp
	call	unpack_roq_cell@PLT
	mov	rax, QWORD PTR 16[rbx]
	mov	edx, DWORD PTR 12[r15]
	mov	rdi, rbp
	mov	rsi, QWORD PTR 16[r15]
	mov	r8d, 2
	mov	rcx, QWORD PTR [rax+r12]
	add	rcx, r14
	add	r14, 4
	call	index_mb@PLT
	cmp	r14, 16
	jne	.L16
	mov	r14, QWORD PTR 8[rsp]
	mov	rdx, QWORD PTR 32[r15]
	add	r13, 16
	mov	rsi, QWORD PTR 16[rbx]
	mov	rdi, QWORD PTR 16[r15]
	add	rdx, r14
	add	rsi, r12
	call	unpack_roq_qcell@PLT
	mov	rax, QWORD PTR 24[r15]
	mov	rdi, QWORD PTR 32[r15]
	lea	rsi, [rax+r14*4]
	add	rdi, r14
	add	r14, 48
	call	enlarge_roq_mb4@PLT
	add	QWORD PTR [rsp], 1
	mov	rax, QWORD PTR [rsp]
	mov	QWORD PTR 8[rsp], r14
	cmp	DWORD PTR 8[r15], eax
	jg	.L17
.L4:
	mov	rdi, QWORD PTR 32[rsp]
	call	av_free@PLT
	mov	rdi, QWORD PTR 16[rsp]
	call	av_free@PLT
	mov	rdi, QWORD PTR 24[rsp]
	call	av_free@PLT
	mov	rax, QWORD PTR 104[rsp]
	xor	rax, QWORD PTR fs:40
	jne	.L31
	mov	eax, DWORD PTR 44[rsp]
	add	rsp, 120
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	pop	rbx
	.cfi_def_cfa_offset 48
	pop	rbp
	.cfi_def_cfa_offset 40
	pop	r12
	.cfi_def_cfa_offset 32
	pop	r13
	.cfi_def_cfa_offset 24
	pop	r14
	.cfi_def_cfa_offset 16
	pop	r15
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L29:
	.cfi_restore_state
	mov	edi, DWORD PTR ENOMEM[rip]
	call	AVERROR@PLT
	mov	DWORD PTR 44[rsp], eax
	jmp	.L4
.L31:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE0:
	.size	generate_new_codebooks, .-generate_new_codebooks
	.comm	MAX_CBS_4x4,4,4
	.comm	MAX_CBS_2x2,4,4
	.comm	ENOMEM,4,4
	.comm	CHROMA_BIAS,4,4
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	 1f - 0f
	.long	 4f - 1f
	.long	 5
0:
	.string	 "GNU"
1:
	.align 8
	.long	 0xc0000002
	.long	 3f - 2f
2:
	.long	 0x3
3:
	.align 8
4:

	.arch armv5t
	.eabi_attribute 20, 1
	.eabi_attribute 21, 1
	.eabi_attribute 23, 3
	.eabi_attribute 24, 1
	.eabi_attribute 25, 1
	.eabi_attribute 26, 2
	.eabi_attribute 30, 2
	.eabi_attribute 34, 0
	.eabi_attribute 18, 4
	.file	"extr_roqvideoenc.c_generate_new_codebooks.c"
	.text
	.section	.rodata.cst4,"aM",%progbits,4
	.align	2
.LC0:
	.word	__stack_chk_guard
	.text
	.align	2
	.syntax unified
	.arm
	.fpu softvfp
	.type	generate_new_codebooks, %function
generate_new_codebooks:
	@ args = 0, pretend = 0, frame = 72
	@ frame_needed = 0, uses_anonymous_args = 0
	push	{r4, r5, r6, r7, r8, r9, r10, fp, lr}
	ldr	r3, [r0, #4]
	ldr	r4, [r0]
	ldr	r7, .L30
	mul	r4, r3, r4
	mov	r6, r0
	cmp	r4, #0
	add	r3, r4, #15
	ldr	r0, [r7]
	movlt	r4, r3
	ldr	r3, .L30+4
	sub	sp, sp, #92
	lsl	r0, r0, #4
	mov	r5, r1
	ldr	r3, [r3]
	str	r3, [sp, #84]
	mov	r3,#0
	bl	av_malloc
	mov	r3, r0
	asr	r4, r4, #4
	mov	r1, #96
	mov	r0, r4
	mov	r9, r3
	str	r3, [sp, #20]
	bl	av_malloc_array
	mov	r8, r0
	mov	r1, #96
	str	r0, [sp, #24]
	mov	r0, r4
	bl	av_malloc_array
	clz	r1, r8
	cmp	r9, #0
	lsr	r1, r1, #5
	moveq	r1, #1
	cmp	r0, #0
	movne	r8, r1
	moveq	r8, #1
	cmp	r8, #0
	str	r0, [sp, #16]
	bne	.L27
	ldm	r6, {r1, r2}
	ldr	r9, [sp, #24]
	ldr	r0, [r6, #20]
	mov	r3, r9
	bl	create_clusters
	add	lr, r4, r4, lsl #1
	lsl	r3, lr, #3
	cmp	r3, #0
	ble	.L4
	ldr	r3, [sp, #16]
	add	lr, r9, lr, lsl #5
	mov	r1, r8
	sub	r0, r9, #4
	mov	r2, #1
	ldr	r8, .L30+8
	ldr	r9, .L30+12
	sub	lr, lr, #4
	sub	ip, r3, #4
	b	.L5
.L9:
	umull	r2, r3, r8, r1
	lsr	r3, r3, #2
	add	r3, r3, r3, lsl #1
	sub	r3, r1, r3, lsl #1
	cmp	r3, #3
	movle	r2, #1
	ldrgt	r2, [r9]
.L5:
	ldr	r3, [r0, #4]!
	add	r1, r1, #1
	mul	r2, r3, r2
	cmp	lr, r0
	str	r2, [ip, #4]!
	bne	.L9
.L4:
	ldr	r2, [r6, #16]
	ldr	r3, [r7]
	cmp	r2, #0
	mov	r2, #4
	subne	r3, r3, #1
	str	r3, [sp, #8]
	ldr	r3, [sp, #20]
	str	r2, [sp, #4]
	str	r3, [sp]
	mov	r1, r5
	mov	r3, r4
	mov	r0, r6
	ldr	r2, [sp, #16]
	bl	generate_codebook
	subs	r3, r0, #0
	str	r3, [sp, #28]
	blt	.L3
	ldr	r2, [r6, #16]
	ldr	r3, [r7]
	cmp	r2, #0
	subne	r3, r3, #1
	mov	r1, #16
	mov	r0, r4
	str	r3, [r5, #4]
	bl	av_malloc_array
	cmp	r0, #0
	str	r0, [r5]
	beq	.L27
	mov	r1, #2
	ldr	r7, .L30+16
	ldr	r2, [r6, #8]
	ldr	r0, [r7]
	lsl	r3, r4, r1
	str	r0, [sp, #8]
	str	r1, [sp, #4]
	str	r2, [sp]
	mov	r1, r5
	mov	r0, r6
	ldr	r2, [sp, #16]
	bl	generate_codebook
	subs	r3, r0, #0
	str	r3, [sp, #28]
	blt	.L3
	ldr	r3, [r7]
	cmp	r3, #0
	movgt	r7, #0
	str	r3, [r5, #8]
	movgt	r4, r7
	ble	.L14
.L12:
	ldr	r1, [r5, #12]
	ldr	r0, [r6, #8]
	add	r1, r1, r7
	add	r0, r0, r4, lsl #2
	bl	unpack_roq_cell
	ldr	r3, [r5, #8]
	add	r4, r4, #1
	cmp	r3, r4
	add	r7, r7, #48
	bgt	.L12
.L14:
	ldr	r3, [r5, #4]
	cmp	r3, #0
	ble	.L3
	mov	r9, #0
	mov	r10, #2
	mov	fp, r9
	ldr	r7, [sp, #20]
.L16:
	mov	r4, #0
	lsl	r8, fp, #2
.L15:
	add	r1, sp, #36
	add	r0, r7, r4
	bl	unpack_roq_cell
	ldr	r3, [r6, #12]
	ldr	r2, [r5, #8]
	ldr	r3, [r3, r8]
	ldr	r1, [r5, #12]
	add	r3, r3, r4
	str	r10, [sp]
	add	r4, r4, #4
	add	r0, sp, #36
	bl	index_mb
	cmp	r4, #16
	bne	.L15
	ldr	r2, [r5, #20]
	ldr	r1, [r6, #12]
	add	r2, r9, r2
	add	r1, r1, r8
	ldr	r0, [r5, #12]
	bl	unpack_roq_qcell
	ldr	r1, [r5, #16]
	ldr	r0, [r5, #20]
	add	r1, r1, r9, lsl #2
	add	r0, r9, r0
	bl	enlarge_roq_mb4
	ldr	r3, [r5, #4]
	add	fp, fp, #1
	cmp	r3, fp
	add	r7, r7, #16
	add	r9, r9, #48
	bgt	.L16
.L3:
	ldr	r0, [sp, #24]
	bl	av_free
	ldr	r0, [sp, #16]
	bl	av_free
	ldr	r0, [sp, #20]
	bl	av_free
	ldr	r3, .L30+4
	ldr	r2, [r3]
	ldr	r3, [sp, #84]
	eors	r2, r3, r2
	mov	r3, #0
	bne	.L29
	ldr	r0, [sp, #28]
	add	sp, sp, #92
	@ sp needed
	pop	{r4, r5, r6, r7, r8, r9, r10, fp, pc}
.L27:
	ldr	r3, .L30+20
	ldr	r0, [r3]
	bl	AVERROR
	str	r0, [sp, #28]
	b	.L3
.L29:
	bl	__stack_chk_fail
.L31:
	.align	2
.L30:
	.word	MAX_CBS_4x4
	.word	.LC0
	.word	-1431655765
	.word	CHROMA_BIAS
	.word	MAX_CBS_2x2
	.word	ENOMEM
	.size	generate_new_codebooks, .-generate_new_codebooks
	.comm	MAX_CBS_4x4,4,4
	.comm	MAX_CBS_2x2,4,4
	.comm	ENOMEM,4,4
	.comm	CHROMA_BIAS,4,4
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",%progbits
