#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 */
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int getopt(int, char **, char *);
int /*<<< orphan*/ hippo_read_hip(char const *, int);
int /*<<< orphan*/ hippo_read_tyc(char const *, int);
scalar_t__ hippo_write(int /*<<< orphan*/, char *);
char *optarg;
scalar_t__ opterr;
int optind;
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strtol(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  const char *H = NULL;
  const char *T = NULL;
  uint32_t d = 10;
  int c;
  opterr = 0;
  while ((c = getopt(argc, argv, "H:T:d:")) != -1)
    switch (c) {
    case 'T':
      T = optarg;
      break;
    case 'H':
      H = optarg;
      break;
    case 'd':
      d = (uint32_t)strtol(optarg, 0, 0);
      break;
    }
  if (optind < argc) {
    if (T && hippo_write(hippo_read_tyc(T, d), argv[optind]))
      return 0;
    if (H && hippo_write(hippo_read_hip(H, d), argv[optind]))
      return 0;
  }
  fprintf(stderr,
          "Usage: %s [-T tyc2.dat] "
          "[-H hip_main.dat] output.riff\n",
          argv[0]);
  return 1;
}


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   $0xa,-0x24(%rbp)
mov    0x2e34(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe57(%rip),%rdx
call   1080 <getopt@plt>
mov    %eax,-0x28(%rbp)
cmp    $0xffffffff,%eax
je     1231 <main+0xd1>
mov    -0x28(%rbp),%eax
mov    %eax,-0x2c(%rbp)
sub    $0x48,%eax
je     1203 <main+0xa3>
jmp    11ce <main+0x6e>
mov    -0x2c(%rbp),%eax
sub    $0x54,%eax
je     11f0 <main+0x90>
jmp    11df <main+0x7f>
mov    -0x2c(%rbp),%eax
sub    $0x64,%eax
je     1216 <main+0xb6>
jmp    122c <main+0xcc>
mov    0x2e01(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    122c <main+0xcc>
mov    0x2dee(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    122c <main+0xcc>
mov    0x2ddb(%rip),%rax
mov    (%rax),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   1060 <strtol@plt>
mov    %eax,-0x24(%rbp)
jmp    119b <main+0x3b>
mov    0x2da8(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jge    12d4 <main+0x174>
cmpq   $0x0,-0x20(%rbp)
je     1289 <main+0x129>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1070 <hippo_read_tyc@plt>
mov    %eax,%edi
mov    -0x10(%rbp),%rax
mov    0x2d79(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <hippo_write@plt>
cmp    $0x0,%rax
je     1289 <main+0x129>
movl   $0x0,-0x4(%rbp)
jmp    12f7 <main+0x197>
cmpq   $0x0,-0x18(%rbp)
je     12cf <main+0x16f>
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1040 <hippo_read_hip@plt>
mov    %eax,%edi
mov    -0x10(%rbp),%rax
mov    0x2d33(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <hippo_write@plt>
cmp    $0x0,%rax
je     12cf <main+0x16f>
movl   $0x0,-0x4(%rbp)
jmp    12f7 <main+0x197>
jmp    12d4 <main+0x174>
mov    0x2cf5(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd1c(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-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
mov    0x2e51(%rip),%rax
movq   $0x0,(%rax)
mov    $0xa,%r15d
xor    %eax,%eax
mov    %rax,(%rsp)
lea    0xe6f(%rip),%r13
mov    0x2e60(%rip),%r14
xor    %r12d,%r12d
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1080 <getopt@plt>
cmp    $0x53,%eax
jg     11d0 <main+0x70>
cmp    $0xffffffff,%eax
je     11f0 <main+0x90>
cmp    $0x48,%eax
jne    11a0 <main+0x40>
mov    (%r14),%rax
mov    %rax,(%rsp)
jmp    11a0 <main+0x40>
cs nopw 0x0(%rax,%rax,1)
nop
cmp    $0x64,%eax
je     11df <main+0x7f>
cmp    $0x54,%eax
jne    11a0 <main+0x40>
mov    (%r14),%r12
jmp    11a0 <main+0x40>
mov    (%r14),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1060 <strtol@plt>
mov    %eax,%r15d
jmp    11a0 <main+0x40>
mov    0x2de9(%rip),%r14
cmp    %ebp,(%r14)
jge    124f <main+0xef>
test   %r12,%r12
je     1224 <main+0xc4>
mov    %r12,%rdi
mov    %r15d,%esi
call   1070 <hippo_read_tyc@plt>
movslq (%r14),%rcx
mov    (%rbx,%rcx,8),%rsi
mov    %eax,%edi
call   1030 <hippo_write@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    126c <main+0x10c>
cmpq   $0x0,(%rsp)
je     124f <main+0xef>
mov    (%rsp),%rdi
mov    %r15d,%esi
call   1040 <hippo_read_hip@plt>
movslq (%r14),%rcx
mov    (%rbx,%rcx,8),%rsi
mov    %eax,%edi
call   1030 <hippo_write@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    126c <main+0x10c>
mov    0x2d7a(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xda5(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@opterr = global i64 0
@.str = [7 x i8] c"H:T:d:\00"
@optarg = global i8* null
@optind = global i32 0
@stderr = global i32 0
@.str.1 = [55 x i8] c"Usage: %s [-T tyc2.dat] [-H hip_main.dat] output.riff\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 10, i32* %8
store i64 0, i64* @opterr
br label %10
10: ; preds = %24, %2
%11 = load i32, i32* %4
%12 = load i8**, i8*** %5
%13 = call i32 @getopt(i32 %11, i8** %12, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 %13, i32* %9
%14 = icmp ne i32 %13, -1
br i1 %14, label %15, label %25
15: ; preds = %10
%16 = load i32, i32* %9
switch i32 %16, label %24 [
i32 84, label %17
i32 72, label %19
i32 100, label %21
]
17: ; preds = %15
%18 = load i8*, i8** @optarg
store i8* %18, i8** %7
br label %24
19: ; preds = %15
%20 = load i8*, i8** @optarg
store i8* %20, i8** %6
br label %24
21: ; preds = %15
%22 = load i8*, i8** @optarg
%23 = call i32 @strtol(i8* %22, i32 0, i32 0)
store i32 %23, i32* %8
br label %24
24: ; preds = %15, %21, %19, %17
br label %10
25: ; preds = %10
%26 = load i32, i32* @optind
%27 = load i32, i32* %4
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %60
29: ; preds = %25
%30 = load i8*, i8** %7
%31 = icmp ne i8* %30, null
br i1 %31, label %32, label %44
32: ; preds = %29
%33 = load i8*, i8** %7
%34 = load i32, i32* %8
%35 = call i32 @hippo_read_tyc(i8* %33, i32 %34)
%36 = load i8**, i8*** %5
%37 = load i32, i32* @optind
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8*, i8** %36, i64 %38
%40 = load i8*, i8** %39
%41 = call i64 @hippo_write(i32 %35, i8* %40)
%42 = icmp ne i64 %41, 0
br i1 %42, label %43, label %44
43: ; preds = %32
store i32 0, i32* %3
br label %66
44: ; preds = %32, %29
%45 = load i8*, i8** %6
%46 = icmp ne i8* %45, null
br i1 %46, label %47, label %59
47: ; preds = %44
%48 = load i8*, i8** %6
%49 = load i32, i32* %8
%50 = call i32 @hippo_read_hip(i8* %48, i32 %49)
%51 = load i8**, i8*** %5
%52 = load i32, i32* @optind
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8*, i8** %51, i64 %53
%55 = load i8*, i8** %54
%56 = call i64 @hippo_write(i32 %50, i8* %55)
%57 = icmp ne i64 %56, 0
br i1 %57, label %58, label %59
58: ; preds = %47
store i32 0, i32* %3
br label %66
59: ; preds = %47, %44
br label %60
60: ; preds = %59, %25
%61 = load i32, i32* @stderr
%62 = load i8**, i8*** %5
%63 = getelementptr inbounds i8*, i8** %62, i64 0
%64 = load i8*, i8** %63
%65 = call i32 @fprintf(i32 %61, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0), i8* %64)
store i32 1, i32* %3
br label %66
66: ; preds = %60, %58, %43
%67 = load i32, i32* %3
ret i32 %67
}

LLVM IR (-O2):
@opterr = global i64 0
@.str = [7 x i8] c"H:T:d:\00"
@optarg = global i8* null
@optind = global i32 0
@stderr = global i32 0
@.str.1 = [55 x i8] c"Usage: %s [-T tyc2.dat] [-H hip_main.dat] output.riff\0A\00"
define i32 @main(i32 %0, i8** %1) {
store i64 0, i64* @opterr
br label %3
3: ; preds = %16, %2
%4 = phi i8* [ %17, %16 ], [ null, %2 ]
%5 = phi i8* [ %8, %16 ], [ null, %2 ]
%6 = phi i32 [ %11, %16 ], [ 10, %2 ]
br label %7
7: ; preds = %3, %14
%8 = phi i8* [ %5, %3 ], [ %15, %14 ]
%9 = phi i32 [ %6, %3 ], [ %11, %14 ]
br label %10
10: ; preds = %7, %18
%11 = phi i32 [ %9, %7 ], [ %20, %18 ]
br label %12
12: ; preds = %10, %12
%13 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
switch i32 %13, label %12 [
i32 -1, label %21
i32 84, label %14
i32 72, label %16
i32 100, label %18
]
14: ; preds = %12
%15 = load i8*, i8** @optarg
br label %7
16: ; preds = %12
%17 = load i8*, i8** @optarg
br label %3
18: ; preds = %12
%19 = load i8*, i8** @optarg
%20 = tail call i32 @strtol(i8* %19, i32 0, i32 0)
br label %10
21: ; preds = %12
%22 = load i32, i32* @optind
%23 = icmp slt i32 %22, %0
br i1 %23, label %24, label %44
24: ; preds = %21
%25 = icmp eq i8* %8, null
br i1 %25, label %34, label %26
26: ; preds = %24
%27 = tail call i32 @hippo_read_tyc(i8* %8, i32 %11)
%28 = load i32, i32* @optind
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %1, i64 %29
%31 = load i8*, i8** %30
%32 = tail call i64 @hippo_write(i32 %27, i8* %31)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %48
34: ; preds = %26, %24
%35 = icmp eq i8* %4, null
br i1 %35, label %44, label %36
36: ; preds = %34
%37 = tail call i32 @hippo_read_hip(i8* %4, i32 %11)
%38 = load i32, i32* @optind
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8*, i8** %1, i64 %39
%41 = load i8*, i8** %40
%42 = tail call i64 @hippo_write(i32 %37, i8* %41)
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %48
44: ; preds = %34, %36, %21
%45 = load i32, i32* @stderr
%46 = load i8*, i8** %1
%47 = tail call i32 @fprintf(i32 %45, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0), i8* %46)
br label %48
48: ; preds = %36, %26, %44
%49 = phi i32 [ 1, %44 ], [ 0, %26 ], [ 0, %36 ]
ret i32 %49
}