// File: /workspace/github_cpp_makefile_star2_O1/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 0x19c67(%rip), %rdi     # 0x2c70f
xorl %eax, %eax
callq 0x3030
testl %r15d, %r15d
je 0x12ade
leal (%r15,%r15,4), %esi
leaq 0x19ebc(%rip), %rdi     # 0x2c97b
xorl %eax, %eax
callq 0x3030
leal -0x79(%r15), %eax
cmpb $-0x35, %al
ja 0x12ade
leaq 0x19ecf(%rip), %rsi     # 0x2c9a4
xorl %edi, %edi
xorl %eax, %eax
callq 0x37ec
cmpb $0x0, 0x2(%rbx)
jns 0x12af0
leaq 0x1b589(%rip), %rdi     # 0x2e074
callq 0x3380
testb $0x40, 0x2(%rbx)
je 0x12b02
leaq 0x1b588(%rip), %rdi     # 0x2e085
callq 0x3380
testb $0x10, 0x2(%rbx)
je 0x12b14
leaq 0x1b594(%rip), %rdi     # 0x2e0a3
callq 0x3380
testb $0x8, 0x2(%rbx)
je 0x12b26
leaq 0x1b5bb(%rip), %rdi     # 0x2e0dc
callq 0x3380
testb $0x4, 0x2(%rbx)
je 0x12b38
leaq 0x1b5d1(%rip), %rdi     # 0x2e104
callq 0x3380
testb $0x2, 0x2(%rbx)
je 0x12b4a
leaq 0x1b5ea(%rip), %rdi     # 0x2e12f
callq 0x3380
testb $0x1, 0x2(%rbx)
je 0x12b5c
leaq 0x1b5fc(%rip), %rdi     # 0x2e153
callq 0x3380
movzbl 0x3(%rbx), %r12d
cmpq $0x10, %r12
jb 0x12c00
movl %r12d, %r13d
shrl $0x4, %r13d
leaq 0x19e56(%rip), %rdi     # 0x2c9cf
xorl %eax, %eax
callq 0x3030
cmpb $0x6f, %r12b
ja 0x12b98
leaq 0x27193(%rip), %rax     # 0x39d20
movq (%rax,%r13,8), %rdi
callq 0x3380
jmp 0x12bc0
movzbl %r13b, %r14d
leaq 0x12319(%rip), %rdi     # 0x24ebc
movl %r14d, %esi
xorl %eax, %eax
callq 0x3030
leaq 0x19e35(%rip), %rsi     # 0x2c9e9
xorl %edi, %edi
movl %r14d, %edx
xorl %eax, %eax
callq 0x37ec
cmpb $0x1, %r13b
sete %al
cmpb $0x3c, %r15b
setb %cl
testb %cl, %al
je 0x12bdb
leaq 0x19e37(%rip), %rsi     # 0x2ca10
jmp 0x12bf7
cmpb $0x20, %r12b
setae %al
cmpb $0x78, %r15b
setb %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x12c00
leaq 0x19e4d(%rip), %rsi     # 0x2ca44
xorl %edi, %edi
xorl %eax, %eax
callq 0x37ec
testb $0x8, 0x3(%rbx)
je 0x12c12
leaq 0x1b56e(%rip), %rdi     # 0x2e17b
callq 0x3380
testb $0x4, 0x3(%rbx)
je 0x12c24
leaq 0x1b571(%rip), %rdi     # 0x2e190
callq 0x3380
testb $0x2, 0x3(%rbx)
je 0x12c36
leaq 0x1b59e(%rip), %rdi     # 0x2e1cf
callq 0x3380
testb $0x1, 0x3(%rbx)
je 0x12c48
leaq 0x1b5cb(%rip), %rdi     # 0x2e20e
callq 0x3380
cmpl $0x5, %ebp
jb 0x12e50
testb $0x20, 0x4(%rbx)
je 0x12c63
leaq 0x1b5ef(%rip), %rdi     # 0x2e24d
callq 0x3380
testb $0x10, 0x4(%rbx)
je 0x12c75
leaq 0x1b5f1(%rip), %rdi     # 0x2e261
callq 0x3380
testb $0x8, 0x4(%rbx)
je 0x12c87
leaq 0x1b611(%rip), %rdi     # 0x2e293
callq 0x3380
testb $0x4, 0x4(%rbx)
je 0x12c99
leaq 0x1b621(%rip), %rdi     # 0x2e2b5
callq 0x3380
testb $0x2, 0x4(%rbx)
je 0x12cab
leaq 0x1b629(%rip), %rdi     # 0x2e2cf
callq 0x3380
testb $0x1, 0x4(%rbx)
je 0x12cbd
leaq 0x1b63a(%rip), %rdi     # 0x2e2f2
callq 0x3380
cmpl $0x5, %ebp
je 0x12e50
movzbl 0x5(%rbx), %esi
andl $0x3f, %esi
leaq 0x19da7(%rip), %rdi     # 0x2ca7b
xorl %eax, %eax
callq 0x3030
movzbl 0x5(%rbx), %eax
andl $-0x40, %eax
movzbl 0x6(%rbx), %ecx
leal (%rcx,%rax,4), %esi
leaq 0x19d9e(%rip), %rdi     # 0x2ca8e
xorl %eax, %eax
callq 0x3030
cmpl $0x8, %ebp
jb 0x12e50
cmpb $0x0, 0x7(%rbx)
jns 0x12d12
leaq 0x1b623(%rip), %rdi     # 0x2e330
callq 0x3380
testb $0x40, 0x7(%rbx)
je 0x12d24
leaq 0x1b638(%rip), %rdi     # 0x2e357
callq 0x3380
testb $0x8, 0x7(%rbx)
je 0x12d36
leaq 0x1b667(%rip), %rdi     # 0x2e398
callq 0x3380
testb $0x4, 0x7(%rbx)
je 0x12d48
leaq 0x1b699(%rip), %rdi     # 0x2e3dc
callq 0x3380
testb $0x2, 0x7(%rbx)
je 0x12d5a
leaq 0x1b6b6(%rip), %rdi     # 0x2e40b
callq 0x3380
testb $0x1, 0x7(%rbx)
je 0x12d6c
leaq 0x1b6d3(%rip), %rdi     # 0x2e43a
callq 0x3380
movzbl 0x8(%rbx), %r14d
andl $0xf, %r14d
je 0x12dc4
leaq 0x19d23(%rip), %rdi     # 0x2caa1
xorl %eax, %eax
callq 0x3030
cmpb $0x7, %r14b
ja 0x12da0
leaq 0x1706a(%rip), %rax     # 0x29dfc
movslq (%rax,%r14,4), %rdi
addq %rax, %rdi
callq 0x3380
jmp 0x12dc4
leaq 0x12115(%rip), %rdi     # 0x24ebc
movl %r14d, %esi
xorl %eax, %eax
callq 0x3030
leaq 0x19cfe(%rip), %rsi     # 0x2cab6
xorl %edi, %edi
movl %r14d, %edx
xorl %eax, %eax
callq 0x37ec
movzbl 0x8(%rbx), %r15d
cmpq $0x10, %r15
jb 0x12e22
movl %r15d, %r14d
shrl $0x4, %r14d
leaq 0x19cfb(%rip), %rdi     # 0x2cad8
xorl %eax, %eax
callq 0x3030
cmpb $0x6f, %r15b
ja 0x12dfc
leaq 0x26f2f(%rip), %rax     # 0x39d20
movq (%rax,%r14,8), %rdi
callq 0x3380
jmp 0x12e22
movzbl %r14b, %ebp
leaq 0x120b5(%rip), %rdi     # 0x24ebc
movl %ebp, %esi
xorl %eax, %eax
callq 0x3030
leaq 0x19cdf(%rip), %rsi     # 0x2caf6
xorl %edi, %edi
movl %ebp, %edx
xorl %eax, %eax
callq 0x37ec
movzbl 0x9(%rbx), %esi
andl $0x3f, %esi
je 0x12e50
shll $0xa, %esi
addl $0x400, %esi            # imm = 0x400
leaq 0x19ce6(%rip), %rdi     # 0x2cb21
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