// File: /workspace/github_cpp_makefile_star2_O1/rpavlik[P]edid-decode/parse-displayid-block.cpp
// Function: edid_state::parse_displayid_parameters_v2(unsigned char const*, unsigned int)
void edid_state::parse_displayid_parameters_v2(const unsigned char *x,
					       unsigned block_rev)
{
	if (!check_displayid_datablock_length(x, 29, 29))
		return;

	unsigned hor_size = (x[4] << 8) + x[3];
	unsigned vert_size = (x[6] << 8) + x[5];

	dispid.has_display_parameters = true;
	if (x[1] & 0x80)
		printf("    Image size: %u mm x %u mm\n",
		       hor_size, vert_size);
	else
		printf("    Image size: %.1f mm x %.1f mm\n",
		       hor_size / 10.0, vert_size / 10.0);
	unsigned w = (x[8] << 8) + x[7];
	unsigned h = (x[10] << 8) + x[9];
	if (w && h) {
		printf("    Native Format: %ux%u\n", w, h);
		dispid.native_width = w;
		dispid.native_height = h;
	} else if (w || h) {
		fail("Invalid Native Format %ux%u.\n", w, h);
	}
	unsigned char v = x[11];
	printf("    Scan Orientation: ");
	switch (v & 0x07) {
	case 0x00: printf("Left to Right, Top to Bottom\n"); break;
	case 0x01: printf("Right to Left, Top to Bottom\n"); break;
	case 0x02: printf("Top to Bottom, Right to Left\n"); break;
	case 0x03: printf("Bottom to Top, Right to Left\n"); break;
	case 0x04: printf("Right to Left, Bottom to Top\n"); break;
	case 0x05: printf("Left to Right, Bottom to Top\n"); break;
	case 0x06: printf("Bottom to Top, Left to Right\n"); break;
	case 0x07: printf("Top to Bottom, Left to Right\n"); break;
	}
	printf("    Luminance Information: ");
	switch ((v >> 3) & 0x03) {
	case 0x00: printf("Minimum guaranteed value\n"); break;
	case 0x01: printf("Guidance for the Source device\n"); break;
	default: printf("Reserved\n"); break;
	}
	printf("    Color Information: CIE %u\n",
	       (v & 0x40) ? 1976 : 1931);
	printf("    Audio Speaker Information: %sintegrated\n",
	       (v & 0x80) ? "not " : "");
	printf("    Native Color Chromaticity:\n");
	printf("      Primary #1:  (%.6f, %.6f)\n",
	       fp2d(x[0x0c] | ((x[0x0d] & 0x0f) << 8)),
	       fp2d(((x[0x0d] & 0xf0) >> 4) | (x[0x0e] << 4)));
	printf("      Primary #2:  (%.6f, %.6f)\n",
	       fp2d(x[0x0f] | ((x[0x10] & 0x0f) << 8)),
	       fp2d(((x[0x10] & 0xf0) >> 4) | (x[0x11] << 4)));
	printf("      Primary #3:  (%.6f, %.6f)\n",
	       fp2d(x[0x12] | ((x[0x13] & 0x0f) << 8)),
	       fp2d(((x[0x13] & 0xf0) >> 4) | (x[0x14] << 4)));
	printf("      White Point: (%.6f, %.6f)\n",
	       fp2d(x[0x15] | ((x[0x16] & 0x0f) << 8)),
	       fp2d(((x[0x16] & 0xf0) >> 4) | (x[0x17] << 4)));
	printf("    Native Maximum Luminance (Full Coverage): %s\n",
	       ieee7542d(x[0x18] | (x[0x19] << 8)).c_str());
	printf("    Native Maximum Luminance (10%% Rectangular Coverage): %s\n",
	       ieee7542d(x[0x1a] | (x[0x1b] << 8)).c_str());
	printf("    Native Minimum Luminance: %s\n",
	       ieee7542d(x[0x1c] | (x[0x1d] << 8)).c_str());
	printf("    Native Color Depth: ");
	if (!(x[0x1e] & 0x07))
		printf("Not defined\n");
	else if (bpc444[x[0x1e] & 0x07])
		printf("%s bpc\n", bpc444[x[0x1e] & 0x07]);
	else
		printf("Reserved\n");
	printf("    Display Device Technology: ");
	switch ((x[0x1e] >> 4) & 0x07) {
	case 0x00: printf("Not Specified\n"); break;
	case 0x01: printf("Active Matrix LCD\n"); break;
	case 0x02: printf("Organic LED\n"); break;
	default: printf("Reserved\n"); break;
	}
	if (block_rev)
		printf("    Display Device Theme Preference: %s\n",
		       (x[0x1e] & 0x80) ? "Dark Theme Preferred" : "No Preference");
	if (x[0x1f] != 0xff)
		printf("    Native Gamma EOTF: %.2f\n",
		       (100 + x[0x1f]) / 100.0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, %r14
movq %rsi, %rdi
movl $0x1d, %esi
movl $0x1d, %edx
xorl %ecx, %ecx
callq 0x165ab
testb %al, %al
je 0x19e9c
movzwl 0x3(%rbx), %esi
movzwl 0x5(%rbx), %edx
movb $0x1, 0x91f(%r14)
cmpb $0x0, 0x1(%rbx)
js 0x19ae8
cvtsi2sd %esi, %xmm0
movsd 0x14b34(%rip), %xmm2    # 0x2e600
divsd %xmm2, %xmm0
cvtsi2sd %edx, %xmm1
divsd %xmm2, %xmm1
leaq 0x15156(%rip), %rdi     # 0x2ec35
movb $0x2, %al
callq 0x3030
jmp 0x19af6
leaq 0x15e96(%rip), %rdi     # 0x2f985
xorl %eax, %eax
callq 0x3030
movzwl 0x7(%rbx), %r12d
movzwl 0x9(%rbx), %r15d
testl %r12d, %r12d
je 0x19b2e
testl %r15d, %r15d
je 0x19b2e
leaq 0x15e93(%rip), %rdi     # 0x2f9a4
movl %r12d, %esi
movl %r15d, %edx
xorl %eax, %eax
callq 0x3030
movl %r12d, 0x940(%r14)
movl %r15d, 0x944(%r14)
jmp 0x19b4c
movl %r12d, %eax
orl %r15d, %eax
je 0x19b4c
leaq 0x15e81(%rip), %rsi     # 0x2f9be
xorl %edi, %edi
movl %r12d, %edx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x37ec
movzbl 0xb(%rbx), %r15d
leaq 0x15e84(%rip), %rdi     # 0x2f9dc
xorl %eax, %eax
callq 0x3030
movl %r15d, %eax
andl $0x7, %eax
leaq 0x14fc8(%rip), %rcx     # 0x2eb34
movslq (%rcx,%rax,4), %rdi
addq %rcx, %rdi
callq 0x3380
leaq 0x15e74(%rip), %rdi     # 0x2f9f3
xorl %eax, %eax
callq 0x3030
movl %r15d, %eax
shrl $0x3, %eax
andl $0x3, %eax
cmpl $0x1, %eax
leaq 0x17c0f(%rip), %rcx     # 0x317a8
leaq 0x179e0(%rip), %r14     # 0x31580
cmovneq %r14, %rcx
testl %eax, %eax
leaq 0x17c1a(%rip), %rdi     # 0x317c7
cmovneq %rcx, %rdi
callq 0x3380
testb $0x40, %r15b
movl $0x78b, %eax            # imm = 0x78B
movl $0x7b8, %esi            # imm = 0x7B8
cmovel %eax, %esi
leaq 0x15e41(%rip), %rdi     # 0x2fa0f
xorl %eax, %eax
callq 0x3030
testb %r15b, %r15b
leaq 0x709a(%rip), %rax      # 0x20c79
leaq 0x1816e(%rip), %rsi     # 0x31d54
cmovnsq %rax, %rsi
leaq 0x15e3d(%rip), %rdi     # 0x2fa2e
xorl %eax, %eax
callq 0x3030
leaq 0x17be1(%rip), %rdi     # 0x317e0
callq 0x3380
movzbl 0xc(%rbx), %eax
movzbl 0xd(%rbx), %ecx
movl %ecx, %edx
andl $0xf, %edx
shll $0x8, %edx
orl %eax, %edx
xorps %xmm0, %xmm0
cvtsi2sd %edx, %xmm0
movsd 0x1033b(%rip), %xmm2    # 0x29f60
mulsd %xmm2, %xmm0
shrl $0x4, %ecx
movzbl 0xe(%rbx), %eax
shll $0x4, %eax
orl %ecx, %eax
cvtsi2sd %eax, %xmm1
mulsd %xmm2, %xmm1
leaq 0x15e17(%rip), %rdi     # 0x2fa5b
movb $0x2, %al
callq 0x3030
movzbl 0xf(%rbx), %eax
movzbl 0x10(%rbx), %ecx
movl %ecx, %edx
andl $0xf, %edx
shll $0x8, %edx
orl %eax, %edx
xorps %xmm0, %xmm0
cvtsi2sd %edx, %xmm0
movsd 0x102f4(%rip), %xmm2    # 0x29f60
mulsd %xmm2, %xmm0
shrl $0x4, %ecx
movzbl 0x11(%rbx), %eax
shll $0x4, %eax
orl %ecx, %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
mulsd %xmm2, %xmm1
leaq 0x15dee(%rip), %rdi     # 0x2fa7c
movb $0x2, %al
callq 0x3030
movzbl 0x12(%rbx), %eax
movzbl 0x13(%rbx), %ecx
movl %ecx, %edx
andl $0xf, %edx
shll $0x8, %edx
orl %eax, %edx
xorps %xmm0, %xmm0
cvtsi2sd %edx, %xmm0
movsd 0x102aa(%rip), %xmm2    # 0x29f60
mulsd %xmm2, %xmm0
shrl $0x4, %ecx
movzbl 0x14(%rbx), %eax
shll $0x4, %eax
orl %ecx, %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
mulsd %xmm2, %xmm1
leaq 0x15dc5(%rip), %rdi     # 0x2fa9d
movb $0x2, %al
callq 0x3030
movzbl 0x15(%rbx), %eax
movzbl 0x16(%rbx), %ecx
movl %ecx, %edx
andl $0xf, %edx
shll $0x8, %edx
orl %eax, %edx
xorps %xmm0, %xmm0
cvtsi2sd %edx, %xmm0
movsd 0x10260(%rip), %xmm2    # 0x29f60
mulsd %xmm2, %xmm0
shrl $0x4, %ecx
movzbl 0x17(%rbx), %eax
shll $0x4, %eax
orl %ecx, %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
mulsd %xmm2, %xmm1
leaq 0x15d9c(%rip), %rdi     # 0x2fabe
movb $0x2, %al
callq 0x3030
movzwl 0x18(%rbx), %esi
movq %rsp, %r15
movq %r15, %rdi
callq 0x19ea9
movq (%r15), %rsi
leaq 0x15d9d(%rip), %rdi     # 0x2fadf
xorl %eax, %eax
callq 0x3030
movq (%r15), %rdi
leaq 0x10(%rsp), %r12
cmpq %r12, %rdi
je 0x19d63
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3260
movzwl 0x1a(%rbx), %esi
movq %rsp, %r15
movq %r15, %rdi
callq 0x19ea9
movq (%r15), %rsi
leaq 0x15d95(%rip), %rdi     # 0x2fb11
xorl %eax, %eax
callq 0x3030
movq (%r15), %rdi
cmpq %r12, %rdi
je 0x19d98
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3260
movzwl 0x1c(%rbx), %esi
movq %rsp, %r15
movq %r15, %rdi
callq 0x19ea9
movq (%r15), %rsi
leaq 0x15d9e(%rip), %rdi     # 0x2fb4f
xorl %eax, %eax
callq 0x3030
movq (%r15), %rdi
cmpq %r12, %rdi
je 0x19dcd
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3260
leaq 0x15d9d(%rip), %rdi     # 0x2fb71
xorl %eax, %eax
callq 0x3030
movzbl 0x1e(%rbx), %eax
andq $0x7, %rax
je 0x19e05
leaq 0x207e4(%rip), %rcx     # 0x3a5d0
movq (%rcx,%rax,8), %rsi
testq %rsi, %rsi
je 0x19e0e
leaq 0x15d8e(%rip), %rdi     # 0x2fb8a
xorl %eax, %eax
callq 0x3030
jmp 0x19e1a
leaq 0x13f64(%rip), %rdi     # 0x2dd70
jmp 0x19e15
leaq 0x1776b(%rip), %rdi     # 0x31580
callq 0x3380
leaq 0x151b4(%rip), %rdi     # 0x2efd5
xorl %eax, %eax
callq 0x3030
movzbl 0x1e(%rbx), %eax
shrl $0x4, %eax
andl $0x7, %eax
cmpb $0x2, %al
ja 0x19e44
leaq 0x14d17(%rip), %rcx     # 0x2eb54
movslq (%rcx,%rax,4), %r14
addq %rcx, %r14
movq %r14, %rdi
callq 0x3380
testl %ebp, %ebp
je 0x19e74
cmpb $0x0, 0x1e(%rbx)
leaq 0x15d75(%rip), %rax     # 0x2fbd0
leaq 0x15d59(%rip), %rsi     # 0x2fbbb
cmovnsq %rax, %rsi
leaq 0x15d25(%rip), %rdi     # 0x2fb92
xorl %eax, %eax
callq 0x3030
movzbl 0x1f(%rbx), %eax
cmpl $0xff, %eax
je 0x19e9c
addl $0x64, %eax
cvtsi2sd %eax, %xmm0
divsd 0x618a(%rip), %xmm0     # 0x20018
leaq 0x15d49(%rip), %rdi     # 0x2fbde
movb $0x1, %al
callq 0x3030
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq