// File: /workspace/github_cpp_makefile_star2_O1/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, 0x38e30(%rip)     # 0x3f121
movq %rdi, %rbx
setne 0x52(%rdi)
cmpl $0x2, 0x4(%rdi)
jb 0x6331
movl $0x1, %r14d
movl $0x80, %r15d
leaq 0x38e9f(%rip), %r12     # 0x3f1b0
movl %r15d, %esi
andl $-0x80, %esi
addq %r12, %rsi
movq %rbx, %rdi
callq 0x6112
incq %r14
movl 0x4(%rbx), %eax
subq $-0x80, %r15
cmpq %rax, %r14
jb 0x6311
cmpb $0x0, 0x38db8(%rip)     # 0x3f0f0
je 0x6373
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 0x23f8f(%rip), %rdi     # 0x2a2f4
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x3030
jmp 0x68e6
cmpb $0x0, 0x38d99(%rip)     # 0x3f113
jne 0x6449
leaq 0x1af3a(%rip), %rdi     # 0x212c1
callq 0x3380
cmpl $0x0, 0x4(%rbx)
setne %bpl
je 0x643d
leaq 0x1a8d8(%rip), %rdi     # 0x20c79
leaq 0x38e08(%rip), %r14     # 0x3f1b0
movq %r14, %rsi
movl $0x80, %edx
xorl %ecx, %ecx
movl $0x10, %r8d
callq 0x5bbb
cmpl $0x1, 0x4(%rbx)
jne 0x63cc
cmpb $0x0, 0x38d1e(%rip)     # 0x3f0e8
jne 0x6434
movl $0x1, %r13d
movl $0x80, %r12d
leaq 0x1a89a(%rip), %r15     # 0x20c79
movl $0xa, %edi
callq 0x3310
movl 0x4(%rbx), %eax
cmpq %rax, %r13
setb %bpl
jae 0x643d
movl %r12d, %esi
andl $-0x80, %esi
addq %r14, %rsi
movq %r15, %rdi
movl $0x80, %edx
xorl %ecx, %ecx
movl $0x10, %r8d
callq 0x5bbb
movl 0x4(%rbx), %ecx
decl %ecx
leaq 0x1(%r13), %rax
subq $-0x80, %r12
cmpq %rcx, %r13
movq %rax, %r13
jne 0x63df
cmpb $0x0, 0x38cb9(%rip)     # 0x3f0e8
movq %rax, %r13
je 0x63df
testb %bpl, %bpl
jne 0x68e4
leaq 0x1ae91(%rip), %rdi     # 0x212d5
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 0x649b
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3260
movl 0x8(%rbx), %esi
movq 0x10(%rbx), %rdx
leaq 0x1a26f(%rip), %rdi     # 0x20718
xorl %eax, %eax
callq 0x3030
leaq 0x38cf9(%rip), %r14     # 0x3f1b0
movq %rbx, %rdi
movq %r14, %rsi
callq 0xca02
cmpl $0x2, 0x4(%rbx)
jb 0x6504
movl $0x1, %r13d
movl $0x80, %ebp
leaq 0x1ae70(%rip), %r12     # 0x2134a
incl 0x8(%rbx)
movq %r12, %rdi
callq 0x3380
movl %ebp, %esi
andl $-0x80, %esi
addq %r14, %rsi
movq %rbx, %rdi
callq 0x6132
incq %r13
movl 0x4(%rbx), %eax
subq $-0x80, %rbp
cmpq %rax, %r13
jb 0x64da
movq 0x18(%rbx), %rdx
leaq 0x1a76a(%rip), %r14     # 0x20c79
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 0x6534
movq %rbx, %rdi
callq 0x1558c
cmpb $0x0, 0x38bd5(%rip)     # 0x3f110
je 0x6592
cmpl $0x0, 0xc8(%rbx)
je 0x6592
leaq 0xc8(%rbx), %r15
leaq 0x1adf6(%rip), %rdi     # 0x2134a
callq 0x3380
leaq 0x1ad87(%rip), %rdi     # 0x212e7
callq 0x3380
movq 0x120(%rbx), %rcx
movq 0x140(%rbx), %r8
movl $0x0, (%rsp)
leaq 0x1eec8(%rip), %rsi     # 0x25449
movq %rbx, %rdi
movq %r15, %rdx
movl $0x1, %r9d
callq 0x3ebe
cmpb $0x0, 0x38b75(%rip)     # 0x3f10e
je 0x65f9
cmpl $0x0, 0xc8(%rbx)
je 0x65f9
cmpb $0x1, 0xc6(%rbx)
jne 0x65f9
leaq 0xc8(%rbx), %r15
leaq 0x1ad8f(%rip), %rdi     # 0x2134a
callq 0x3380
leaq 0x1ad53(%rip), %rdi     # 0x2131a
callq 0x3380
movq 0x120(%rbx), %rcx
movq 0x140(%rbx), %r8
movl $0x0, (%rsp)
leaq 0x1ee61(%rip), %rsi     # 0x25449
movq %rbx, %rdi
movq %r15, %rdx
movl $0x1, %r9d
callq 0x3ebe
cmpb $0x0, 0x38b10(%rip)     # 0x3f110
je 0x66ad
movq 0x1c0(%rbx), %rax
cmpq 0x1c8(%rbx), %rax
je 0x66ad
leaq 0x1ad29(%rip), %rdi     # 0x2134a
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 0x1a712(%rip), %rsi     # 0x20d63
cmovbq %r14, %rsi
leaq 0x1a13d(%rip), %rdi     # 0x20799
xorl %eax, %eax
callq 0x3030
movq 0x1c0(%rbx), %r15
cmpq 0x1c8(%rbx), %r15
je 0x66ad
leaq 0x1edcf(%rip), %r12     # 0x25449
movq 0x58(%r15), %rcx
movq 0x78(%r15), %r8
movl $0x0, (%rsp)
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
movl $0x1, %r9d
callq 0x3ebe
addq $0x98, %r15
cmpq 0x1c8(%rbx), %r15
jne 0x667a
cmpb $0x0, 0x38a5a(%rip)     # 0x3f10e
je 0x6761
movq 0x2a8(%rbx), %rax
cmpq 0x2b0(%rbx), %rax
je 0x6761
leaq 0x1ac75(%rip), %rdi     # 0x2134a
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 0x1a65e(%rip), %rsi     # 0x20d63
cmovbq %r14, %rsi
leaq 0x1a0ce(%rip), %rdi     # 0x207de
xorl %eax, %eax
callq 0x3030
movq 0x2a8(%rbx), %r15
cmpq 0x2b0(%rbx), %r15
je 0x6761
leaq 0x1ed1b(%rip), %r12     # 0x25449
movq 0x58(%r15), %rcx
movq 0x78(%r15), %r8
movl $0x0, (%rsp)
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
movl $0x1, %r9d
callq 0x3ebe
addq $0x98, %r15
cmpq 0x2b0(%rbx), %r15
jne 0x672e
cmpb $0x0, 0x389a8(%rip)     # 0x3f110
je 0x6818
movq 0x928(%rbx), %rax
cmpq 0x930(%rbx), %rax
je 0x6818
leaq 0x1abc1(%rip), %rdi     # 0x2134a
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 0x1a5aa(%rip), %rax     # 0x20d63
cmovaeq %rax, %r14
leaq 0x1a05c(%rip), %rdi     # 0x20820
movq %r14, %rsi
xorl %eax, %eax
callq 0x3030
movq 0x928(%rbx), %r14
cmpq 0x930(%rbx), %r14
je 0x6818
leaq 0x1ec64(%rip), %r15     # 0x25449
movq 0x58(%r14), %rcx
movq 0x78(%r14), %r8
movl $0x0, (%rsp)
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
movl $0x1, %r9d
callq 0x3ebe
addq $0x98, %r14
cmpq 0x930(%rbx), %r14
jne 0x67e5
movb 0x388c5(%rip), %al      # 0x3f0e3
orb 0x388df(%rip), %al      # 0x3f103
je 0x68e4
movq %rbx, %rdi
callq 0xd8e6
cmpb $0x1, 0x50(%rbx)
jne 0x6840
movq %rbx, %rdi
callq 0x15604
cmpb $0x1, 0x51(%rbx)
jne 0x684e
movq %rbx, %rdi
callq 0x1d5dc
leaq 0x1aaf5(%rip), %rdi     # 0x2134a
callq 0x3380
cmpb $0x0, 0x388bf(%rip)     # 0x3f120
jne 0x687f
leaq 0x19ffd(%rip), %rdi     # 0x20867
leaq 0x1a00f(%rip), %rsi     # 0x20880
leaq 0x1a015(%rip), %rdx     # 0x2088d
xorl %eax, %eax
callq 0x3030
cmpb $0x0, 0x3887d(%rip)     # 0x3f103
je 0x68a8
cmpl $0x0, 0x7c(%rbx)
je 0x6898
movl $0x1, %edi
callq 0x68f7
cmpl $0x0, 0x80(%rbx)
je 0x68a8
xorl %edi, %edi
callq 0x68f7
cmpl $0x0, 0x80(%rbx)
leaq 0x1a001(%rip), %rax     # 0x208b7
leaq 0x1983c(%rip), %rsi     # 0x200f9
cmoveq %rax, %rsi
leaq 0x19fd9(%rip), %rdi     # 0x208a1
xorl %eax, %eax
callq 0x3030
xorl %eax, %eax
cmpl $0x0, 0x80(%rbx)
sete %al
leal -0x2(,%rax,2), %ebx
jmp 0x68e6
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq