// File: /workspace/github_cpp_makefile_star2_O3/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 0x19e32(%rip), %rdi     # 0x2c737
xorl %eax, %eax
callq 0x3030
testl %r15d, %r15d
je 0x1293b
leal (%r15,%r15,4), %esi
leaq 0x1a087(%rip), %rdi     # 0x2c9a3
xorl %eax, %eax
callq 0x3030
leal -0x79(%r15), %eax
cmpb $-0x35, %al
ja 0x1293b
leaq 0x1a09a(%rip), %rsi     # 0x2c9cc
xorl %edi, %edi
xorl %eax, %eax
callq 0x37cc
movb 0x2(%rbx), %al
testb %al, %al
jns 0x12951
leaq 0x1b753(%rip), %rdi     # 0x2e09c
callq 0x3380
movb 0x2(%rbx), %al
testb $0x40, %al
je 0x12964
leaq 0x1b751(%rip), %rdi     # 0x2e0ad
callq 0x3380
movb 0x2(%rbx), %al
testb $0x10, %al
je 0x12977
leaq 0x1b75c(%rip), %rdi     # 0x2e0cb
callq 0x3380
movb 0x2(%rbx), %al
testb $0x8, %al
je 0x1298a
leaq 0x1b782(%rip), %rdi     # 0x2e104
callq 0x3380
movb 0x2(%rbx), %al
testb $0x4, %al
je 0x1299d
leaq 0x1b797(%rip), %rdi     # 0x2e12c
callq 0x3380
movb 0x2(%rbx), %al
testb $0x2, %al
je 0x129b0
leaq 0x1b7af(%rip), %rdi     # 0x2e157
callq 0x3380
movb 0x2(%rbx), %al
testb $0x1, %al
je 0x129c0
leaq 0x1b7c0(%rip), %rdi     # 0x2e17b
callq 0x3380
movzbl 0x3(%rbx), %r12d
cmpq $0x10, %r12
jb 0x12a64
movl %r12d, %r13d
shrl $0x4, %r13d
leaq 0x1a01a(%rip), %rdi     # 0x2c9f7
xorl %eax, %eax
callq 0x3030
cmpb $0x6f, %r12b
ja 0x129fc
leaq 0x2732f(%rip), %rax     # 0x39d20
movq (%rax,%r13,8), %rdi
callq 0x3380
jmp 0x12a24
movzbl %r13b, %r14d
leaq 0x12505(%rip), %rdi     # 0x24f0c
movl %r14d, %esi
xorl %eax, %eax
callq 0x3030
leaq 0x19ff9(%rip), %rsi     # 0x2ca11
xorl %edi, %edi
movl %r14d, %edx
xorl %eax, %eax
callq 0x37cc
cmpb $0x1, %r13b
sete %al
cmpb $0x3c, %r15b
setb %cl
testb %cl, %al
je 0x12a3f
leaq 0x19ffb(%rip), %rsi     # 0x2ca38
jmp 0x12a5b
cmpb $0x20, %r12b
setae %al
cmpb $0x78, %r15b
setb %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x12a64
leaq 0x1a011(%rip), %rsi     # 0x2ca6c
xorl %edi, %edi
xorl %eax, %eax
callq 0x37cc
movb 0x3(%rbx), %al
testb $0x8, %al
je 0x12a7a
leaq 0x1b731(%rip), %rdi     # 0x2e1a3
callq 0x3380
movb 0x3(%rbx), %al
testb $0x4, %al
je 0x12a8d
leaq 0x1b733(%rip), %rdi     # 0x2e1b8
callq 0x3380
movb 0x3(%rbx), %al
testb $0x2, %al
je 0x12aa0
leaq 0x1b75f(%rip), %rdi     # 0x2e1f7
callq 0x3380
movb 0x3(%rbx), %al
testb $0x1, %al
je 0x12ab0
leaq 0x1b78b(%rip), %rdi     # 0x2e236
callq 0x3380
cmpl $0x5, %ebp
jb 0x12cca
movb 0x4(%rbx), %al
testb $0x20, %al
je 0x12acf
leaq 0x1b7ae(%rip), %rdi     # 0x2e275
callq 0x3380
movb 0x4(%rbx), %al
testb $0x10, %al
je 0x12ae2
leaq 0x1b7af(%rip), %rdi     # 0x2e289
callq 0x3380
movb 0x4(%rbx), %al
testb $0x8, %al
je 0x12af5
leaq 0x1b7ce(%rip), %rdi     # 0x2e2bb
callq 0x3380
movb 0x4(%rbx), %al
testb $0x4, %al
je 0x12b08
leaq 0x1b7dd(%rip), %rdi     # 0x2e2dd
callq 0x3380
movb 0x4(%rbx), %al
testb $0x2, %al
je 0x12b1b
leaq 0x1b7e4(%rip), %rdi     # 0x2e2f7
callq 0x3380
movb 0x4(%rbx), %al
testb $0x1, %al
je 0x12b2b
leaq 0x1b7f4(%rip), %rdi     # 0x2e31a
callq 0x3380
cmpl $0x5, %ebp
je 0x12cca
movzbl 0x5(%rbx), %esi
andl $0x3f, %esi
leaq 0x19f61(%rip), %rdi     # 0x2caa3
xorl %eax, %eax
callq 0x3030
movzbl 0x5(%rbx), %eax
andl $-0x40, %eax
movzbl 0x6(%rbx), %ecx
leal (%rcx,%rax,4), %esi
leaq 0x19f58(%rip), %rdi     # 0x2cab6
xorl %eax, %eax
callq 0x3030
cmpl $0x8, %ebp
jb 0x12cca
movb 0x7(%rbx), %al
testb %al, %al
jns 0x12b84
leaq 0x1b7dc(%rip), %rdi     # 0x2e358
callq 0x3380
movb 0x7(%rbx), %al
testb $0x40, %al
je 0x12b97
leaq 0x1b7f0(%rip), %rdi     # 0x2e37f
callq 0x3380
movb 0x7(%rbx), %al
testb $0x8, %al
je 0x12baa
leaq 0x1b81e(%rip), %rdi     # 0x2e3c0
callq 0x3380
movb 0x7(%rbx), %al
testb $0x4, %al
je 0x12bbd
leaq 0x1b84f(%rip), %rdi     # 0x2e404
callq 0x3380
movb 0x7(%rbx), %al
testb $0x2, %al
je 0x12bd0
leaq 0x1b86b(%rip), %rdi     # 0x2e433
callq 0x3380
movb 0x7(%rbx), %al
testb $0x1, %al
je 0x12be0
leaq 0x1b887(%rip), %rdi     # 0x2e462
callq 0x3380
movzbl 0x8(%rbx), %r15d
movl %r15d, %r14d
andl $0xf, %r14d
je 0x12c3f
leaq 0x19ed4(%rip), %rdi     # 0x2cac9
xorl %eax, %eax
callq 0x3030
cmpb $0x7, %r14b
ja 0x12c17
leaq 0x17213(%rip), %rax     # 0x29e1c
movslq (%rax,%r14,4), %rdi
addq %rax, %rdi
callq 0x3380
jmp 0x12c3b
leaq 0x122ee(%rip), %rdi     # 0x24f0c
movl %r14d, %esi
xorl %eax, %eax
callq 0x3030
leaq 0x19eaf(%rip), %rsi     # 0x2cade
xorl %edi, %edi
movl %r14d, %edx
xorl %eax, %eax
callq 0x37cc
movb 0x8(%rbx), %r15b
cmpb $0x10, %r15b
jb 0x12c9c
movl %r15d, %ebp
shrb $0x4, %bpl
leaq 0x19ead(%rip), %rdi     # 0x2cb00
xorl %eax, %eax
callq 0x3030
cmpb $0x6f, %r15b
ja 0x12c76
movzbl %bpl, %eax
leaq 0x270b5(%rip), %rcx     # 0x39d20
movq (%rcx,%rax,8), %rdi
callq 0x3380
jmp 0x12c9c
movzbl %bpl, %ebp
leaq 0x1228b(%rip), %rdi     # 0x24f0c
movl %ebp, %esi
xorl %eax, %eax
callq 0x3030
leaq 0x19e8d(%rip), %rsi     # 0x2cb1e
xorl %edi, %edi
movl %ebp, %edx
xorl %eax, %eax
callq 0x37cc
movzbl 0x9(%rbx), %esi
andl $0x3f, %esi
je 0x12cca
shll $0xa, %esi
addl $0x400, %esi            # imm = 0x400
leaq 0x19e94(%rip), %rdi     # 0x2cb49
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
nop