// File: /workspace/github_cpp_makefile_star2_O2/rpavlik[P]edid-decode/edid-decode.cpp
// Function: edid_state::parse_edid()
int edid_state::parse_edid()
{
	hide_serial_numbers = options[OptHideSerialNumbers];

	for (unsigned i = 1; i < num_blocks; i++)
		preparse_extension(edid + i * EDID_PAGE_SIZE);

	if (options[OptPhysicalAddress]) {
		printf("%x.%x.%x.%x\n",
		       (cta.preparsed_phys_addr >> 12) & 0xf,
		       (cta.preparsed_phys_addr >> 8) & 0xf,
		       (cta.preparsed_phys_addr >> 4) & 0xf,
		       cta.preparsed_phys_addr & 0xf);
		return 0;
	}

	if (!options[OptSkipHexDump]) {
		printf("edid-decode (hex):\n\n");
		for (unsigned i = 0; i < num_blocks; i++) {
			hex_block("", edid + i * EDID_PAGE_SIZE, EDID_PAGE_SIZE, false);
			if (i == num_blocks - 1 && options[OptOnlyHexDump])
				return 0;
			printf("\n");
		}
		printf("----------------\n\n");
	}

	block = block_name(0x00);
	printf("Block %u, %s:\n", block_nr, block.c_str());
	parse_base_block(edid);

	for (unsigned i = 1; i < num_blocks; i++) {
		block_nr++;
		printf("\n----------------\n");
		parse_extension(edid + i * EDID_PAGE_SIZE);
	}

	block = "";
	block_nr = EDID_MAX_BLOCKS;

	if (has_cta)
		cta_resolve_svrs();

	if (options[OptPreferredTimings] && base.preferred_timing.is_valid()) {
		printf("\n----------------\n");
		printf("\nPreferred Video Timing if only Block 0 is parsed:\n");
		print_timings("  ", base.preferred_timing, true, false);
	}

	if (options[OptNativeTimings] &&
	    base.preferred_timing.is_valid() && base.preferred_is_also_native) {
		printf("\n----------------\n");
		printf("\nNative Video Timing if only Block 0 is parsed:\n");
		print_timings("  ", base.preferred_timing, true, false);
	}

	if (options[OptPreferredTimings] && !cta.preferred_timings.empty()) {
		printf("\n----------------\n");
		printf("\nPreferred Video Timing%s if Block 0 and CTA-861 Blocks are parsed:\n",
		       cta.preferred_timings.size() > 1 ? "s" : "");
		for (vec_timings_ext::iterator iter = cta.preferred_timings.begin();
		     iter != cta.preferred_timings.end(); ++iter)
			print_timings("  ", *iter, true, false);
	}

	if (options[OptNativeTimings] && !cta.native_timings.empty()) {
		printf("\n----------------\n");
		printf("\nNative Video Timing%s if Block 0 and CTA-861 Blocks are parsed:\n",
		       cta.native_timings.size() > 1 ? "s" : "");
		for (vec_timings_ext::iterator iter = cta.native_timings.begin();
		     iter != cta.native_timings.end(); ++iter)
			print_timings("  ", *iter, true, false);
	}

	if (options[OptPreferredTimings] && !dispid.preferred_timings.empty()) {
		printf("\n----------------\n");
		printf("\nPreferred Video Timing%s if Block 0 and DisplayID Blocks are parsed:\n",
		       dispid.preferred_timings.size() > 1 ? "s" : "");
		for (vec_timings_ext::iterator iter = dispid.preferred_timings.begin();
		     iter != dispid.preferred_timings.end(); ++iter)
			print_timings("  ", *iter, true, false);
	}

	if (!options[OptCheck] && !options[OptCheckInline])
		return 0;

	check_base_block();
	if (has_cta)
		check_cta_blocks();
	if (has_dispid)
		check_displayid_blocks();

	printf("\n----------------\n");

	if (!options[OptSkipSHA] && strlen(STRING(SHA))) {
		printf("\nedid-decode SHA: %s %s\n", STRING(SHA), STRING(DATE));
	}

	if (options[OptCheck]) {
		if (warnings)
			show_msgs(true);
		if (failures)
			show_msgs(false);
	}
	printf("\nEDID conformity: %s\n", failures ? "FAIL" : "PASS");
	return failures ? -2 : 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
cmpb $0x0, 0x33bc8(%rip)     # 0x39141
movq %rdi, %rbx
setne 0x52(%rdi)
pushq $0x1
popq %r15
movl $0x80, %r12d
leaq 0x33c3f(%rip), %r14     # 0x391d0
movl 0x4(%rbx), %eax
cmpq %rax, %r15
jae 0x55b3
movl %r12d, %esi
andl $-0x80, %esi
addq %r14, %rsi
movq %rbx, %rdi
callq 0x53ca
incq %r15
subq $-0x80, %r12
jmp 0x5591
cmpb $0x0, 0x33b56(%rip)     # 0x39110
je 0x5603
movzwl 0x2d0(%rbx), %r8d
movl %r8d, %esi
shrl $0xc, %esi
movl %r8d, %edx
shrl $0x8, %edx
andl $0xf, %edx
movl %r8d, %ecx
shrl $0x4, %ecx
andl $0xf, %ecx
andl $0xf, %r8d
leaq 0x1ed35(%rip), %rdi     # 0x2431c
xorl %r13d, %r13d
xorl %eax, %eax
callq 0x3030
movl %r13d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpb $0x0, 0x33b29(%rip)     # 0x39133
jne 0x567b
leaq 0x15cbe(%rip), %rdi     # 0x1b2d1
callq 0x33b0
xorl %r15d, %r15d
pushq $0x10
popq %rbp
xorl %r12d, %r12d
xorl %r13d, %r13d
movl 0x4(%rbx), %eax
cmpq %rax, %r12
jae 0x566f
movl %r15d, %esi
andl $-0x80, %esi
addq %r14, %rsi
leaq 0x1564d(%rip), %rdi     # 0x1ac89
movl $0x80, %edx
xorl %ecx, %ecx
movl %ebp, %r8d
callq 0x4fc1
movl 0x4(%rbx), %eax
decl %eax
cmpq %rax, %r12
jne 0x565e
cmpb $0x0, 0x33aac(%rip)     # 0x39108
jne 0x55f1
pushq $0xa
popq %rdi
callq 0x3340
incq %r12
subq $-0x80, %r15
jmp 0x5624
leaq 0x15c6f(%rip), %rdi     # 0x1b2e5
callq 0x33b0
leaq 0x8(%rsp), %r12
movq %r12, %rdi
xorl %esi, %esi
callq 0x50da
leaq 0x10(%rbx), %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0x32f0
movq %r12, %rdi
callq 0x3130
movl 0x8(%rbx), %esi
movq 0x10(%rbx), %rdx
leaq 0x15079(%rip), %rdi     # 0x1a728
xorl %eax, %eax
callq 0x3030
movq %rbx, %rdi
movq %r14, %rsi
callq 0xa996
pushq $0x1
popq %r13
movl $0x80, %ebp
leaq 0x15c89(%rip), %r12     # 0x1b35a
movl 0x4(%rbx), %eax
cmpq %rax, %r13
jae 0x56fd
incl 0x8(%rbx)
movq %r12, %rdi
callq 0x33b0
movl %ebp, %esi
andl $-0x80, %esi
addq %r14, %rsi
movq %rbx, %rdi
callq 0x53ea
incq %r13
subq $-0x80, %rbp
jmp 0x56d1
leaq 0x15585(%rip), %r14     # 0x1ac89
movq %r15, %rdi
movq %r14, %rsi
callq 0x3460
movl $0x100, 0x8(%rbx)       # imm = 0x100
cmpb $0x0, 0x50(%rbx)
je 0x5724
movq %rbx, %rdi
callq 0x1197c
cmpb $0x0, 0x33a05(%rip)     # 0x39130
je 0x576d
cmpl $0x0, 0xc8(%rbx)
je 0x576d
leaq 0xc8(%rbx), %r15
leaq 0x15c16(%rip), %rdi     # 0x1b35a
callq 0x33b0
leaq 0x15ba7(%rip), %rdi     # 0x1b2f7
callq 0x33b0
leaq 0x19d3d(%rip), %rsi     # 0x1f499
pushq $0x1
popq %rcx
movq %rbx, %rdi
movq %r15, %rdx
xorl %r8d, %r8d
callq 0x771c
cmpb $0x0, 0x339ba(%rip)     # 0x3912e
je 0x57bf
cmpl $0x0, 0xc8(%rbx)
je 0x57bf
cmpb $0x1, 0xc6(%rbx)
jne 0x57bf
leaq 0xc8(%rbx), %r15
leaq 0x15bc4(%rip), %rdi     # 0x1b35a
callq 0x33b0
leaq 0x15b88(%rip), %rdi     # 0x1b32a
callq 0x33b0
leaq 0x19ceb(%rip), %rsi     # 0x1f499
pushq $0x1
popq %rcx
movq %rbx, %rdi
movq %r15, %rdx
xorl %r8d, %r8d
callq 0x771c
cmpb $0x0, 0x3396a(%rip)     # 0x39130
je 0x5853
movq 0x1c0(%rbx), %rax
cmpq 0x1c8(%rbx), %rax
je 0x5853
leaq 0x15b77(%rip), %rdi     # 0x1b35a
callq 0x33b0
movq 0x1c8(%rbx), %rax
subq 0x1c0(%rbx), %rax
movl $0x98, %ecx
cqto
idivq %rcx
cmpq $0x2, %rax
leaq 0x15568(%rip), %rsi     # 0x1ad73
cmovbq %r14, %rsi
leaq 0x14f93(%rip), %rdi     # 0x1a7a9
xorl %eax, %eax
callq 0x3030
movq 0x1c0(%rbx), %r15
leaq 0x19c6e(%rip), %r12     # 0x1f499
pushq $0x1
popq %rbp
cmpq 0x1c8(%rbx), %r15
je 0x5853
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
movl %ebp, %ecx
xorl %r8d, %r8d
callq 0x771c
addq $0x98, %r15
jmp 0x582e
cmpb $0x0, 0x338d4(%rip)     # 0x3912e
je 0x58e7
movq 0x2a8(%rbx), %rax
cmpq 0x2b0(%rbx), %rax
je 0x58e7
leaq 0x15ae3(%rip), %rdi     # 0x1b35a
callq 0x33b0
movq 0x2b0(%rbx), %rax
subq 0x2a8(%rbx), %rax
movl $0x98, %ecx
cqto
idivq %rcx
cmpq $0x2, %rax
leaq 0x154d4(%rip), %rsi     # 0x1ad73
cmovbq %r14, %rsi
leaq 0x14f44(%rip), %rdi     # 0x1a7ee
xorl %eax, %eax
callq 0x3030
movq 0x2a8(%rbx), %r15
leaq 0x19bda(%rip), %r12     # 0x1f499
pushq $0x1
popq %rbp
cmpq 0x2b0(%rbx), %r15
je 0x58e7
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
movl %ebp, %ecx
xorl %r8d, %r8d
callq 0x771c
addq $0x98, %r15
jmp 0x58c2
cmpb $0x0, 0x33842(%rip)     # 0x39130
je 0x597e
movq 0x928(%rbx), %rax
cmpq 0x930(%rbx), %rax
je 0x597e
leaq 0x15a4f(%rip), %rdi     # 0x1b35a
callq 0x33b0
movq 0x930(%rbx), %rax
subq 0x928(%rbx), %rax
movl $0x98, %ecx
cqto
idivq %rcx
cmpq $0x2, %rax
leaq 0x15440(%rip), %rax     # 0x1ad73
cmovaeq %rax, %r14
leaq 0x14ef2(%rip), %rdi     # 0x1a830
movq %r14, %rsi
xorl %eax, %eax
callq 0x3030
movq 0x928(%rbx), %r14
leaq 0x19b43(%rip), %r15     # 0x1f499
pushq $0x1
popq %rbp
cmpq 0x930(%rbx), %r14
je 0x597e
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
movl %ebp, %ecx
xorl %r8d, %r8d
callq 0x771c
addq $0x98, %r14
jmp 0x5959
movb 0x3377f(%rip), %al      # 0x39103
xorl %r13d, %r13d
orb 0x33796(%rip), %al      # 0x39123
je 0x55f1
movq %rbx, %rdi
callq 0xb732
cmpb $0x1, 0x50(%rbx)
jne 0x59a9
movq %rbx, %rdi
callq 0x119ee
cmpb $0x1, 0x51(%rbx)
jne 0x59b7
movq %rbx, %rdi
callq 0x17702
leaq 0x1599c(%rip), %rdi     # 0x1b35a
callq 0x33b0
cmpb $0x0, 0x33776(%rip)     # 0x39140
jne 0x59e8
leaq 0x14ea4(%rip), %rdi     # 0x1a877
leaq 0x14eb6(%rip), %rsi     # 0x1a890
leaq 0x14ebc(%rip), %rdx     # 0x1a89d
xorl %eax, %eax
callq 0x3030
cmpb $0x0, 0x33734(%rip)     # 0x39123
je 0x5a0f
cmpl $0x0, 0x7c(%rbx)
je 0x59ff
pushq $0x1
popq %rdi
callq 0x5a4f
cmpl $0x0, 0x80(%rbx)
je 0x5a0f
xorl %edi, %edi
callq 0x5a4f
cmpl $0x0, 0x80(%rbx)
leaq 0x14eaa(%rip), %rax     # 0x1a8c7
leaq 0x146e5(%rip), %rsi     # 0x1a109
cmoveq %rax, %rsi
leaq 0x14e82(%rip), %rdi     # 0x1a8b1
xorl %eax, %eax
callq 0x3030
xorl %eax, %eax
cmpl $0x0, 0x80(%rbx)
sete %al
leal -0x2(,%rax,2), %r13d
jmp 0x55f1