// File: /workspace/github_cpp_makefile_star2_O3/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, 0x38e02(%rip)     # 0x3f121
movq %rdi, %rbx
setne 0x52(%rdi)
cmpl $0x2, 0x4(%rdi)
jb 0x635f
movl $0x1, %r14d
movl $0x80, %r15d
leaq 0x38e71(%rip), %r12     # 0x3f1b0
movl %r15d, %esi
andl $-0x80, %esi
addq %r12, %rsi
movq %rbx, %rdi
callq 0x613c
incq %r14
movl 0x4(%rbx), %eax
subq $-0x80, %r15
cmpq %rax, %r14
jb 0x633f
cmpb $0x0, 0x38d8a(%rip)     # 0x3f0f0
je 0x63a2
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 0x23f89(%rip), %rdi     # 0x2a31c
xorl %r14d, %r14d
xorl %eax, %eax
callq 0x3030
jmp 0x68ce
cmpb $0x0, 0x38d6a(%rip)     # 0x3f113
jne 0x6431
leaq 0x1af1b(%rip), %rdi     # 0x212d1
callq 0x3380
cmpl $0x0, 0x4(%rbx)
je 0x6425
xorl %r14d, %r14d
leaq 0x38de5(%rip), %r12     # 0x3f1b0
leaq 0x1a8b7(%rip), %r15     # 0x20c89
xorl %r13d, %r13d
xorl %ebp, %ebp
movl %r13d, %esi
andl $-0x80, %esi
addq %r12, %rsi
movq %r15, %rdi
movl $0x80, %edx
xorl %ecx, %ecx
movl $0x10, %r8d
callq 0x5bd2
movl 0x4(%rbx), %eax
decl %eax
cmpq %rax, %rbp
jne 0x640c
cmpb $0x0, 0x38ce2(%rip)     # 0x3f0e8
jne 0x68ce
movl $0xa, %edi
callq 0x3310
incq %rbp
movl 0x4(%rbx), %eax
subq $-0x80, %r13
cmpq %rax, %rbp
jb 0x63d7
leaq 0x1aeb9(%rip), %rdi     # 0x212e5
callq 0x3380
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
movabsq $0x4944452065736142, %rax # imm = 0x4944452065736142
movq %rax, (%r12)
movw $0x44, 0x8(%r12)
movq $0x9, -0x8(%r12)
leaq 0x10(%rbx), %r15
leaq 0x8(%rsp), %r14
movq %r15, %rdi
movq %r14, %rsi
callq 0x32d0
movq (%r14), %rdi
cmpq %r12, %rdi
je 0x6483
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3260
movl 0x8(%rbx), %esi
movq 0x10(%rbx), %rdx
leaq 0x1a297(%rip), %rdi     # 0x20728
xorl %eax, %eax
callq 0x3030
leaq 0x38d11(%rip), %r14     # 0x3f1b0
movq %rbx, %rdi
movq %r14, %rsi
callq 0xc7f6
cmpl $0x2, 0x4(%rbx)
jb 0x64ec
movl $0x1, %r13d
movl $0x80, %ebp
leaq 0x1ae98(%rip), %r12     # 0x2135a
incl 0x8(%rbx)
movq %r12, %rdi
callq 0x3380
movl %ebp, %esi
andl $-0x80, %esi
addq %r14, %rsi
movq %rbx, %rdi
callq 0x615c
incq %r13
movl 0x4(%rbx), %eax
subq $-0x80, %rbp
cmpq %rax, %r13
jb 0x64c2
movq 0x18(%rbx), %rdx
leaq 0x1a792(%rip), %r14     # 0x20c89
movq %r15, %rdi
xorl %esi, %esi
movq %r14, %rcx
xorl %r8d, %r8d
callq 0x3390
movl $0x100, 0x8(%rbx)       # imm = 0x100
cmpb $0x0, 0x50(%rbx)
je 0x651c
movq %rbx, %rdi
callq 0x15412
cmpb $0x0, 0x38bed(%rip)     # 0x3f110
je 0x657a
cmpl $0x0, 0xc8(%rbx)
je 0x657a
leaq 0xc8(%rbx), %r15
leaq 0x1ae1e(%rip), %rdi     # 0x2135a
callq 0x3380
leaq 0x1adaf(%rip), %rdi     # 0x212f7
callq 0x3380
movq 0x120(%rbx), %rcx
movq 0x140(%rbx), %r8
movl $0x0, (%rsp)
leaq 0x1ef30(%rip), %rsi     # 0x25499
movq %rbx, %rdi
movq %r15, %rdx
movl $0x1, %r9d
callq 0x3e8c
cmpb $0x0, 0x38b8d(%rip)     # 0x3f10e
je 0x65e1
cmpl $0x0, 0xc8(%rbx)
je 0x65e1
cmpb $0x1, 0xc6(%rbx)
jne 0x65e1
leaq 0xc8(%rbx), %r15
leaq 0x1adb7(%rip), %rdi     # 0x2135a
callq 0x3380
leaq 0x1ad7b(%rip), %rdi     # 0x2132a
callq 0x3380
movq 0x120(%rbx), %rcx
movq 0x140(%rbx), %r8
movl $0x0, (%rsp)
leaq 0x1eec9(%rip), %rsi     # 0x25499
movq %rbx, %rdi
movq %r15, %rdx
movl $0x1, %r9d
callq 0x3e8c
cmpb $0x0, 0x38b28(%rip)     # 0x3f110
je 0x6695
movq 0x1c0(%rbx), %rax
cmpq 0x1c8(%rbx), %rax
je 0x6695
leaq 0x1ad51(%rip), %rdi     # 0x2135a
callq 0x3380
movq 0x1c8(%rbx), %rax
subq 0x1c0(%rbx), %rax
sarq $0x3, %rax
movabsq $-0x79435e50d79435e5, %rcx # imm = 0x86BCA1AF286BCA1B
imulq %rax, %rcx
cmpq $0x2, %rcx
leaq 0x1a73a(%rip), %rsi     # 0x20d73
cmovbq %r14, %rsi
leaq 0x1a165(%rip), %rdi     # 0x207a9
xorl %eax, %eax
callq 0x3030
movq 0x1c0(%rbx), %r15
cmpq 0x1c8(%rbx), %r15
je 0x6695
leaq 0x1ee37(%rip), %r12     # 0x25499
movq 0x58(%r15), %rcx
movq 0x78(%r15), %r8
movl $0x0, (%rsp)
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
movl $0x1, %r9d
callq 0x3e8c
addq $0x98, %r15
cmpq 0x1c8(%rbx), %r15
jne 0x6662
cmpb $0x0, 0x38a72(%rip)     # 0x3f10e
je 0x6749
movq 0x2a8(%rbx), %rax
cmpq 0x2b0(%rbx), %rax
je 0x6749
leaq 0x1ac9d(%rip), %rdi     # 0x2135a
callq 0x3380
movq 0x2b0(%rbx), %rax
subq 0x2a8(%rbx), %rax
sarq $0x3, %rax
movabsq $-0x79435e50d79435e5, %rcx # imm = 0x86BCA1AF286BCA1B
imulq %rax, %rcx
cmpq $0x2, %rcx
leaq 0x1a686(%rip), %rsi     # 0x20d73
cmovbq %r14, %rsi
leaq 0x1a0f6(%rip), %rdi     # 0x207ee
xorl %eax, %eax
callq 0x3030
movq 0x2a8(%rbx), %r15
cmpq 0x2b0(%rbx), %r15
je 0x6749
leaq 0x1ed83(%rip), %r12     # 0x25499
movq 0x58(%r15), %rcx
movq 0x78(%r15), %r8
movl $0x0, (%rsp)
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
movl $0x1, %r9d
callq 0x3e8c
addq $0x98, %r15
cmpq 0x2b0(%rbx), %r15
jne 0x6716
cmpb $0x0, 0x389c0(%rip)     # 0x3f110
je 0x6800
movq 0x928(%rbx), %rax
cmpq 0x930(%rbx), %rax
je 0x6800
leaq 0x1abe9(%rip), %rdi     # 0x2135a
callq 0x3380
movq 0x930(%rbx), %rax
subq 0x928(%rbx), %rax
sarq $0x3, %rax
movabsq $-0x79435e50d79435e5, %rcx # imm = 0x86BCA1AF286BCA1B
imulq %rax, %rcx
cmpq $0x2, %rcx
leaq 0x1a5d2(%rip), %rax     # 0x20d73
cmovaeq %rax, %r14
leaq 0x1a084(%rip), %rdi     # 0x20830
movq %r14, %rsi
xorl %eax, %eax
callq 0x3030
movq 0x928(%rbx), %r14
cmpq 0x930(%rbx), %r14
je 0x6800
leaq 0x1eccc(%rip), %r15     # 0x25499
movq 0x58(%r14), %rcx
movq 0x78(%r14), %r8
movl $0x0, (%rsp)
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
movl $0x1, %r9d
callq 0x3e8c
addq $0x98, %r14
cmpq 0x930(%rbx), %r14
jne 0x67cd
movb 0x388dd(%rip), %al      # 0x3f0e3
xorl %r14d, %r14d
orb 0x388f4(%rip), %al      # 0x3f103
je 0x68ce
movq %rbx, %rdi
callq 0xd704
cmpb $0x1, 0x50(%rbx)
jne 0x682b
movq %rbx, %rdi
callq 0x15498
cmpb $0x1, 0x51(%rbx)
jne 0x6839
movq %rbx, %rdi
callq 0x1d246
leaq 0x1ab1a(%rip), %rdi     # 0x2135a
callq 0x3380
cmpb $0x0, 0x388d4(%rip)     # 0x3f120
jne 0x686a
leaq 0x1a022(%rip), %rdi     # 0x20877
leaq 0x1a034(%rip), %rsi     # 0x20890
leaq 0x1a03a(%rip), %rdx     # 0x2089d
xorl %eax, %eax
callq 0x3030
cmpb $0x0, 0x38892(%rip)     # 0x3f103
je 0x6893
cmpl $0x0, 0x7c(%rbx)
je 0x6883
movl $0x1, %edi
callq 0x68e0
cmpl $0x0, 0x80(%rbx)
je 0x6893
xorl %edi, %edi
callq 0x68e0
cmpl $0x0, 0x80(%rbx)
leaq 0x1a026(%rip), %rax     # 0x208c7
leaq 0x19861(%rip), %rsi     # 0x20109
cmoveq %rax, %rsi
leaq 0x19ffe(%rip), %rdi     # 0x208b1
xorl %eax, %eax
callq 0x3030
xorl %eax, %eax
cmpl $0x0, 0x80(%rbx)
sete %al
leal -0x2(,%rax,2), %r14d
movl %r14d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq