// File: /workspace/github_cpp_makefile_star2_O2/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
cmpb $0x2d, (%rdi)
jne 0x6c14
cmpb $0x0, 0x1(%r14)
je 0x6d0a
movq %r14, %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x3190
cmpl $-0x1, %eax
je 0x6dcc
movl %eax, %ebp
movb $0x0, 0x3a59e(%rip)     # 0x411d0
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %r15
movaps %xmm0, (%r15)
andq $0x0, 0x10(%r15)
leaq 0x30(%rsp), %r12
movl $0x80, %edx
movl %ebp, %edi
movq %r12, %rsi
callq 0x3370
testq %rax, %rax
js 0x6d1f
je 0x6c7c
movq 0x18(%rsp), %rsi
leaq (%rsp,%rax), %rcx
addq $0x30, %rcx
movq %r15, %rdi
movq %r12, %rdx
callq 0x7a9e
jmp 0x6c48
movq 0x10(%rsp), %r12
movq 0x18(%rsp), %r15
cmpq %r15, %r12
je 0x6d18
leaq 0x143a2(%rip), %rsi     # 0x1b038
movq %r12, %rdi
callq 0x3080
testq %rax, %rax
jne 0x6cbb
leaq 0x1439a(%rip), %rsi     # 0x1b044
movq %r12, %rdi
callq 0x3080
testq %rax, %rax
je 0x6dd6
pushq $0x3a
popq %rsi
movq %rax, %rdi
callq 0x30e0
pushq $0x1
popq %rsi
movq %rax, %rdi
callq 0x71ca
movl %eax, %r15d
leaq 0x10(%rsp), %rdi
callq 0x7cc8
testb %r15b, %r15b
je 0x6d29
movl 0x2da17(%rip), %edx     # 0x34700
testb $0x7f, %dl
je 0x6d9a
leaq 0x142f7(%rip), %rsi     # 0x1aff0
movq %rbx, %rdi
movl $0x80, %ecx
xorl %eax, %eax
callq 0x3360
jmp 0x6d85
xorl %ebp, %ebp
leaq 0x1426c(%rip), %r14     # 0x1af7f
jmp 0x6c2b
andl $0x0, 0x2d9e1(%rip)     # 0x34700
leaq 0x10(%rsp), %rdi
callq 0x7cc8
cmpl $0x0, 0x2d9d0(%rip)     # 0x34700
je 0x6d5a
leaq 0x14265(%rip), %rsi     # 0x1af9e
movq %rbx, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x3360
cmpb $0x1, 0x3a483(%rip)     # 0x411d0
jne 0x6d70
leaq 0x14266(%rip), %rdi     # 0x1afbc
pushq $0x22
jmp 0x6d79
leaq 0x14224(%rip), %rsi     # 0x1af85
movq %rbx, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x3360
jmp 0x6d85
leaq 0x14268(%rip), %rdi     # 0x1afdf
pushq $0x10
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rcx
callq 0x3470
pushq $-0x1
popq %rax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
shrl $0x7, %edx
movl %edx, 0x2d961(%rip)     # 0x34704
testl %ebp, %ebp
je 0x6dae
movl %ebp, %edi
callq 0x3490
xorl %eax, %eax
movabsq $0xffffffffffff00, %rcx # imm = 0xFFFFFFFFFFFF00
cmpq %rcx, 0x3240f(%rip)     # 0x391d0
je 0x6d88
leaq 0x1424f(%rip), %rsi     # 0x1b019
jmp 0x6d61
movq %r14, %rdi
callq 0x3200
jmp 0x6d85
leaq 0x1427a(%rip), %rsi     # 0x1b057
movq %r12, %rdi
callq 0x3080
testq %rax, %rax
je 0x6e00
pushq $0x7b
popq %rsi
movq %rax, %rdi
callq 0x30e0
leaq 0x1(%rax), %rdi
xorl %esi, %esi
jmp 0x6ccc
leaq 0x14269(%rip), %rsi     # 0x1b070
movq %r12, %rdi
callq 0x3080
testq %rax, %rax
je 0x6e8d
pushq $0x3e
popq %rsi
pushq $0x1
popq %r13
movq %rax, %rdi
callq 0x30e0
testq %rax, %rax
je 0x6d1f
movq %rax, %r12
incq %r12
xorl %r15d, %r15d
cmpb $0x0, (%r12,%r15)
je 0x6e66
cmpq $0xff, %r15
ja 0x6e66
cmpb $0x0, 0x1(%r12,%r15)
je 0x6e66
leaq (%r12,%r15), %rdi
movl %r13d, %esi
callq 0x72a5
addq $0x2, %r15
testb %al, %al
jne 0x6e35
jmp 0x6d1f
movq %r12, %rdi
leaq 0x14200(%rip), %rsi     # 0x1b070
callq 0x3080
testq %rax, %rax
pushq $0x3e
popq %rsi
jne 0x6e1b
cmpl $0x0, 0x2d87c(%rip)     # 0x34700
setne %r15b
jmp 0x6cd4
leaq 0x141e3(%rip), %rsi     # 0x1b077
movq %r12, %rdi
callq 0x3080
testq %rax, %rax
jne 0x6eb9
leaq 0x141da(%rip), %rsi     # 0x1b082
movq %r12, %rdi
callq 0x3080
testq %rax, %rax
je 0x6f85
movq %rax, %r13
leaq 0x1321d(%rip), %r15     # 0x1a0e0
movq %r13, %rdi
movq %r15, %rsi
callq 0x3080
testq %rax, %rax
je 0x6eef
movq %rax, %r12
movq %r13, %rdi
leaq 0x13214(%rip), %rsi     # 0x1a0f4
callq 0x3080
cmpq %rax, %r12
ja 0x6e7d
movq %r15, %rdi
jmp 0x6f25
movq %r13, %rdi
leaq 0x131f8(%rip), %rsi     # 0x1a0f1
callq 0x3080
testq %rax, %rax
je 0x6e7d
movq %rax, %r12
movq %r13, %rdi
pushq $0x9
popq %rsi
callq 0x30e0
cmpq %rax, %r12
ja 0x6e7d
leaq 0x131cc(%rip), %rdi     # 0x1a0f1
callq 0x3110
movq %rax, %r15
addq %r12, %r15
xorl %r12d, %r12d
leaq (%r15,%r12), %r13
cmpl $0x20, %r12d
je 0x6ebc
movsbl (%r13), %edi
callq 0x3090
testl %eax, %eax
je 0x6f77
movsbl 0x1(%r15,%r12), %edi
callq 0x3090
testl %eax, %eax
je 0x6f77
movq %r13, %rdi
pushq $0x1
popq %rsi
callq 0x72a5
testb %al, %al
je 0x6d1f
addq $0x2, %r12
jmp 0x6f33
testl %r12d, %r12d
jne 0x6ebc
jmp 0x6d1f
leaq 0x140fc(%rip), %rsi     # 0x1b088
movq %r12, %rdi
callq 0x3080
testq %rax, %rax
je 0x7041
leaq 0x140f3(%rip), %rsi     # 0x1b097
movq %rax, %rdi
callq 0x3080
testq %rax, %rax
je 0x7041
movq %rax, %r13
movb $0x1, %al
leaq 0x14120(%rip), %r15     # 0x1b0e1
pushq $0x1
popq %r12
movsbl (%r13), %edi
testl %edi, %edi
je 0x6e7d
testb $0x1, %al
je 0x7017
movq %r13, %rdi
movq %r15, %rsi
callq 0x3080
testq %rax, %rax
jne 0x6ffe
movq %r13, %rdi
leaq 0x140f5(%rip), %rsi     # 0x1b0e5
callq 0x3080
testq %rax, %rax
je 0x6e7d
movq %rax, %r13
decq %r13
movsbl 0x2(%r13), %edi
callq 0x3090
incq %r13
testl %eax, %eax
je 0x7004
jmp 0x7036
callq 0x3090
testl %eax, %eax
je 0x703d
movq %r13, %rdi
movl %r12d, %esi
callq 0x72a5
testb %al, %al
je 0x6d1f
incq %r13
xorl %eax, %eax
incq %r13
jmp 0x6fc5
movb $0x1, %al
jmp 0x7038
xorl %r13d, %r13d
cmpq $0x20, %r13
je 0x7094
movsbl (%r12,%r13), %edi
movl %edi, 0xc(%rsp)
callq 0x3040
testl %eax, %eax
jne 0x708f
leaq 0x14089(%rip), %rdi     # 0x1b0ec
movl 0xc(%rsp), %esi
pushq $0x4
popq %rdx
callq 0x32b0
testq %rax, %rax
jne 0x708f
movl 0xc(%rsp), %edi
callq 0x3380
cmpl $0x78, %eax
je 0x708f
movl 0xc(%rsp), %edi
callq 0x3090
testl %eax, %eax
je 0x709f
incq %r13
jmp 0x7044
pushq $0x1
popq %rsi
movq %r12, %rdi
jmp 0x6ccc
subq %r12, %r15
cmpq $0x8001, %r15           # imm = 0x8001
jb 0x70c9
leaq 0x13fea(%rip), %rsi     # 0x1b09c
movl $0x8000, %ecx           # imm = 0x8000
movq %rbx, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x3360
jmp 0x6d1f
leaq 0x32100(%rip), %rdi     # 0x391d0
movq %r12, %rsi
movq %r15, %rdx
callq 0x31f0
movl %r15d, 0x2d61e(%rip)    # 0x34700
leaq 0x10(%rsp), %rdi
callq 0x7cc8
jmp 0x6ce3
jmp 0x70f3
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x7cc8
movq %rbx, %rdi
callq 0x3430