// File: /workspace/github_cpp_makefile_star2_O2/rpavlik[P]edid-decode/parse-cta-block.cpp
// Function: cta_hf_scdb(unsigned char const*, unsigned int)
static void cta_hf_scdb(const unsigned char *x, unsigned length)
{
	unsigned rate = x[1] * 5;

	printf("    Version: %u\n", x[0]);
	if (rate) {
		printf("    Maximum TMDS Character Rate: %u MHz\n", rate);
		if (rate <= 340 || rate > 600)
			fail("Max TMDS rate is > 0 and <= 340 or > 600.\n");
	}
	if (x[2] & 0x80)
		printf("    SCDC Present\n");
	if (x[2] & 0x40)
		printf("    SCDC Read Request Capable\n");
	if (x[2] & 0x10)
		printf("    Supports Color Content Bits Per Component Indication\n");
	if (x[2] & 0x08)
		printf("    Supports scrambling for <= 340 Mcsc\n");
	if (x[2] & 0x04)
		printf("    Supports 3D Independent View signaling\n");
	if (x[2] & 0x02)
		printf("    Supports 3D Dual View signaling\n");
	if (x[2] & 0x01)
		printf("    Supports 3D OSD Disparity signaling\n");
	if (x[3] & 0xf0) {
		unsigned max_frl_rate = x[3] >> 4;

		printf("    Max Fixed Rate Link: ");
		if (max_frl_rate < ARRAY_SIZE(max_frl_rates)) {
			printf("%s\n", max_frl_rates[max_frl_rate]);
		} else {
			printf("Unknown (0x%02x)\n", max_frl_rate);
			fail("Unknown Max Fixed Rate Link (0x%02x).\n", max_frl_rate);
		}
		if (max_frl_rate == 1 && rate < 300)
			fail("Max Fixed Rate Link is 1, but Max TMDS rate < 300.\n");
		else if (max_frl_rate >= 2 && rate < 600)
			fail("Max Fixed Rate Link is >= 2, but Max TMDS rate < 600.\n");
	}
	if (x[3] & 0x08)
		printf("    Supports UHD VIC\n");
	if (x[3] & 0x04)
		printf("    Supports 16-bits/component Deep Color 4:2:0 Pixel Encoding\n");
	if (x[3] & 0x02)
		printf("    Supports 12-bits/component Deep Color 4:2:0 Pixel Encoding\n");
	if (x[3] & 0x01)
		printf("    Supports 10-bits/component Deep Color 4:2:0 Pixel Encoding\n");

	if (length <= 4)
		return;

	if (x[4] & 0x20)
		printf("    Supports Mdelta\n");
	if (x[4] & 0x10)
		printf("    Supports media rates below VRRmin (CinemaVRR)\n");
	if (x[4] & 0x08)
		printf("    Supports negative Mvrr values\n");
	if (x[4] & 0x04)
		printf("    Supports Fast Vactive\n");
	if (x[4] & 0x02)
		printf("    Supports Auto Low-Latency Mode\n");
	if (x[4] & 0x01)
		printf("    Supports a FAPA in blanking after first active video line\n");

	if (length <= 5)
		return;

	printf("    VRRmin: %d Hz\n", x[5] & 0x3f);
	printf("    VRRmax: %d Hz\n", (x[5] & 0xc0) << 2 | x[6]);

	if (length <= 7)
		return;

	if (x[7] & 0x80)
		printf("    Supports VESA DSC 1.2a compression\n");
	if (x[7] & 0x40)
		printf("    Supports Compressed Video Transport for 4:2:0 Pixel Encoding\n");
	if (x[7] & 0x08)
		printf("    Supports Compressed Video Transport at any valid 1/16th bit bpp\n");
	if (x[7] & 0x04)
		printf("    Supports 16 bpc Compressed Video Transport\n");
	if (x[7] & 0x02)
		printf("    Supports 12 bpc Compressed Video Transport\n");
	if (x[7] & 0x01)
		printf("    Supports 10 bpc Compressed Video Transport\n");
	if (x[8] & 0xf) {
		unsigned max_slices = x[8] & 0xf;

		printf("    DSC Max Slices: ");
		if (max_slices < ARRAY_SIZE(dsc_max_slices)) {
			printf("%s\n", dsc_max_slices[max_slices]);
		} else {
			printf("Unknown (0x%02x)\n", max_slices);
			fail("Unknown DSC Max Slices (0x%02x).\n", max_slices);
		}
	}
	if (x[8] & 0xf0) {
		unsigned max_frl_rate = x[8] >> 4;

		printf("    DSC Max Fixed Rate Link: ");
		if (max_frl_rate < ARRAY_SIZE(max_frl_rates)) {
			printf("%s\n", max_frl_rates[max_frl_rate]);
		} else {
			printf("Unknown (0x%02x)\n", max_frl_rate);
			fail("Unknown DSC Max Fixed Rate Link (0x%02x).\n", max_frl_rate);
		}
	}
	if (x[9] & 0x3f)
		printf("    Maximum number of bytes in a line of chunks: %u\n",
		       1024 * (1 + (x[9] & 0x3f)));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %ebp
movq %rdi, %rbx
movzbl 0x1(%rdi), %r15d
movzbl (%rdi), %esi
leaq 0x16b13(%rip), %rdi     # 0x26737
xorl %eax, %eax
callq 0x3030
testl %r15d, %r15d
je 0xfc5a
leal (%r15,%r15,4), %esi
leaq 0x16d68(%rip), %rdi     # 0x269a3
xorl %eax, %eax
callq 0x3030
leal -0x79(%r15), %eax
cmpb $-0x35, %al
ja 0xfc5a
leaq 0x16d7b(%rip), %rsi     # 0x269cc
xorl %edi, %edi
xorl %eax, %eax
callq 0x362c
movb 0x2(%rbx), %al
testb %al, %al
jns 0xfc70
leaq 0x18439(%rip), %rdi     # 0x280a1
callq 0x33b0
movb 0x2(%rbx), %al
testb $0x40, %al
je 0xfc83
leaq 0x18437(%rip), %rdi     # 0x280b2
callq 0x33b0
movb 0x2(%rbx), %al
testb $0x10, %al
je 0xfc96
leaq 0x18442(%rip), %rdi     # 0x280d0
callq 0x33b0
movb 0x2(%rbx), %al
testb $0x8, %al
je 0xfca9
leaq 0x18468(%rip), %rdi     # 0x28109
callq 0x33b0
movb 0x2(%rbx), %al
testb $0x4, %al
je 0xfcbc
leaq 0x1847d(%rip), %rdi     # 0x28131
callq 0x33b0
movb 0x2(%rbx), %al
testb $0x2, %al
je 0xfccf
leaq 0x18495(%rip), %rdi     # 0x2815c
callq 0x33b0
movb 0x2(%rbx), %al
testb $0x1, %al
je 0xfcdf
leaq 0x184a6(%rip), %rdi     # 0x28180
callq 0x33b0
movzbl 0x3(%rbx), %r12d
cmpq $0x10, %r12
jb 0xfd83
movl %r12d, %r13d
shrl $0x4, %r13d
leaq 0x16cfb(%rip), %rdi     # 0x269f7
xorl %eax, %eax
callq 0x3030
cmpb $0x6f, %r12b
ja 0xfd1b
leaq 0x24010(%rip), %rax     # 0x33d20
movq (%rax,%r13,8), %rdi
callq 0x33b0
jmp 0xfd43
movzbl %r13b, %r14d
leaq 0xf1e6(%rip), %rdi      # 0x1ef0c
movl %r14d, %esi
xorl %eax, %eax
callq 0x3030
leaq 0x16cda(%rip), %rsi     # 0x26a11
xorl %edi, %edi
movl %r14d, %edx
xorl %eax, %eax
callq 0x362c
cmpb $0x1, %r13b
sete %al
cmpb $0x3c, %r15b
setb %cl
testb %cl, %al
je 0xfd5e
leaq 0x16cdc(%rip), %rsi     # 0x26a38
jmp 0xfd7a
cmpb $0x20, %r12b
setae %al
cmpb $0x78, %r15b
setb %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0xfd83
leaq 0x16cf2(%rip), %rsi     # 0x26a6c
xorl %edi, %edi
xorl %eax, %eax
callq 0x362c
movb 0x3(%rbx), %al
testb $0x8, %al
je 0xfd99
leaq 0x18417(%rip), %rdi     # 0x281a8
callq 0x33b0
movb 0x3(%rbx), %al
testb $0x4, %al
je 0xfdac
leaq 0x18419(%rip), %rdi     # 0x281bd
callq 0x33b0
movb 0x3(%rbx), %al
testb $0x2, %al
je 0xfdbf
leaq 0x18445(%rip), %rdi     # 0x281fc
callq 0x33b0
movb 0x3(%rbx), %al
testb $0x1, %al
je 0xfdcf
leaq 0x18471(%rip), %rdi     # 0x2823b
callq 0x33b0
cmpl $0x5, %ebp
jb 0xffe9
movb 0x4(%rbx), %al
testb $0x20, %al
je 0xfdee
leaq 0x18494(%rip), %rdi     # 0x2827a
callq 0x33b0
movb 0x4(%rbx), %al
testb $0x10, %al
je 0xfe01
leaq 0x18495(%rip), %rdi     # 0x2828e
callq 0x33b0
movb 0x4(%rbx), %al
testb $0x8, %al
je 0xfe14
leaq 0x184b4(%rip), %rdi     # 0x282c0
callq 0x33b0
movb 0x4(%rbx), %al
testb $0x4, %al
je 0xfe27
leaq 0x184c3(%rip), %rdi     # 0x282e2
callq 0x33b0
movb 0x4(%rbx), %al
testb $0x2, %al
je 0xfe3a
leaq 0x184ca(%rip), %rdi     # 0x282fc
callq 0x33b0
movb 0x4(%rbx), %al
testb $0x1, %al
je 0xfe4a
leaq 0x184da(%rip), %rdi     # 0x2831f
callq 0x33b0
cmpl $0x5, %ebp
je 0xffe9
movzbl 0x5(%rbx), %esi
andl $0x3f, %esi
leaq 0x16c42(%rip), %rdi     # 0x26aa3
xorl %eax, %eax
callq 0x3030
movzbl 0x5(%rbx), %eax
andl $-0x40, %eax
movzbl 0x6(%rbx), %ecx
leal (%rcx,%rax,4), %esi
leaq 0x16c39(%rip), %rdi     # 0x26ab6
xorl %eax, %eax
callq 0x3030
cmpl $0x8, %ebp
jb 0xffe9
movb 0x7(%rbx), %al
testb %al, %al
jns 0xfea3
leaq 0x184c2(%rip), %rdi     # 0x2835d
callq 0x33b0
movb 0x7(%rbx), %al
testb $0x40, %al
je 0xfeb6
leaq 0x184d6(%rip), %rdi     # 0x28384
callq 0x33b0
movb 0x7(%rbx), %al
testb $0x8, %al
je 0xfec9
leaq 0x18504(%rip), %rdi     # 0x283c5
callq 0x33b0
movb 0x7(%rbx), %al
testb $0x4, %al
je 0xfedc
leaq 0x18535(%rip), %rdi     # 0x28409
callq 0x33b0
movb 0x7(%rbx), %al
testb $0x2, %al
je 0xfeef
leaq 0x18551(%rip), %rdi     # 0x28438
callq 0x33b0
movb 0x7(%rbx), %al
testb $0x1, %al
je 0xfeff
leaq 0x1856d(%rip), %rdi     # 0x28467
callq 0x33b0
movzbl 0x8(%rbx), %r15d
movl %r15d, %r14d
andl $0xf, %r14d
je 0xff5e
leaq 0x16bb5(%rip), %rdi     # 0x26ac9
xorl %eax, %eax
callq 0x3030
cmpb $0x7, %r14b
ja 0xff36
leaq 0x13ef4(%rip), %rax     # 0x23e1c
movslq (%rax,%r14,4), %rdi
addq %rax, %rdi
callq 0x33b0
jmp 0xff5a
leaq 0xefcf(%rip), %rdi      # 0x1ef0c
movl %r14d, %esi
xorl %eax, %eax
callq 0x3030
leaq 0x16b90(%rip), %rsi     # 0x26ade
xorl %edi, %edi
movl %r14d, %edx
xorl %eax, %eax
callq 0x362c
movb 0x8(%rbx), %r15b
cmpb $0x10, %r15b
jb 0xffbb
movl %r15d, %ebp
shrb $0x4, %bpl
leaq 0x16b8e(%rip), %rdi     # 0x26b00
xorl %eax, %eax
callq 0x3030
cmpb $0x6f, %r15b
ja 0xff95
movzbl %bpl, %eax
leaq 0x23d96(%rip), %rcx     # 0x33d20
movq (%rcx,%rax,8), %rdi
callq 0x33b0
jmp 0xffbb
movzbl %bpl, %ebp
leaq 0xef6c(%rip), %rdi      # 0x1ef0c
movl %ebp, %esi
xorl %eax, %eax
callq 0x3030
leaq 0x16b6e(%rip), %rsi     # 0x26b1e
xorl %edi, %edi
movl %ebp, %edx
xorl %eax, %eax
callq 0x362c
movzbl 0x9(%rbx), %esi
andl $0x3f, %esi
je 0xffe9
shll $0xa, %esi
addl $0x400, %esi            # imm = 0x400
leaq 0x16b75(%rip), %rdi     # 0x26b49
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3030
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq