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

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

	if (x[13] & 0x80) {
		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);
	if (x[2] & 0x40) {
		double aspect_mult = x[14] * 3.0 / 256.0;
		unsigned size_mult = 1 + (x[16] >> 4);

		t.vsize_mm = size_mult * (1 + (x[15] | ((x[16] & 0xf) << 8)));
		t.hsize_mm = t.vsize_mm * aspect_mult;
	}

	switch ((x[13] >> 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[2] & 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
xorpd %xmm0, %xmm0
movupd %xmm0, 0xb0(%rsp)
movupd %xmm0, 0xa4(%rsp)
movupd %xmm0, 0x94(%rsp)
movupd %xmm0, 0x84(%rsp)
movupd %xmm0, 0x74(%rsp)
leaq 0x38(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x15baa(%rip), %rsi     # 0x2ee49
leaq 0x15baa(%rip), %rdx     # 0x2ee50
leaq 0x28(%rsp), %rdi
callq 0x8d58
movzwl (%r14), %eax
movzbl 0x2(%r14), %ecx
andl $0x3f, %ecx
shll $0x10, %ecx
addl %ecx, %eax
incl %eax
movl %eax, 0x7c(%rsp)
movzbl 0x3(%r14), %eax
movzbl 0x4(%r14), %ecx
movl %ecx, %edx
andl $0x3f, %edx
shll $0x8, %edx
addl %edx, %eax
incl %eax
movl %eax, 0x6c(%rsp)
testb %cl, %cl
jns 0x192ed
movb $0x1, 0x94(%rsp)
movzbl 0x7(%r14), %eax
movzbl 0x9(%r14), %ecx
movl %ecx, %edx
andl $0xf, %edx
shll $0x8, %edx
orl %eax, %edx
movzbl 0x8(%r14), %eax
shll $0x4, %ecx
andl $0xf00, %ecx            # imm = 0xF00
leal (%rcx,%rax), %esi
addl %ecx, %eax
incl %eax
movl %eax, 0x88(%rsp)
movzbl 0xa(%r14), %eax
leal 0x1(%rax), %ecx
movl %ecx, 0x8c(%rsp)
notl %edx
addl %esi, %eax
addl %edx, %eax
movl $0xfffffffe, %ecx       # imm = 0xFFFFFFFE
subl %eax, %ecx
movl %ecx, 0x90(%rsp)
movzbl 0x5(%r14), %eax
movzbl 0x6(%r14), %ecx
movl %ecx, %edx
andl $0x3f, %edx
shll $0x8, %edx
addl %edx, %eax
incl %eax
movl %eax, 0x70(%rsp)
testb %cl, %cl
jns 0x19366
movb $0x1, 0xa4(%rsp)
movzbl 0xb(%r14), %eax
movzbl 0xc(%r14), %esi
leal 0x1(%rsi), %ecx
movl %ecx, 0x98(%rsp)
movzbl 0xd(%r14), %edi
movl %edi, %r8d
andl $0xf, %r8d
leal 0x1(%r8), %edx
movl %edx, 0x9c(%rsp)
addl %r8d, %esi
incl %esi
subl %esi, %eax
movl %eax, 0xa0(%rsp)
testb %dil, %dil
jns 0x193d2
movb $0x1, 0x84(%rsp)
shrl %ecx
movl %ecx, 0x98(%rsp)
shrl %edx
movl %edx, 0x9c(%rsp)
movzwl %ax, %ecx
shrl $0xf, %ecx
addl %eax, %ecx
movswl %cx, %eax
sarl %eax
movl %eax, 0xa0(%rsp)
leaq 0x6c(%rsp), %rdi
callq 0x3c00
movl 0x74(%rsp), %ebp
movl $0x1, %eax
cmpl $0xa, %ebp
jb 0x1942e
movl $0x4, %eax
movl $0xd1b71759, %ecx       # imm = 0xD1B71759
movl %ebp, %edx
cmpl $0x63, %edx
jbe 0x19427
cmpl $0x3e7, %edx            # imm = 0x3E7
jbe 0x1942c
cmpl $0x2710, %edx           # imm = 0x2710
jb 0x1942e
movl %edx, %esi
imulq %rcx, %rsi
shrq $0x2d, %rsi
addl $0x4, %eax
cmpl $0x1869f, %edx          # imm = 0x1869F
movl %esi, %edx
ja 0x193f6
addl $-0x3, %eax
jmp 0x1942e
addl $-0x2, %eax
jmp 0x1942e
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 0x7c2d(%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 0x19497
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x194a0
movupd (%rcx), %xmm0
movupd %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 0x1950a
movl $0x4, %eax
movl $0xd1b71759, %ecx       # imm = 0xD1B71759
movl %ebp, %edx
cmpl $0x63, %edx
jbe 0x19503
cmpl $0x3e7, %edx            # imm = 0x3E7
jbe 0x19508
cmpl $0x2710, %edx           # imm = 0x2710
jb 0x1950a
movl %edx, %esi
imulq %rcx, %rsi
shrq $0x2d, %rsi
addl $0x4, %eax
cmpl $0x1869f, %edx          # imm = 0x1869F
movl %esi, %edx
ja 0x194d2
addl $-0x3, %eax
jmp 0x1950a
addl $-0x2, %eax
jmp 0x1950a
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 0x19554
movq 0x18(%rsp), %rdi
movq 0x48(%rsp), %rsi
cmpq %rdi, %rax
jbe 0x19572
movl $0xf, %edi
cmpq %r12, %rsi
je 0x1956d
movq 0x58(%rsp), %rdi
cmpq %rdi, %rax
jbe 0x1957e
leaq 0x8(%rsp), %rdi
callq 0x30b0
jmp 0x1958c
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 0x195b9
movq %rsi, 0xe0(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xf0(%rsp)
jmp 0x195c1
movupd (%rcx), %xmm0
movupd %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 0x1961c
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x3260
movq 0x48(%rsp), %rdi
cmpq %r12, %rdi
je 0x19633
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3260
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x1964a
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3260
movq 0xc0(%rsp), %rdi
cmpq %r13, %rdi
je 0x19667
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x3260
testb $0x40, 0x2(%r14)
jne 0x19690
movzbl 0xd(%r14), %eax
shrl $0x5, %eax
andl $0x3, %eax
leaq 0x157fb(%rip), %rsi     # 0x2ee7b
leaq 0x150d9(%rip), %rcx     # 0x2e760
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movzbl 0xe(%r14), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x14f94(%rip), %xmm0    # 0x2e638
mulsd 0x108b4(%rip), %xmm0    # 0x29f60
movzbl 0x10(%r14), %eax
movl %eax, %ecx
shrl $0x4, %ecx
incl %ecx
movzbl 0xf(%r14), %edx
andl $0xf, %eax
shll $0x8, %eax
addl %edx, %eax
incl %eax
imull %ecx, %eax
cvtsi2sd %eax, %xmm1
movl %eax, 0xb8(%rsp)
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %rax
movl %eax, 0xb4(%rsp)
movzbl 0xd(%r14), %eax
shrl $0x5, %eax
andl $0x3, %eax
leaq 0x15784(%rip), %rsi     # 0x2ee7b
leaq 0x15062(%rip), %rcx     # 0x2e760
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x1577c(%rip), %rsi     # 0x2ee8a
jmp 0x19717
leaq 0x1577f(%rip), %rsi     # 0x2ee96
leaq 0x28(%rsp), %rdi
callq 0x3420
jmp 0x19744
leaq 0x10e7d(%rip), %rsi     # 0x2a5a7
leaq 0x28(%rsp), %rdi
callq 0x3420
leaq 0x1577e(%rip), %rsi     # 0x2eeb9
xorl %edi, %edi
xorl %eax, %eax
callq 0x37cc
cmpb $0x0, 0x2(%r14)
jns 0x19804
leaq 0x15788(%rip), %rsi     # 0x2eede
leaq 0x28(%rsp), %rdi
callq 0x3420
leaq 0x8(%rsp), %rdi
movq %r15, (%rdi)
leaq 0x6b4e(%rip), %rsi      # 0x202bd
leaq 0x6b4a(%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 0x197cc
movq 0x168(%rsp), %rsi
incq %rsi
callq 0x3260
leaq 0x148(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x197ed
movq 0x148(%rsp), %rsi
incq %rsi
callq 0x3260
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x19804
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3260
movq 0x28(%rsp), %r8
movl $0x1, (%rsp)
leaq 0xbc80(%rip), %rsi      # 0x25497
leaq 0x6a9f(%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 0x1984d
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 0x19874
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x19913
movq 0x18(%rsp), %rsi
jmp 0x19904
jmp 0x19910
movq %rax, %rbx
leaq 0xf0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x198b7
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x3260
jmp 0x198b7
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r12, %rdi
je 0x198d3
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3260
jmp 0x198d3
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x198ef
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3260
jmp 0x198ef
movq %rax, %rbx
movq 0xc0(%rsp), %rdi
cmpq %r13, %rdi
je 0x19913
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x3260
jmp 0x19913
jmp 0x19910
movq %rax, %rbx
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x1992f
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x3260
movq %rbx, %rdi
callq 0x3400
nop