// File: /workspace/github_cpp_makefile_star2_O3/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 0x1644b
testb %al, %al
je 0x19d5a
movzwl 0x3(%rbx), %esi
movzwl 0x5(%rbx), %edx
movb $0x1, 0x91f(%r14)
cmpb $0x0, 0x1(%rbx)
js 0x199a6
cvtsi2sd %esi, %xmm0
movsd 0x14c9e(%rip), %xmm2    # 0x2e628
divsd %xmm2, %xmm0
cvtsi2sd %edx, %xmm1
divsd %xmm2, %xmm1
leaq 0x152d8(%rip), %rdi     # 0x2ec75
movb $0x2, %al
callq 0x3030
jmp 0x199b4
leaq 0x16018(%rip), %rdi     # 0x2f9c5
xorl %eax, %eax
callq 0x3030
movzwl 0x7(%rbx), %r12d
movzwl 0x9(%rbx), %r15d
testl %r12d, %r12d
je 0x199ec
testl %r15d, %r15d
je 0x199ec
leaq 0x16015(%rip), %rdi     # 0x2f9e4
movl %r12d, %esi
movl %r15d, %edx
xorl %eax, %eax
callq 0x3030
movl %r12d, 0x940(%r14)
movl %r15d, 0x944(%r14)
jmp 0x19a0a
movl %r12d, %eax
orl %r15d, %eax
je 0x19a0a
leaq 0x16003(%rip), %rsi     # 0x2f9fe
xorl %edi, %edi
movl %r12d, %edx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x37cc
movzbl 0xb(%rbx), %r15d
leaq 0x16006(%rip), %rdi     # 0x2fa1c
xorl %eax, %eax
callq 0x3030
movl %r15d, %eax
andl $0x7, %eax
leaq 0x15132(%rip), %rcx     # 0x2eb5c
movslq (%rcx,%rax,4), %rdi
addq %rcx, %rdi
callq 0x3380
leaq 0x15ff6(%rip), %rdi     # 0x2fa33
xorl %eax, %eax
callq 0x3030
movl %r15d, %eax
shrl $0x3, %eax
andl $0x3, %eax
cmpl $0x1, %eax
leaq 0x17d91(%rip), %rcx     # 0x317e8
leaq 0x17b62(%rip), %r14     # 0x315c0
cmovneq %r14, %rcx
testl %eax, %eax
leaq 0x17d9c(%rip), %rdi     # 0x31807
cmovneq %rcx, %rdi
callq 0x3380
testb $0x40, %r15b
movl $0x78b, %eax            # imm = 0x78B
movl $0x7b8, %esi            # imm = 0x7B8
cmovel %eax, %esi
leaq 0x15fc3(%rip), %rdi     # 0x2fa4f
xorl %eax, %eax
callq 0x3030
testb %r15b, %r15b
leaq 0x71ec(%rip), %rax      # 0x20c89
leaq 0x182f0(%rip), %rsi     # 0x31d94
cmovnsq %rax, %rsi
leaq 0x15fbf(%rip), %rdi     # 0x2fa6e
xorl %eax, %eax
callq 0x3030
leaq 0x17d63(%rip), %rdi     # 0x31820
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 0x104a5(%rip), %xmm2    # 0x29f88
mulsd %xmm2, %xmm0
shrl $0x4, %ecx
movzbl 0xe(%rbx), %eax
shll $0x4, %eax
orl %ecx, %eax
cvtsi2sd %eax, %xmm1
mulsd %xmm2, %xmm1
leaq 0x15f99(%rip), %rdi     # 0x2fa9b
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 0x1045e(%rip), %xmm2    # 0x29f88
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 0x15f70(%rip), %rdi     # 0x2fabc
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 0x10414(%rip), %xmm2    # 0x29f88
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 0x15f47(%rip), %rdi     # 0x2fadd
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 0x103ca(%rip), %xmm2    # 0x29f88
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 0x15f1e(%rip), %rdi     # 0x2fafe
movb $0x2, %al
callq 0x3030
movzwl 0x18(%rbx), %esi
movq %rsp, %r15
movq %r15, %rdi
callq 0x19d67
movq (%r15), %rsi
leaq 0x15f1f(%rip), %rdi     # 0x2fb1f
xorl %eax, %eax
callq 0x3030
movq (%r15), %rdi
leaq 0x10(%rsp), %r12
cmpq %r12, %rdi
je 0x19c21
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3260
movzwl 0x1a(%rbx), %esi
movq %rsp, %r15
movq %r15, %rdi
callq 0x19d67
movq (%r15), %rsi
leaq 0x15f17(%rip), %rdi     # 0x2fb51
xorl %eax, %eax
callq 0x3030
movq (%r15), %rdi
cmpq %r12, %rdi
je 0x19c56
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3260
movzwl 0x1c(%rbx), %esi
movq %rsp, %r15
movq %r15, %rdi
callq 0x19d67
movq (%r15), %rsi
leaq 0x15f20(%rip), %rdi     # 0x2fb8f
xorl %eax, %eax
callq 0x3030
movq (%r15), %rdi
cmpq %r12, %rdi
je 0x19c8b
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3260
leaq 0x15f1f(%rip), %rdi     # 0x2fbb1
xorl %eax, %eax
callq 0x3030
movzbl 0x1e(%rbx), %eax
andq $0x7, %rax
je 0x19cc3
leaq 0x20926(%rip), %rcx     # 0x3a5d0
movq (%rcx,%rax,8), %rsi
testq %rsi, %rsi
je 0x19ccc
leaq 0x15f10(%rip), %rdi     # 0x2fbca
xorl %eax, %eax
callq 0x3030
jmp 0x19cd8
leaq 0x140ce(%rip), %rdi     # 0x2dd98
jmp 0x19cd3
leaq 0x178ed(%rip), %rdi     # 0x315c0
callq 0x3380
leaq 0x15336(%rip), %rdi     # 0x2f015
xorl %eax, %eax
callq 0x3030
movzbl 0x1e(%rbx), %eax
shrl $0x4, %eax
andl $0x7, %eax
cmpb $0x2, %al
ja 0x19d02
leaq 0x14e81(%rip), %rcx     # 0x2eb7c
movslq (%rcx,%rax,4), %r14
addq %rcx, %r14
movq %r14, %rdi
callq 0x3380
testl %ebp, %ebp
je 0x19d32
cmpb $0x0, 0x1e(%rbx)
leaq 0x15ef7(%rip), %rax     # 0x2fc10
leaq 0x15edb(%rip), %rsi     # 0x2fbfb
cmovnsq %rax, %rsi
leaq 0x15ea7(%rip), %rdi     # 0x2fbd2
xorl %eax, %eax
callq 0x3030
movzbl 0x1f(%rbx), %eax
cmpl $0xff, %eax
je 0x19d5a
addl $0x64, %eax
cvtsi2sd %eax, %xmm0
divsd 0x62d4(%rip), %xmm0     # 0x20020
leaq 0x15ecb(%rip), %rdi     # 0x2fc1e
movb $0x1, %al
callq 0x3030
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq