// File: rpavlik[P]edid-decode/parse-displayid-block.cpp
// Function: edid_state::parse_displayid_type_9_timing(unsigned char const*)
void edid_state::parse_displayid_type_9_timing(const unsigned char *x)
{
	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;
	}
	if (x[0] & 0x10)
		s += ", refresh rate * (1000/1001) supported";

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

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

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x138(%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, -0x130(%rbp)
callq 0x4560
movq -0x130(%rbp), %rdx
leaq 0x17768(%rip), %rsi     # 0x3e4f5
leaq -0x90(%rbp), %rdi
callq 0xb510
jmp 0x26d9b
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 0x26dcc
movl -0x68(%rbp), %esi
leaq -0x108(%rbp), %rdi
callq 0xb6d0
jmp 0x26ddd
leaq 0xa576(%rip), %rdx      # 0x3135a
leaq -0xe8(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0xb4c0
jmp 0x26df9
movl -0x64(%rbp), %esi
leaq -0x128(%rbp), %rdi
callq 0xb6d0
jmp 0x26e0a
leaq -0xc8(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
leaq -0x128(%rbp), %rdx
callq 0xb7b0
jmp 0x26e26
leaq -0x90(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x43f0
jmp 0x26e3b
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, -0x140(%rbp)
subl $0x3, %eax
ja 0x26fcd
movq -0x140(%rbp), %rax
leaq 0x16f44(%rip), %rcx     # 0x3dddc
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 0x270a3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x27097
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x26f4d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x26f41
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x26f35
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 0x27097
leaq 0x175cc(%rip), %rsi     # 0x3e531
leaq -0x90(%rbp), %rdi
callq 0x4300
jmp 0x26f73
jmp 0x26fcd
leaq 0x175c4(%rip), %rsi     # 0x3e540
leaq -0x90(%rbp), %rdi
callq 0x4300
jmp 0x26f8a
jmp 0x26fcd
leaq 0x175b9(%rip), %rsi     # 0x3e54c
leaq -0x90(%rbp), %rdi
callq 0x4300
jmp 0x26fa1
jmp 0x26fcd
leaq 0x12dd1(%rip), %rsi     # 0x39d7b
leaq -0x90(%rbp), %rdi
callq 0x4300
jmp 0x26fb8
leaq 0x175b0(%rip), %rsi     # 0x3e56f
xorl %edi, %edi
movb %dil, %al
callq 0x47d0
jmp 0x26fcb
jmp 0x26fcd
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x26ff3
leaq 0x1864b(%rip), %rsi     # 0x3f62e
leaq -0x90(%rbp), %rdi
callq 0x4300
jmp 0x26ff1
jmp 0x26ff3
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
andl $0x7, %eax
movl %eax, -0x144(%rbp)
subl $0x1, %eax
je 0x27017
jmp 0x2700a
movl -0x144(%rbp), %eax
subl $0x2, %eax
je 0x27020
jmp 0x27029
movl $0x1, -0x5c(%rbp)
jmp 0x2702b
movl $0x2, -0x5c(%rbp)
jmp 0x2702b
jmp 0x2702b
movq -0x138(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x5(%rax), %esi
incl %esi
leaq -0x70(%rbp), %rdx
callq 0x2e180
jmp 0x27047
leaq -0x90(%rbp), %rdi
callq 0x4150
movq -0x138(%rbp), %rdi
movq %rax, %r8
movq %rsp, %rax
movl $0x1, (%rax)
leaq 0xd772(%rip), %rsi      # 0x347df
leaq 0x8dff(%rip), %rcx      # 0x2fe73
leaq -0x70(%rbp), %rdx
xorl %r9d, %r9d
callq 0x50c0
jmp 0x27082
leaq -0x90(%rbp), %rdi
callq 0x41f0
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
leaq -0x90(%rbp), %rdi
callq 0x41f0
movq -0xa0(%rbp), %rdi
callq 0x4550
nop