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

	switch (x[0] & 0xf) {
	case 0:
		s += "1:1";
		t.hratio = t.vratio = 1;
		break;
	case 1:
		s += "5:4";
		t.hratio = 5;
		t.vratio = 4;
		break;
	case 2:
		s += "4:3";
		t.hratio = 4;
		t.vratio = 3;
		break;
	case 3:
		s += "15:9";
		t.hratio = 15;
		t.vratio = 9;
		break;
	case 4:
		s += "16:9";
		t.hratio = 16;
		t.vratio = 9;
		break;
	case 5:
		s += "16:10";
		t.hratio = 16;
		t.vratio = 10;
		break;
	case 6:
		s += "64:27";
		t.hratio = 64;
		t.vratio = 27;
		break;
	case 7:
		s += "256:135";
		t.hratio = 256;
		t.vratio = 135;
		break;
	default:
		s += "undefined";
		if ((x[3] & 0xf) > (dispid.version <= 0x12 ? 7 : 8))
			fail("Unknown aspect 0x%02x.\n", x[3] & 0xf);
		break;
	}

	t.rb = ((x[0] & 0x70) >> 4) == 1 ? RB_CVT_V1 : RB_NONE;
	t.hact = 8 + 8 * x[1];
	t.vact = t.hact * t.vratio / t.hratio;

	edid_cvt_mode(1 + (x[2] & 0x7f), 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 $0x1a0, %rsp            # imm = 0x1A0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x178(%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, -0x170(%rbp)
callq 0x4560
movq -0x170(%rbp), %rdx
leaq 0x1b168(%rip), %rsi     # 0x3e4f5
leaq -0x90(%rbp), %rdi
callq 0xb510
jmp 0x2339b
leaq -0x91(%rbp), %rdi
callq 0x4370
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
andl $0xf, %eax
movl %eax, %ecx
movq %rcx, -0x180(%rbp)
subl $0x7, %eax
ja 0x23551
movq -0x180(%rbp), %rax
leaq 0x1a7f7(%rip), %rcx     # 0x3dbc8
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 0x23798
leaq 0x1b0f9(%rip), %rsi     # 0x3e4fd
leaq -0x90(%rbp), %rdi
callq 0x4300
jmp 0x23412
movl $0x1, -0x64(%rbp)
movl $0x1, -0x68(%rbp)
jmp 0x235b5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x2378c
leaq 0x10a66(%rip), %rsi     # 0x33ea9
leaq -0x90(%rbp), %rdi
callq 0x4300
jmp 0x23451
movl $0x5, -0x68(%rbp)
movl $0x4, -0x64(%rbp)
jmp 0x235b5
leaq 0x10a2c(%rip), %rsi     # 0x33e97
leaq -0x90(%rbp), %rdi
callq 0x4300
jmp 0x23479
movl $0x4, -0x68(%rbp)
movl $0x3, -0x64(%rbp)
jmp 0x235b5
leaq 0x10a1b(%rip), %rsi     # 0x33eae
leaq -0x90(%rbp), %rdi
callq 0x4300
jmp 0x234a1
movl $0xf, -0x68(%rbp)
movl $0x9, -0x64(%rbp)
jmp 0x235b5
leaq 0x109e1(%rip), %rsi     # 0x33e9c
leaq -0x90(%rbp), %rdi
callq 0x4300
jmp 0x234c9
movl $0x10, -0x68(%rbp)
movl $0x9, -0x64(%rbp)
jmp 0x235b5
leaq 0x109bf(%rip), %rsi     # 0x33ea2
leaq -0x90(%rbp), %rdi
callq 0x4300
jmp 0x234f1
movl $0x10, -0x68(%rbp)
movl $0xa, -0x64(%rbp)
jmp 0x235b5
leaq 0x1aff6(%rip), %rsi     # 0x3e501
leaq -0x90(%rbp), %rdi
callq 0x4300
jmp 0x23519
movl $0x40, -0x68(%rbp)
movl $0x1b, -0x64(%rbp)
jmp 0x235b5
leaq 0x1afd4(%rip), %rsi     # 0x3e507
leaq -0x90(%rbp), %rdi
callq 0x4300
jmp 0x23541
movl $0x100, -0x68(%rbp)     # imm = 0x100
movl $0x87, -0x64(%rbp)
jmp 0x235b5
leaq 0x1afb7(%rip), %rsi     # 0x3e50f
leaq -0x90(%rbp), %rdi
callq 0x4300
jmp 0x23566
movq -0x178(%rbp), %rcx
movq -0x10(%rbp), %rax
movzbl 0x3(%rax), %eax
andl $0xf, %eax
movzbl 0x910(%rcx), %esi
movl $0x8, %ecx
movl $0x7, %edx
cmpl $0x12, %esi
cmovlel %edx, %ecx
cmpl %ecx, %eax
jle 0x235b3
movq -0x10(%rbp), %rax
movzbl 0x3(%rax), %edx
andl $0xf, %edx
leaq 0x1af74(%rip), %rsi     # 0x3e519
xorl %edi, %edi
movb %dil, %al
callq 0x47d0
jmp 0x235b1
jmp 0x235b3
jmp 0x235b5
movq -0x178(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
andl $0x70, %eax
shrl $0x4, %eax
subl $0x1, %eax
sete %al
movzbl %al, %eax
movl %eax, -0x5c(%rbp)
movq -0x10(%rbp), %rax
movzbl 0x1(%rax), %ecx
movl %ecx, %eax
leal 0x8(,%rax,8), %eax
movl %eax, -0x70(%rbp)
movl -0x64(%rbp), %edx
movl -0x70(%rbp), %eax
movl -0x68(%rbp), %ecx
imull %edx, %eax
xorl %edx, %edx
divl %ecx
movl %eax, -0x6c(%rbp)
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %esi
andl $0x7f, %esi
incl %esi
leaq -0x70(%rbp), %rdx
callq 0x2e180
jmp 0x23614
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x2373c
leaq 0x1af64(%rip), %rsi     # 0x3e594
leaq -0x90(%rbp), %rdi
callq 0x4300
jmp 0x2363e
movq -0x178(%rbp), %rax
addq $0x928, %rax            # imm = 0x928
movq %rax, -0x190(%rbp)
leaq -0x161(%rbp), %rdi
movq %rdi, -0x188(%rbp)
callq 0x4560
movq -0x188(%rbp), %rdx
leaq 0xc800(%rip), %rsi      # 0x2fe73
leaq -0x160(%rbp), %rdi
callq 0xb510
jmp 0x23681
leaq -0x140(%rbp), %rdi
leaq -0x70(%rbp), %rsi
leaq -0x160(%rbp), %rdx
leaq -0x90(%rbp), %rcx
callq 0x148f0
jmp 0x236a1
movq -0x190(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0x1ff90
jmp 0x236b6
leaq -0x140(%rbp), %rdi
callq 0xc3d0
leaq -0x160(%rbp), %rdi
callq 0x41f0
leaq -0x161(%rbp), %rdi
callq 0x4370
jmp 0x2373c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x2372e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x23722
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x140(%rbp), %rdi
callq 0xc3d0
leaq -0x160(%rbp), %rdi
callq 0x41f0
leaq -0x161(%rbp), %rdi
callq 0x4370
jmp 0x2378c
leaq -0x90(%rbp), %rdi
callq 0x4150
movq -0x178(%rbp), %rdi
movq %rax, %r8
movq %rsp, %rax
movl $0x1, (%rax)
leaq 0x1107d(%rip), %rsi     # 0x347df
leaq 0xc70a(%rip), %rcx      # 0x2fe73
leaq -0x70(%rbp), %rdx
xorl %r9d, %r9d
callq 0x50c0
jmp 0x23777
leaq -0x90(%rbp), %rdi
callq 0x41f0
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
leaq -0x90(%rbp), %rdi
callq 0x41f0
movq -0xa0(%rbp), %rdi
callq 0x4550
nopw %cs:(%rax,%rax)