#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int getopt(int, char **, char *);
char *optarg;
int pack(char *, char *, int);
int /*<<< orphan*/ printUsage(char *);
int /*<<< orphan*/ printVersion(char *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  int compress = 0;
  char *inputFilename = NULL;
  char *outputFilename = NULL;
  int c;
  while ((c = getopt(argc, argv, "i:o:cdhv")) != -1) {
    switch (c) {
    case 'i':
      inputFilename = optarg;
      break;
    case 'o':
      outputFilename = optarg;
      break;
    case 'c':
      compress = 1;
      break;
    case 'd':
      compress = 0;
      break;
    case 'h':
      printUsage(argv[0]);
      return 0;
    case '?':
      printUsage(argv[0]);
      return 1;
    case 'v':
      printVersion(argv[0]);
      return 0;
    }
  }
  if (inputFilename == NULL && outputFilename == NULL) {
    fprintf(
        stderr,
        "ERROR: At least an input file or output file must be specified!\n");
    return 1;
  } else
    return pack(inputFilename, outputFilename, compress);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xf55(%rip),%rdx
call   1070 <getopt@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0xffffffff,%eax
je     1250 <main+0x100>
mov    -0x2c(%rbp),%eax
add    $0xffffffc1,%eax
mov    %eax,%ecx
mov    %rcx,-0x38(%rbp)
sub    $0x37,%eax
ja     124b <main+0xfb>
mov    -0x38(%rbp),%rax
lea    0xe44(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2e2c(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    124b <main+0xfb>
mov    0x2e19(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    124b <main+0xfb>
movl   $0x1,-0x14(%rbp)
jmp    124b <main+0xfb>
movl   $0x0,-0x14(%rbp)
jmp    124b <main+0xfb>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <printUsage@plt>
movl   $0x0,-0x4(%rbp)
jmp    129a <main+0x14a>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <printUsage@plt>
movl   $0x1,-0x4(%rbp)
jmp    129a <main+0x14a>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <printVersion@plt>
movl   $0x0,-0x4(%rbp)
jmp    129a <main+0x14a>
jmp    117d <main+0x2d>
cmpq   $0x0,-0x20(%rbp)
jne    1287 <main+0x137>
cmpq   $0x0,-0x28(%rbp)
jne    1287 <main+0x137>
mov    0x2d6b(%rip),%rax
mov    (%rax),%edi
lea    0xe73(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    129a <main+0x14a>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <pack@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %eax,%eax
mov    %rax,(%rsp)
lea    0xf73(%rip),%r13
lea    0xe8c(%rip),%r15
xor    %r12d,%r12d
xor    %r14d,%r14d
jmp    1185 <main+0x35>
nopl   0x0(%rax)
cmp    $0xffffffff,%eax
je     1200 <main+0xb0>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1070 <getopt@plt>
lea    -0x3f(%rax),%ecx
cmp    $0x37,%ecx
ja     1180 <main+0x30>
movslq (%r15,%rcx,4),%rax
add    %r15,%rax
jmp    *%rax
mov    $0x1,%eax
mov    %rax,(%rsp)
jmp    1185 <main+0x35>
xor    %eax,%eax
mov    %rax,(%rsp)
jmp    1185 <main+0x35>
mov    0x2e3b(%rip),%rax
mov    (%rax),%r12
jmp    1185 <main+0x35>
mov    0x2e2f(%rip),%rax
mov    (%rax),%r14
jmp    1185 <main+0x35>
mov    (%rbx),%rdi
call   1060 <printUsage@plt>
mov    $0x1,%eax
jmp    11f1 <main+0xa1>
mov    (%rbx),%rdi
call   1060 <printUsage@plt>
jmp    11ef <main+0x9f>
mov    (%rbx),%rdi
call   1050 <printVersion@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r12,%rax
or     %r14,%rax
jne    1224 <main+0xd4>
mov    0x2dc9(%rip),%rax
mov    (%rax),%edi
lea    0xed1(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%eax
jmp    11f1 <main+0xa1>
mov    %r12,%rdi
mov    %r14,%rsi
mov    (%rsp),%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <pack@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"i:o:cdhv\00"
@optarg = global i8* null
@stderr = global i32 0
@.str.1 = [65 x i8] c"ERROR: At least an input file or output file must be specified!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i8* null, i8** %7
store i8* null, i8** %8
br label %10
10: ; preds = %38, %2
%11 = load i32, i32* %4
%12 = load i8**, i8*** %5
%13 = call i32 @getopt(i32 %11, i8** %12, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
store i32 %13, i32* %9
%14 = icmp ne i32 %13, -1
br i1 %14, label %15, label %39
15: ; preds = %10
%16 = load i32, i32* %9
switch i32 %16, label %38 [
i32 105, label %17
i32 111, label %19
i32 99, label %21
i32 100, label %22
i32 104, label %23
i32 63, label %28
i32 118, label %33
]
17: ; preds = %15
%18 = load i8*, i8** @optarg
store i8* %18, i8** %7
br label %38
19: ; preds = %15
%20 = load i8*, i8** @optarg
store i8* %20, i8** %8
br label %38
21: ; preds = %15
store i32 1, i32* %6
br label %38
22: ; preds = %15
store i32 0, i32* %6
br label %38
23: ; preds = %15
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 0
%26 = load i8*, i8** %25
%27 = call i32 @printUsage(i8* %26)
store i32 0, i32* %3
br label %53
28: ; preds = %15
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 0
%31 = load i8*, i8** %30
%32 = call i32 @printUsage(i8* %31)
store i32 1, i32* %3
br label %53
33: ; preds = %15
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 0
%36 = load i8*, i8** %35
%37 = call i32 @printVersion(i8* %36)
store i32 0, i32* %3
br label %53
38: ; preds = %15, %22, %21, %19, %17
br label %10
39: ; preds = %10
%40 = load i8*, i8** %7
%41 = icmp eq i8* %40, null
br i1 %41, label %42, label %48
42: ; preds = %39
%43 = load i8*, i8** %8
%44 = icmp eq i8* %43, null
br i1 %44, label %45, label %48
45: ; preds = %42
%46 = load i32, i32* @stderr
%47 = call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %53
48: ; preds = %42, %39
%49 = load i8*, i8** %7
%50 = load i8*, i8** %8
%51 = load i32, i32* %6
%52 = call i32 @pack(i8* %49, i8* %50, i32 %51)
store i32 %52, i32* %3
br label %53
53: ; preds = %48, %45, %33, %28, %23
%54 = load i32, i32* %3
ret i32 %54
}

LLVM IR (-O2):
@.str = [9 x i8] c"i:o:cdhv\00"
@optarg = global i8* null
@stderr = global i32 0
@.str.1 = [65 x i8] c"ERROR: At least an input file or output file must be specified!\0A\00"
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %19, %2
%4 = phi i32 [ 0, %2 ], [ %20, %19 ]
%5 = phi i8* [ null, %2 ], [ %8, %19 ]
%6 = phi i8* [ null, %2 ], [ %11, %19 ]
br label %7
7: ; preds = %3, %14
%8 = phi i8* [ %5, %3 ], [ %15, %14 ]
%9 = phi i8* [ %6, %3 ], [ %11, %14 ]
br label %10
10: ; preds = %7, %16
%11 = phi i8* [ %9, %7 ], [ %17, %16 ]
br label %12
12: ; preds = %10, %12
%13 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
switch i32 %13, label %12 [
i32 -1, label %30
i32 105, label %14
i32 111, label %16
i32 99, label %19
i32 100, label %18
i32 104, label %21
i32 63, label %24
i32 118, label %27
]
14: ; preds = %12
%15 = load i8*, i8** @optarg
br label %7
16: ; preds = %12
%17 = load i8*, i8** @optarg
br label %10
18: ; preds = %12
br label %19
19: ; preds = %12, %18
%20 = phi i32 [ 0, %18 ], [ 1, %12 ]
br label %3
21: ; preds = %12
%22 = load i8*, i8** %1
%23 = tail call i32 @printUsage(i8* %22)
br label %39
24: ; preds = %12
%25 = load i8*, i8** %1
%26 = tail call i32 @printUsage(i8* %25)
br label %39
27: ; preds = %12
%28 = load i8*, i8** %1
%29 = tail call i32 @printVersion(i8* %28)
br label %39
30: ; preds = %12
%31 = icmp eq i8* %8, null
%32 = icmp eq i8* %11, null
%33 = select i1 %31, i1 %32, i1 false
br i1 %33, label %34, label %37
34: ; preds = %30
%35 = load i32, i32* @stderr
%36 = tail call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.1, i64 0, i64 0))
br label %39
37: ; preds = %30
%38 = tail call i32 @pack(i8* %8, i8* %11, i32 %4)
br label %39
39: ; preds = %37, %34, %27, %24, %21
%40 = phi i32 [ 0, %27 ], [ 1, %24 ], [ 0, %21 ], [ 1, %34 ], [ %38, %37 ]
ret i32 %40
}