#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[]) {
  char *inputFilename = NULL;
  char *outputFilename = NULL;
  int compress = 0;
  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    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xf55(%rip),%rdx
call   1070 <getopt@plt>
mov    %eax,-0x28(%rbp)
cmp    $0xffffffff,%eax
je     1250 <main+0x100>
mov    -0x28(%rbp),%eax
add    $0xffffffc1,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x37,%eax
ja     124b <main+0xfb>
mov    -0x30(%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,-0x18(%rbp)
jmp    124b <main+0xfb>
mov    0x2e19(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    124b <main+0xfb>
movl   $0x1,-0x24(%rbp)
jmp    124b <main+0xfb>
movl   $0x0,-0x24(%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,-0x18(%rbp)
jne    1287 <main+0x137>
cmpq   $0x0,-0x20(%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    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1030 <pack@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%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),%r14
xor    %r15d,%r15d
xor    %r12d,%r12d
jmp    1185 <main+0x35>
nopl   0x0(%rax)
cmp    $0xffffffff,%eax
je     11f9 <main+0xa9>
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 (%r14,%rcx,4),%rax
add    %r14,%rax
jmp    *%rax
mov    $0x1,%r12d
jmp    1185 <main+0x35>
mov    0x2e46(%rip),%rax
mov    (%rax),%rax
mov    %rax,(%rsp)
jmp    1185 <main+0x35>
mov    0x2e36(%rip),%rax
mov    (%rax),%r15
jmp    1185 <main+0x35>
mov    (%rbx),%rdi
call   1060 <printUsage@plt>
mov    $0x1,%eax
jmp    11ea <main+0x9a>
mov    (%rbx),%rdi
call   1060 <printUsage@plt>
jmp    11e8 <main+0x98>
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    (%rsp),%rdi
mov    %rdi,%rax
or     %r15,%rax
jne    1221 <main+0xd1>
mov    0x2dcc(%rip),%rax
mov    (%rax),%edi
lea    0xed4(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%eax
jmp    11ea <main+0x9a>
mov    %r15,%rsi
mov    %r12d,%edx
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 i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
store i8* null, i8** %7
store i32 0, i32* %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** %6
br label %38
19: ; preds = %15
%20 = load i8*, i8** @optarg
store i8* %20, i8** %7
br label %38
21: ; preds = %15
store i32 1, i32* %8
br label %38
22: ; preds = %15
store i32 0, i32* %8
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** %6
%41 = icmp eq i8* %40, null
br i1 %41, label %42, label %48
42: ; preds = %39
%43 = load i8*, i8** %7
%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** %6
%50 = load i8*, i8** %7
%51 = load i32, i32* %8
%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 = %14, %2
%4 = phi i8* [ %15, %14 ], [ null, %2 ]
%5 = phi i8* [ %8, %14 ], [ null, %2 ]
%6 = phi i32 [ %11, %14 ], [ 0, %2 ]
br label %7
7: ; preds = %3, %16
%8 = phi i8* [ %5, %3 ], [ %17, %16 ]
%9 = phi i32 [ %6, %3 ], [ %11, %16 ]
br label %10
10: ; preds = %19, %7
%11 = phi i32 [ %9, %7 ], [ %20, %19 ]
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 %3
16: ; preds = %12
%17 = load i8*, i8** @optarg
br label %7
18: ; preds = %12
br label %19
19: ; preds = %12, %18
%20 = phi i32 [ 0, %18 ], [ 1, %12 ]
br label %10
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* %4, null
%32 = icmp eq i8* %8, 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* %4, i8* %8, i32 %11)
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
}