// File: /workspace/github_cpp_makefile_star2_O2/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 $0x28, %rsp
movq %rdi, %rbx
addq $0x30, %rdi
leaq 0x13503(%rip), %rsi     # 0x24f0d
callq 0x3460
movq 0x1c0(%rbx), %rax
movq 0x1c8(%rbx), %rcx
xorl %r8d, %r8d
xorl %r12d, %r12d
xorl %edi, %edi
xorl %r14d, %r14d
cmpq %rcx, %rax
je 0x11a75
movl 0x4(%rax), %edx
cmpb $0x1, 0x18(%rax)
jne 0x11a42
cmpl %r14d, %edx
jbe 0x11a4f
movl (%rax), %edi
movl %edx, %r14d
jmp 0x11a6d
cmpl %r12d, %edx
jbe 0x11a5e
movl (%rax), %r8d
movl %edx, %r12d
jmp 0x11a6d
jne 0x11a6d
movl (%rax), %esi
cmpl %edi, %esi
cmovael %edx, %r14d
cmoval %esi, %edi
jmp 0x11a6d
jne 0x11a6d
movl (%rax), %esi
cmpl %r8d, %esi
cmoval %esi, %r8d
cmovael %edx, %r12d
addq $0x98, %rax
jmp 0x11a28
movl %r8d, 0x14(%rsp)
movl %edi, 0x18(%rsp)
movq 0x2a8(%rbx), %rax
movq %rbx, 0x20(%rsp)
movq 0x2b0(%rbx), %rcx
xorl %r15d, %r15d
xorl %ebx, %ebx
xorl %esi, %esi
xorl %edi, %edi
xorl %ebp, %ebp
xorl %r13d, %r13d
xorl %r8d, %r8d
xorl %r9d, %r9d
cmpq %rcx, %rax
je 0x11af4
movl (%rax), %edx
cmpb $0x1, 0x18(%rax)
jne 0x11ac9
incl %ebp
testl %r13d, %r13d
je 0x11ade
cmpl %edx, %r13d
jne 0x11ac4
cmpl 0x4(%rax), %r8d
je 0x11aec
movb $0x1, %r9b
jmp 0x11aec
incl %r15d
testl %ebx, %ebx
je 0x11ae7
cmpl %edx, %ebx
jne 0x11ad9
cmpl 0x4(%rax), %esi
je 0x11aec
movb $0x1, %dil
jmp 0x11aec
movl 0x4(%rax), %r8d
movl %edx, %r13d
jmp 0x11aec
movl 0x4(%rax), %esi
movl %edx, %ebx
addq $0x98, %rax
jmp 0x11aa5
testb $0x1, %dil
movl %esi, 0x10(%rsp)
movl %edi, 0x8(%rsp)
movl %r8d, 0x1c(%rsp)
movl %r9d, 0xc(%rsp)
je 0x11b25
leaq 0x13cde(%rip), %rsi     # 0x257f1
xorl %edi, %edi
xorl %eax, %eax
callq 0x362c
movl 0xc(%rsp), %r9d
movl 0x8(%rsp), %edi
testb $0x1, %r9b
je 0x11b44
leaq 0x13cfd(%rip), %rsi     # 0x2582f
xorl %edi, %edi
xorl %eax, %eax
callq 0x362c
movl 0xc(%rsp), %r9d
movl 0x8(%rsp), %edi
testl %ebp, %ebp
sete %al
testl %r15d, %r15d
setne %cl
orb %al, %cl
je 0x11b82
cmpl $0x2, %r15d
setb %al
orb %dil, %al
testb $0x1, %al
movq 0x20(%rsp), %r15
jne 0x11ba0
leaq 0x13d4c(%rip), %rsi     # 0x258b9
pushq $0x1
popq %rdi
xorl %eax, %eax
callq 0x362c
movl 0xc(%rsp), %r9d
movl 0x8(%rsp), %edi
jmp 0x11ba0
leaq 0x13ce3(%rip), %rsi     # 0x2586c
xorl %edi, %edi
xorl %eax, %eax
callq 0x362c
movl 0xc(%rsp), %r9d
movl 0x8(%rsp), %edi
movq 0x20(%rsp), %r15
cmpl $0x2, %ebp
setb %al
orb %r9b, %al
testb $0x1, %al
jne 0x11bc7
leaq 0x13d37(%rip), %rsi     # 0x258eb
pushq $0x1
popq %rdi
xorl %eax, %eax
callq 0x362c
movl 0xc(%rsp), %r9d
movl 0x8(%rsp), %edi
movl 0x10(%rsp), %ecx
testl %ecx, %ecx
sete %al
orb %dil, %al
testb $0x1, %al
movl 0x1c(%rsp), %r8d
jne 0x11c16
cmpl %ecx, %r12d
ja 0x11be9
jne 0x11c16
cmpl %ebx, 0x14(%rsp)
jbe 0x11c16
leaq 0x13d2c(%rip), %rsi     # 0x2591c
pushq $0x1
popq %rdi
movl %ebx, %edx
movl 0x14(%rsp), %r8d
movl %r12d, %r9d
xorl %eax, %eax
callq 0x362c
movl 0xc(%rsp), %r9d
movl 0x1c(%rsp), %r8d
movl 0x8(%rsp), %edi
movl 0x10(%rsp), %ecx
testl %r8d, %r8d
sete %al
orb %al, %r9b
testb $0x1, %r9b
jne 0x11c5a
cmpl %r8d, %r14d
ja 0x11c33
jne 0x11c5a
cmpl %r13d, 0x18(%rsp)
jbe 0x11c5a
leaq 0x13d4a(%rip), %rsi     # 0x25984
pushq $0x1
popq %rdi
movl %r13d, %edx
movl %r8d, %ecx
movl 0x18(%rsp), %r8d
movl %r14d, %r9d
xorl %eax, %eax
callq 0x362c
movl 0x8(%rsp), %edi
movl 0x10(%rsp), %ecx
movl 0x940(%r15), %eax
testl %eax, %eax
sete %sil
testl %ebx, %ebx
sete %dl
orb %dl, %dil
orb %sil, %dil
testb $0x1, %dil
jne 0x11c85
cmpl %ebx, %eax
jne 0x11c94
cmpl %ecx, 0x944(%r15)
jne 0x11c94
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x13d4f(%rip), %rsi     # 0x259ea
xorl %edi, %edi
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x362c