// File: /workspace/github_cpp_makefile_star2_O1/rpavlik[P]edid-decode/parse-cta-block.cpp
// Function: edid_state::cta_sldb(unsigned char const*, unsigned int)
void edid_state::cta_sldb(const unsigned char *x, unsigned length)
{
	if (length < 2) {
		fail("Empty Data Block with length %u.\n", length);
		return;
	}

	unsigned active_cnt = 0;
	unsigned channel_is_active = 0;

	while (length >= 2) {
		printf("    Channel: %u (%sactive)\n", x[0] & 0x1f,
		       (x[0] & 0x20) ? "" : "not ");
		if (x[0] & 0x20) {
			if (channel_is_active & (1U << (x[0] & 0x1f)))
				fail("Channel Index %u was already marked 'Active'.\n",
				     x[0] & 0x1f);
			channel_is_active |= 1U << (x[0] & 0x1f);
			active_cnt++;
		}
		if ((x[1] & 0x1f) < ARRAY_SIZE(speaker_location))
			printf("      Speaker: %s\n", speaker_location[x[1] & 0x1f]);
		if (length >= 5 && (x[0] & 0x40)) {
			printf("      X: %.3f * Xmax\n", decode_uchar_as_double(x[2]));
			printf("      Y: %.3f * Ymax\n", decode_uchar_as_double(x[3]));
			printf("      Z: %.3f * Zmax\n", decode_uchar_as_double(x[4]));
			length -= 3;
			x += 3;
		}

		length -= 2;
		x += 2;
	}
	if (active_cnt != cta.preparsed_speaker_count)
		fail("There are %u active speakers, but 'Speaker Count' is %u.\n",
		     active_cnt, cta.preparsed_speaker_count);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %ebx
cmpl $0x2, %edx
jae 0x1026f
leaq 0x19ed1(%rip), %rsi     # 0x2a127
xorl %edi, %edi
movl %ebx, %edx
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x37ec
movq %rsi, %r12
movq %rdi, 0x10(%rsp)
leaq 0x21ad6(%rip), %r15     # 0x31d54
leaq 0x109f4(%rip), %r14     # 0x20c79
leaq 0x1a5d0(%rip), %r13     # 0x2a85c
movl $0x0, 0xc(%rsp)
xorl %ebp, %ebp
movzbl (%r12), %eax
movl %eax, %esi
andl $0x1f, %esi
testb $0x20, %al
movq %r14, %rdx
cmoveq %r15, %rdx
movq %r13, %rdi
xorl %eax, %eax
callq 0x3030
movzbl (%r12), %edx
testb $0x20, %dl
je 0x102ea
andl $0x1f, %edx
movl 0xc(%rsp), %eax
btl %edx, %eax
jae 0x102d9
xorl %edi, %edi
leaq 0x1a5a6(%rip), %rsi     # 0x2a878
xorl %eax, %eax
callq 0x37ec
movb (%r12), %al
movl 0xc(%rsp), %ecx
btsl %eax, %ecx
movl %ecx, 0xc(%rsp)
incl %ebp
movzbl 0x1(%r12), %eax
andl $0x1f, %eax
cmpb $0x1b, %al
ja 0x10313
leaq 0x19a5e(%rip), %rcx     # 0x29d5c
movslq (%rcx,%rax,4), %rsi
addq %rcx, %rsi
leaq 0x1a59b(%rip), %rdi     # 0x2a8a7
xorl %eax, %eax
callq 0x3030
cmpl $0x5, %ebx
jb 0x103b8
testb $0x40, (%r12)
je 0x103b8
movsbl 0x2(%r12), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd 0x19bdc(%rip), %xmm1    # 0x29f18
mulsd %xmm1, %xmm0
leaq 0x1a573(%rip), %rdi     # 0x2a8ba
movb $0x1, %al
callq 0x3030
movl %ebp, %r13d
movq %r14, %rbp
movq %r15, %r14
leaq 0x3(%r12), %r15
movsbl 0x3(%r12), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x19ba7(%rip), %xmm0    # 0x29f18
leaq 0x1a558(%rip), %rdi     # 0x2a8d0
movb $0x1, %al
callq 0x3030
movsbl 0x4(%r12), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x19b84(%rip), %xmm0    # 0x29f18
leaq 0x1a54b(%rip), %rdi     # 0x2a8e6
movb $0x1, %al
callq 0x3030
addl $-0x3, %ebx
movq %r15, %r12
movq %r14, %r15
movq %rbp, %r14
movl %r13d, %ebp
leaq 0x1a4a4(%rip), %r13     # 0x2a85c
addl $-0x2, %ebx
addq $0x2, %r12
cmpl $0x1, %ebx
ja 0x10296
movq 0x10(%rsp), %rax
movl 0x2c8(%rax), %ecx
cmpl %ecx, %ebp
jne 0x103e6
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1a50f(%rip), %rsi     # 0x2a8fc
xorl %edi, %edi
movl %ebp, %edx
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x37ec