// File: /workspace/github_c_makefile_star2_O0/tvlabs[P]edge264/edge264_headers.c
// Function: parse_pred_weight_table
static void parse_pred_weight_table(Edge264Decoder *dec, Edge264SeqParameterSet *sps, Edge264Task *t)
{
	// further tests will depend only on weighted_bipred_idc
	if (t->slice_type == 0)
		t->pps.weighted_bipred_idc = t->pps.weighted_pred_flag;
	
	// parse explicit weights/offsets
	if (t->pps.weighted_bipred_idc == 1) {
		t->luma_log2_weight_denom = get_ue16(&dec->_gb, 7);
		if (sps->ChromaArrayType != 0)
			t->chroma_log2_weight_denom = get_ue16(&dec->_gb, 7);
		for (int l = 0; l <= t->slice_type; l++) {
			log_dec(dec, "  explicit_weights_l%u:\n", l);
			for (int i = l * 32; i < l * 32 + t->pps.num_ref_idx_active[l]; i++) {
				if (get_u1(&dec->_gb)) {
					t->explicit_weights[0][i] = get_se16(&dec->_gb, -128, 127);
					t->explicit_offsets[0][i] = get_se16(&dec->_gb, -128, 127);
				} else {
					t->explicit_weights[0][i] = 1 << t->luma_log2_weight_denom;
					t->explicit_offsets[0][i] = 0;
				}
				if (sps->ChromaArrayType != 0 && get_u1(&dec->_gb)) {
					t->explicit_weights[1][i] = get_se16(&dec->_gb, -128, 127);
					t->explicit_offsets[1][i] = get_se16(&dec->_gb, -128, 127);
					t->explicit_weights[2][i] = get_se16(&dec->_gb, -128, 127);
					t->explicit_offsets[2][i] = get_se16(&dec->_gb, -128, 127);
				} else {
					t->explicit_weights[1][i] = 1 << t->chroma_log2_weight_denom;
					t->explicit_offsets[1][i] = 0;
					t->explicit_weights[2][i] = 1 << t->chroma_log2_weight_denom;
					t->explicit_offsets[2][i] = 0;
				}
				log_dec(dec, sps->ChromaArrayType ? "    - {Y: \"*%d>>%u+%d\", Cb: \"*%d>>%u+%d\", Cr: \"*%d>>%u+%d\"}\n" : "    - {Y: \"*%d>>%u+%d\"}\n",
					t->explicit_weights[0][i], t->luma_log2_weight_denom, t->explicit_offsets[0][i],
					t->explicit_weights[1][i], t->chroma_log2_weight_denom, t->explicit_offsets[1][i],
					t->explicit_weights[2][i], t->chroma_log2_weight_denom, t->explicit_offsets[2][i]);
			}
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x50, %rsp
movq %rdi, -0x28(%rbp)
movq %rsi, -0x30(%rbp)
movq %rdx, -0x38(%rbp)
movq -0x38(%rbp), %rax
movsbl 0x20(%rax), %eax
cmpl $0x0, %eax
jne 0x77b9c
movq -0x38(%rbp), %rax
movb 0x224(%rax), %cl
movq -0x38(%rbp), %rax
movb %cl, 0x225(%rax)
movq -0x38(%rbp), %rax
movsbl 0x225(%rax), %eax
cmpl $0x1, %eax
jne 0x77f82
movq -0x28(%rbp), %rdi
movl $0x7, %esi
callq 0x76d10
movb %al, %cl
movq -0x38(%rbp), %rax
movb %cl, 0x25(%rax)
movq -0x30(%rbp), %rax
movsbl 0x8(%rax), %eax
cmpl $0x0, %eax
je 0x77beb
movq -0x28(%rbp), %rdi
movl $0x7, %esi
callq 0x76d10
movb %al, %cl
movq -0x38(%rbp), %rax
movb %cl, 0x26(%rax)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x38(%rbp), %rcx
movsbl 0x20(%rcx), %ecx
cmpl %ecx, %eax
jg 0x77f80
movq -0x28(%rbp), %rax
movswq 0x7ca0(%rax), %rax
cmpq $0x2542, %rax           # imm = 0x2542
jae 0x77c6f
movq -0x28(%rbp), %rdi
addq $0x7ca2, %rdi           # imm = 0x7CA2
movq -0x28(%rbp), %rax
movswl 0x7ca0(%rax), %eax
cltq
addq %rax, %rdi
movq -0x28(%rbp), %rax
movswq 0x7ca0(%rax), %rax
movl $0x2542, %esi           # imm = 0x2542
subq %rax, %rsi
movl -0x3c(%rbp), %ecx
leaq 0x5900e(%rip), %rdx     # 0xd0c60
movb $0x0, %al
callq 0x7070
movl %eax, %edx
movq -0x28(%rbp), %rax
movswl 0x7ca0(%rax), %ecx
addl %edx, %ecx
movw %cx, 0x7ca0(%rax)
movl -0x3c(%rbp), %eax
shll $0x5, %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
movl -0x3c(%rbp), %ecx
shll $0x5, %ecx
movq -0x38(%rbp), %rdx
movslq -0x3c(%rbp), %rsi
movsbl 0x222(%rdx,%rsi), %edx
addl %edx, %ecx
cmpl %ecx, %eax
jge 0x77f70
movq -0x28(%rbp), %rdi
callq 0x77060
cmpl $0x0, %eax
je 0x77cf5
movq -0x28(%rbp), %rdi
movl $0xffffff80, %esi       # imm = 0xFFFFFF80
movl $0x7f, %edx
callq 0x770f0
movw %ax, %dx
movq -0x38(%rbp), %rax
movslq -0x40(%rbp), %rcx
movw %dx, 0x410(%rax,%rcx,2)
movq -0x28(%rbp), %rdi
movl $0xffffff80, %esi       # imm = 0xFFFFFF80
movl $0x7f, %edx
callq 0x770f0
movb %al, %dl
movq -0x38(%rbp), %rax
movslq -0x40(%rbp), %rcx
movb %dl, 0x590(%rax,%rcx)
jmp 0x77d27
movq -0x38(%rbp), %rax
movsbl 0x25(%rax), %ecx
movl $0x1, %eax
shll %cl, %eax
movw %ax, %dx
movq -0x38(%rbp), %rax
movslq -0x40(%rbp), %rcx
movw %dx, 0x410(%rax,%rcx,2)
movq -0x38(%rbp), %rax
movslq -0x40(%rbp), %rcx
movb $0x0, 0x590(%rax,%rcx)
movq -0x30(%rbp), %rax
movsbl 0x8(%rax), %eax
cmpl $0x0, %eax
je 0x77de0
movq -0x28(%rbp), %rdi
callq 0x77060
cmpl $0x0, %eax
je 0x77de0
movq -0x28(%rbp), %rdi
movl $0xffffff80, %esi       # imm = 0xFFFFFF80
movl $0x7f, %edx
callq 0x770f0
movw %ax, %dx
movq -0x38(%rbp), %rax
movslq -0x40(%rbp), %rcx
movw %dx, 0x490(%rax,%rcx,2)
movq -0x28(%rbp), %rdi
movl $0xffffff80, %esi       # imm = 0xFFFFFF80
movl $0x7f, %edx
callq 0x770f0
movb %al, %dl
movq -0x38(%rbp), %rax
movslq -0x40(%rbp), %rcx
movb %dl, 0x5d0(%rax,%rcx)
movq -0x28(%rbp), %rdi
movl $0xffffff80, %esi       # imm = 0xFFFFFF80
movl $0x7f, %edx
callq 0x770f0
movw %ax, %dx
movq -0x38(%rbp), %rax
movslq -0x40(%rbp), %rcx
movw %dx, 0x510(%rax,%rcx,2)
movq -0x28(%rbp), %rdi
movl $0xffffff80, %esi       # imm = 0xFFFFFF80
movl $0x7f, %edx
callq 0x770f0
movb %al, %dl
movq -0x38(%rbp), %rax
movslq -0x40(%rbp), %rcx
movb %dl, 0x610(%rax,%rcx)
jmp 0x77e44
movq -0x38(%rbp), %rax
movsbl 0x26(%rax), %ecx
movl $0x1, %eax
shll %cl, %eax
movw %ax, %dx
movq -0x38(%rbp), %rax
movslq -0x40(%rbp), %rcx
movw %dx, 0x490(%rax,%rcx,2)
movq -0x38(%rbp), %rax
movslq -0x40(%rbp), %rcx
movb $0x0, 0x5d0(%rax,%rcx)
movq -0x38(%rbp), %rax
movsbl 0x26(%rax), %ecx
movl $0x1, %eax
shll %cl, %eax
movw %ax, %dx
movq -0x38(%rbp), %rax
movslq -0x40(%rbp), %rcx
movw %dx, 0x510(%rax,%rcx,2)
movq -0x38(%rbp), %rax
movslq -0x40(%rbp), %rcx
movb $0x0, 0x610(%rax,%rcx)
movq -0x28(%rbp), %rax
movswq 0x7ca0(%rax), %rax
cmpq $0x2542, %rax           # imm = 0x2542
jae 0x77f60
movq -0x28(%rbp), %rdi
addq $0x7ca2, %rdi           # imm = 0x7CA2
movq -0x28(%rbp), %rax
movswl 0x7ca0(%rax), %eax
cltq
addq %rax, %rdi
movq -0x28(%rbp), %rax
movswq 0x7ca0(%rax), %rax
movl $0x2542, %esi           # imm = 0x2542
subq %rax, %rsi
movq -0x30(%rbp), %rax
movsbl 0x8(%rax), %ecx
leaq 0x58e1c(%rip), %rdx     # 0xd0cb6
leaq 0x58dd8(%rip), %rax     # 0xd0c79
cmpl $0x0, %ecx
cmovneq %rax, %rdx
movq -0x38(%rbp), %rax
movslq -0x40(%rbp), %rcx
movswl 0x410(%rax,%rcx,2), %ecx
movq -0x38(%rbp), %rax
movsbl 0x25(%rax), %r8d
movq -0x38(%rbp), %rax
movslq -0x40(%rbp), %r9
movsbl 0x590(%rax,%r9), %r9d
movq -0x38(%rbp), %rax
movslq -0x40(%rbp), %r10
movswl 0x490(%rax,%r10,2), %r15d
movq -0x38(%rbp), %rax
movsbl 0x26(%rax), %r14d
movq -0x38(%rbp), %rax
movslq -0x40(%rbp), %r10
movsbl 0x5d0(%rax,%r10), %ebx
movq -0x38(%rbp), %rax
movslq -0x40(%rbp), %r10
movswl 0x510(%rax,%r10,2), %r11d
movq -0x38(%rbp), %rax
movsbl 0x26(%rax), %r10d
movq -0x38(%rbp), %rax
movslq -0x40(%rbp), %r12
movsbl 0x610(%rax,%r12), %eax
movl %r15d, (%rsp)
movl %r14d, 0x8(%rsp)
movl %ebx, 0x10(%rsp)
movl %r11d, 0x18(%rsp)
movl %r10d, 0x20(%rsp)
movl %eax, 0x28(%rsp)
movb $0x0, %al
callq 0x7070
movl %eax, %edx
movq -0x28(%rbp), %rax
movswl 0x7ca0(%rax), %ecx
addl %edx, %ecx
movw %cx, 0x7ca0(%rax)
jmp 0x77f62
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x77c78
jmp 0x77f72
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x77bf2
jmp 0x77f82
addq $0x50, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop