// File: rpavlik[P]edid-decode/parse-cta-block.cpp
// Function: edid_state::cta_vfpdb(unsigned char const*, unsigned int)
void edid_state::cta_vfpdb(const unsigned char *x, unsigned length)
{
	unsigned i;

	if (length == 0) {
		fail("Empty Data Block with length %u.\n", length);
		return;
	}
	cta.preferred_timings.clear();
	for (i = 0; i < length; i++)  {
		unsigned char svr = x[i];
		char suffix[16];

		if ((svr > 0 && svr < 128) || (svr > 192 && svr < 254)) {
			const struct timings *t;
			unsigned char vic = svr;

			sprintf(suffix, "VIC %3u", vic);

			t = find_vic_id(vic);
			if (t) {
				print_timings("    ", t, suffix);
				cta.preferred_timings.push_back(timings_ext(*t, suffix, ""));
			} else {
				printf("    %s: Unknown\n", suffix);
				fail("Unknown VIC %u.\n", vic);
			}

		} else if (svr >= 129 && svr <= 144) {
			sprintf(suffix, "DTD %3u", svr - 128);
			if (svr >= cta.preparsed_total_dtds + 129) {
				printf("    %s: Invalid\n", suffix);
				fail("Invalid DTD %u.\n", svr - 128);
			} else {
				printf("    %s\n", suffix);
				cta.preferred_timings.push_back(timings_ext(svr, suffix));
			}
		} else if (svr >= 145 && svr <= 160) {
			sprintf(suffix, "VTDB %3u", svr - 144);
			if (svr >= cta.preparsed_total_vtdbs + 145) {
				printf("    %s: Invalid\n", suffix);
				fail("Invalid VTDB %u.\n", svr - 144);
			} else {
				printf("    %s\n", suffix);
				cta.preferred_timings.push_back(timings_ext(svr, suffix));
			}
		} else if (svr == 254) {
			sprintf(suffix, "T8VTDB");
			if (!cta.preparsed_has_t8vtdb) {
				printf("    %s: Invalid\n", suffix);
				fail("Invalid T8VTDB.\n");
			} else {
				printf("    %s\n", suffix);
				cta.preferred_timings.push_back(timings_ext(svr, suffix));
			}
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x410, %rsp            # imm = 0x410
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x380(%rbp)
cmpl $0x0, -0x14(%rbp)
jne 0x164ff
movl -0x14(%rbp), %edx
xorl %edi, %edi
leaq 0x230bc(%rip), %rsi     # 0x395af
movb $0x0, %al
callq 0x47d0
jmp 0x16c61
movq -0x380(%rbp), %rdi
addq $0x180, %rdi            # imm = 0x180
addq $0x40, %rdi
callq 0x14a90
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x14(%rbp), %eax
jae 0x16c61
movq -0x10(%rbp), %rax
movl -0x18(%rbp), %ecx
movb (%rax,%rcx), %al
movb %al, -0x19(%rbp)
movzbl -0x19(%rbp), %eax
cmpl $0x0, %eax
jle 0x1654a
movzbl -0x19(%rbp), %eax
cmpl $0x80, %eax
jl 0x16568
movzbl -0x19(%rbp), %eax
cmpl $0xc0, %eax
jle 0x16781
movzbl -0x19(%rbp), %eax
cmpl $0xfe, %eax
jge 0x16781
movb -0x19(%rbp), %al
movb %al, -0x39(%rbp)
leaq -0x30(%rbp), %rdi
movzbl -0x39(%rbp), %edx
leaq 0x19561(%rip), %rsi     # 0x2fade
movb $0x0, %al
callq 0x40a0
movzbl -0x39(%rbp), %edi
callq 0x154d0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x16756
movq -0x380(%rbp), %rdi
movq -0x38(%rbp), %rdx
movq %rsp, %rax
movl $0x1, (%rax)
leaq 0x1e228(%rip), %rsi     # 0x347df
leaq 0x198fb(%rip), %r8      # 0x2feb9
leaq -0x30(%rbp), %rcx
movq %rcx, -0x390(%rbp)
xorl %r9d, %r9d
callq 0x50c0
movq -0x380(%rbp), %rax
addq $0x1c0, %rax            # imm = 0x1C0
movq %rax, -0x3a0(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x398(%rbp)
leaq -0xf9(%rbp), %rdi
movq %rdi, -0x388(%rbp)
callq 0x4560
movq -0x390(%rbp), %rsi
movq -0x388(%rbp), %rdx
leaq -0xf8(%rbp), %rdi
callq 0xb510
jmp 0x1661f
leaq -0x131(%rbp), %rdi
movq %rdi, -0x3a8(%rbp)
callq 0x4560
movq -0x3a8(%rbp), %rdx
leaq 0x19879(%rip), %rsi     # 0x2feb9
leaq -0x130(%rbp), %rdi
callq 0xb510
jmp 0x1664e
movq -0x398(%rbp), %rsi
leaq -0xd8(%rbp), %rdi
leaq -0xf8(%rbp), %rdx
leaq -0x130(%rbp), %rcx
callq 0x148f0
jmp 0x16671
movq -0x3a0(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x1ff90
jmp 0x16686
leaq -0xd8(%rbp), %rdi
callq 0xc3d0
leaq -0x130(%rbp), %rdi
callq 0x41f0
leaq -0x131(%rbp), %rdi
callq 0x4370
leaq -0xf8(%rbp), %rdi
callq 0x41f0
leaq -0xf9(%rbp), %rdi
callq 0x4370
jmp 0x1677c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
jmp 0x16745
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
jmp 0x1672d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
jmp 0x16721
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0xc3d0
leaq -0x130(%rbp), %rdi
callq 0x41f0
leaq -0x131(%rbp), %rdi
callq 0x4370
leaq -0xf8(%rbp), %rdi
callq 0x41f0
leaq -0xf9(%rbp), %rdi
callq 0x4370
jmp 0x16c6a
leaq -0x30(%rbp), %rsi
leaq 0x22e70(%rip), %rdi     # 0x395d1
movb $0x0, %al
callq 0x4050
movzbl -0x39(%rbp), %edx
xorl %edi, %edi
leaq 0x22d17(%rip), %rsi     # 0x3948c
movb $0x0, %al
callq 0x47d0
jmp 0x16c51
movzbl -0x19(%rbp), %eax
cmpl $0x81, %eax
jl 0x1692b
movzbl -0x19(%rbp), %eax
cmpl $0x90, %eax
jg 0x1692b
leaq -0x30(%rbp), %rdi
movzbl -0x19(%rbp), %edx
subl $0x80, %edx
leaq 0x22e2e(%rip), %rsi     # 0x395e2
movb $0x0, %al
callq 0x40a0
movq -0x380(%rbp), %rcx
movzbl -0x19(%rbp), %eax
movl 0x180(%rcx), %ecx
addl $0x81, %ecx
cmpl %ecx, %eax
jb 0x16807
leaq -0x30(%rbp), %rsi
leaq 0x22e09(%rip), %rdi     # 0x395ea
movb $0x0, %al
callq 0x4050
movzbl -0x19(%rbp), %edx
subl $0x80, %edx
xorl %edi, %edi
leaq 0x22e00(%rip), %rsi     # 0x395fb
movb $0x0, %al
callq 0x47d0
jmp 0x16926
leaq 0x23709(%rip), %rdi     # 0x39f17
xorl %eax, %eax
leaq -0x30(%rbp), %rsi
movq %rsi, -0x3b8(%rbp)
callq 0x4050
movq -0x380(%rbp), %rax
addq $0x1c0, %rax            # imm = 0x1C0
movq %rax, -0x3c8(%rbp)
movzbl -0x19(%rbp), %eax
movl %eax, -0x3bc(%rbp)
leaq -0x1f1(%rbp), %rdi
movq %rdi, -0x3b0(%rbp)
callq 0x4560
movq -0x3b8(%rbp), %rsi
movq -0x3b0(%rbp), %rdx
leaq -0x1f0(%rbp), %rdi
callq 0xb510
jmp 0x1686d
movl -0x3bc(%rbp), %esi
leaq -0x1d0(%rbp), %rdi
leaq -0x1f0(%rbp), %rdx
callq 0x20000
jmp 0x16888
movq -0x3c8(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
callq 0x1ff90
jmp 0x1689d
leaq -0x1d0(%rbp), %rdi
callq 0xc3d0
leaq -0x1f0(%rbp), %rdi
callq 0x41f0
leaq -0x1f1(%rbp), %rdi
callq 0x4370
jmp 0x16926
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
jmp 0x16915
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
jmp 0x16909
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
leaq -0x1d0(%rbp), %rdi
callq 0xc3d0
leaq -0x1f0(%rbp), %rdi
callq 0x41f0
leaq -0x1f1(%rbp), %rdi
callq 0x4370
jmp 0x16c6a
jmp 0x16c4f
movzbl -0x19(%rbp), %eax
cmpl $0x91, %eax
jl 0x16ad5
movzbl -0x19(%rbp), %eax
cmpl $0xa0, %eax
jg 0x16ad5
leaq -0x30(%rbp), %rdi
movzbl -0x19(%rbp), %edx
subl $0x90, %edx
leaq 0x22cae(%rip), %rsi     # 0x3960c
movb $0x0, %al
callq 0x40a0
movq -0x380(%rbp), %rcx
movzbl -0x19(%rbp), %eax
movl 0x1a0(%rcx), %ecx
addl $0x91, %ecx
cmpl %ecx, %eax
jb 0x169b1
leaq -0x30(%rbp), %rsi
leaq 0x22c5f(%rip), %rdi     # 0x395ea
movb $0x0, %al
callq 0x4050
movzbl -0x19(%rbp), %edx
subl $0x90, %edx
xorl %edi, %edi
leaq 0x22c70(%rip), %rsi     # 0x39615
movb $0x0, %al
callq 0x47d0
jmp 0x16ad0
leaq 0x2355f(%rip), %rdi     # 0x39f17
xorl %eax, %eax
leaq -0x30(%rbp), %rsi
movq %rsi, -0x3d8(%rbp)
callq 0x4050
movq -0x380(%rbp), %rax
addq $0x1c0, %rax            # imm = 0x1C0
movq %rax, -0x3e8(%rbp)
movzbl -0x19(%rbp), %eax
movl %eax, -0x3dc(%rbp)
leaq -0x2b1(%rbp), %rdi
movq %rdi, -0x3d0(%rbp)
callq 0x4560
movq -0x3d8(%rbp), %rsi
movq -0x3d0(%rbp), %rdx
leaq -0x2b0(%rbp), %rdi
callq 0xb510
jmp 0x16a17
movl -0x3dc(%rbp), %esi
leaq -0x290(%rbp), %rdi
leaq -0x2b0(%rbp), %rdx
callq 0x20000
jmp 0x16a32
movq -0x3e8(%rbp), %rdi
leaq -0x290(%rbp), %rsi
callq 0x1ff90
jmp 0x16a47
leaq -0x290(%rbp), %rdi
callq 0xc3d0
leaq -0x2b0(%rbp), %rdi
callq 0x41f0
leaq -0x2b1(%rbp), %rdi
callq 0x4370
jmp 0x16ad0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
jmp 0x16abf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
jmp 0x16ab3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
leaq -0x290(%rbp), %rdi
callq 0xc3d0
leaq -0x2b0(%rbp), %rdi
callq 0x41f0
leaq -0x2b1(%rbp), %rdi
callq 0x4370
jmp 0x16c6a
jmp 0x16c4d
movzbl -0x19(%rbp), %eax
cmpl $0xfe, %eax
jne 0x16c4b
leaq -0x30(%rbp), %rdi
leaq 0x22b38(%rip), %rsi     # 0x39627
movb $0x0, %al
callq 0x40a0
movq -0x380(%rbp), %rax
testb $0x1, 0x1d8(%rax)
jne 0x16b2d
leaq -0x30(%rbp), %rsi
leaq 0x22ad9(%rip), %rdi     # 0x395ea
movb $0x0, %al
callq 0x4050
xorl %edi, %edi
leaq 0x22b0d(%rip), %rsi     # 0x3962e
movb $0x0, %al
callq 0x47d0
jmp 0x16c49
leaq 0x233e3(%rip), %rdi     # 0x39f17
xorl %eax, %eax
leaq -0x30(%rbp), %rsi
movq %rsi, -0x3f8(%rbp)
callq 0x4050
movq -0x380(%rbp), %rax
addq $0x1c0, %rax            # imm = 0x1C0
movq %rax, -0x408(%rbp)
movzbl -0x19(%rbp), %eax
movl %eax, -0x3fc(%rbp)
leaq -0x371(%rbp), %rdi
movq %rdi, -0x3f0(%rbp)
callq 0x4560
movq -0x3f8(%rbp), %rsi
movq -0x3f0(%rbp), %rdx
leaq -0x370(%rbp), %rdi
callq 0xb510
jmp 0x16b93
movl -0x3fc(%rbp), %esi
leaq -0x350(%rbp), %rdi
leaq -0x370(%rbp), %rdx
callq 0x20000
jmp 0x16bae
movq -0x408(%rbp), %rdi
leaq -0x350(%rbp), %rsi
callq 0x1ff90
jmp 0x16bc3
leaq -0x350(%rbp), %rdi
callq 0xc3d0
leaq -0x370(%rbp), %rdi
callq 0x41f0
leaq -0x371(%rbp), %rdi
callq 0x4370
jmp 0x16c49
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
jmp 0x16c3b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
jmp 0x16c2f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
leaq -0x350(%rbp), %rdi
callq 0xc3d0
leaq -0x370(%rbp), %rdi
callq 0x41f0
leaq -0x371(%rbp), %rdi
callq 0x4370
jmp 0x16c6a
jmp 0x16c4b
jmp 0x16c4d
jmp 0x16c4f
jmp 0x16c51
jmp 0x16c53
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x1651d
addq $0x410, %rsp            # imm = 0x410
popq %rbp
retq
movq -0x108(%rbp), %rdi
callq 0x4550
nopw %cs:(%rax,%rax)