// File: rpavlik[P]edid-decode/parse-displayid-block.cpp
// Function: edid_state::parse_displayid_interface_features(unsigned char const*)
void edid_state::parse_displayid_interface_features(const unsigned char *x)
{
	check_displayid_datablock_revision(x[1]);

	if (!check_displayid_datablock_length(x, 9))
		return;

	dispid.has_display_interface_features = true;
	unsigned len = x[2];
	if (len > 0) print_flags("    Supported bpc for RGB encoding", x[3], bpc444);
	if (len > 1) print_flags("    Supported bpc for YCbCr 4:4:4 encoding", x[4], bpc444);
	if (len > 2) print_flags("    Supported bpc for YCbCr 4:2:2 encoding", x[5], bpc4xx);
	if (len > 3) print_flags("    Supported bpc for YCbCr 4:2:0 encoding", x[6], bpc4xx);
	if (len > 4 && x[7])
		printf("    Minimum pixel rate at which YCbCr 4:2:0 encoding is supported: %.3f MHz\n",
		       74.25 * x[7]);
	if (len > 5) print_flags("    Supported audio capability and features (kHz)",
				 x[8], audiorates, true);
	if (len > 6) print_flags("    Supported color space and EOTF standard combination 1",
				 x[9], colorspace_eotf_combinations);
	if (len > 7) print_flags("    Supported color space and EOTF standard combination 2",x[10], colorspace_eotf_reserved);

	unsigned i = 0;

	if (len > 8 && x[11]) {
		printf("    Supported color space and EOTF additional combinations:");
		for (i = 0; i < x[11]; i++) {
			if (i > 6) {
				printf("\n    Number of additional color space and EOTF combinations (%d) is greater than allowed (7).", x[11]);
				break;
			} else if (i + 10 > len) {
				printf("\n    Number of additional color space and EOTF combinations (%d) is too many to fit in block (%d).", x[11], len - 9);
				break;
			}

			const char *colorspace = "Out of range";
			const char *eotf = "Out of range";
			unsigned colorspace_index = (x[12 + i] >> 4) & 0xf;
			unsigned eotf_index = x[12 + i] & 0xf;

			if (colorspace_index < sizeof(colorspaces) / sizeof(colorspaces[0]))
				colorspace = colorspaces[colorspace_index];
			if (eotf_index < sizeof(eotfs) / sizeof(eotfs[0]))
				eotf = eotfs[eotf_index];

			if (i > 0)
				printf(", ");
			if (!strcmp(colorspace, eotf))
				printf("%s", colorspace);
			else
				printf("%s/%s", colorspace, eotf);
		}
		printf("\n");
	}
	check_displayid_datablock_length(x, 9 + i, 9 + i, 9 + i);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x38(%rbp)
movq -0x10(%rbp), %rax
xorl %ecx, %ecx
movzbl 0x1(%rax), %esi
movl %ecx, %edx
callq 0x21b00
movq -0x10(%rbp), %rdi
movl $0x9, %esi
movl $0x76, %edx
xorl %ecx, %ecx
callq 0x21f90
testb $0x1, %al
jne 0x27257
jmp 0x27539
movq -0x38(%rbp), %rax
movb $0x1, 0x921(%rax)
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %eax
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jbe 0x27290
movq -0x10(%rbp), %rax
leaq 0x17ec5(%rip), %rdi     # 0x3f143
leaq 0x2471b(%rip), %rdx     # 0x4b9a0
xorl %ecx, %ecx
movzbl 0x3(%rax), %esi
callq 0x24f50
cmpl $0x1, -0x14(%rbp)
jbe 0x272b3
movq -0x10(%rbp), %rax
leaq 0x17ec5(%rip), %rdi     # 0x3f166
leaq 0x246f8(%rip), %rdx     # 0x4b9a0
xorl %ecx, %ecx
movzbl 0x4(%rax), %esi
callq 0x24f50
cmpl $0x2, -0x14(%rbp)
jbe 0x272d6
movq -0x10(%rbp), %rax
leaq 0x17ecd(%rip), %rdi     # 0x3f191
leaq 0x24715(%rip), %rdx     # 0x4b9e0
xorl %ecx, %ecx
movzbl 0x5(%rax), %esi
callq 0x24f50
cmpl $0x3, -0x14(%rbp)
jbe 0x272f9
movq -0x10(%rbp), %rax
leaq 0x18c06(%rip), %rdi     # 0x3feed
leaq 0x246f2(%rip), %rdx     # 0x4b9e0
xorl %ecx, %ecx
movzbl 0x6(%rax), %esi
callq 0x24f50
cmpl $0x4, -0x14(%rbp)
jbe 0x2732f
movq -0x10(%rbp), %rax
cmpb $0x0, 0x7(%rax)
je 0x2732f
movq -0x10(%rbp), %rax
movzbl 0x7(%rax), %eax
cvtsi2sd %eax, %xmm1
movsd 0x1685b(%rip), %xmm0    # 0x3db78
mulsd %xmm1, %xmm0
leaq 0x18bf0(%rip), %rdi     # 0x3ff18
movb $0x1, %al
callq 0x4050
cmpl $0x5, -0x14(%rbp)
jbe 0x27355
movq -0x10(%rbp), %rax
leaq 0x18c25(%rip), %rdi     # 0x3ff65
leaq 0x246d9(%rip), %rdx     # 0x4ba20
movl $0x1, %ecx
movzbl 0x8(%rax), %esi
callq 0x24f50
cmpl $0x6, -0x14(%rbp)
jbe 0x27378
movq -0x10(%rbp), %rax
leaq 0x18c31(%rip), %rdi     # 0x3ff97
leaq 0x246f3(%rip), %rdx     # 0x4ba60
xorl %ecx, %ecx
movzbl 0x9(%rax), %esi
callq 0x24f50
cmpl $0x7, -0x14(%rbp)
jbe 0x2739b
movq -0x10(%rbp), %rax
leaq 0x18c48(%rip), %rdi     # 0x3ffd1
leaq 0x31330(%rip), %rdx     # 0x586c0
xorl %ecx, %ecx
movzbl 0xa(%rax), %esi
callq 0x24f50
movl $0x0, -0x18(%rbp)
cmpl $0x8, -0x14(%rbp)
jbe 0x2751e
movq -0x10(%rbp), %rax
cmpb $0x0, 0xb(%rax)
je 0x2751e
leaq 0x18c4a(%rip), %rdi     # 0x4000b
movb $0x0, %al
callq 0x4050
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
movq -0x10(%rbp), %rcx
movzbl 0xb(%rcx), %ecx
cmpl %ecx, %eax
jae 0x27510
cmpl $0x6, -0x18(%rbp)
jbe 0x27403
movq -0x10(%rbp), %rax
movzbl 0xb(%rax), %esi
leaq 0x18c50(%rip), %rdi     # 0x40047
movb $0x0, %al
callq 0x4050
jmp 0x27510
movl -0x18(%rbp), %eax
addl $0xa, %eax
cmpl -0x14(%rbp), %eax
jbe 0x2742f
movq -0x10(%rbp), %rax
movzbl 0xb(%rax), %esi
movl -0x14(%rbp), %edx
subl $0x9, %edx
leaq 0x18c82(%rip), %rdi     # 0x400a5
movb $0x0, %al
callq 0x4050
jmp 0x27510
jmp 0x27431
leaq 0x18cd0(%rip), %rax     # 0x40108
movq %rax, -0x20(%rbp)
leaq 0x18cc5(%rip), %rax     # 0x40108
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movl -0x18(%rbp), %ecx
addl $0xc, %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
sarl $0x4, %eax
andl $0xf, %eax
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movl -0x18(%rbp), %ecx
addl $0xc, %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
andl $0xf, %eax
movl %eax, -0x30(%rbp)
movl -0x2c(%rbp), %eax
cmpq $0x8, %rax
jae 0x27493
movl -0x2c(%rbp), %eax
movl %eax, %ecx
leaq 0x24615(%rip), %rax     # 0x4baa0
movq (%rax,%rcx,8), %rax
movq %rax, -0x20(%rbp)
movl -0x30(%rbp), %eax
cmpq $0xb, %rax
jae 0x274b0
movl -0x30(%rbp), %eax
movl %eax, %ecx
leaq 0x24638(%rip), %rax     # 0x4bae0
movq (%rax,%rcx,8), %rax
movq %rax, -0x28(%rbp)
cmpl $0x0, -0x18(%rbp)
jbe 0x274c4
leaq 0x883c(%rip), %rdi      # 0x2fcf9
movb $0x0, %al
callq 0x4050
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x4440
cmpl $0x0, %eax
jne 0x274ea
movq -0x20(%rbp), %rsi
leaq 0x8adb(%rip), %rdi      # 0x2ffbc
movb $0x0, %al
callq 0x4050
jmp 0x27500
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
leaq 0x18c1c(%rip), %rdi     # 0x40115
movb $0x0, %al
callq 0x4050
jmp 0x27502
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x273cf
leaq 0x83f2(%rip), %rdi      # 0x2f909
movb $0x0, %al
callq 0x4050
movq -0x10(%rbp), %rdi
movl -0x18(%rbp), %esi
addl $0x9, %esi
movl -0x18(%rbp), %edx
addl $0x9, %edx
movl -0x18(%rbp), %ecx
addl $0x9, %ecx
callq 0x21f90
addq $0x40, %rsp
popq %rbp
retq
nop