// File: /workspace/github_cpp_makefile_star2_O3/rpavlik[P]edid-decode/edid-decode.cpp
// Function: edid_to_file(char const*, output_format)
static int edid_to_file(const char *to_file, enum output_format out_fmt)
{
	FILE *out;

	if (!strcmp(to_file, "-")) {
		to_file = "stdout";
		out = stdout;
	} else if ((out = fopen(to_file, "w")) == NULL) {
		perror(to_file);
		return -1;
	}
	if (out_fmt == OUT_FMT_DEFAULT)
		out_fmt = out == stdout ? OUT_FMT_HEX : OUT_FMT_RAW;

	switch (out_fmt) {
	default:
	case OUT_FMT_HEX:
		hexdumpedid(out, edid, state.edid_size);
		break;
	case OUT_FMT_RAW:
		fwrite(edid, state.edid_size, 1, out);
		break;
	case OUT_FMT_CARRAY:
		carraydumpedid(out, edid, state.edid_size);
		break;
	case OUT_FMT_XML:
		xmldumpedid(out, edid, state.edid_size);
		break;
	}

	if (out != stdout)
		fclose(out);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %esi, %ebp
movq %rdi, %r14
cmpb $0x2d, (%rdi)
jne 0x7c6a
cmpb $0x0, 0x1(%r14)
je 0x8053
leaq 0x18c61(%rip), %rsi     # 0x208d2
movq %r14, %rdi
callq 0x32b0
testq %rax, %rax
je 0x8065
movq %rax, %rbx
movq 0x32324(%rip), %rax     # 0x39fb0
movq (%rax), %rcx
xorl %eax, %eax
cmpq %rcx, %rbx
setne %al
incl %eax
testl %ebp, %ebp
cmovnel %ebp, %eax
movl 0x32a3c(%rip), %ecx     # 0x3a6e0
movq %rcx, (%rsp)
cmpl $0x2, %eax
je 0x7f04
cmpl $0x3, %eax
je 0x7dcc
cmpl $0x4, %eax
jne 0x7f43
leaq 0x194cf(%rip), %rdi     # 0x21199
movl $0x37, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x3430
leaq 0x194ee(%rip), %rdi     # 0x211d1
movl $0xa, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x3430
leaq 0x194e0(%rip), %rdi     # 0x211dc
movl $0x27, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x3430
leaq 0x194ef(%rip), %rdi     # 0x21204
movl $0xb, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x3430
cmpl $0x80, (%rsp)
jb 0x7da2
movq (%rsp), %rax
shrl $0x7, %eax
movq %rax, (%rsp)
leaq 0x3746e(%rip), %r14     # 0x3f1b0
leaq 0x18782(%rip), %r12     # 0x204cb
leaq 0x194d2(%rip), %r13     # 0x21222
xorl %ebp, %ebp
movq %rbx, %rdi
leaq 0x194b4(%rip), %rsi     # 0x21210
movl %ebp, %edx
xorl %eax, %eax
callq 0x3330
xorl %r15d, %r15d
movzbl (%r14,%r15), %edx
movq %rbx, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x3330
incq %r15
cmpq $0x80, %r15
jne 0x7d68
movq %rbx, %rdi
movq %r13, %rsi
movl %ebp, %edx
xorl %eax, %eax
callq 0x3330
incq %rbp
subq $-0x80, %r14
cmpq (%rsp), %rbp
jne 0x7d52
leaq 0x19485(%rip), %rdi     # 0x2122e
movl $0xc, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x3430
leaq 0x19479(%rip), %rdi     # 0x2123b
movl $0xb, %esi
jmp 0x7efd
leaq 0x19356(%rip), %rdi     # 0x21129
movl $0x1f, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x3430
cmpl $0x80, (%rsp)
jb 0x7ef1
movq (%rsp), %rax
shrl $0x7, %eax
movq %rax, (%rsp)
leaq 0x373ac(%rip), %r14     # 0x3f1b0
leaq 0x19347(%rip), %r12     # 0x21152
xorl %ebp, %ebp
testq %rbp, %rbp
je 0x7e1f
movl $0xa, %edi
movq %rbx, %rsi
callq 0x32e0
movq %rbp, 0x8(%rsp)
shlq $0x7, %rbp
movq %r14, 0x10(%rsp)
xorl %r15d, %r15d
leaq (%r15,%rbp), %rax
leaq 0x37375(%rip), %rcx     # 0x3f1b0
movzbl (%rcx,%rax), %edx
movq %rbx, %rdi
leaq 0x19300(%rip), %rsi     # 0x21149
xorl %eax, %eax
callq 0x3330
movl $0x1, %r13d
movzbl (%r14,%r13), %edx
movq %rbx, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x3330
incq %r13
cmpq $0x8, %r13
jne 0x7e56
movl $0xa, %edi
movq %rbx, %rsi
callq 0x32e0
leaq 0x8(%r15), %rax
addq $0x8, %r14
cmpq $0x78, %r15
movq %rax, %r15
jb 0x7e30
xorl %eax, %eax
xorl %ecx, %ecx
movq 0x10(%rsp), %r14
addb (%r14,%rax), %cl
incq %rax
cmpq $0x7f, %rax
jne 0x7e98
leaq 0x37304(%rip), %rax     # 0x3f1b0
addb 0x7f(%rbp,%rax), %cl
movq 0x8(%rsp), %rbp
je 0x7ee0
xorl %eax, %eax
xorl %ecx, %ecx
addb (%r14,%rax), %cl
incq %rax
cmpq $0x7f, %rax
jne 0x7ebb
negb %cl
movzbl %cl, %ecx
movq %rbx, %rdi
leaq 0x19284(%rip), %rsi     # 0x2115b
movl %ebp, %edx
xorl %eax, %eax
callq 0x3330
incq %rbp
subq $-0x80, %r14
cmpq (%rsp), %rbp
jne 0x7e0d
leaq 0x1929d(%rip), %rdi     # 0x21195
movl $0x3, %esi
movl $0x1, %edx
jmp 0x7f14
leaq 0x372a5(%rip), %rdi     # 0x3f1b0
movl $0x1, %edx
movq (%rsp), %rsi
movq %rbx, %rcx
callq 0x3430
movq 0x3208d(%rip), %rax     # 0x39fb0
xorl %ebp, %ebp
cmpq (%rax), %rbx
je 0x7f32
movq %rbx, %rdi
callq 0x3240
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x80, (%rsp)
jb 0x7f1c
movq (%rsp), %rax
shrl $0x7, %eax
movq %rax, (%rsp)
leaq 0x37252(%rip), %r13     # 0x3f1b0
leaq 0x1918b(%rip), %r12     # 0x210f0
xorl %ebp, %ebp
testq %rbp, %rbp
je 0x7f79
movl $0xa, %edi
movq %rbx, %rsi
callq 0x32e0
movq %rbp, 0x8(%rsp)
shlq $0x7, %rbp
movq %r13, 0x10(%rsp)
xorl %r15d, %r15d
leaq (%r15,%rbp), %rax
leaq 0x3721b(%rip), %rcx     # 0x3f1b0
movzbl (%rcx,%rax), %edx
movq %rbx, %rdi
leaq 0x1914e(%rip), %rsi     # 0x210f1
xorl %eax, %eax
callq 0x3330
movl $0x1, %r14d
movzbl (%r13,%r14), %edx
movq %rbx, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x3330
incq %r14
cmpq $0x10, %r14
jne 0x7fb0
movl $0xa, %edi
movq %rbx, %rsi
callq 0x32e0
leaq 0x10(%r15), %rax
addq $0x10, %r13
cmpq $0x70, %r15
movq %rax, %r15
jb 0x7f8a
xorl %eax, %eax
xorl %ecx, %ecx
movq 0x10(%rsp), %r13
addb (%r13,%rax), %cl
incq %rax
cmpq $0x7f, %rax
jne 0x7ff3
leaq 0x371a8(%rip), %rax     # 0x3f1b0
addb 0x7f(%rbp,%rax), %cl
movq 0x8(%rsp), %rbp
je 0x803d
xorl %eax, %eax
xorl %ecx, %ecx
addb (%r13,%rax), %cl
incq %rax
cmpq $0x7f, %rax
jne 0x8017
negb %cl
movzbl %cl, %ecx
movq %rbx, %rdi
leaq 0x190c2(%rip), %rsi     # 0x210f6
movl %ebp, %edx
xorl %eax, %eax
callq 0x3330
incq %rbp
subq $-0x80, %r13
cmpq (%rsp), %rbp
jne 0x7f67
jmp 0x7f1c
movq 0x31f56(%rip), %rax     # 0x39fb0
movq (%rax), %rcx
movq %rcx, %rbx
jmp 0x7c8f
movq %r14, %rdi
callq 0x31e0
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x7f32