// File: /workspace/github_cpp_makefile_star2_O2/rpavlik[P]edid-decode/parse-displayid-block.cpp
// Function: edid_state::parse_displayid_type_10_timing(unsigned char const*, bool)
void edid_state::parse_displayid_type_10_timing(const unsigned char *x, bool is_cta)
{
	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;
	}

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

	if (x[0] & 0x10) {
		if (t.rb == RB_CVT_V2) {
			s += ", refresh rate * (1000/1001) supported";
			t.rb |= RB_ALT;
		} else if (t.rb == RB_CVT_V3) {
			s += ", hblank is 160 pixels";
			t.rb |= RB_ALT;
		} else {
			fail("VR_HB must be 0.\n");
		}
	}
	if (x[0] & 0x80)
		s += ", YCbCr 4:2:0";

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

	print_timings("    ", &t, "CVT", s.c_str());
	if (is_cta) {
		timings_ext te(t, "CVT", s);
		cta.vec_vtdbs.push_back(te);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x178, %rsp            # imm = 0x178
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
xorps %xmm0, %xmm0
leaq 0x88(%rsp), %r15
movups %xmm0, 0x44(%r15)
movups %xmm0, 0x38(%r15)
movups %xmm0, 0x28(%r15)
movups %xmm0, 0x18(%r15)
movups %xmm0, 0x8(%r15)
leaq 0x13335(%rip), %rsi     # 0x28e49
leaq 0x8(%rsp), %rdi
leaq 0xe0(%rsp), %rdx
callq 0x75c4
movd 0x1(%r14), %xmm0
punpcklwd 0x1306c(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1],xmm0[2],mem[2],xmm0[3],mem[3]
pcmpeqd %xmm1, %xmm1
psubd %xmm1, %xmm0
movq %xmm0, (%r15)
movq %r15, %rdi
callq 0x38fe
movl 0x90(%rsp), %esi
leaq 0x48(%rsp), %rdi
callq 0x7675
leaq 0x5534(%rip), %rdx      # 0x1b095
leaq 0x28(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x75a4
movl 0x94(%rsp), %esi
leaq 0x68(%rsp), %rdi
callq 0x7675
leaq 0xe0(%rsp), %rdi
leaq 0x28(%rsp), %rsi
leaq 0x68(%rsp), %rdx
callq 0x76b4
leaq 0x8(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0x3480
leaq 0xe0(%rsp), %rdi
callq 0x3130
leaq 0x68(%rsp), %rdi
callq 0x3130
leaq 0x28(%rsp), %rdi
callq 0x3130
leaq 0x48(%rsp), %rdi
callq 0x3130
movzbl (%r14), %eax
shrl $0x5, %eax
andl $0x3, %eax
leaq 0x12ba2(%rip), %rcx     # 0x28788
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x13285(%rip), %rsi     # 0x28e7b
jmp 0x15c2b
leaq 0x13297(%rip), %rsi     # 0x28e96
jmp 0x15c2b
leaq 0xe99f(%rip), %rsi      # 0x245a7
leaq 0x8(%rsp), %rdi
callq 0x3450
leaq 0x132a0(%rip), %rsi     # 0x28eb9
xorl %edi, %edi
xorl %eax, %eax
callq 0x362c
jmp 0x15c35
leaq 0x1325f(%rip), %rsi     # 0x28e8a
leaq 0x8(%rsp), %rdi
callq 0x3450
movzbl (%r14), %eax
movl %eax, %ecx
andl $0x7, %ecx
leal -0x1(%rcx), %edx
cmpb $0x2, %dl
ja 0x15c4d
movl %ecx, 0x9c(%rsp)
testb $0x10, %al
je 0x15c96
movl 0x9c(%rsp), %eax
cmpl $0x2, %eax
je 0x15c6b
cmpl $0x3, %eax
jne 0x15c86
leaq 0x142c5(%rip), %rsi     # 0x29f2e
jmp 0x15c72
leaq 0x13a86(%rip), %rsi     # 0x296f8
leaq 0x8(%rsp), %rdi
callq 0x3450
orb $-0x80, 0x9c(%rsp)
jmp 0x15c96
leaq 0x142b8(%rip), %rsi     # 0x29f45
xorl %edi, %edi
xorl %eax, %eax
callq 0x362c
cmpb $0x0, (%r14)
jns 0x15cad
leaq 0x1322d(%rip), %rsi     # 0x28ed0
leaq 0x8(%rsp), %rdi
callq 0x3450
movzbl 0x5(%r14), %esi
incl %esi
leaq 0x88(%rsp), %rdx
movq %rbx, %rdi
callq 0x19e2a
movq 0x8(%rsp), %r8
movl $0x1, (%rsp)
leaq 0x97c0(%rip), %rsi      # 0x1f497
leaq 0x150f0(%rip), %rcx     # 0x2adce
leaq 0x88(%rsp), %rdx
movq %rbx, %rdi
xorl %r9d, %r9d
callq 0x3af0
testb %bpl, %bpl
je 0x15d59
leaq 0x150d1(%rip), %rsi     # 0x2adce
leaq 0x28(%rsp), %rdi
leaq 0x48(%rsp), %rdx
callq 0x75c4
leaq 0xe0(%rsp), %rdi
leaq 0x88(%rsp), %rsi
leaq 0x28(%rsp), %rdx
leaq 0x8(%rsp), %rcx
callq 0xbb34
leaq 0x28(%rsp), %rdi
callq 0x3130
addq $0x1a8, %rbx            # imm = 0x1A8
leaq 0xe0(%rsp), %rsi
movq %rbx, %rdi
callq 0xbbe4
leaq 0xe0(%rsp), %rdi
callq 0x78cc
leaq 0x8(%rsp), %rdi
callq 0x3130
addq $0x178, %rsp            # imm = 0x178
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0xe0(%rsp), %rdi
callq 0x78cc
jmp 0x15dd3
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
jmp 0x15dc7
jmp 0x15dd0
movq %rax, %rbx
leaq 0xe0(%rsp), %rdi
callq 0x3130
jmp 0x15da4
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x3130
jmp 0x15db3
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x3130
jmp 0x15dc2
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x3130
jmp 0x15dd3
jmp 0x15dd0
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x3130
movq %rbx, %rdi
callq 0x3430
nop