// File: /workspace/github_c_makefile_star2_O0/tvlabs[P]edge264/edge264_headers.c
// Function: parse_scaling_lists
static void parse_scaling_lists(Edge264Decoder *dec, i8x16 *w4x4, i8x16 *w8x8, int transform_8x8_mode_flag, int chroma_format_idc)
{
	i8x16 fb4x4 = *w4x4; // fall-back
	i8x16 d4x4 = Default_4x4_Intra; // for useDefaultScalingMatrixFlag
	for (int i = 0; i < 6; i++, w4x4++) {
		log_dec(dec, "    - [");
		if (i == 3) {
			fb4x4 = *w4x4;
			d4x4 = Default_4x4_Inter;
		}
		if (!get_u1(&dec->_gb)) { // scaling_list_present_flag
			*w4x4 = fb4x4;
		} else {
			unsigned nextScale = (8 + get_se16(&dec->_gb, -128, 127)) & 255;
			log_dec(dec, "%u", nextScale);
			if (nextScale == 0) {
				*w4x4 = fb4x4 = d4x4;
			} else {
				for (unsigned j = 0, lastScale;;) {
					((uint8_t *)w4x4)[((int8_t *)scan_4x4)[j]] = nextScale ?: lastScale;
					if (++j >= 16)
						break;
					if (nextScale != 0) {
						lastScale = nextScale;
						nextScale = (nextScale + get_se16(&dec->_gb, -128, 127)) & 255;
						log_dec(dec, ",%u", nextScale);
					}
				}
				fb4x4 = *w4x4;
			}
		}
		log_dec(dec, "]\n");
	}
	
	// For 8x8 scaling lists, we really have no better choice than pointers.
	if (!transform_8x8_mode_flag)
		return;
	for (int i = 0; i < (chroma_format_idc == 3 ? 6 : 2); i++, w8x8 += 4) {
		log_dec(dec, "    - [");
		if (!get_u1(&dec->_gb)) {
			if (i >= 2) {
				w8x8[0] = w8x8[-8];
				w8x8[1] = w8x8[-7];
				w8x8[2] = w8x8[-6];
				w8x8[3] = w8x8[-5];
			}
		} else {
			unsigned nextScale = (8 + get_se16(&dec->_gb, -128, 127)) & 255;
			log_dec(dec, "%u", nextScale);
			if (nextScale == 0) {
				const i8x16 *d8x8 = (i % 2 == 0) ? Default_8x8_Intra : Default_8x8_Inter;
				w8x8[0] = d8x8[0];
				w8x8[1] = d8x8[1];
				w8x8[2] = d8x8[2];
				w8x8[3] = d8x8[3];
			} else {
				for (unsigned j = 0, lastScale;;) {
					((uint8_t *)w8x8)[((int8_t *)scan_8x8_cabac)[j]] = nextScale ?: lastScale;
					if (++j >= 64)
						break;
					if (nextScale != 0) {
						lastScale = nextScale;
						nextScale = (nextScale + get_se16(&dec->_gb, -128, 127)) & 255;
						log_dec(dec, ",%u", nextScale);
					}
				}
			}
		}
		log_dec(dec, "]\n");
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movq -0x10(%rbp), %rax
vmovdqa (%rax), %xmm0
vmovdqa %xmm0, -0x30(%rbp)
vmovdqa 0x4edbd(%rip), %xmm0    # 0xc9250
vmovdqa %xmm0, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
cmpl $0x6, -0x44(%rbp)
jge 0x7a780
movq -0x8(%rbp), %rax
movswq 0x7ca0(%rax), %rax
cmpq $0x2542, %rax           # imm = 0x2542
jae 0x7a510
movq -0x8(%rbp), %rdi
addq $0x7ca2, %rdi           # imm = 0x7CA2
movq -0x8(%rbp), %rax
movswl 0x7ca0(%rax), %eax
cltq
addq %rax, %rdi
movq -0x8(%rbp), %rax
movswq 0x7ca0(%rax), %rax
movl $0x2542, %esi           # imm = 0x2542
subq %rax, %rsi
leaq 0x56848(%rip), %rdx     # 0xd0d3b
movb $0x0, %al
callq 0x7070
movl %eax, %edx
movq -0x8(%rbp), %rax
movswl 0x7ca0(%rax), %ecx
addl %edx, %ecx
movw %cx, 0x7ca0(%rax)
cmpl $0x3, -0x44(%rbp)
jne 0x7a530
movq -0x10(%rbp), %rax
vmovdqa (%rax), %xmm0
vmovdqa %xmm0, -0x30(%rbp)
vmovdqa 0x4ed35(%rip), %xmm0    # 0xc9260
vmovdqa %xmm0, -0x40(%rbp)
movq -0x8(%rbp), %rdi
callq 0x77060
cmpl $0x0, %eax
jne 0x7a550
vmovdqa -0x30(%rbp), %xmm0
movq -0x10(%rbp), %rax
vmovdqa %xmm0, (%rax)
jmp 0x7a6fd
movq -0x8(%rbp), %rdi
movl $0xffffff80, %esi       # imm = 0xFFFFFF80
movl $0x7f, %edx
callq 0x770f0
addl $0x8, %eax
andl $0xff, %eax
movl %eax, -0x48(%rbp)
movq -0x8(%rbp), %rax
movswq 0x7ca0(%rax), %rax
cmpq $0x2542, %rax           # imm = 0x2542
jae 0x7a5d8
movq -0x8(%rbp), %rdi
addq $0x7ca2, %rdi           # imm = 0x7CA2
movq -0x8(%rbp), %rax
movswl 0x7ca0(%rax), %eax
cltq
addq %rax, %rdi
movq -0x8(%rbp), %rax
movswq 0x7ca0(%rax), %rax
movl $0x2542, %esi           # imm = 0x2542
subq %rax, %rsi
movl -0x48(%rbp), %ecx
leaq 0x55941(%rip), %rdx     # 0xcfefc
movb $0x0, %al
callq 0x7070
movl %eax, %edx
movq -0x8(%rbp), %rax
movswl 0x7ca0(%rax), %ecx
addl %edx, %ecx
movw %cx, 0x7ca0(%rax)
cmpl $0x0, -0x48(%rbp)
jne 0x7a5f5
vmovdqa -0x40(%rbp), %xmm0
vmovdqa %xmm0, -0x30(%rbp)
movq -0x10(%rbp), %rax
vmovdqa %xmm0, (%rax)
jmp 0x7a6fb
movl $0x0, -0x4c(%rbp)
movl -0x48(%rbp), %eax
movl %eax, -0x6c(%rbp)
cmpl $0x0, %eax
je 0x7a60f
movl -0x6c(%rbp), %eax
movl %eax, -0x70(%rbp)
jmp 0x7a615
movl -0x50(%rbp), %eax
movl %eax, -0x70(%rbp)
movl -0x70(%rbp), %eax
movb %al, %dl
movq -0x10(%rbp), %rax
movl -0x4c(%rbp), %ecx
movl %ecx, %esi
leaq 0x543c6(%rip), %rcx     # 0xce9f0
movsbq (%rcx,%rsi), %rcx
movb %dl, (%rax,%rcx)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
cmpl $0x10, %eax
jb 0x7a645
jmp 0x7a6ee
cmpl $0x0, -0x48(%rbp)
je 0x7a6e9
movl -0x48(%rbp), %eax
movl %eax, -0x50(%rbp)
movl -0x48(%rbp), %eax
movl %eax, -0x74(%rbp)
movq -0x8(%rbp), %rdi
movl $0xffffff80, %esi       # imm = 0xFFFFFF80
movl $0x7f, %edx
callq 0x770f0
movl %eax, %ecx
movl -0x74(%rbp), %eax
addl %ecx, %eax
andl $0xff, %eax
movl %eax, -0x48(%rbp)
movq -0x8(%rbp), %rax
movswq 0x7ca0(%rax), %rax
cmpq $0x2542, %rax           # imm = 0x2542
jae 0x7a6e7
movq -0x8(%rbp), %rdi
addq $0x7ca2, %rdi           # imm = 0x7CA2
movq -0x8(%rbp), %rax
movswl 0x7ca0(%rax), %eax
cltq
addq %rax, %rdi
movq -0x8(%rbp), %rax
movswq 0x7ca0(%rax), %rax
movl $0x2542, %esi           # imm = 0x2542
subq %rax, %rsi
movl -0x48(%rbp), %ecx
leaq 0x56679(%rip), %rdx     # 0xd0d43
movb $0x0, %al
callq 0x7070
movl %eax, %edx
movq -0x8(%rbp), %rax
movswl 0x7ca0(%rax), %ecx
addl %edx, %ecx
movw %cx, 0x7ca0(%rax)
jmp 0x7a6e9
jmp 0x7a5fc
movq -0x10(%rbp), %rax
vmovdqa (%rax), %xmm0
vmovdqa %xmm0, -0x30(%rbp)
jmp 0x7a6fd
movq -0x8(%rbp), %rax
movswq 0x7ca0(%rax), %rax
cmpq $0x2542, %rax           # imm = 0x2542
jae 0x7a764
movq -0x8(%rbp), %rdi
addq $0x7ca2, %rdi           # imm = 0x7CA2
movq -0x8(%rbp), %rax
movswl 0x7ca0(%rax), %eax
cltq
addq %rax, %rdi
movq -0x8(%rbp), %rax
movswq 0x7ca0(%rax), %rax
movl $0x2542, %esi           # imm = 0x2542
subq %rax, %rsi
leaq 0x56471(%rip), %rdx     # 0xd0bb8
movb $0x0, %al
callq 0x7070
movl %eax, %edx
movq -0x8(%rbp), %rax
movswl 0x7ca0(%rax), %ecx
addl %edx, %ecx
movw %cx, 0x7ca0(%rax)
jmp 0x7a766
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
movq -0x10(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x10(%rbp)
jmp 0x7a49f
cmpl $0x0, -0x1c(%rbp)
jne 0x7a78b
jmp 0x7aaf4
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
movl -0x20(%rbp), %esi
movl $0x2, %ecx
movl $0x6, %edx
cmpl $0x3, %esi
cmovel %edx, %ecx
cmpl %ecx, %eax
jge 0x7aaf4
movq -0x8(%rbp), %rax
movswq 0x7ca0(%rax), %rax
cmpq $0x2542, %rax           # imm = 0x2542
jae 0x7a817
movq -0x8(%rbp), %rdi
addq $0x7ca2, %rdi           # imm = 0x7CA2
movq -0x8(%rbp), %rax
movswl 0x7ca0(%rax), %eax
cltq
addq %rax, %rdi
movq -0x8(%rbp), %rax
movswq 0x7ca0(%rax), %rax
movl $0x2542, %esi           # imm = 0x2542
subq %rax, %rsi
leaq 0x56541(%rip), %rdx     # 0xd0d3b
movb $0x0, %al
callq 0x7070
movl %eax, %edx
movq -0x8(%rbp), %rax
movswl 0x7ca0(%rax), %ecx
addl %edx, %ecx
movw %cx, 0x7ca0(%rax)
movq -0x8(%rbp), %rdi
callq 0x77060
cmpl $0x0, %eax
jne 0x7a877
cmpl $0x2, -0x54(%rbp)
jl 0x7a872
movq -0x18(%rbp), %rax
vmovdqa -0x80(%rax), %xmm0
movq -0x18(%rbp), %rax
vmovdqa %xmm0, (%rax)
movq -0x18(%rbp), %rax
vmovdqa -0x70(%rax), %xmm0
movq -0x18(%rbp), %rax
vmovdqa %xmm0, 0x10(%rax)
movq -0x18(%rbp), %rax
vmovdqa -0x60(%rax), %xmm0
movq -0x18(%rbp), %rax
vmovdqa %xmm0, 0x20(%rax)
movq -0x18(%rbp), %rax
vmovdqa -0x50(%rax), %xmm0
movq -0x18(%rbp), %rax
vmovdqa %xmm0, 0x30(%rax)
jmp 0x7aa71
movq -0x8(%rbp), %rdi
movl $0xffffff80, %esi       # imm = 0xFFFFFF80
movl $0x7f, %edx
callq 0x770f0
addl $0x8, %eax
andl $0xff, %eax
movl %eax, -0x58(%rbp)
movq -0x8(%rbp), %rax
movswq 0x7ca0(%rax), %rax
cmpq $0x2542, %rax           # imm = 0x2542
jae 0x7a8ff
movq -0x8(%rbp), %rdi
addq $0x7ca2, %rdi           # imm = 0x7CA2
movq -0x8(%rbp), %rax
movswl 0x7ca0(%rax), %eax
cltq
addq %rax, %rdi
movq -0x8(%rbp), %rax
movswq 0x7ca0(%rax), %rax
movl $0x2542, %esi           # imm = 0x2542
subq %rax, %rsi
movl -0x58(%rbp), %ecx
leaq 0x5561a(%rip), %rdx     # 0xcfefc
movb $0x0, %al
callq 0x7070
movl %eax, %edx
movq -0x8(%rbp), %rax
movswl 0x7ca0(%rax), %ecx
addl %edx, %ecx
movw %cx, 0x7ca0(%rax)
cmpl $0x0, -0x58(%rbp)
jne 0x7a974
movl -0x54(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
leaq 0x53b99(%rip), %rax     # 0xce4b0
leaq 0x53b52(%rip), %rcx     # 0xce470
cmpl $0x0, %edx
cmoveq %rcx, %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
vmovdqa (%rax), %xmm0
movq -0x18(%rbp), %rax
vmovdqa %xmm0, (%rax)
movq -0x60(%rbp), %rax
vmovdqa 0x10(%rax), %xmm0
movq -0x18(%rbp), %rax
vmovdqa %xmm0, 0x10(%rax)
movq -0x60(%rbp), %rax
vmovdqa 0x20(%rax), %xmm0
movq -0x18(%rbp), %rax
vmovdqa %xmm0, 0x20(%rax)
movq -0x60(%rbp), %rax
vmovdqa 0x30(%rax), %xmm0
movq -0x18(%rbp), %rax
vmovdqa %xmm0, 0x30(%rax)
jmp 0x7aa6f
movl $0x0, -0x64(%rbp)
movl -0x58(%rbp), %eax
movl %eax, -0x78(%rbp)
cmpl $0x0, %eax
je 0x7a98e
movl -0x78(%rbp), %eax
movl %eax, -0x7c(%rbp)
jmp 0x7a994
movl -0x68(%rbp), %eax
movl %eax, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
movb %al, %dl
movq -0x18(%rbp), %rax
movl -0x64(%rbp), %ecx
movl %ecx, %esi
leaq 0x53d17(%rip), %rcx     # 0xce6c0
movsbq (%rcx,%rsi), %rcx
movb %dl, (%rax,%rcx)
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
cmpl $0x40, %eax
jb 0x7a9c4
jmp 0x7aa6d
cmpl $0x0, -0x58(%rbp)
je 0x7aa68
movl -0x58(%rbp), %eax
movl %eax, -0x68(%rbp)
movl -0x58(%rbp), %eax
movl %eax, -0x80(%rbp)
movq -0x8(%rbp), %rdi
movl $0xffffff80, %esi       # imm = 0xFFFFFF80
movl $0x7f, %edx
callq 0x770f0
movl %eax, %ecx
movl -0x80(%rbp), %eax
addl %ecx, %eax
andl $0xff, %eax
movl %eax, -0x58(%rbp)
movq -0x8(%rbp), %rax
movswq 0x7ca0(%rax), %rax
cmpq $0x2542, %rax           # imm = 0x2542
jae 0x7aa66
movq -0x8(%rbp), %rdi
addq $0x7ca2, %rdi           # imm = 0x7CA2
movq -0x8(%rbp), %rax
movswl 0x7ca0(%rax), %eax
cltq
addq %rax, %rdi
movq -0x8(%rbp), %rax
movswq 0x7ca0(%rax), %rax
movl $0x2542, %esi           # imm = 0x2542
subq %rax, %rsi
movl -0x58(%rbp), %ecx
leaq 0x562fa(%rip), %rdx     # 0xd0d43
movb $0x0, %al
callq 0x7070
movl %eax, %edx
movq -0x8(%rbp), %rax
movswl 0x7ca0(%rax), %ecx
addl %edx, %ecx
movw %cx, 0x7ca0(%rax)
jmp 0x7aa68
jmp 0x7a97b
jmp 0x7aa6f
jmp 0x7aa71
movq -0x8(%rbp), %rax
movswq 0x7ca0(%rax), %rax
cmpq $0x2542, %rax           # imm = 0x2542
jae 0x7aad8
movq -0x8(%rbp), %rdi
addq $0x7ca2, %rdi           # imm = 0x7CA2
movq -0x8(%rbp), %rax
movswl 0x7ca0(%rax), %eax
cltq
addq %rax, %rdi
movq -0x8(%rbp), %rax
movswq 0x7ca0(%rax), %rax
movl $0x2542, %esi           # imm = 0x2542
subq %rax, %rsi
leaq 0x560fd(%rip), %rdx     # 0xd0bb8
movb $0x0, %al
callq 0x7070
movl %eax, %edx
movq -0x8(%rbp), %rax
movswl 0x7ca0(%rax), %ecx
addl %edx, %ecx
movw %cx, 0x7ca0(%rax)
jmp 0x7aada
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
movq -0x18(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x18(%rbp)
jmp 0x7a792
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax)