// File: /workspace/github_cpp_makefile_star2_O1/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 $0x188, %rsp            # imm = 0x188
movq %rsi, %r14
movq %rdi, %rbx
xorpd %xmm0, %xmm0
movapd %xmm0, 0xb0(%rsp)
movapd %xmm0, 0xa0(%rsp)
movapd %xmm0, 0x90(%rsp)
movapd %xmm0, 0x80(%rsp)
movapd %xmm0, 0x70(%rsp)
movl $0x0, 0xc0(%rsp)
leaq 0x40(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x15a29(%rip), %rsi     # 0x2ee09
leaq 0x15a29(%rip), %rdx     # 0x2ee10
leaq 0x30(%rsp), %rdi
callq 0x8f6e
movzwl (%r14), %eax
movzbl 0x2(%r14), %ecx
andl $0x3f, %ecx
shll $0x10, %ecx
addl %ecx, %eax
incl %eax
movl %eax, 0x80(%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, 0x70(%rsp)
testb %cl, %cl
jns 0x19431
movb $0x1, 0x98(%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, 0x8c(%rsp)
movzbl 0xa(%r14), %eax
leal 0x1(%rax), %ecx
movl %ecx, 0x90(%rsp)
notl %edx
addl %esi, %eax
addl %edx, %eax
movl $0xfffffffe, %ecx       # imm = 0xFFFFFFFE
subl %eax, %ecx
movl %ecx, 0x94(%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, 0x74(%rsp)
testb %cl, %cl
jns 0x194aa
movb $0x1, 0xa8(%rsp)
movzbl 0xb(%r14), %eax
movzbl 0xc(%r14), %esi
leal 0x1(%rsi), %ecx
movl %ecx, 0x9c(%rsp)
movzbl 0xd(%r14), %edi
movl %edi, %r8d
andl $0xf, %r8d
leal 0x1(%r8), %edx
movl %edx, 0xa0(%rsp)
addl %r8d, %esi
incl %esi
subl %esi, %eax
movl %eax, 0xa4(%rsp)
testb %dil, %dil
jns 0x19512
movb $0x1, 0x88(%rsp)
shrl %ecx
movl %ecx, 0x9c(%rsp)
shrl %edx
movl %edx, 0xa0(%rsp)
movl %eax, %ecx
shrl $0x1f, %ecx
addl %eax, %ecx
sarl %ecx
movl %ecx, 0xa4(%rsp)
leaq 0x70(%rsp), %rdi
callq 0x3c2c
movl 0x78(%rsp), %ebp
movl $0x1, %eax
cmpl $0xa, %ebp
jb 0x1956e
movl $0x4, %eax
movl $0xd1b71759, %ecx       # imm = 0xD1B71759
movl %ebp, %edx
cmpl $0x63, %edx
jbe 0x19567
cmpl $0x3e7, %edx            # imm = 0x3E7
jbe 0x1956c
cmpl $0x2710, %edx           # imm = 0x2710
jb 0x1956e
movl %edx, %esi
imulq %rcx, %rsi
shrq $0x2d, %rsi
addl $0x4, %eax
cmpl $0x1869f, %edx          # imm = 0x1869F
movl %esi, %edx
ja 0x19536
addl $-0x3, %eax
jmp 0x1956e
addl $-0x2, %eax
jmp 0x1956e
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 0x7add(%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 0x195d7
movq %rdx, 0x10(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x20(%rsp)
jmp 0x195e0
movupd (%rcx), %xmm0
movupd %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 0x1964a
movl $0x4, %eax
movl $0xd1b71759, %ecx       # imm = 0xD1B71759
movl %ebp, %edx
cmpl $0x63, %edx
jbe 0x19643
cmpl $0x3e7, %edx            # imm = 0x3E7
jbe 0x19648
cmpl $0x2710, %edx           # imm = 0x2710
jb 0x1964a
movl %edx, %esi
imulq %rcx, %rsi
shrq $0x2d, %rsi
addl $0x4, %eax
cmpl $0x1869f, %edx          # imm = 0x1869F
movl %esi, %edx
ja 0x19612
addl $-0x3, %eax
jmp 0x1964a
addl $-0x2, %eax
jmp 0x1964a
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 0x19694
movq 0x20(%rsp), %rsi
cmpq %rsi, %rax
jbe 0x196af
movl $0xf, %esi
cmpq %r12, 0x50(%rsp)
je 0x196aa
movq 0x60(%rsp), %rsi
cmpq %rsi, %rax
jbe 0x196c0
movq 0x50(%rsp), %rsi
leaq 0x10(%rsp), %rdi
callq 0x30b0
jmp 0x196ce
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 0x196fb
movq %rsi, 0xf0(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x100(%rsp)
jmp 0x19703
movupd (%rcx), %xmm0
movupd %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 0x1975e
movq 0x100(%rsp), %rsi
incq %rsi
callq 0x3260
movq 0x50(%rsp), %rdi
cmpq %r12, %rdi
je 0x19775
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x3260
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0x1978c
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3260
movq 0xd0(%rsp), %rdi
cmpq %r13, %rdi
je 0x197a9
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x3260
testb $0x40, 0x2(%r14)
jne 0x197d2
movzbl 0xd(%r14), %eax
shrl $0x5, %eax
andl $0x3, %eax
leaq 0x15679(%rip), %rsi     # 0x2ee3b
leaq 0x14f6f(%rip), %rcx     # 0x2e738
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movzbl 0xe(%r14), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x14e2a(%rip), %xmm0    # 0x2e610
mulsd 0x1074a(%rip), %xmm0    # 0x29f38
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, 0xbc(%rsp)
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %rax
movl %eax, 0xb8(%rsp)
movzbl 0xd(%r14), %eax
shrl $0x5, %eax
andl $0x3, %eax
leaq 0x15602(%rip), %rsi     # 0x2ee3b
leaq 0x14ef8(%rip), %rcx     # 0x2e738
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x155fa(%rip), %rsi     # 0x2ee4a
jmp 0x19859
leaq 0x155fd(%rip), %rsi     # 0x2ee56
leaq 0x30(%rsp), %rdi
callq 0x3420
jmp 0x19886
leaq 0x10d13(%rip), %rsi     # 0x2a57f
leaq 0x30(%rsp), %rdi
callq 0x3420
leaq 0x155fc(%rip), %rsi     # 0x2ee79
xorl %edi, %edi
xorl %eax, %eax
callq 0x37ec
cmpb $0x0, 0x2(%r14)
jns 0x19946
leaq 0x15606(%rip), %rsi     # 0x2ee9e
leaq 0x30(%rsp), %rdi
callq 0x3420
leaq 0x10(%rsp), %rdi
movq %r15, (%rdi)
leaq 0x69fc(%rip), %rsi      # 0x202ad
leaq 0x69f8(%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 0x1990e
movq 0x178(%rsp), %rsi
incq %rsi
callq 0x3260
leaq 0x158(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1992f
movq 0x158(%rsp), %rsi
incq %rsi
callq 0x3260
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0x19946
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3260
movq 0x30(%rsp), %r8
movl $0x1, (%rsp)
leaq 0xbaee(%rip), %rsi      # 0x25447
leaq 0x694d(%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 0x1998f
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 0x199b6
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0x19a55
movq 0x20(%rsp), %rsi
jmp 0x19a46
jmp 0x19a52
movq %rax, %rbx
leaq 0x100(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x199f9
movq 0x100(%rsp), %rsi
incq %rsi
callq 0x3260
jmp 0x199f9
movq %rax, %rbx
movq 0x50(%rsp), %rdi
cmpq %r12, %rdi
je 0x19a15
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x3260
jmp 0x19a15
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0x19a31
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3260
jmp 0x19a31
movq %rax, %rbx
movq 0xd0(%rsp), %rdi
cmpq %r13, %rdi
je 0x19a55
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x3260
jmp 0x19a55
jmp 0x19a52
movq %rax, %rbx
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x19a71
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3260
movq %rbx, %rdi
callq 0x3400
nop