#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 /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exportAudioFiles(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printInformation(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ replaceAudio(char *, char *, char *, int);
int /*<<< orphan*/ *stdout;
int main(int argc, char **argv) {
  if (argc > 2) {
    switch (argv[1][0]) {
    case 'X':
    case 'x':
      if (argc == 3) {
        exportAudioFiles(argv[2], "", 0);
        return 1;
      } else if (argc == 4) {
        exportAudioFiles(argv[3], argv[2], 0);
        return 1;
      }
      break;
    case 'I':
    case 'i':
      if (argc == 3) {
        printInformation(argv[2], stdout);
        return 1;
      } else if (argc == 4) {
        FILE *fp = fopen(argv[2], "wb");
        printInformation(argv[3], fp);
        fclose(fp);
        return 1;
      }
      break;
    case 'R':
    case 'r':
      if (argc == 5) {
        replaceAudio(argv[4], argv[3], argv[2], 0);
        return 1;
      }
      break;
    case 'N':
    case 'n':
      if (argc == 5) {
        replaceAudio(argv[4], argv[3], argv[2], 1);
        return 1;
      }
      break;
    }
  }
  printf("GME Library\n");
  printf("usage: libtiptoi <mode> [options] <inputfile>\n");
  printf("modes:\n");
  printf("\tx [path] - Extract audio files to [path]\n");
  printf("\tl <filelist> - create audio list\n");
  printf("\ti [outputfile] - print information\n");
  printf("\tr <filelist> <outputfile> - replace audio\n");
  printf("\tn <audiopath> <outputfile> - replace audio with numbers\n");
  return 0;
}


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)
cmpl   $0x2,-0x8(%rbp)
jle    130f <main+0x1af>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
add    $0xffffffb7,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x2f,%eax
ja     130a <main+0x1aa>
mov    -0x20(%rbp),%rax
lea    0xe58(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
cmpl   $0x3,-0x8(%rbp)
jne    11dd <main+0x7d>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xf3c(%rip),%rsi
xor    %edx,%edx
call   1080 <exportAudioFiles@plt>
movl   $0x1,-0x4(%rbp)
jmp    1376 <main+0x216>
cmpl   $0x4,-0x8(%rbp)
jne    120a <main+0xaa>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
xor    %edx,%edx
call   1080 <exportAudioFiles@plt>
movl   $0x1,-0x4(%rbp)
jmp    1376 <main+0x216>
jmp    120f <main+0xaf>
jmp    130a <main+0x1aa>
cmpl   $0x3,-0x8(%rbp)
jne    1241 <main+0xe1>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    0x2db3(%rip),%rax
mov    (%rax),%rsi
call   1060 <printInformation@plt>
movl   $0x1,-0x4(%rbp)
jmp    1376 <main+0x216>
cmpl   $0x4,-0x8(%rbp)
jne    1289 <main+0x129>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe66(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <printInformation@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x1,-0x4(%rbp)
jmp    1376 <main+0x216>
jmp    128e <main+0x12e>
jmp    130a <main+0x1aa>
cmpl   $0x5,-0x8(%rbp)
jne    12c8 <main+0x168>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
xor    %ecx,%ecx
call   1030 <replaceAudio@plt>
movl   $0x1,-0x4(%rbp)
jmp    1376 <main+0x216>
jmp    130a <main+0x1aa>
cmpl   $0x5,-0x8(%rbp)
jne    1305 <main+0x1a5>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
mov    $0x1,%ecx
call   1030 <replaceAudio@plt>
movl   $0x1,-0x4(%rbp)
jmp    1376 <main+0x216>
jmp    130a <main+0x1aa>
jmp    130f <main+0x1af>
lea    0xdad(%rip),%rdi
call   1050 <printf@plt>
lea    0xdae(%rip),%rdi
call   1050 <printf@plt>
lea    0xdd1(%rip),%rdi
call   1050 <printf@plt>
lea    0xdcd(%rip),%rdi
call   1050 <printf@plt>
lea    0xdec(%rip),%rdi
call   1050 <printf@plt>
lea    0xe03(%rip),%rdi
call   1050 <printf@plt>
lea    0xe1c(%rip),%rdi
call   1050 <printf@plt>
lea    0xe3c(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x3,%edi
jl     1227 <main+0xc7>
mov    %rsi,%rbx
mov    0x8(%rsi),%rax
movsbl (%rax),%eax
add    $0xffffffb7,%eax
cmp    $0x2f,%eax
ja     1227 <main+0xc7>
lea    0xe76(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
cmp    $0x4,%edi
je     1293 <main+0x133>
cmp    $0x3,%edi
jne    1227 <main+0xc7>
mov    0x10(%rbx),%rdi
mov    0x2e30(%rip),%rax
mov    (%rax),%rsi
call   1060 <printInformation@plt>
mov    $0x1,%ebx
jmp    1289 <main+0x129>
cmp    $0x5,%edi
jne    1227 <main+0xc7>
mov    0x20(%rbx),%rdi
mov    0x10(%rbx),%rdx
mov    0x18(%rbx),%rsi
mov    $0x1,%ebx
mov    $0x1,%ecx
call   1030 <replaceAudio@plt>
jmp    1289 <main+0x129>
cmp    $0x5,%edi
jne    1227 <main+0xc7>
mov    0x20(%rbx),%rdi
mov    0x10(%rbx),%rdx
mov    0x18(%rbx),%rsi
xor    %ecx,%ecx
call   1030 <replaceAudio@plt>
mov    $0x1,%ebx
jmp    1289 <main+0x129>
cmp    $0x4,%edi
je     12c1 <main+0x161>
cmp    $0x3,%edi
jne    1227 <main+0xc7>
mov    0x10(%rbx),%rdi
lea    0xee1(%rip),%rsi
jmp    12c9 <main+0x169>
lea    0xe95(%rip),%rdi
call   1040 <puts@plt>
lea    0xe95(%rip),%rdi
call   1040 <puts@plt>
lea    0xeb7(%rip),%rdi
call   1040 <puts@plt>
lea    0xeb2(%rip),%rdi
call   1040 <puts@plt>
lea    0xed0(%rip),%rdi
call   1040 <puts@plt>
lea    0xee6(%rip),%rdi
call   1040 <puts@plt>
lea    0xefe(%rip),%rdi
call   1040 <puts@plt>
lea    0xf1d(%rip),%rdi
call   1040 <puts@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x10(%rbx),%rdi
lea    0xe22(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r14
mov    0x18(%rbx),%rdi
mov    %rax,%rsi
call   1060 <printInformation@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    $0x1,%ebx
jmp    1289 <main+0x129>
mov    0x10(%rbx),%rsi
mov    0x18(%rbx),%rdi
xor    %edx,%edx
call   1080 <exportAudioFiles@plt>
mov    $0x1,%ebx
jmp    1289 <main+0x129>

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@stdout = global i32* null
@.str.1 = [3 x i8] c"wb\00"
@.str.2 = [13 x i8] c"GME Library\0A\00"
@.str.3 = [47 x i8] c"usage: libtiptoi <mode> [options] <inputfile>\0A\00"
@.str.4 = [8 x i8] c"modes:\0A\00"
@.str.5 = [43 x i8] c"\09x [path] - Extract audio files to [path]\0A\00"
@.str.6 = [35 x i8] c"\09l <filelist> - create audio list\0A\00"
@.str.7 = [37 x i8] c"\09i [outputfile] - print information\0A\00"
@.str.8 = [44 x i8] c"\09r <filelist> <outputfile> - replace audio\0A\00"
@.str.9 = [58 x i8] c"\09n <audiopath> <outputfile> - replace audio with numbers\0A\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
%7 = load i32, i32* %4
%8 = icmp sgt i32 %7, 2
br i1 %8, label %9, label %94
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = getelementptr inbounds i8, i8* %12, i64 0
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
switch i32 %15, label %93 [
i32 88, label %16
i32 120, label %16
i32 73, label %37
i32 105, label %37
i32 82, label %63
i32 114, label %63
i32 78, label %78
i32 110, label %78
]
16: ; preds = %9, %9
%17 = load i32, i32* %4
%18 = icmp eq i32 %17, 3
br i1 %18, label %19, label %24
19: ; preds = %16
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 2
%22 = load i8*, i8** %21
%23 = call i32 @exportAudioFiles(i8* %22, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i32 0)
store i32 1, i32* %3
br label %103
24: ; preds = %16
%25 = load i32, i32* %4
%26 = icmp eq i32 %25, 4
br i1 %26, label %27, label %35
27: ; preds = %24
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 3
%30 = load i8*, i8** %29
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 2
%33 = load i8*, i8** %32
%34 = call i32 @exportAudioFiles(i8* %30, i8* %33, i32 0)
store i32 1, i32* %3
br label %103
35: ; preds = %24
br label %36
36: ; preds = %35
br label %93
37: ; preds = %9, %9
%38 = load i32, i32* %4
%39 = icmp eq i32 %38, 3
br i1 %39, label %40, label %46
40: ; preds = %37
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 2
%43 = load i8*, i8** %42
%44 = load i32*, i32** @stdout
%45 = call i32 @printInformation(i8* %43, i32* %44)
store i32 1, i32* %3
br label %103
46: ; preds = %37
%47 = load i32, i32* %4
%48 = icmp eq i32 %47, 4
br i1 %48, label %49, label %61
49: ; preds = %46
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 2
%52 = load i8*, i8** %51
%53 = call i32* @fopen(i8* %52, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %53, i32** %6
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 3
%56 = load i8*, i8** %55
%57 = load i32*, i32** %6
%58 = call i32 @printInformation(i8* %56, i32* %57)
%59 = load i32*, i32** %6
%60 = call i32 @fclose(i32* %59)
store i32 1, i32* %3
br label %103
61: ; preds = %46
br label %62
62: ; preds = %61
br label %93
63: ; preds = %9, %9
%64 = load i32, i32* %4
%65 = icmp eq i32 %64, 5
br i1 %65, label %66, label %77
66: ; preds = %63
%67 = load i8**, i8*** %5
%68 = getelementptr inbounds i8*, i8** %67, i64 4
%69 = load i8*, i8** %68
%70 = load i8**, i8*** %5
%71 = getelementptr inbounds i8*, i8** %70, i64 3
%72 = load i8*, i8** %71
%73 = load i8**, i8*** %5
%74 = getelementptr inbounds i8*, i8** %73, i64 2
%75 = load i8*, i8** %74
%76 = call i32 @replaceAudio(i8* %69, i8* %72, i8* %75, i32 0)
store i32 1, i32* %3
br label %103
77: ; preds = %63
br label %93
78: ; preds = %9, %9
%79 = load i32, i32* %4
%80 = icmp eq i32 %79, 5
br i1 %80, label %81, label %92
81: ; preds = %78
%82 = load i8**, i8*** %5
%83 = getelementptr inbounds i8*, i8** %82, i64 4
%84 = load i8*, i8** %83
%85 = load i8**, i8*** %5
%86 = getelementptr inbounds i8*, i8** %85, i64 3
%87 = load i8*, i8** %86
%88 = load i8**, i8*** %5
%89 = getelementptr inbounds i8*, i8** %88, i64 2
%90 = load i8*, i8** %89
%91 = call i32 @replaceAudio(i8* %84, i8* %87, i8* %90, i32 1)
store i32 1, i32* %3
br label %103
92: ; preds = %78
br label %93
93: ; preds = %9, %92, %77, %62, %36
br label %94
94: ; preds = %93, %2
%95 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%96 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0))
%97 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%98 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0))
%99 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0))
%100 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0))
%101 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.8, i64 0, i64 0))
%102 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.9, i64 0, i64 0))
store i32 0, i32* %3
br label %103
103: ; preds = %94, %81, %66, %49, %40, %27, %19
%104 = load i32, i32* %3
ret i32 %104
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@stdout = global i32* null
@.str.1 = [3 x i8] c"wb\00"
@str = [12 x i8] c"GME Library\00"
@str.10 = [46 x i8] c"usage: libtiptoi <mode> [options] <inputfile>\00"
@str.11 = [7 x i8] c"modes:\00"
@str.12 = [42 x i8] c"\09x [path] - Extract audio files to [path]\00"
@str.13 = [34 x i8] c"\09l <filelist> - create audio list\00"
@str.14 = [36 x i8] c"\09i [outputfile] - print information\00"
@str.15 = [43 x i8] c"\09r <filelist> <outputfile> - replace audio\00"
@str.16 = [57 x i8] c"\09n <audiopath> <outputfile> - replace audio with numbers\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 2
br i1 %3, label %4, label %54
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
switch i32 %8, label %54 [
i32 88, label %9
i32 120, label %9
i32 73, label %20
i32 105, label %20
i32 82, label %34
i32 114, label %34
i32 78, label %44
i32 110, label %44
]
9: ; preds = %4, %4
switch i32 %0, label %54 [
i32 3, label %10
i32 4, label %14
]
10: ; preds = %9
%11 = getelementptr inbounds i8*, i8** %1, i64 2
%12 = load i8*, i8** %11
%13 = tail call i32 @exportAudioFiles(i8* %12, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i32 0)
br label %63
14: ; preds = %9
%15 = getelementptr inbounds i8*, i8** %1, i64 3
%16 = load i8*, i8** %15
%17 = getelementptr inbounds i8*, i8** %1, i64 2
%18 = load i8*, i8** %17
%19 = tail call i32 @exportAudioFiles(i8* %16, i8* %18, i32 0)
br label %63
20: ; preds = %4, %4
switch i32 %0, label %54 [
i32 3, label %21
i32 4, label %26
]
21: ; preds = %20
%22 = getelementptr inbounds i8*, i8** %1, i64 2
%23 = load i8*, i8** %22
%24 = load i32*, i32** @stdout
%25 = tail call i32 @printInformation(i8* %23, i32* %24)
br label %63
26: ; preds = %20
%27 = getelementptr inbounds i8*, i8** %1, i64 2
%28 = load i8*, i8** %27
%29 = tail call i32* @fopen(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%30 = getelementptr inbounds i8*, i8** %1, i64 3
%31 = load i8*, i8** %30
%32 = tail call i32 @printInformation(i8* %31, i32* %29)
%33 = tail call i32 @fclose(i32* %29)
br label %63
34: ; preds = %4, %4
%35 = icmp eq i32 %0, 5
br i1 %35, label %36, label %54
36: ; preds = %34
%37 = getelementptr inbounds i8*, i8** %1, i64 4
%38 = load i8*, i8** %37
%39 = getelementptr inbounds i8*, i8** %1, i64 3
%40 = load i8*, i8** %39
%41 = getelementptr inbounds i8*, i8** %1, i64 2
%42 = load i8*, i8** %41
%43 = tail call i32 @replaceAudio(i8* %38, i8* %40, i8* %42, i32 0)
br label %63
44: ; preds = %4, %4
%45 = icmp eq i32 %0, 5
br i1 %45, label %46, label %54
46: ; preds = %44
%47 = getelementptr inbounds i8*, i8** %1, i64 4
%48 = load i8*, i8** %47
%49 = getelementptr inbounds i8*, i8** %1, i64 3
%50 = load i8*, i8** %49
%51 = getelementptr inbounds i8*, i8** %1, i64 2
%52 = load i8*, i8** %51
%53 = tail call i32 @replaceAudio(i8* %48, i8* %50, i8* %52, i32 1)
br label %63
54: ; preds = %20, %9, %4, %34, %44, %2
%55 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%56 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.10, i64 0, i64 0))
%57 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.11, i64 0, i64 0))
%58 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.12, i64 0, i64 0))
%59 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.13, i64 0, i64 0))
%60 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.14, i64 0, i64 0))
%61 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.15, i64 0, i64 0))
%62 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str.16, i64 0, i64 0))
br label %63
63: ; preds = %54, %46, %36, %26, %21, %14, %10
%64 = phi i32 [ 0, %54 ], [ 1, %46 ], [ 1, %36 ], [ 1, %21 ], [ 1, %26 ], [ 1, %10 ], [ 1, %14 ]
ret i32 %64
}