// File: /workspace/github_cpp_makefile_star2_O1/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 $0x188, %rsp            # imm = 0x188
movq %rsi, %r14
movq %rdi, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, 0xb0(%rsp)
movaps %xmm0, 0xa0(%rsp)
movaps %xmm0, 0x90(%rsp)
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
movl $0x0, 0xc0(%rsp)
leaq 0x40(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x17e85(%rip), %rsi     # 0x2ee09
leaq 0x17e85(%rip), %rdx     # 0x2ee10
leaq 0x30(%rsp), %rdi
callq 0x8f6e
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, 0x80(%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, 0x70(%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, 0x8c(%rsp)
andl $0xf, %ecx
leal 0x8(,%rcx,8), %esi
movl %esi, 0x90(%rsp)
leal (%rdx,%rcx,8), %ecx
addl $0x10, %ecx
subl %ecx, %eax
addl $0x8, %eax
movl %eax, 0x94(%rsp)
movb 0x3(%r14), %al
testb $0x8, %al
je 0x17024
movb $0x1, 0x98(%rsp)
movzbl 0x7(%r14), %ecx
movzbl 0x8(%r14), %edx
andl $0xf, %edx
shll $0x8, %edx
addl %edx, %ecx
incl %ecx
movl %ecx, 0x74(%rsp)
movzbl 0x9(%r14), %esi
movzbl 0xa(%r14), %edi
movl %edi, %r8d
shrl $0x4, %r8d
leal 0x1(%r8), %ecx
movl %ecx, 0x9c(%rsp)
andl $0xf, %edi
leal 0x1(%rdi), %edx
movl %edx, 0xa0(%rsp)
addl %r8d, %edi
addl $0x2, %edi
negl %edi
addl %edi, %esi
incl %esi
movl %esi, 0xa4(%rsp)
testb $0x4, 0x11(%r14)
je 0x17087
movb $0x1, 0xa8(%rsp)
testb $0x10, %al
je 0x170b5
movb $0x1, 0x88(%rsp)
shrl %ecx
movl %ecx, 0x9c(%rsp)
shrl %edx
movl %edx, 0xa0(%rsp)
movl %esi, %eax
shrl $0x1f, %eax
addl %esi, %eax
sarl %eax
movl %eax, 0xa4(%rsp)
leaq 0x70(%rsp), %rdi
callq 0x3c2c
movl 0x78(%rsp), %ebp
movl $0x1, %eax
cmpl $0xa, %ebp
jb 0x17111
movl $0x4, %eax
movl $0xd1b71759, %ecx       # imm = 0xD1B71759
movl %ebp, %edx
cmpl $0x63, %edx
jbe 0x1710a
cmpl $0x3e7, %edx            # imm = 0x3E7
jbe 0x1710f
cmpl $0x2710, %edx           # imm = 0x2710
jb 0x17111
movl %edx, %esi
imulq %rcx, %rsi
shrq $0x2d, %rsi
addl $0x4, %eax
cmpl $0x1869f, %edx          # imm = 0x1869F
movl %esi, %edx
ja 0x170d9
addl $-0x3, %eax
jmp 0x17111
addl $-0x2, %eax
jmp 0x17111
decl %eax
movl %eax, %esi
leaq 0xe0(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0xd0(%rsp), %rdi
xorl %edx, %edx
callq 0x32a0
leaq 0xd0(%rsp), %r15
movq (%r15), %rdi
movl 0x8(%r15), %esi
movl %ebp, %edx
callq 0x8c91
leaq 0x9f3a(%rip), %rsi      # 0x21085
movq %r15, %rdi
callq 0x3420
leaq 0x20(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x1717a
movq %rdx, 0x10(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x20(%rsp)
jmp 0x17181
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq 0x8(%rax), %rdx
movq %rdx, 0x18(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movl 0x7c(%rsp), %ebp
movl $0x1, %eax
cmpl $0xa, %ebp
jb 0x171eb
movl $0x4, %eax
movl $0xd1b71759, %ecx       # imm = 0xD1B71759
movl %ebp, %edx
cmpl $0x63, %edx
jbe 0x171e4
cmpl $0x3e7, %edx            # imm = 0x3E7
jbe 0x171e9
cmpl $0x2710, %edx           # imm = 0x2710
jb 0x171eb
movl %edx, %esi
imulq %rcx, %rsi
shrq $0x2d, %rsi
addl $0x4, %eax
cmpl $0x1869f, %edx          # imm = 0x1869F
movl %esi, %edx
ja 0x171b3
addl $-0x3, %eax
jmp 0x171eb
addl $-0x2, %eax
jmp 0x171eb
decl %eax
movl %eax, %esi
leaq 0x60(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x50(%rsp), %rdi
xorl %edx, %edx
callq 0x32a0
movq 0x50(%rsp), %rdi
movl 0x58(%rsp), %esi
movl %ebp, %edx
callq 0x8c91
movq 0x10(%rsp), %rcx
movq 0x18(%rsp), %r8
movq 0x58(%rsp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %esi
cmpq %r15, %rcx
je 0x17235
movq 0x20(%rsp), %rsi
cmpq %rsi, %rax
jbe 0x17250
movl $0xf, %esi
cmpq %r12, 0x50(%rsp)
je 0x1724b
movq 0x60(%rsp), %rsi
cmpq %rsi, %rax
jbe 0x17261
movq 0x50(%rsp), %rsi
leaq 0x10(%rsp), %rdi
callq 0x30b0
jmp 0x1726f
leaq 0x50(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x3290
leaq 0x100(%rsp), %rdx
movq %rdx, -0x10(%rdx)
movq (%rax), %rsi
leaq 0x10(%rax), %rcx
cmpq %rcx, %rsi
je 0x1729c
movq %rsi, 0xf0(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x100(%rsp)
jmp 0x172a2
movups (%rcx), %xmm0
movups %xmm0, (%rdx)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0xf8(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
movq 0xf0(%rsp), %rsi
movq 0xf8(%rsp), %rdx
leaq 0x30(%rsp), %rdi
callq 0x30b0
leaq 0x100(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x172fd
movq 0x100(%rsp), %rsi
incq %rsi
callq 0x3260
movq 0x50(%rsp), %rdi
cmpq %r12, %rdi
je 0x17314
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x3260
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0x1732b
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3260
movq 0xd0(%rsp), %rdi
cmpq %r13, %rdi
je 0x17348
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x3260
movzbl 0x3(%r14), %eax
shrl $0x5, %eax
andl $0x3, %eax
leaq 0x17306(%rip), %rcx     # 0x2e660
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x17ad1(%rip), %rsi     # 0x2ee3b
jmp 0x1739f
leaq 0x17ae3(%rip), %rsi     # 0x2ee56
jmp 0x1739f
leaq 0x13203(%rip), %rsi     # 0x2a57f
leaq 0x30(%rsp), %rdi
callq 0x3420
leaq 0x17aec(%rip), %rsi     # 0x2ee79
xorl %edi, %edi
xorl %eax, %eax
callq 0x37ec
jmp 0x173a9
leaq 0x17aab(%rip), %rsi     # 0x2ee4a
leaq 0x30(%rsp), %rdi
callq 0x3420
cmpb $0x0, 0x3(%r14)
jns 0x17469
leaq 0x17ae3(%rip), %rsi     # 0x2ee9e
leaq 0x30(%rsp), %rdi
callq 0x3420
leaq 0x10(%rsp), %rdi
movq %r15, (%rdi)
leaq 0x8ed9(%rip), %rsi      # 0x202ad
leaq 0x8ed5(%rip), %rdx      # 0x202b0
callq 0x8f6e
leaq 0xf0(%rsp), %rdi
leaq 0x70(%rsp), %rsi
leaq 0x10(%rsp), %rdx
leaq 0x30(%rsp), %rcx
callq 0xdce2
leaq 0x928(%rbx), %rdi
leaq 0xf0(%rsp), %rsi
callq 0x16042
leaq 0x178(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x17431
movq 0x178(%rsp), %rsi
incq %rsi
callq 0x3260
leaq 0x158(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x17452
movq 0x158(%rsp), %rsi
incq %rsi
callq 0x3260
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0x17469
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3260
movq 0x30(%rsp), %r8
movl $0x1, (%rsp)
leaq 0xdfcb(%rip), %rsi      # 0x25447
leaq 0x8e2a(%rip), %rcx      # 0x202ad
leaq 0x70(%rsp), %rdx
movq %rbx, %rdi
movl $0x1, %r9d
callq 0x3ebe
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x174b2
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3260
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
callq 0xdd9e
jmp 0x174d9
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0x17578
movq 0x20(%rsp), %rsi
jmp 0x17569
jmp 0x17575
movq %rax, %rbx
leaq 0x100(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1751c
movq 0x100(%rsp), %rsi
incq %rsi
callq 0x3260
jmp 0x1751c
movq %rax, %rbx
movq 0x50(%rsp), %rdi
cmpq %r12, %rdi
je 0x17538
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x3260
jmp 0x17538
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0x17554
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3260
jmp 0x17554
movq %rax, %rbx
movq 0xd0(%rsp), %rdi
cmpq %r13, %rdi
je 0x17578
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x3260
jmp 0x17578
jmp 0x17575
movq %rax, %rbx
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x17594
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3260
movq %rbx, %rdi
callq 0x3400