#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*/ BuildCueFile(char *, char *);
int /*<<< orphan*/ IsISOValid(char *);
int /*<<< orphan*/ Iso2Raw(char *, char *);
int /*<<< orphan*/ PatchIso(char *, char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ init_tables();
char *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main(int argc, char *argv[]) {
  char *licFile;
  char *isoFile;
  char *temp;
  char *infile;
  char *cueFile;
  char *rawFile;
  int licence = 1;
  printf("---------------------------------\n");
  printf("ISO9660 2048->2352 converter tool\n");
  printf("---------------------------------\n\n");
  if (argc < 2) {
    printf("Wrong number of argument.\n\tUsage: iso2raw licence "
           "isofile.iso\n\t\tIf you don't want to merge a licence file, write "
           "nolicence\n");
    exit(1);
  }
  infile = malloc(1024);
  strcpy(infile, argv[2]);
  printf("Input file: %s\n", infile);
  rawFile = malloc(1024);
  strcpy(rawFile, infile);
  strcat(rawFile, ".bin");
  printf("Output file: %s\n", rawFile);
  cueFile = malloc(1024);
  strcpy(cueFile, infile);
  strcat(cueFile, ".cue");
  printf("Cue file: %s\n", cueFile);
  if (!strcmp(argv[1], "nolicence"))
    licence = 0;
  else {
    licFile = argv[1];
    printf("Licence file: %s\n", licFile);
  }
  if (!IsISOValid(infile))
    exit(1);
  init_tables();
  if (!Iso2Raw(infile, rawFile))
    exit(1);
  if (licence)
    if (!PatchIso(licFile, rawFile))
      exit(1);
  if (!BuildCueFile(rawFile, cueFile))
    exit(1);
  printf("Done \"%s\".\n", cueFile);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x44(%rbp)
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x2,-0x8(%rbp)
jge    1219 <main+0x69>
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    $0x400,%edi
call   1080 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1030 <strcpy@plt>
mov    -0x30(%rbp),%rsi
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x400,%edi
call   1080 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x40(%rbp),%rdi
lea    0xe86(%rip),%rsi
call   10b0 <strcat@plt>
mov    -0x40(%rbp),%rsi
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x400,%edi
call   1080 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x38(%rbp),%rdi
lea    0xe5f(%rip),%rsi
call   10b0 <strcat@plt>
mov    -0x38(%rbp),%rsi
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe4c(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    12ed <main+0x13d>
movl   $0x0,-0x44(%rbp)
jmp    130b <main+0x15b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x30(%rbp),%rdi
call   1090 <IsISOValid@plt>
cmp    $0x0,%eax
jne    1327 <main+0x177>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    $0x0,%al
call   10d0 <init_tables@plt>
mov    -0x30(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1040 <Iso2Raw@plt>
cmp    $0x0,%eax
jne    134e <main+0x19e>
mov    $0x1,%edi
call   10c0 <exit@plt>
cmpl   $0x0,-0x44(%rbp)
je     137d <main+0x1cd>
mov    -0x18(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   10a0 <PatchIso@plt>
cmp    $0x0,%eax
jne    1378 <main+0x1c8>
mov    $0x1,%edi
call   10c0 <exit@plt>
jmp    137d <main+0x1cd>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1070 <BuildCueFile@plt>
cmp    $0x0,%eax
jne    139d <main+0x1ed>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x38(%rbp),%rsi
lea    0xd93(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r12
mov    %edi,%ebx
lea    0xe83(%rip),%rdi
call   1040 <puts@plt>
lea    0xe99(%rip),%rdi
call   1040 <puts@plt>
lea    0xeaf(%rip),%rdi
call   1040 <puts@plt>
cmp    $0x1,%ebx
jle    1320 <main+0x160>
mov    $0x400,%edi
call   1090 <malloc@plt>
mov    %rax,%rbx
mov    0x10(%r12),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
lea    0xde5(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x400,%edi
call   1090 <malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
lea    0xdcc(%rip),%rsi
mov    %r14,%rdi
call   10c0 <strcat@plt>
lea    0xdc2(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x400,%edi
call   1090 <malloc@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
lea    0xdaa(%rip),%rsi
mov    %r15,%rdi
call   10c0 <strcat@plt>
lea    0xda0(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x8(%r12),%r12
lea    0xe8e(%rip),%rsi
mov    %r12,%rdi
call   1070 <strcmp@plt>
mov    %eax,%ebp
test   %eax,%eax
je     12c0 <main+0x100>
lea    0xd83(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   10a0 <IsISOValid@plt>
test   %eax,%eax
je     132c <main+0x16c>
xor    %eax,%eax
call   10e0 <init_tables@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <Iso2Raw@plt>
test   %eax,%eax
je     132c <main+0x16c>
test   %ebp,%ebp
je     12f5 <main+0x135>
mov    %r12,%rdi
mov    %r14,%rsi
call   10b0 <PatchIso@plt>
test   %eax,%eax
je     132c <main+0x16c>
mov    %r14,%rdi
mov    %r15,%rsi
call   1080 <BuildCueFile@plt>
test   %eax,%eax
je     132c <main+0x16c>
lea    0xd40(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd97(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
@.str = [35 x i8] c"---------------------------------\0A\00"
@.str.1 = [35 x i8] c"ISO9660 2048->2352 converter tool\0A\00"
@.str.2 = [36 x i8] c"---------------------------------\0A\0A\00"
@.str.3 = [124 x i8] c"Wrong number of argument.\0A\09Usage: iso2raw licence isofile.iso\0A\09\09If you don't want to merge a licence file, write nolicence\0A\00"
@.str.4 = [16 x i8] c"Input file: %s\0A\00"
@.str.5 = [5 x i8] c".bin\00"
@.str.6 = [17 x i8] c"Output file: %s\0A\00"
@.str.7 = [5 x i8] c".cue\00"
@.str.8 = [14 x i8] c"Cue file: %s\0A\00"
@.str.9 = [10 x i8] c"nolicence\00"
@.str.10 = [18 x i8] c"Licence file: %s\0A\00"
@.str.11 = [12 x i8] c"Done \22%s\22.\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 i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %12
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
%16 = load i32, i32* %4
%17 = icmp slt i32 %16, 2
br i1 %17, label %18, label %21
18: ; preds = %2
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([124 x i8], [124 x i8]* @.str.3, i64 0, i64 0))
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %2
%22 = call i8* @malloc(i32 1024)
store i8* %22, i8** %9
%23 = load i8*, i8** %9
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
%27 = call i32 @strcpy(i8* %23, i8* %26)
%28 = load i8*, i8** %9
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8* %28)
%30 = call i8* @malloc(i32 1024)
store i8* %30, i8** %11
%31 = load i8*, i8** %11
%32 = load i8*, i8** %9
%33 = call i32 @strcpy(i8* %31, i8* %32)
%34 = load i8*, i8** %11
%35 = call i32 @strcat(i8* %34, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%36 = load i8*, i8** %11
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i8* %36)
%38 = call i8* @malloc(i32 1024)
store i8* %38, i8** %10
%39 = load i8*, i8** %10
%40 = load i8*, i8** %9
%41 = call i32 @strcpy(i8* %39, i8* %40)
%42 = load i8*, i8** %10
%43 = call i32 @strcat(i8* %42, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%44 = load i8*, i8** %10
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0), i8* %44)
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 1
%48 = load i8*, i8** %47
%49 = call i32 @strcmp(i8* %48, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0))
%50 = icmp ne i32 %49, 0
br i1 %50, label %52, label %51
51: ; preds = %21
store i32 0, i32* %12
br label %58
52: ; preds = %21
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 1
%55 = load i8*, i8** %54
store i8* %55, i8** %6
%56 = load i8*, i8** %6
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0), i8* %56)
br label %58
58: ; preds = %52, %51
%59 = load i8*, i8** %9
%60 = call i32 @IsISOValid(i8* %59)
%61 = icmp ne i32 %60, 0
br i1 %61, label %64, label %62
62: ; preds = %58
%63 = call i32 @exit(i32 1)
unreachable
64: ; preds = %58
%65 = call i32 (...) @init_tables()
%66 = load i8*, i8** %9
%67 = load i8*, i8** %11
%68 = call i32 @Iso2Raw(i8* %66, i8* %67)
%69 = icmp ne i32 %68, 0
br i1 %69, label %72, label %70
70: ; preds = %64
%71 = call i32 @exit(i32 1)
unreachable
72: ; preds = %64
%73 = load i32, i32* %12
%74 = icmp ne i32 %73, 0
br i1 %74, label %75, label %83
75: ; preds = %72
%76 = load i8*, i8** %6
%77 = load i8*, i8** %11
%78 = call i32 @PatchIso(i8* %76, i8* %77)
%79 = icmp ne i32 %78, 0
br i1 %79, label %82, label %80
80: ; preds = %75
%81 = call i32 @exit(i32 1)
unreachable
82: ; preds = %75
br label %83
83: ; preds = %82, %72
%84 = load i8*, i8** %11
%85 = load i8*, i8** %10
%86 = call i32 @BuildCueFile(i8* %84, i8* %85)
%87 = icmp ne i32 %86, 0
br i1 %87, label %90, label %88
88: ; preds = %83
%89 = call i32 @exit(i32 1)
unreachable
90: ; preds = %83
%91 = load i8*, i8** %10
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0), i8* %91)
%93 = load i32, i32* %3
ret i32 %93
}

LLVM IR (-O2):
@.str.4 = [16 x i8] c"Input file: %s\0A\00"
@.str.5 = [5 x i8] c".bin\00"
@.str.6 = [17 x i8] c"Output file: %s\0A\00"
@.str.7 = [5 x i8] c".cue\00"
@.str.8 = [14 x i8] c"Cue file: %s\0A\00"
@.str.9 = [10 x i8] c"nolicence\00"
@.str.10 = [18 x i8] c"Licence file: %s\0A\00"
@.str.11 = [12 x i8] c"Done \22%s\22.\0A\00"
@str = [34 x i8] c"---------------------------------\00"
@str.12 = [34 x i8] c"ISO9660 2048->2352 converter tool\00"
@str.13 = [35 x i8] c"---------------------------------\0A\00"
@str.14 = [123 x i8] c"Wrong number of argument.\0A\09Usage: iso2raw licence isofile.iso\0A\09\09If you don't want to merge a licence file, write nolicence\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.12, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.13, i64 0, i64 0))
%6 = icmp slt i32 %0, 2
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([123 x i8], [123 x i8]* @str.14, i64 0, i64 0))
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %2
%11 = tail call dereferenceable_or_null(1024) i8* @malloc(i32 1024)
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = tail call i32 @strcpy(i8* %11, i8* %13)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8* %11)
%16 = tail call dereferenceable_or_null(1024) i8* @malloc(i32 1024)
%17 = tail call i32 @strcpy(i8* %16, i8* %11)
%18 = tail call i32 @strcat(i8* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i8* %16)
%20 = tail call dereferenceable_or_null(1024) i8* @malloc(i32 1024)
%21 = tail call i32 @strcpy(i8* %20, i8* %11)
%22 = tail call i32 @strcat(i8* %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0), i8* %20)
%24 = getelementptr inbounds i8*, i8** %1, i64 1
%25 = load i8*, i8** %24
%26 = tail call i32 @strcmp(i8* dereferenceable(1) %25, i8* dereferenceable(10) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0))
%27 = icmp eq i32 %26, 0
br i1 %27, label %30, label %28
28: ; preds = %10
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0), i8* %25)
br label %30
30: ; preds = %10, %28
%31 = tail call i32 @IsISOValid(i8* %11)
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = tail call i32 @exit(i32 1)
unreachable
35: ; preds = %30
%36 = tail call i32 (...) @init_tables()
%37 = tail call i32 @Iso2Raw(i8* %11, i8* %16)
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %35
%40 = tail call i32 @exit(i32 1)
unreachable
41: ; preds = %35
br i1 %27, label %47, label %42
42: ; preds = %41
%43 = tail call i32 @PatchIso(i8* %25, i8* %16)
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %42
%46 = tail call i32 @exit(i32 1)
unreachable
47: ; preds = %42, %41
%48 = tail call i32 @BuildCueFile(i8* %16, i8* %20)
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %52
50: ; preds = %47
%51 = tail call i32 @exit(i32 1)
unreachable
52: ; preds = %47
%53 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0), i8* %20)
ret i32 0
}