// File: /workspace/github_cpp_makefile_star2_O1/rpavlik[P]edid-decode/edid-decode.cpp
// Function: edid_from_file(char const*, _IO_FILE*)
static int edid_from_file(const char *from_file, FILE *error)
{
#ifdef O_BINARY
	// Windows compatibility
	int flags = O_RDONLY | O_BINARY;
#else
	int flags = O_RDONLY;
#endif
	int fd;

	if (!strcmp(from_file, "-")) {
		from_file = "stdin";
		fd = 0;
	} else if ((fd = open(from_file, flags)) == -1) {
		perror(from_file);
		return -1;
	}

	odd_hex_digits = false;
	if (!extract_edid(fd, error)) {
		if (!state.edid_size) {
			fprintf(error, "EDID of '%s' was empty.\n", from_file);
			return -1;
		}
		fprintf(error, "EDID extract of '%s' failed: ", from_file);
		if (odd_hex_digits)
			fprintf(error, "odd number of hexadecimal digits.\n");
		else
			fprintf(error, "unknown format.\n");
		return -1;
	}
	if (state.edid_size % EDID_PAGE_SIZE) {
		fprintf(error, "EDID length %u is not a multiple of %u.\n",
			state.edid_size, EDID_PAGE_SIZE);
		return -1;
	}
	state.num_blocks = state.edid_size / EDID_PAGE_SIZE;
	if (fd != 0)
		close(fd);

	if (memcmp(edid, "\x00\xFF\xFF\xFF\xFF\xFF\xFF\x00", 8)) {
		fprintf(error, "No EDID header found in '%s'.\n", from_file);
		return -1;
	}
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x19930(%rip), %rsi     # 0x2135a
callq 0x3320
testl %eax, %eax
je 0x7a4c
movq %r14, %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x3170
cmpl $-0x1, %eax
je 0x7cd2
movl %eax, %ebp
jmp 0x7a55
xorl %ebp, %ebp
leaq 0x1951a(%rip), %r14     # 0x20f6f
movb $0x0, 0x3f754(%rip)     # 0x471b0
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %r15
movaps %xmm0, (%r15)
movq $0x0, 0x10(%r15)
leaq 0x30(%rsp), %r12
movl $0x80, %edx
movl %ebp, %edi
movq %r12, %rsi
callq 0x3340
testq %rax, %rax
js 0x7aa8
je 0x7ab0
movq 0x18(%rsp), %rsi
leaq (%rsp,%rax), %rcx
addq $0x30, %rcx
xorl %r13d, %r13d
movq %r15, %rdi
movq %r12, %rdx
callq 0x8d8e
jmp 0x7ab6
movl $0x1, %r13d
jmp 0x7ab6
movl $0x2, %r13d
testl %r13d, %r13d
je 0x7a75
cmpl $0x2, %r13d
jne 0x7b19
movq 0x10(%rsp), %r12
movq 0x18(%rsp), %r15
cmpq %r15, %r12
je 0x7b0f
leaq 0x19551(%rip), %rsi     # 0x21028
movq %r12, %rdi
callq 0x3080
testq %rax, %rax
jne 0x7af3
leaq 0x19549(%rip), %rsi     # 0x21034
movq %r12, %rdi
callq 0x3080
testq %rax, %rax
je 0x7b1e
movq %rax, %rdi
movl $0x3a, %esi
callq 0x30e0
movq %rax, %rdi
movl $0x1, %esi
jmp 0x7b49
movl $0x0, 0x32bc7(%rip)     # 0x3a6e0
xorl %r12d, %r12d
jmp 0x7b51
leaq 0x19522(%rip), %rsi     # 0x21047
movq %r12, %rdi
callq 0x3080
testq %rax, %rax
je 0x7c3a
movq %rax, %rdi
movl $0x7b, %esi
callq 0x30e0
leaq 0x1(%rax), %rdi
xorl %esi, %esi
callq 0x839f
movl %eax, %r12d
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x7b68
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x3260
movl 0x32b72(%rip), %edx     # 0x3a6e0
testb %r12b, %r12b
je 0x7b93
testb $0x7f, %dl
je 0x7bc2
leaq 0x19461(%rip), %rsi     # 0x20fe0
movq %rbx, %rdi
movl $0x80, %ecx
xorl %eax, %eax
callq 0x3330
jmp 0x7c23
testl %edx, %edx
je 0x7bf4
leaq 0x193f0(%rip), %rsi     # 0x20f8e
movq %rbx, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x3330
cmpb $0x1, 0x3f5fe(%rip)     # 0x471b0
jne 0x7c0a
leaq 0x193f1(%rip), %rdi     # 0x20fac
movl $0x22, %esi
jmp 0x7c16
shrl $0x7, %edx
movl %edx, 0x32b19(%rip)     # 0x3a6e4
testl %ebp, %ebp
je 0x7bd6
movl %ebp, %edi
callq 0x3440
xorl %eax, %eax
movabsq $0xffffffffffff00, %rcx # imm = 0xFFFFFFFFFFFF00
cmpq %rcx, 0x375c7(%rip)     # 0x3f1b0
je 0x7c28
leaq 0x19417(%rip), %rsi     # 0x21009
jmp 0x7bfb
leaq 0x1937a(%rip), %rsi     # 0x20f75
movq %rbx, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x3330
jmp 0x7c23
leaq 0x193be(%rip), %rdi     # 0x20fcf
movl $0x10, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x3430
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1941f(%rip), %rsi     # 0x21060
movq %r12, %rdi
callq 0x3080
testq %rax, %rax
je 0x7cdf
movq %rax, %rdi
movl $0x3e, %esi
callq 0x30e0
testq %rax, %rax
je 0x7b19
movq %rax, %r12
incq %r12
cmpb $0x0, 0x1(%rax)
je 0x7cae
movq %r12, %r13
xorl %r15d, %r15d
cmpq $0xff, %r15
ja 0x7cae
cmpb $0x0, 0x1(%r13)
je 0x7cae
movq %r13, %rdi
movl $0x1, %esi
callq 0x865c
testb %al, %al
je 0x7b19
addq $0x2, %r15
cmpb $0x0, 0x2(%r13)
leaq 0x2(%r13), %r13
jne 0x7c7a
movq %r12, %rdi
leaq 0x193a8(%rip), %rsi     # 0x21060
callq 0x3080
testq %rax, %rax
jne 0x7c52
cmpl $0x0, 0x32a17(%rip)     # 0x3a6e0
setne %r12b
jmp 0x7b51
movq %r14, %rdi
callq 0x31e0
jmp 0x7c23
leaq 0x19381(%rip), %rsi     # 0x21067
movq %r12, %rdi
callq 0x3080
testq %rax, %rax
jne 0x7d02
leaq 0x19378(%rip), %rsi     # 0x21072
movq %r12, %rdi
callq 0x3080
testq %rax, %rax
je 0x7d14
movq %rax, %rdi
callq 0x8487
jmp 0x7b4e
leaq 0x1935d(%rip), %rsi     # 0x21078
movq %r12, %rdi
callq 0x3080
testq %rax, %rax
je 0x7d39
leaq 0x19358(%rip), %rsi     # 0x21087
movq %rax, %rdi
callq 0x3080
jmp 0x7d3b
xorl %eax, %eax
testq %rax, %rax
je 0x7d4d
movq %rax, %rdi
callq 0x85a6
jmp 0x7b4e
movq $-0x20, %r13
movsbl 0x20(%r12,%r13), %edi
movl %edi, 0xc(%rsp)
callq 0x3040
testl %eax, %eax
jne 0x7d9c
movl $0x4, %edx
leaq 0x19369(%rip), %rdi     # 0x210dc
movl 0xc(%rsp), %esi
callq 0x3280
testq %rax, %rax
jne 0x7d9c
movl 0xc(%rsp), %edi
callq 0x3350
cmpl $0x78, %eax
je 0x7d9c
movl 0xc(%rsp), %edi
callq 0x3090
testl %eax, %eax
je 0x7da9
incq %r13
jne 0x7d54
movq %r12, %rdi
jmp 0x7b08
testq %r13, %r13
je 0x7da1
subq %r12, %r15
cmpq $0x8001, %r15           # imm = 0x8001
jb 0x7ddb
leaq 0x192cb(%rip), %rsi     # 0x2108c
xorl %r12d, %r12d
movl $0x8000, %ecx           # imm = 0x8000
movq %rbx, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x3330
jmp 0x7b51
leaq 0x373ce(%rip), %rdi     # 0x3f1b0
movq %r12, %rsi
movq %r15, %rdx
callq 0x31d0
movl %r15d, 0x328ec(%rip)    # 0x3a6e0
movb $0x1, %r12b
jmp 0x7b51
jmp 0x7dfe
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x7e18
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x3260
movq %rbx, %rdi
callq 0x3400