#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 */
struct option {
  char *member_0;
  int member_1;
  char member_3;
  int /*<<< orphan*/ member_2;
};

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int getopt_long(int, char **, char const *, struct option const *,
                int /*<<< orphan*/);
int /*<<< orphan*/ load_tmu(char *);
char *optarg;
int optind;
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ usage();
int main(int argc, char **argv) {
  char *output_file = NULL;
  char *input_file = NULL;
  int opt;
  static const struct option options[] = {
      {"help", 0, 0, 'h'},
      {"output", 1, 0, 'o'},
      {0, 0, 0, 0},
  };
  static const char short_options[] = "ho:";
  while ((opt = getopt_long(argc, argv, short_options, options, 0)) != -1) {
    switch (opt) {
    case '?':
    case 'h':
      usage();
      return 0;
    case 'o':
      output_file = optarg;
      break;
    default:
      break;
    }
  }
  if (output_file == NULL) {
    fprintf(stderr, "Need to specify output filename\n");
    usage();
    return -1;
  }
  if (argc - optind <= 0) {
    fprintf(stderr, "No input file specified\n");
    usage();
    return -1;
  }
  input_file = argv[optind];
  load_tmu(input_file);
  return 0;
}


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)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xed2(%rip),%rdx
lea    0x2c45(%rip),%rcx
xor    %r8d,%r8d
call   1030 <getopt_long@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
je     11f5 <main+0xb5>
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
sub    $0x3f,%eax
je     11c5 <main+0x85>
jmp    11a3 <main+0x63>
mov    -0x28(%rbp),%eax
sub    $0x68,%eax
je     11c5 <main+0x85>
jmp    11b4 <main+0x74>
mov    -0x28(%rbp),%eax
sub    $0x6f,%eax
je     11d8 <main+0x98>
jmp    11eb <main+0xab>
mov    $0x0,%al
call   1050 <usage@plt>
movl   $0x0,-0x4(%rbp)
jmp    128b <main+0x14b>
mov    0x2e19(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    11f0 <main+0xb0>
jmp    11f0 <main+0xb0>
jmp    1166 <main+0x26>
cmpq   $0x0,-0x18(%rbp)
jne    1228 <main+0xe8>
mov    0x2dc9(%rip),%rax
mov    (%rax),%edi
lea    0xdfc(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x0,%al
call   1050 <usage@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    128b <main+0x14b>
mov    -0x8(%rbp),%eax
mov    0x2dae(%rip),%rcx
sub    (%rcx),%eax
cmp    $0x0,%eax
jg     1265 <main+0x125>
mov    0x2d8c(%rip),%rax
mov    (%rax),%edi
lea    0xde0(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x0,%al
call   1050 <usage@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    128b <main+0x14b>
mov    -0x10(%rbp),%rax
mov    0x2d70(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <load_tmu@plt>
movl   $0x0,-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    %r12d,%r12d
lea    0xeec(%rip),%r14
lea    0x2c5f(%rip),%r15
mov    0x2e90(%rip),%r13
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %r15,%rcx
xor    %r8d,%r8d
call   1030 <getopt_long@plt>
cmp    $0x67,%eax
jg     11a0 <main+0x60>
cmp    $0xffffffff,%eax
je     11bd <main+0x7d>
cmp    $0x3f,%eax
jne    1170 <main+0x30>
jmp    11b2 <main+0x72>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    $0x6f,%eax
je     11ac <main+0x6c>
cmp    $0x68,%eax
jne    1170 <main+0x30>
jmp    11b2 <main+0x72>
mov    0x0(%r13),%r12
jmp    1170 <main+0x30>
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <usage@plt>
jmp    1210 <main+0xd0>
test   %r12,%r12
je     11dd <main+0x9d>
mov    0x2e17(%rip),%rax
movslq (%rax),%rax
cmp    %ebp,%eax
jge    11ef <main+0xaf>
mov    (%rbx,%rax,8),%rdi
call   1060 <load_tmu@plt>
xor    %ebx,%ebx
jmp    1210 <main+0xd0>
mov    0x2dec(%rip),%rax
mov    (%rax),%edi
lea    0xe1f(%rip),%rsi
jmp    11ff <main+0xbf>
mov    0x2dda(%rip),%rax
mov    (%rax),%edi
lea    0xe2e(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
call   1050 <usage@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.option = type { i8*, i32, i8, i32 }
@main.options = internal constant [3 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i32 0, i8 0, i32 104 }, %struct.option { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i32 0, i32 0), i32 1, i8 0, i32 111 }, %struct.option zeroinitializer]
@.str = [5 x i8] c"help\00"
@.str.1 = [7 x i8] c"output\00"
@main.short_options = internal constant [4 x i8] c"ho:\00"
@optarg = global i8* null
@stderr = global i32 0
@.str.2 = [33 x i8] c"Need to specify output filename\0A\00"
@optind = global i32 0
@.str.3 = [25 x i8] c"No input file 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
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
br label %9
9: ; preds = %21, %2
%10 = load i32, i32* %4
%11 = load i8**, i8*** %5
%12 = call i32 @getopt_long(i32 %10, i8** %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @main.short_options, i64 0, i64 0), %struct.option* getelementptr inbounds ([3 x %struct.option], [3 x %struct.option]* @main.options, i64 0, i64 0), i32 0)
store i32 %12, i32* %8
%13 = icmp ne i32 %12, -1
br i1 %13, label %14, label %22
14: ; preds = %9
%15 = load i32, i32* %8
switch i32 %15, label %20 [
i32 63, label %16
i32 104, label %16
i32 111, label %18
]
16: ; preds = %14, %14
%17 = call i32 (...) @usage()
store i32 0, i32* %3
br label %46
18: ; preds = %14
%19 = load i8*, i8** @optarg
store i8* %19, i8** %6
br label %21
20: ; preds = %14
br label %21
21: ; preds = %20, %18
br label %9
22: ; preds = %9
%23 = load i8*, i8** %6
%24 = icmp eq i8* %23, null
br i1 %24, label %25, label %29
25: ; preds = %22
%26 = load i32, i32* @stderr
%27 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%28 = call i32 (...) @usage()
store i32 -1, i32* %3
br label %46
29: ; preds = %22
%30 = load i32, i32* %4
%31 = load i32, i32* @optind
%32 = sub nsw i32 %30, %31
%33 = icmp sle i32 %32, 0
br i1 %33, label %34, label %38
34: ; preds = %29
%35 = load i32, i32* @stderr
%36 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%37 = call i32 (...) @usage()
store i32 -1, i32* %3
br label %46
38: ; preds = %29
%39 = load i8**, i8*** %5
%40 = load i32, i32* @optind
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8*, i8** %39, i64 %41
%43 = load i8*, i8** %42
store i8* %43, i8** %7
%44 = load i8*, i8** %7
%45 = call i32 @load_tmu(i8* %44)
store i32 0, i32* %3
br label %46
46: ; preds = %38, %34, %25, %16
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
%struct.option = type { i8*, i32, i8, i32 }
@main.options = internal constant [3 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i32 0, i8 0, i32 104 }, %struct.option { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i32 0, i32 0), i32 1, i8 0, i32 111 }, %struct.option zeroinitializer]
@.str = [5 x i8] c"help\00"
@.str.1 = [7 x i8] c"output\00"
@main.short_options = internal constant [4 x i8] c"ho:\00"
@optarg = global i8* null
@stderr = global i32 0
@.str.2 = [33 x i8] c"Need to specify output filename\0A\00"
@optind = global i32 0
@.str.3 = [25 x i8] c"No input file specified\0A\00"
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %9, %2
%4 = phi i8* [ %10, %9 ], [ null, %2 ]
br label %5
5: ; preds = %3, %5
%6 = tail call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @main.short_options, i64 0, i64 0), %struct.option* getelementptr inbounds ([3 x %struct.option], [3 x %struct.option]* @main.options, i64 0, i64 0), i32 0)
switch i32 %6, label %5 [
i32 -1, label %11
i32 63, label %7
i32 104, label %7
i32 111, label %9
]
7: ; preds = %5, %5
%8 = tail call i32 (...) @usage()
br label %29
9: ; preds = %5
%10 = load i8*, i8** @optarg
br label %3
11: ; preds = %5
%12 = icmp eq i8* %4, null
br i1 %12, label %13, label %17
13: ; preds = %11
%14 = load i32, i32* @stderr
%15 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%16 = tail call i32 (...) @usage()
br label %29
17: ; preds = %11
%18 = load i32, i32* @optind
%19 = icmp slt i32 %18, %0
br i1 %19, label %24, label %20
20: ; preds = %17
%21 = load i32, i32* @stderr
%22 = tail call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%23 = tail call i32 (...) @usage()
br label %29
24: ; preds = %17
%25 = sext i32 %18 to i64
%26 = getelementptr inbounds i8*, i8** %1, i64 %25
%27 = load i8*, i8** %26
%28 = tail call i32 @load_tmu(i8* %27)
br label %29
29: ; preds = %24, %20, %13, %7
%30 = phi i32 [ 0, %7 ], [ -1, %13 ], [ -1, %20 ], [ 0, %24 ]
ret i32 %30
}