// File: /workspace/github_cpp_makefile_star2_O1/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 0x158c1(%rip), %rcx     # 0x2aee5
xorl %r13d, %r13d
movl $0x7, %r8d
xorl %esi, %esi
callq 0x3390
movq 0x1c0(%rbx), %rax
movq 0x1c8(%rbx), %rcx
movl $0x0, %r8d
movl $0x0, %r12d
movl $0x0, %edi
movl $0x0, %r14d
cmpq %rcx, %rax
je 0x156ac
xorl %r14d, %r14d
xorl %edi, %edi
xorl %r12d, %r12d
xorl %r8d, %r8d
movb 0x18(%rax), %dl
cmpb $0x1, %dl
jne 0x15686
movl 0x4(%rax), %esi
cmpl %r14d, %esi
jbe 0x15680
movl (%rax), %edi
movl %esi, %r14d
jmp 0x15686
jne 0x15686
cmpl %edi, (%rax)
jae 0x15679
testb %dl, %dl
jne 0x156a1
movl 0x4(%rax), %edx
cmpl %r12d, %edx
jbe 0x1569a
movl (%rax), %r8d
movl %edx, %r12d
jmp 0x156a1
jne 0x156a1
cmpl %r8d, (%rax)
jae 0x15692
addq $0x98, %rax
cmpq %rcx, %rax
jne 0x15669
movl %r8d, 0x28(%rsp)
movl %edi, 0x2c(%rsp)
movq 0x2a8(%rbx), %rax
movq %rbx, 0x30(%rsp)
movq 0x2b0(%rbx), %rcx
cmpq %rcx, %rax
je 0x15730
xorl %edi, %edi
xorl %r9d, %r9d
xorl %r15d, %r15d
xorl %ebp, %ebp
xorl %r8d, %r8d
xorl %esi, %esi
xorl %ebx, %ebx
xorl %r13d, %r13d
movl (%rax), %edx
cmpb $0x1, 0x18(%rax)
jne 0x15700
incl %ebp
testl %r15d, %r15d
je 0x15715
cmpl %edx, %r15d
jne 0x156fb
cmpl 0x4(%rax), %r9d
je 0x15723
movb $0x1, %dil
jmp 0x15723
incl %r13d
testl %ebx, %ebx
je 0x1571e
cmpl %edx, %ebx
jne 0x15710
cmpl 0x4(%rax), %esi
je 0x15723
movb $0x1, %r8b
jmp 0x15723
movl 0x4(%rax), %r9d
movl %edx, %r15d
jmp 0x15723
movl 0x4(%rax), %esi
movl %edx, %ebx
addq $0x98, %rax
cmpq %rcx, %rax
jne 0x156e1
jmp 0x15741
xorl %ebx, %ebx
xorl %esi, %esi
xorl %r8d, %r8d
xorl %ebp, %ebp
xorl %r15d, %r15d
xorl %r9d, %r9d
xorl %edi, %edi
movl %esi, 0x1c(%rsp)
testb $0x1, %r8b
movq %r8, 0x10(%rsp)
movl %r9d, 0xc(%rsp)
movq %rdi, 0x20(%rsp)
je 0x15779
leaq 0x16068(%rip), %rsi     # 0x2b7c9
xorl %edi, %edi
xorl %eax, %eax
callq 0x37ec
movq 0x20(%rsp), %rdi
movl 0xc(%rsp), %r9d
movq 0x10(%rsp), %r8
testb $0x1, %dil
je 0x1579e
leaq 0x16081(%rip), %rsi     # 0x2b807
xorl %edi, %edi
xorl %eax, %eax
callq 0x37ec
movq 0x20(%rsp), %rdi
movl 0xc(%rsp), %r9d
movq 0x10(%rsp), %r8
testl %ebp, %ebp
sete %al
testl %r13d, %r13d
setne %cl
orb %al, %cl
jne 0x157cc
leaq 0x16090(%rip), %rsi     # 0x2b844
xorl %edi, %edi
xorl %eax, %eax
callq 0x37ec
movq 0x20(%rsp), %rdi
movl 0xc(%rsp), %r9d
movq 0x10(%rsp), %r8
cmpl $0x2, %r13d
setb %al
orb %r8b, %al
testb $0x1, %al
jne 0x157fc
leaq 0x160b0(%rip), %rsi     # 0x2b891
movl $0x1, %edi
xorl %eax, %eax
callq 0x37ec
movq 0x20(%rsp), %rdi
movl 0xc(%rsp), %r9d
movq 0x10(%rsp), %r8
cmpl $0x2, %ebp
setb %al
orb %dil, %al
testb $0x1, %al
jne 0x1582b
leaq 0x160b3(%rip), %rsi     # 0x2b8c3
movl $0x1, %edi
xorl %eax, %eax
callq 0x37ec
movq 0x20(%rsp), %rdi
movl 0xc(%rsp), %r9d
movq 0x10(%rsp), %r8
movl 0x1c(%rsp), %ecx
testl %ecx, %ecx
sete %al
orb %r8b, %al
testb $0x1, %al
jne 0x15878
cmpl %ecx, %r12d
ja 0x15848
jne 0x15878
cmpl %ebx, 0x28(%rsp)
jbe 0x15878
leaq 0x160a5(%rip), %rsi     # 0x2b8f4
movl $0x1, %edi
movl %ebx, %edx
movl 0x28(%rsp), %r8d
movl %r12d, %r9d
xorl %eax, %eax
callq 0x37ec
movq 0x20(%rsp), %rdi
movl 0xc(%rsp), %r9d
movq 0x10(%rsp), %r8
movl 0x1c(%rsp), %ecx
testl %r9d, %r9d
sete %al
orb %al, %dil
testb $0x1, %dil
jne 0x158bf
cmpl %r9d, %r14d
ja 0x15895
jne 0x158bf
cmpl %r15d, 0x2c(%rsp)
jbe 0x158bf
leaq 0x160c0(%rip), %rsi     # 0x2b95c
movl $0x1, %edi
movl %r15d, %edx
movl %r9d, %ecx
movl 0x2c(%rsp), %r8d
movl %r14d, %r9d
xorl %eax, %eax
callq 0x37ec
movq 0x10(%rsp), %r8
movl 0x1c(%rsp), %ecx
movq 0x30(%rsp), %rsi
movl 0x940(%rsi), %eax
testl %eax, %eax
sete %dil
testl %ebx, %ebx
sete %dl
orb %r8b, %dl
orb %dil, %dl
testb $0x1, %dl
jne 0x158ec
cmpl %ebx, %eax
jne 0x158fb
cmpl %ecx, 0x944(%rsi)
jne 0x158fb
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x160c0(%rip), %rsi     # 0x2b9c2
xorl %edi, %edi
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x37ec