#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 getopt(int, char **, char *);
int /*<<< orphan*/ optarg;
int /*<<< orphan*/ printf(char *, char *);
char *read_file(char *);
int /*<<< orphan*/ upload_file(int /*<<< orphan*/);
char *version();
int main(int argc, char **argv) {
  int c;
  while ((c = getopt(argc, argv, "cf:hlv")) != -1) {
    switch (c) {
    case 'c':
      printf("%s\n", read_file("CREDITS"));
      return 0;
      break;
    case 'f':
      upload_file(optarg);
      break;
    case 'h':
      printf("%s\n", read_file("README.md"));
      return 0;
      break;
    case 'l':
      printf("%s", read_file("LICENSE"));
      return 0;
      break;
    case 'v':
      printf("%s\n", version());
      return 0;
      break;
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xedc(%rip),%rdx
call   1060 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     125d <main+0x10d>
mov    -0x14(%rbp),%eax
add    $0xffffff9d,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x13,%eax
ja     1258 <main+0x108>
mov    -0x20(%rbp),%rax
lea    0xe5b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xea6(%rip),%rdi
call   1040 <read_file@plt>
mov    %rax,%rsi
lea    0xe93(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    125d <main+0x10d>
mov    0x2e1c(%rip),%rax
mov    (%rax),%edi
call   1070 <upload_file@plt>
jmp    1258 <main+0x108>
lea    0xe74(%rip),%rdi
call   1040 <read_file@plt>
mov    %rax,%rsi
lea    0xe59(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    125d <main+0x10d>
lea    0xe5a(%rip),%rdi
call   1040 <read_file@plt>
mov    %rax,%rsi
lea    0xe48(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    125d <main+0x10d>
mov    $0x0,%al
call   1050 <version@plt>
mov    %rax,%rsi
lea    0xe10(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    125d <main+0x10d>
jmp    1166 <main+0x16>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xeec(%rip),%r14
lea    0xe95(%rip),%r15
mov    0x2e86(%rip),%r12
jmp    1189 <main+0x39>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r12),%edi
call   1070 <upload_file@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1060 <getopt@plt>
lea    -0x63(%rax),%ecx
cmp    $0x13,%ecx
ja     11b0 <main+0x60>
movslq (%r15,%rcx,4),%rax
add    %r15,%rax
jmp    *%rax
nopw   0x0(%rax,%rax,1)
cmp    $0xffffffff,%eax
jne    1189 <main+0x39>
jmp    11fe <main+0xae>
lea    0xe9d(%rip),%rdi
call   1040 <read_file@plt>
jmp    11ef <main+0x9f>
lea    0xe97(%rip),%rdi
call   1040 <read_file@plt>
jmp    11ef <main+0x9f>
lea    0xe96(%rip),%rdi
call   1040 <read_file@plt>
lea    0xe87(%rip),%rdi
jmp    11f6 <main+0xa6>
xor    %eax,%eax
call   1050 <version@plt>
lea    0xe61(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"cf:hlv\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [8 x i8] c"CREDITS\00"
@optarg = global i32 0
@.str.3 = [10 x i8] c"README.md\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [8 x i8] c"LICENSE\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %7
7: ; preds = %29, %2
%8 = load i32, i32* %4
%9 = load i8**, i8*** %5
%10 = call i32 @getopt(i32 %8, i8** %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 %10, i32* %6
%11 = icmp ne i32 %10, -1
br i1 %11, label %12, label %30
12: ; preds = %7
%13 = load i32, i32* %6
switch i32 %13, label %29 [
i32 99, label %14
i32 102, label %17
i32 104, label %20
i32 108, label %23
i32 118, label %26
]
14: ; preds = %12
%15 = call i8* @read_file(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %15)
store i32 0, i32* %3
br label %30
17: ; preds = %12
%18 = load i32, i32* @optarg
%19 = call i32 @upload_file(i32 %18)
br label %29
20: ; preds = %12
%21 = call i8* @read_file(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %21)
store i32 0, i32* %3
br label %30
23: ; preds = %12
%24 = call i8* @read_file(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%25 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %24)
store i32 0, i32* %3
br label %30
26: ; preds = %12
%27 = call i8* (...) @version()
%28 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %27)
store i32 0, i32* %3
br label %30
29: ; preds = %12, %17
br label %7
30: ; preds = %14, %20, %23, %26, %7
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
@.str = [7 x i8] c"cf:hlv\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [8 x i8] c"CREDITS\00"
@optarg = global i32 0
@.str.3 = [10 x i8] c"README.md\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [8 x i8] c"LICENSE\00"
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %5, %2
%4 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
switch i32 %4, label %5 [
i32 -1, label %21
i32 99, label %6
i32 102, label %9
i32 104, label %12
i32 108, label %15
i32 118, label %18
]
5: ; preds = %3, %9
br label %3
6: ; preds = %3
%7 = tail call i8* @read_file(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%8 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %7)
br label %21
9: ; preds = %3
%10 = load i32, i32* @optarg
%11 = tail call i32 @upload_file(i32 %10)
br label %5
12: ; preds = %3
%13 = tail call i8* @read_file(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%14 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %13)
br label %21
15: ; preds = %3
%16 = tail call i8* @read_file(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%17 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %16)
br label %21
18: ; preds = %3
%19 = tail call i8* (...) @version()
%20 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %19)
br label %21
21: ; preds = %3, %18, %15, %12, %6
ret i32 0
}