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

	t.pixclk_khz = 10 * (1 + (x[0] + (x[1] << 8) + (x[2] << 16)));
	t.hact = 8 + 8 * (x[4] | ((x[5] & 0x01) << 8));
	hbl = 8 + 8 * ((x[5] & 0xfe) >> 1);
	t.hfp = 8 + 8 * ((x[6] & 0xf0) >> 4);
	t.hsync = 8 + 8 * (x[6] & 0xf);
	t.hbp = hbl - t.hfp - t.hsync;
	if ((x[3] >> 3) & 0x1)
		t.pos_pol_hsync = true;
	t.vact = 1 + (x[7] | ((x[8] & 0xf) << 8));
	vbl = 1 + x[9];
	t.vfp = 1 + (x[10] >> 4);
	t.vsync = 1 + (x[10] & 0xf);
	t.vbp = vbl - t.vfp - t.vsync;
	if ((x[17] >> 2) & 0x1)
		t.pos_pol_vsync = true;

	if (x[3] & 0x10) {
		t.interlaced = true;
		t.vfp /= 2;
		t.vsync /= 2;
		t.vbp /= 2;
	}

	calc_ratio(&t);

	s += std::to_string(t.hratio) + ":" + std::to_string(t.vratio);

	switch ((x[3] >> 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[3] & 0x80) {
		s += ", preferred";
		dispid.preferred_timings.push_back(timings_ext(t, "DTD", s));
	}

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x178, %rsp            # imm = 0x178
movq %rsi, %r14
movq %rdi, %rbx
xorps %xmm0, %xmm0
movups %xmm0, 0xb0(%rsp)
movups %xmm0, 0xa4(%rsp)
movups %xmm0, 0x94(%rsp)
movups %xmm0, 0x84(%rsp)
movups %xmm0, 0x74(%rsp)
leaq 0x38(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1803a(%rip), %rsi     # 0x2ee49
leaq 0x1803a(%rip), %rdx     # 0x2ee50
leaq 0x28(%rsp), %rdi
callq 0x8d58
movzwl (%r14), %eax
movzbl 0x2(%r14), %ecx
shll $0x10, %ecx
orl %eax, %ecx
leal (%rcx,%rcx,4), %eax
leal 0xa(,%rax,2), %eax
movl %eax, 0x7c(%rsp)
movzbl 0x4(%r14), %ecx
movzbl 0x5(%r14), %eax
movl %eax, %edx
andl $0x1, %edx
shll $0xb, %edx
leal (%rdx,%rcx,8), %ecx
addl $0x8, %ecx
movl %ecx, 0x6c(%rsp)
andl $-0x2, %eax
shll $0x2, %eax
movzbl 0x6(%r14), %ecx
movl %ecx, %edx
shrl $0x4, %edx
leal 0x8(,%rdx,8), %esi
shll $0x3, %edx
movl %esi, 0x88(%rsp)
andl $0xf, %ecx
leal 0x8(,%rcx,8), %esi
movl %esi, 0x8c(%rsp)
leal (%rdx,%rcx,8), %ecx
addl $0x10, %ecx
subl %ecx, %eax
addl $0x8, %eax
movl %eax, 0x90(%rsp)
movb 0x3(%r14), %al
testb $0x8, %al
je 0x16eac
movb $0x1, 0x94(%rsp)
movzbl 0x7(%r14), %ecx
movzbl 0x8(%r14), %edx
andl $0xf, %edx
shll $0x8, %edx
addl %edx, %ecx
incl %ecx
movl %ecx, 0x70(%rsp)
movzbl 0x9(%r14), %esi
movzbl 0xa(%r14), %edi
movl %edi, %r8d
shrl $0x4, %r8d
leal 0x1(%r8), %ecx
movl %ecx, 0x98(%rsp)
andl $0xf, %edi
leal 0x1(%rdi), %edx
movl %edx, 0x9c(%rsp)
addl %r8d, %edi
addl $0x2, %edi
negl %edi
addl %edi, %esi
incl %esi
movl %esi, 0xa0(%rsp)
testb $0x4, 0x11(%r14)
je 0x16f0f
movb $0x1, 0xa4(%rsp)
testb $0x10, %al
je 0x16f3f
movb $0x1, 0x84(%rsp)
shrl %ecx
movl %ecx, 0x98(%rsp)
shrl %edx
movl %edx, 0x9c(%rsp)
movzwl %si, %eax
shrl $0xf, %eax
addl %esi, %eax
cwtl
sarl %eax
movl %eax, 0xa0(%rsp)
leaq 0x6c(%rsp), %rdi
callq 0x3c00
movl 0x74(%rsp), %ebp
movl $0x1, %eax
cmpl $0xa, %ebp
jb 0x16f9b
movl $0x4, %eax
movl $0xd1b71759, %ecx       # imm = 0xD1B71759
movl %ebp, %edx
cmpl $0x63, %edx
jbe 0x16f94
cmpl $0x3e7, %edx            # imm = 0x3E7
jbe 0x16f99
cmpl $0x2710, %edx           # imm = 0x2710
jb 0x16f9b
movl %edx, %esi
imulq %rcx, %rsi
shrq $0x2d, %rsi
addl $0x4, %eax
cmpl $0x1869f, %edx          # imm = 0x1869F
movl %esi, %edx
ja 0x16f63
addl $-0x3, %eax
jmp 0x16f9b
addl $-0x2, %eax
jmp 0x16f9b
decl %eax
movl %eax, %esi
leaq 0xd0(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0xc0(%rsp), %rdi
xorl %edx, %edx
callq 0x32a0
leaq 0xc0(%rsp), %r15
movq (%r15), %rdi
movl 0x8(%r15), %esi
movl %ebp, %edx
callq 0x8a6d
leaq 0xa0c0(%rip), %rsi      # 0x21095
movq %r15, %rdi
callq 0x3420
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x17004
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x1700b
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq 0x8(%rax), %rdx
movq %rdx, 0x10(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movl 0x78(%rsp), %ebp
movl $0x1, %eax
cmpl $0xa, %ebp
jb 0x17075
movl $0x4, %eax
movl $0xd1b71759, %ecx       # imm = 0xD1B71759
movl %ebp, %edx
cmpl $0x63, %edx
jbe 0x1706e
cmpl $0x3e7, %edx            # imm = 0x3E7
jbe 0x17073
cmpl $0x2710, %edx           # imm = 0x2710
jb 0x17075
movl %edx, %esi
imulq %rcx, %rsi
shrq $0x2d, %rsi
addl $0x4, %eax
cmpl $0x1869f, %edx          # imm = 0x1869F
movl %esi, %edx
ja 0x1703d
addl $-0x3, %eax
jmp 0x17075
addl $-0x2, %eax
jmp 0x17075
decl %eax
movl %eax, %esi
leaq 0x58(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x48(%rsp), %rdi
xorl %edx, %edx
callq 0x32a0
movq 0x48(%rsp), %rdi
movl 0x50(%rsp), %esi
movl %ebp, %edx
callq 0x8a6d
movq 0x8(%rsp), %rcx
movq 0x10(%rsp), %r8
movq 0x50(%rsp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %edi
cmpq %r15, %rcx
je 0x170bf
movq 0x18(%rsp), %rdi
movq 0x48(%rsp), %rsi
cmpq %rdi, %rax
jbe 0x170dd
movl $0xf, %edi
cmpq %r12, %rsi
je 0x170d8
movq 0x58(%rsp), %rdi
cmpq %rdi, %rax
jbe 0x170e9
leaq 0x8(%rsp), %rdi
callq 0x30b0
jmp 0x170f7
leaq 0x48(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x3290
leaq 0xf0(%rsp), %rdx
movq %rdx, -0x10(%rdx)
movq (%rax), %rsi
leaq 0x10(%rax), %rcx
cmpq %rcx, %rsi
je 0x17124
movq %rsi, 0xe0(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xf0(%rsp)
jmp 0x1712a
movups (%rcx), %xmm0
movups %xmm0, (%rdx)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0xe8(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
movq 0xe0(%rsp), %rsi
movq 0xe8(%rsp), %rdx
leaq 0x28(%rsp), %rdi
callq 0x30b0
leaq 0xf0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x17185
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x3260
movq 0x48(%rsp), %rdi
cmpq %r12, %rdi
je 0x1719c
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3260
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x171b3
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3260
movq 0xc0(%rsp), %rdi
cmpq %r13, %rdi
je 0x171d0
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x3260
movzbl 0x3(%r14), %eax
shrl $0x5, %eax
andl $0x3, %eax
leaq 0x174a6(%rip), %rcx     # 0x2e688
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x17c89(%rip), %rsi     # 0x2ee7b
jmp 0x17227
leaq 0x17c9b(%rip), %rsi     # 0x2ee96
jmp 0x17227
leaq 0x133a3(%rip), %rsi     # 0x2a5a7
leaq 0x28(%rsp), %rdi
callq 0x3420
leaq 0x17ca4(%rip), %rsi     # 0x2eeb9
xorl %edi, %edi
xorl %eax, %eax
callq 0x37cc
jmp 0x17231
leaq 0x17c63(%rip), %rsi     # 0x2ee8a
leaq 0x28(%rsp), %rdi
callq 0x3420
cmpb $0x0, 0x3(%r14)
jns 0x172f1
leaq 0x17c9b(%rip), %rsi     # 0x2eede
leaq 0x28(%rsp), %rdi
callq 0x3420
leaq 0x8(%rsp), %rdi
movq %r15, (%rdi)
leaq 0x9061(%rip), %rsi      # 0x202bd
leaq 0x905d(%rip), %rdx      # 0x202c0
callq 0x8d58
leaq 0xe0(%rsp), %rdi
leaq 0x6c(%rsp), %rsi
leaq 0x8(%rsp), %rdx
leaq 0x28(%rsp), %rcx
callq 0xdb20
leaq 0x928(%rbx), %rdi
leaq 0xe0(%rsp), %rsi
callq 0x15ede
leaq 0x168(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x172b9
movq 0x168(%rsp), %rsi
incq %rsi
callq 0x3260
leaq 0x148(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x172da
movq 0x148(%rsp), %rsi
incq %rsi
callq 0x3260
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x172f1
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3260
movq 0x28(%rsp), %r8
movl $0x1, (%rsp)
leaq 0xe193(%rip), %rsi      # 0x25497
leaq 0x8fb2(%rip), %rcx      # 0x202bd
leaq 0x6c(%rsp), %rdx
movq %rbx, %rdi
movl $0x1, %r9d
callq 0x3e8c
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x1733a
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x3260
addq $0x178, %rsp            # imm = 0x178
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0xe0(%rsp), %rdi
callq 0xdbdc
jmp 0x17361
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x17400
movq 0x18(%rsp), %rsi
jmp 0x173f1
jmp 0x173fd
movq %rax, %rbx
leaq 0xf0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x173a4
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x3260
jmp 0x173a4
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r12, %rdi
je 0x173c0
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3260
jmp 0x173c0
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x173dc
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3260
jmp 0x173dc
movq %rax, %rbx
movq 0xc0(%rsp), %rdi
cmpq %r13, %rdi
je 0x17400
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x3260
jmp 0x17400
jmp 0x173fd
movq %rax, %rbx
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x1741c
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x3260
movq %rbx, %rdi
callq 0x3400