// File: rpavlik[P]edid-decode/parse-displayid-block.cpp
// Function: edid_state::parse_displayid_type_5_timing(unsigned char const*)
void edid_state::parse_displayid_type_5_timing(const unsigned char *x)
{
	struct timings t = {};
	std::string s("aspect ");

	t.hact = 1 + (x[2] | (x[3] << 8));
	t.vact = 1 + (x[4] | (x[5] << 8));
	calc_ratio(&t);
	s += std::to_string(t.hratio) + ":" + std::to_string(t.vratio);
	switch ((x[0] >> 5) & 0x3) {
	case 0:
		s += ", no 3D stereo";
		break;
	case 1:
		s += ", 3D stereo";
		break;
	case 2:
		s += ", 3D stereo depends on user action";
		break;
	case 3:
		s += ", reserved";
		fail("Reserved stereo 0x03.\n");
		break;
	}
	if (x[0] & 0x10)
		s += ", refresh rate * (1000/1001) supported";

	t.rb = RB_CVT_V2;
	if ((x[0] & 0x03) == 1)
		warn("Unexpected use of 'custom reduced blanking'.\n");
	else if ((x[0] & 0x03) > 1)
		fail("Invalid Timing Formula.\n");

	edid_cvt_mode(1 + x[6], t);

	if (x[0] & 0x80) {
		s += ", preferred";
		dispid.preferred_timings.push_back(timings_ext(t, "CVT", s));
	}

	print_timings("    ", &t, "CVT", s.c_str());
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x220, %rsp            # imm = 0x220
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x1f8(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x30(%rbp)
movaps %xmm0, -0x40(%rbp)
movaps %xmm0, -0x50(%rbp)
movaps %xmm0, -0x60(%rbp)
movaps %xmm0, -0x70(%rbp)
movl $0x0, -0x20(%rbp)
leaq -0x91(%rbp), %rdi
movq %rdi, -0x1f0(%rbp)
callq 0x4560
movq -0x1f0(%rbp), %rdx
leaq 0x18ee8(%rip), %rsi     # 0x3e4f5
leaq -0x90(%rbp), %rdi
callq 0xb510
jmp 0x2561b
leaq -0x91(%rbp), %rdi
callq 0x4370
movq -0x10(%rbp), %rax
movzwl 0x2(%rax), %eax
incl %eax
movl %eax, -0x70(%rbp)
movq -0x10(%rbp), %rax
movzwl 0x4(%rax), %eax
incl %eax
movl %eax, -0x6c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x4c30
jmp 0x2564c
movl -0x68(%rbp), %esi
leaq -0x108(%rbp), %rdi
callq 0xb6d0
jmp 0x2565d
leaq 0xbcf6(%rip), %rdx      # 0x3135a
leaq -0xe8(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0xb4c0
jmp 0x25679
movl -0x64(%rbp), %esi
leaq -0x128(%rbp), %rdi
callq 0xb6d0
jmp 0x2568a
leaq -0xc8(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
leaq -0x128(%rbp), %rdx
callq 0xb7b0
jmp 0x256a6
leaq -0x90(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x43f0
jmp 0x256bb
leaq -0xc8(%rbp), %rdi
callq 0x41f0
leaq -0x128(%rbp), %rdi
callq 0x41f0
leaq -0xe8(%rbp), %rdi
callq 0x41f0
leaq -0x108(%rbp), %rdi
callq 0x41f0
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
shrl $0x5, %eax
andl $0x3, %eax
movl %eax, %ecx
movq %rcx, -0x200(%rbp)
subl $0x3, %eax
ja 0x2584d
movq -0x200(%rbp), %rax
leaq 0x18674(%rip), %rcx     # 0x3dd8c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x91(%rbp), %rdi
callq 0x4370
jmp 0x25a66
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x25a5a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x257cd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x257c1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x257b5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x41f0
leaq -0x128(%rbp), %rdi
callq 0x41f0
leaq -0xe8(%rbp), %rdi
callq 0x41f0
leaq -0x108(%rbp), %rdi
callq 0x41f0
jmp 0x25a5a
leaq 0x18d4c(%rip), %rsi     # 0x3e531
leaq -0x90(%rbp), %rdi
callq 0x4300
jmp 0x257f3
jmp 0x2584d
leaq 0x18d44(%rip), %rsi     # 0x3e540
leaq -0x90(%rbp), %rdi
callq 0x4300
jmp 0x2580a
jmp 0x2584d
leaq 0x18d39(%rip), %rsi     # 0x3e54c
leaq -0x90(%rbp), %rdi
callq 0x4300
jmp 0x25821
jmp 0x2584d
leaq 0x14551(%rip), %rsi     # 0x39d7b
leaq -0x90(%rbp), %rdi
callq 0x4300
jmp 0x25838
leaq 0x18d30(%rip), %rsi     # 0x3e56f
xorl %edi, %edi
movb %dil, %al
callq 0x47d0
jmp 0x2584b
jmp 0x2584d
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x25873
leaq 0x19dcb(%rip), %rsi     # 0x3f62e
leaq -0x90(%rbp), %rdi
callq 0x4300
jmp 0x25871
jmp 0x25873
movl $0x2, -0x5c(%rbp)
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
andl $0x3, %eax
cmpl $0x1, %eax
jne 0x258a0
leaq 0x19dc5(%rip), %rsi     # 0x3f655
xorl %eax, %eax
movl $0x1, %edi
callq 0x47d0
jmp 0x2589e
jmp 0x258c6
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
andl $0x3, %eax
cmpl $0x1, %eax
jle 0x258c4
leaq 0x19dcd(%rip), %rsi     # 0x3f683
xorl %edi, %edi
movb %dil, %al
callq 0x47d0
jmp 0x258c2
jmp 0x258c4
jmp 0x258c6
movq -0x1f8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x6(%rax), %esi
incl %esi
leaq -0x70(%rbp), %rdx
callq 0x2e180
jmp 0x258e2
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x25a0a
leaq 0x18c96(%rip), %rsi     # 0x3e594
leaq -0x90(%rbp), %rdi
callq 0x4300
jmp 0x2590c
movq -0x1f8(%rbp), %rax
addq $0x928, %rax            # imm = 0x928
movq %rax, -0x210(%rbp)
leaq -0x1e1(%rbp), %rdi
movq %rdi, -0x208(%rbp)
callq 0x4560
movq -0x208(%rbp), %rdx
leaq 0xa532(%rip), %rsi      # 0x2fe73
leaq -0x1e0(%rbp), %rdi
callq 0xb510
jmp 0x2594f
leaq -0x1c0(%rbp), %rdi
leaq -0x70(%rbp), %rsi
leaq -0x1e0(%rbp), %rdx
leaq -0x90(%rbp), %rcx
callq 0x148f0
jmp 0x2596f
movq -0x210(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0x1ff90
jmp 0x25984
leaq -0x1c0(%rbp), %rdi
callq 0xc3d0
leaq -0x1e0(%rbp), %rdi
callq 0x41f0
leaq -0x1e1(%rbp), %rdi
callq 0x4370
jmp 0x25a0a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x259fc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x259f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0xc3d0
leaq -0x1e0(%rbp), %rdi
callq 0x41f0
leaq -0x1e1(%rbp), %rdi
callq 0x4370
jmp 0x25a5a
leaq -0x90(%rbp), %rdi
callq 0x4150
movq -0x1f8(%rbp), %rdi
movq %rax, %r8
movq %rsp, %rax
movl $0x1, (%rax)
leaq 0xedaf(%rip), %rsi      # 0x347df
leaq 0xa43c(%rip), %rcx      # 0x2fe73
leaq -0x70(%rbp), %rdx
xorl %r9d, %r9d
callq 0x50c0
jmp 0x25a45
leaq -0x90(%rbp), %rdi
callq 0x41f0
addq $0x220, %rsp            # imm = 0x220
popq %rbp
retq
leaq -0x90(%rbp), %rdi
callq 0x41f0
movq -0xa0(%rbp), %rdi
callq 0x4550
nopw %cs:(%rax,%rax)