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

	t.hact = 1 + (x[1] | (x[2] << 8));
	t.vact = 1 + (x[3] | (x[4] << 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;
	}

	switch (x[0] & 0x07) {
	case 1: t.rb = RB_CVT_V1; break;
	case 2: t.rb = RB_CVT_V2; break;
	case 3: t.rb = RB_CVT_V3; break;
	default: break;
	}

	if (x[0] & 0x10) {
		if (t.rb == RB_CVT_V2) {
			s += ", refresh rate * (1000/1001) supported";
			t.rb |= RB_ALT;
		} else if (t.rb == RB_CVT_V3) {
			s += ", hblank is 160 pixels";
			t.rb |= RB_ALT;
		} else {
			fail("VR_HB must be 0.\n");
		}
	}
	if (x[0] & 0x80)
		s += ", YCbCr 4:2:0";

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

	print_timings("    ", &t, "CVT", s.c_str());
	if (is_cta) {
		timings_ext te(t, "CVT", s);
		cta.vec_vtdbs.push_back(te);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x220, %rsp            # imm = 0x220
movb %dl, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
andb $0x1, %al
movb %al, -0x11(%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 0x16ea1(%rip), %rsi     # 0x3e4f5
leaq -0x90(%rbp), %rdi
callq 0xb510
jmp 0x27662
leaq -0x91(%rbp), %rdi
callq 0x4370
movq -0x10(%rbp), %rax
movzwl 0x1(%rax), %eax
incl %eax
movl %eax, -0x70(%rbp)
movq -0x10(%rbp), %rax
movzwl 0x3(%rax), %eax
incl %eax
movl %eax, -0x6c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x4c30
jmp 0x27693
movl -0x68(%rbp), %esi
leaq -0x108(%rbp), %rdi
callq 0xb6d0
jmp 0x276a4
leaq 0x9caf(%rip), %rdx      # 0x3135a
leaq -0xe8(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0xb4c0
jmp 0x276c0
movl -0x64(%rbp), %esi
leaq -0x128(%rbp), %rdi
callq 0xb6d0
jmp 0x276d1
leaq -0xc8(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
leaq -0x128(%rbp), %rdx
callq 0xb7b0
jmp 0x276ed
leaq -0x90(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x43f0
jmp 0x27702
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 0x27894
movq -0x200(%rbp), %rax
leaq 0x1668d(%rip), %rcx     # 0x3ddec
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 0x27af5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x27ae9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x27814
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x27808
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x277fc
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 0x27ae9
leaq 0x16d05(%rip), %rsi     # 0x3e531
leaq -0x90(%rbp), %rdi
callq 0x4300
jmp 0x2783a
jmp 0x27894
leaq 0x16cfd(%rip), %rsi     # 0x3e540
leaq -0x90(%rbp), %rdi
callq 0x4300
jmp 0x27851
jmp 0x27894
leaq 0x16cf2(%rip), %rsi     # 0x3e54c
leaq -0x90(%rbp), %rdi
callq 0x4300
jmp 0x27868
jmp 0x27894
leaq 0x1250a(%rip), %rsi     # 0x39d7b
leaq -0x90(%rbp), %rdi
callq 0x4300
jmp 0x2787f
leaq 0x16ce9(%rip), %rsi     # 0x3e56f
xorl %edi, %edi
movb %dil, %al
callq 0x47d0
jmp 0x27892
jmp 0x27894
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
andl $0x7, %eax
movl %eax, -0x204(%rbp)
subl $0x1, %eax
je 0x278c5
jmp 0x278ab
movl -0x204(%rbp), %eax
subl $0x2, %eax
je 0x278ce
jmp 0x278b8
movl -0x204(%rbp), %eax
subl $0x3, %eax
je 0x278d7
jmp 0x278e0
movl $0x1, -0x5c(%rbp)
jmp 0x278e2
movl $0x2, -0x5c(%rbp)
jmp 0x278e2
movl $0x3, -0x5c(%rbp)
jmp 0x278e2
jmp 0x278e2
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x2795a
cmpl $0x2, -0x5c(%rbp)
jne 0x27919
leaq 0x17d30(%rip), %rsi     # 0x3f62e
leaq -0x90(%rbp), %rdi
callq 0x4300
jmp 0x2790c
movl -0x5c(%rbp), %eax
orl $0x80, %eax
movl %eax, -0x5c(%rbp)
jmp 0x27958
cmpl $0x3, -0x5c(%rbp)
jne 0x27941
leaq 0x187f5(%rip), %rsi     # 0x4011b
leaq -0x90(%rbp), %rdi
callq 0x4300
jmp 0x27934
movl -0x5c(%rbp), %eax
orl $0x80, %eax
movl %eax, -0x5c(%rbp)
jmp 0x27956
leaq 0x187ea(%rip), %rsi     # 0x40132
xorl %edi, %edi
movb %dil, %al
callq 0x47d0
jmp 0x27954
jmp 0x27956
jmp 0x27958
jmp 0x2795a
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x27982
leaq 0x16c14(%rip), %rsi     # 0x3e586
leaq -0x90(%rbp), %rdi
callq 0x4300
jmp 0x27980
jmp 0x27982
movq -0x1f8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x5(%rax), %esi
incl %esi
leaq -0x70(%rbp), %rdx
callq 0x2e180
jmp 0x2799e
leaq -0x90(%rbp), %rdi
callq 0x4150
movq -0x1f8(%rbp), %rdi
movq %rax, %r8
movq %rsp, %rax
movl $0x1, (%rax)
leaq 0xce1b(%rip), %rsi      # 0x347df
leaq 0x84a8(%rip), %rcx      # 0x2fe73
leaq -0x70(%rbp), %rdx
xorl %r9d, %r9d
callq 0x50c0
jmp 0x279d9
testb $0x1, -0x11(%rbp)
je 0x27ad4
leaq -0x1e1(%rbp), %rdi
movq %rdi, -0x210(%rbp)
callq 0x4560
movq -0x210(%rbp), %rdx
leaq 0x846f(%rip), %rsi      # 0x2fe73
leaq -0x1e0(%rbp), %rdi
callq 0xb510
jmp 0x27a12
leaq -0x1c0(%rbp), %rdi
leaq -0x70(%rbp), %rsi
leaq -0x1e0(%rbp), %rdx
leaq -0x90(%rbp), %rcx
callq 0x148f0
jmp 0x27a32
leaq -0x1e0(%rbp), %rdi
callq 0x41f0
leaq -0x1e1(%rbp), %rdi
callq 0x4370
movq -0x1f8(%rbp), %rdi
addq $0x1a8, %rdi            # imm = 0x1A8
leaq -0x1c0(%rbp), %rsi
callq 0x14a20
jmp 0x27a66
leaq -0x1c0(%rbp), %rdi
callq 0xc3d0
jmp 0x27ad4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x27aa6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x1e0(%rbp), %rdi
callq 0x41f0
leaq -0x1e1(%rbp), %rdi
callq 0x4370
jmp 0x27ae9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0xc3d0
jmp 0x27ae9
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)