// File: /workspace/github_cpp_makefile_star2_O3/rpavlik[P]edid-decode/parse-cta-block.cpp
// Function: edid_state::check_cta_blocks()
void edid_state::check_cta_blocks()
{
	unsigned max_pref_prog_hact = 0;
	unsigned max_pref_prog_vact = 0;
	unsigned max_pref_ilace_hact = 0;
	unsigned max_pref_ilace_vact = 0;

	data_block = "CTA-861";
	for (vec_timings_ext::iterator iter = cta.preferred_timings.begin();
	     iter != cta.preferred_timings.end(); ++iter) {
		if (iter->t.interlaced &&
		    (iter->t.vact > max_pref_ilace_vact ||
		     (iter->t.vact == max_pref_ilace_vact && iter->t.hact >= max_pref_ilace_hact))) {
			max_pref_ilace_hact = iter->t.hact;
			max_pref_ilace_vact = iter->t.vact;
		}
		if (!iter->t.interlaced &&
		    (iter->t.vact > max_pref_prog_vact ||
		     (iter->t.vact == max_pref_prog_vact && iter->t.hact >= max_pref_prog_hact))) {
			max_pref_prog_hact = iter->t.hact;
			max_pref_prog_vact = iter->t.vact;
		}
	}

	unsigned native_prog = 0;
	unsigned native_prog_hact = 0;
	unsigned native_prog_vact = 0;
	bool native_prog_mixed_resolutions = false;
	unsigned native_ilace = 0;
	unsigned native_ilace_hact = 0;
	unsigned native_ilace_vact = 0;
	bool native_ilace_mixed_resolutions = false;

	for (vec_timings_ext::iterator iter = cta.native_timings.begin();
	     iter != cta.native_timings.end(); ++iter) {
		if (iter->t.interlaced) {
			native_ilace++;
			if (!native_ilace_hact) {
				native_ilace_hact = iter->t.hact;
				native_ilace_vact = iter->t.vact;
			} else if (native_ilace_hact != iter->t.hact ||
				   native_ilace_vact != iter->t.vact) {
				native_ilace_mixed_resolutions = true;
			}
		} else {
			native_prog++;
			if (!native_prog_hact) {
				native_prog_hact = iter->t.hact;
				native_prog_vact = iter->t.vact;
			} else if (native_prog_hact != iter->t.hact ||
				   native_prog_vact != iter->t.vact) {
				native_prog_mixed_resolutions = true;
			}
		}
	}

	if (native_prog_mixed_resolutions)
		fail("Native progressive timings are a mix of several resolutions.\n");
	if (native_ilace_mixed_resolutions)
		fail("Native interlaced timings are a mix of several resolutions.\n");
	if (native_ilace && !native_prog)
		fail("A native interlaced timing is present, but not a native progressive timing.\n");
	if (!native_prog_mixed_resolutions && native_prog > 1)
		warn("Multiple native progressive timings are defined.\n");
	if (!native_ilace_mixed_resolutions && native_ilace > 1)
		warn("Multiple native interlaced timings are defined.\n");

	if (!native_prog_mixed_resolutions && native_prog_vact &&
	    (max_pref_prog_vact > native_prog_vact ||
	     (max_pref_prog_vact == native_prog_vact && max_pref_prog_hact > native_prog_hact)))
		warn("Native progressive resolution of %ux%u is smaller than the max preferred progressive resolution %ux%u.\n",
		     native_prog_hact, native_prog_vact,
		     max_pref_prog_hact, max_pref_prog_vact);
	if (!native_ilace_mixed_resolutions && native_ilace_vact &&
	    (max_pref_ilace_vact > native_ilace_vact ||
	     (max_pref_ilace_vact == native_ilace_vact && max_pref_ilace_hact > native_ilace_hact)))
		warn("Native interlaced resolution of %ux%u is smaller than the max preferred interlaced resolution %ux%u.\n",
		     native_ilace_hact, native_ilace_vact,
		     max_pref_ilace_hact, max_pref_ilace_vact);

	if (dispid.native_width && native_prog_hact &&
	    !native_prog_mixed_resolutions) {
		if (dispid.native_width != native_prog_hact ||
		    dispid.native_height != native_prog_vact)
			fail("Mismatch between CTA-861 and DisplayID native progressive resolution.\n");
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
addq $0x30, %rdi
movq 0x38(%rbx), %rdx
leaq 0x15a55(%rip), %rcx     # 0x2af0d
xorl %r14d, %r14d
movl $0x7, %r8d
xorl %esi, %esi
callq 0x3390
movq 0x1c0(%rbx), %rax
movq 0x1c8(%rbx), %rcx
movl $0x0, %r12d
movl $0x0, %edi
movl $0x0, %ebp
cmpq %rcx, %rax
je 0x1553d
xorl %ebp, %ebp
xorl %edi, %edi
xorl %r12d, %r12d
xorl %r14d, %r14d
movl 0x4(%rax), %edx
cmpb $0x1, 0x18(%rax)
jne 0x15508
cmpl %ebp, %edx
jbe 0x15515
movl (%rax), %edi
movl %edx, %ebp
jmp 0x15532
cmpl %r12d, %edx
jbe 0x15523
movl (%rax), %r14d
movl %edx, %r12d
jmp 0x15532
jne 0x15532
movl (%rax), %esi
cmpl %edi, %esi
cmovael %edx, %ebp
cmoval %esi, %edi
jmp 0x15532
jne 0x15532
movl (%rax), %esi
cmpl %r14d, %esi
cmoval %esi, %r14d
cmovael %edx, %r12d
addq $0x98, %rax
cmpq %rcx, %rax
jne 0x154f5
movq 0x2a8(%rbx), %rax
movq 0x2b0(%rbx), %rcx
cmpq %rcx, %rax
je 0x1578d
movq %r14, 0x28(%rsp)
movq %rbx, 0x30(%rsp)
xorl %r10d, %r10d
xorl %r8d, %r8d
xorl %r13d, %r13d
xorl %r14d, %r14d
xorl %r9d, %r9d
xorl %esi, %esi
xorl %ebx, %ebx
xorl %r15d, %r15d
movl (%rax), %edx
cmpb $0x1, 0x18(%rax)
jne 0x15594
incl %r14d
testl %r13d, %r13d
je 0x155a9
cmpl %edx, %r13d
jne 0x1558f
cmpl 0x4(%rax), %r8d
je 0x155b7
movb $0x1, %r10b
jmp 0x155b7
incl %r15d
testl %ebx, %ebx
je 0x155b2
cmpl %edx, %ebx
jne 0x155a4
cmpl 0x4(%rax), %esi
je 0x155b7
movb $0x1, %r9b
jmp 0x155b7
movl 0x4(%rax), %r8d
movl %edx, %r13d
jmp 0x155b7
movl 0x4(%rax), %esi
movl %edx, %ebx
addq $0x98, %rax
cmpq %rcx, %rax
jne 0x15574
movl %r9d, 0x24(%rsp)
testb $0x1, %r9b
movl %edi, 0x14(%rsp)
je 0x15606
movl %r8d, 0x18(%rsp)
movl %esi, 0x1c(%rsp)
leaq 0x16210(%rip), %rsi     # 0x2b7f1
movl $0x0, 0x10(%rsp)
xorl %edi, %edi
xorl %eax, %eax
movl %r10d, 0x20(%rsp)
callq 0x37cc
movb $0x1, %al
movl %eax, 0xc(%rsp)
testb $0x1, 0x20(%rsp)
jne 0x15615
jmp 0x15645
movl %r8d, 0x18(%rsp)
movl %esi, 0x1c(%rsp)
testb $0x1, %r10b
je 0x15635
leaq 0x16213(%rip), %rsi     # 0x2b82f
xorl %edi, %edi
xorl %eax, %eax
callq 0x37cc
movb $0x1, %al
movl %eax, 0x10(%rsp)
movl 0x24(%rsp), %eax
movl %eax, 0xc(%rsp)
jmp 0x15645
movl $0x0, 0xc(%rsp)
movl $0x0, 0x10(%rsp)
testl %r14d, %r14d
sete %al
testl %r15d, %r15d
setne %cl
orb %al, %cl
je 0x1567d
cmpl $0x2, %r15d
setb %al
movl 0xc(%rsp), %r15d
orb %r15b, %al
testb $0x1, %al
jne 0x15692
leaq 0x1624a(%rip), %rsi     # 0x2b8b9
movl $0x1, %edi
xorl %eax, %eax
callq 0x37cc
jmp 0x15692
leaq 0x161e8(%rip), %rsi     # 0x2b86c
xorl %edi, %edi
xorl %eax, %eax
callq 0x37cc
movl 0xc(%rsp), %r15d
cmpl $0x2, %r14d
setb %al
movl 0x10(%rsp), %r14d
orb %r14b, %al
jne 0x156b6
leaq 0x16241(%rip), %rsi     # 0x2b8eb
movl $0x1, %edi
xorl %eax, %eax
callq 0x37cc
movl 0x1c(%rsp), %r8d
testl %r8d, %r8d
sete %al
orb %r15b, %al
testb $0x1, %al
movq 0x30(%rsp), %rsi
movl 0x18(%rsp), %r9d
jne 0x1571a
cmpl %r8d, %r12d
ja 0x156df
jne 0x1571a
cmpl %ebx, 0x28(%rsp)
jbe 0x1571a
leaq 0x16236(%rip), %rsi     # 0x2b91c
movl $0x1, %edi
movl %ebx, %edx
movl %r8d, %ecx
movl %r8d, %r15d
movq 0x28(%rsp), %r8
movl %r9d, %r14d
movl %r12d, %r9d
xorl %eax, %eax
callq 0x37cc
movq 0x30(%rsp), %rsi
movl %r14d, %r9d
movl 0x10(%rsp), %r14d
movl %r15d, %r8d
movl 0xc(%rsp), %r15d
testl %r9d, %r9d
sete %al
orb %al, %r14b
jne 0x15765
cmpl %r9d, %ebp
ja 0x15733
jne 0x15765
cmpl %r13d, 0x14(%rsp)
jbe 0x15765
movq %rsi, %r14
leaq 0x16247(%rip), %rsi     # 0x2b984
movl $0x1, %edi
movl %r13d, %edx
movl %r9d, %ecx
movl %r8d, %r15d
movl 0x14(%rsp), %r8d
movl %ebp, %r9d
xorl %eax, %eax
callq 0x37cc
movq %r14, %rsi
movl %r15d, %r8d
movl 0xc(%rsp), %r15d
movl 0x940(%rsi), %eax
testl %eax, %eax
sete %cl
testl %ebx, %ebx
sete %dl
orb %cl, %dl
orb %dl, %r15b
testb $0x1, %r15b
jne 0x1578d
cmpl %ebx, %eax
jne 0x1579c
cmpl %r8d, 0x944(%rsi)
jne 0x1579c
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x16247(%rip), %rsi     # 0x2b9ea
xorl %edi, %edi
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x37cc