#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*/ ReadWrite(char *, char *, int, int, int, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ *strstr(char *, char *);
int main(int argc, char *argv[]) {
  int inFileBool = 0;
  int outFileBool = 0;
  int in_xtcBool = 0;
  int out_xtcBool = 0;
  int in_trrBool = 0;
  int out_trrBool = 0;
  char *rfile = NULL, *wfile = NULL;
  if (argc != 5) {
    fprintf(stderr, "Usage: %s -i inFile -o outFile\n", argv[0]);
    exit(1);
  } else {
    int ii = 1;
    while (ii < argc) {
      if (strcmp(argv[ii], "-i") == 0) {
        ii++;
        inFileBool = 1;
        if (strstr(argv[ii], ".xtc") != NULL) {
          in_xtcBool = 1;
          in_trrBool = 0;
        }
        if (strstr(argv[ii], ".trr") != NULL) {
          in_trrBool = 1;
          in_xtcBool = 0;
        }
        rfile = argv[ii];
      }
      if (strcmp(argv[ii], "-o") == 0) {
        ii++;
        outFileBool = 1;
        if (strstr(argv[ii], ".xtc") != NULL) {
          out_xtcBool = 1;
          out_trrBool = 0;
        }
        if (strstr(argv[ii], ".trr") != NULL) {
          out_trrBool = 1;
          out_xtcBool = 0;
        }
        wfile = argv[ii];
      }
      ii++;
    }
  }
  if (!inFileBool || !outFileBool) {
    perror("Usage : ./ReadWrite -i inFile -o outFile");
    exit(1);
  }
  ReadWrite(rfile, wfile, in_xtcBool, out_xtcBool, in_trrBool, out_trrBool);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
cmpl   $0x5,-0x8(%rbp)
je     11e0 <main+0x80>
mov    0x2e1f(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe2f(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
movl   $0x1,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1345 <main+0x1e5>
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe1a(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1295 <main+0x135>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdeb(%rip),%rsi
call   1080 <strstr@plt>
cmp    $0x0,%rax
je     1255 <main+0xf5>
movl   $0x1,-0x1c(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdc0(%rip),%rsi
call   1080 <strstr@plt>
cmp    $0x0,%rax
je     1285 <main+0x125>
movl   $0x1,-0x24(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd85(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1337 <main+0x1d7>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd49(%rip),%rsi
call   1080 <strstr@plt>
cmp    $0x0,%rax
je     12f7 <main+0x197>
movl   $0x1,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd1e(%rip),%rsi
call   1080 <strstr@plt>
cmp    $0x0,%rax
je     1327 <main+0x1c7>
movl   $0x1,-0x28(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x38(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11e7 <main+0x87>
jmp    134a <main+0x1ea>
cmpl   $0x0,-0x14(%rbp)
je     135e <main+0x1fe>
cmpl   $0x0,-0x18(%rbp)
jne    1374 <main+0x214>
lea    0xccb(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
mov    -0x24(%rbp),%r8d
mov    -0x28(%rbp),%r9d
call   1060 <ReadWrite@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r15
cmp    $0x5,%edi
jne    1322 <main+0x1c2>
mov    $0x1,%r14d
xor    %eax,%eax
mov    %rax,0x20(%rsp)
xor    %eax,%eax
mov    %rax,0x18(%rsp)
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
movl   $0x0,(%rsp)
movl   $0x0,0x4(%rsp)
movl   $0x0,0x10(%rsp)
movl   $0x0,0x14(%rsp)
jmp    11d1 <main+0x71>
nop
lea    0x1(%r14),%eax
cmp    $0x4,%r14d
mov    %eax,%r14d
jge    12e3 <main+0x183>
movslq %r14d,%rbp
mov    (%r15,%rbp,8),%rdi
lea    0xe41(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11f0 <main+0x90>
mov    (%r15,%rbp,8),%r13
jmp    125b <main+0xfb>
nop
lea    0x1(%rbp),%r14d
mov    0x8(%r15,%rbp,8),%r13
mov    %r13,%rdi
lea    0xe20(%rip),%rsi
call   1080 <strstr@plt>
test   %rax,%rax
mov    $0x1,%eax
mov    0x4(%rsp),%ebx
cmovne %eax,%ebx
mov    0x8(%rsp),%ebp
mov    $0x0,%r12d
cmovne %r12d,%ebp
mov    %r13,%rdi
lea    0xdf9(%rip),%rsi
call   1080 <strstr@plt>
test   %rax,%rax
cmovne %r12d,%ebx
mov    %ebx,0x4(%rsp)
movl   $0x1,0x14(%rsp)
mov    $0x1,%eax
cmovne %eax,%ebp
mov    %ebp,0x8(%rsp)
mov    %r13,%rax
mov    %r13,0x18(%rsp)
mov    %r13,%rdi
lea    0xdc8(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
jne    11c0 <main+0x60>
movslq %r14d,%rax
add    $0x1,%r14d
mov    0x8(%r15,%rax,8),%r13
mov    %r13,%rdi
lea    0xd9a(%rip),%rsi
call   1080 <strstr@plt>
test   %rax,%rax
mov    $0x1,%ecx
mov    (%rsp),%eax
cmovne %ecx,%eax
mov    0xc(%rsp),%ebp
mov    %eax,%ebx
mov    $0x0,%r12d
cmovne %r12d,%ebp
mov    %r13,0x20(%rsp)
mov    %r13,%rdi
lea    0xd6d(%rip),%rsi
call   1080 <strstr@plt>
test   %rax,%rax
cmovne %r12d,%ebx
mov    %ebx,(%rsp)
movl   $0x1,0x10(%rsp)
mov    $0x1,%eax
cmovne %eax,%ebp
mov    %ebp,0xc(%rsp)
jmp    11c0 <main+0x60>
cmpl   $0x0,0x14(%rsp)
je     1344 <main+0x1e4>
cmpl   $0x0,0x10(%rsp)
je     1344 <main+0x1e4>
mov    0x18(%rsp),%rdi
mov    0x20(%rsp),%rsi
mov    0x4(%rsp),%edx
mov    (%rsp),%ecx
mov    0x8(%rsp),%r8d
mov    0xc(%rsp),%r9d
call   1060 <ReadWrite@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2cb7(%rip),%rax
mov    (%rax),%edi
mov    (%r15),%rdx
lea    0xccb(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
lea    0xce5(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [32 x i8] c"Usage: %s -i inFile -o outFile\0A\00"
@.str.1 = [3 x i8] c"-i\00"
@.str.2 = [5 x i8] c".xtc\00"
@.str.3 = [5 x i8] c".trr\00"
@.str.4 = [3 x i8] c"-o\00"
@.str.5 = [41 x i8] c"Usage : ./ReadWrite -i inFile -o outFile\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
store i8* null, i8** %12
store i8* null, i8** %13
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 5
br i1 %16, label %17, label %24
17: ; preds = %2
%18 = load i32, i32* @stderr
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 0
%21 = load i8*, i8** %20
%22 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %21)
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %2
store i32 1, i32* %14
br label %25
25: ; preds = %97, %24
%26 = load i32, i32* %14
%27 = load i32, i32* %4
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %100
29: ; preds = %25
%30 = load i8**, i8*** %5
%31 = load i32, i32* %14
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8*, i8** %30, i64 %32
%34 = load i8*, i8** %33
%35 = call i64 @strcmp(i8* %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %63
37: ; preds = %29
%38 = load i32, i32* %14
%39 = add nsw i32 %38, 1
store i32 %39, i32* %14
store i32 1, i32* %6
%40 = load i8**, i8*** %5
%41 = load i32, i32* %14
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8*, i8** %40, i64 %42
%44 = load i8*, i8** %43
%45 = call i32* @strstr(i8* %44, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%46 = icmp ne i32* %45, null
br i1 %46, label %47, label %48
47: ; preds = %37
store i32 1, i32* %8
store i32 0, i32* %10
br label %48
48: ; preds = %47, %37
%49 = load i8**, i8*** %5
%50 = load i32, i32* %14
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8*, i8** %49, i64 %51
%53 = load i8*, i8** %52
%54 = call i32* @strstr(i8* %53, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%55 = icmp ne i32* %54, null
br i1 %55, label %56, label %57
56: ; preds = %48
store i32 1, i32* %10
store i32 0, i32* %8
br label %57
57: ; preds = %56, %48
%58 = load i8**, i8*** %5
%59 = load i32, i32* %14
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8*, i8** %58, i64 %60
%62 = load i8*, i8** %61
store i8* %62, i8** %12
br label %63
63: ; preds = %57, %29
%64 = load i8**, i8*** %5
%65 = load i32, i32* %14
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i8*, i8** %64, i64 %66
%68 = load i8*, i8** %67
%69 = call i64 @strcmp(i8* %68, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%70 = icmp eq i64 %69, 0
br i1 %70, label %71, label %97
71: ; preds = %63
%72 = load i32, i32* %14
%73 = add nsw i32 %72, 1
store i32 %73, i32* %14
store i32 1, i32* %7
%74 = load i8**, i8*** %5
%75 = load i32, i32* %14
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds i8*, i8** %74, i64 %76
%78 = load i8*, i8** %77
%79 = call i32* @strstr(i8* %78, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%80 = icmp ne i32* %79, null
br i1 %80, label %81, label %82
81: ; preds = %71
store i32 1, i32* %9
store i32 0, i32* %11
br label %82
82: ; preds = %81, %71
%83 = load i8**, i8*** %5
%84 = load i32, i32* %14
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds i8*, i8** %83, i64 %85
%87 = load i8*, i8** %86
%88 = call i32* @strstr(i8* %87, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%89 = icmp ne i32* %88, null
br i1 %89, label %90, label %91
90: ; preds = %82
store i32 1, i32* %11
store i32 0, i32* %9
br label %91
91: ; preds = %90, %82
%92 = load i8**, i8*** %5
%93 = load i32, i32* %14
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds i8*, i8** %92, i64 %94
%96 = load i8*, i8** %95
store i8* %96, i8** %13
br label %97
97: ; preds = %91, %63
%98 = load i32, i32* %14
%99 = add nsw i32 %98, 1
store i32 %99, i32* %14
br label %25
100: ; preds = %25
br label %101
101: ; preds = %100
%102 = load i32, i32* %6
%103 = icmp ne i32 %102, 0
br i1 %103, label %104, label %107
104: ; preds = %101
%105 = load i32, i32* %7
%106 = icmp ne i32 %105, 0
br i1 %106, label %110, label %107
107: ; preds = %104, %101
%108 = call i32 @perror(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0))
%109 = call i32 @exit(i32 1)
unreachable
110: ; preds = %104
%111 = load i8*, i8** %12
%112 = load i8*, i8** %13
%113 = load i32, i32* %8
%114 = load i32, i32* %9
%115 = load i32, i32* %10
%116 = load i32, i32* %11
%117 = call i32 @ReadWrite(i8* %111, i8* %112, i32 %113, i32 %114, i32 %115, i32 %116)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [32 x i8] c"Usage: %s -i inFile -o outFile\0A\00"
@.str.1 = [3 x i8] c"-i\00"
@.str.2 = [5 x i8] c".xtc\00"
@.str.3 = [5 x i8] c".trr\00"
@.str.4 = [3 x i8] c"-o\00"
@.str.5 = [41 x i8] c"Usage : ./ReadWrite -i inFile -o outFile\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 5
br i1 %3, label %9, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2, %61
%10 = phi i32 [ %67, %61 ], [ 1, %2 ]
%11 = phi i8* [ %65, %61 ], [ null, %2 ]
%12 = phi i8* [ %44, %61 ], [ null, %2 ]
%13 = phi i32 [ %64, %61 ], [ 0, %2 ]
%14 = phi i32 [ %43, %61 ], [ 0, %2 ]
%15 = phi i32 [ %63, %61 ], [ 0, %2 ]
%16 = phi i32 [ %42, %61 ], [ 0, %2 ]
%17 = phi i32 [ %62, %61 ], [ 0, %2 ]
%18 = phi i32 [ %41, %61 ], [ 0, %2 ]
%19 = sext i32 %10 to i64
%20 = getelementptr inbounds i8*, i8** %1, i64 %19
%21 = load i8*, i8** %20
%22 = tail call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %26, label %24
24: ; preds = %9
%25 = load i8*, i8** %20
br label %39
26: ; preds = %9
%27 = add nsw i32 %10, 1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %1, i64 %28
%30 = load i8*, i8** %29
%31 = tail call i32* @strstr(i8* dereferenceable(1) %30, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%32 = icmp eq i32* %31, null
%33 = select i1 %32, i32 %16, i32 1
%34 = select i1 %32, i32 %14, i32 0
%35 = tail call i32* @strstr(i8* dereferenceable(1) %30, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%36 = icmp eq i32* %35, null
%37 = select i1 %36, i32 %33, i32 0
%38 = select i1 %36, i32 %34, i32 1
br label %39
39: ; preds = %24, %26
%40 = phi i8* [ %30, %26 ], [ %25, %24 ]
%41 = phi i32 [ 1, %26 ], [ %18, %24 ]
%42 = phi i32 [ %37, %26 ], [ %16, %24 ]
%43 = phi i32 [ %38, %26 ], [ %14, %24 ]
%44 = phi i8* [ %30, %26 ], [ %12, %24 ]
%45 = phi i32 [ %27, %26 ], [ %10, %24 ]
%46 = tail call i64 @strcmp(i8* %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %61
48: ; preds = %39
%49 = add nsw i32 %45, 1
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8*, i8** %1, i64 %50
%52 = load i8*, i8** %51
%53 = tail call i32* @strstr(i8* dereferenceable(1) %52, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%54 = icmp eq i32* %53, null
%55 = select i1 %54, i32 %15, i32 1
%56 = select i1 %54, i32 %13, i32 0
%57 = tail call i32* @strstr(i8* dereferenceable(1) %52, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%58 = icmp eq i32* %57, null
%59 = select i1 %58, i32 %55, i32 0
%60 = select i1 %58, i32 %56, i32 1
br label %61
61: ; preds = %48, %39
%62 = phi i32 [ 1, %48 ], [ %17, %39 ]
%63 = phi i32 [ %59, %48 ], [ %15, %39 ]
%64 = phi i32 [ %60, %48 ], [ %13, %39 ]
%65 = phi i8* [ %52, %48 ], [ %11, %39 ]
%66 = phi i32 [ %49, %48 ], [ %45, %39 ]
%67 = add nsw i32 %66, 1
%68 = icmp slt i32 %66, 4
br i1 %68, label %9, label %69
69: ; preds = %61
%70 = icmp ne i32 %41, 0
%71 = icmp ne i32 %62, 0
%72 = select i1 %70, i1 %71, i1 false
br i1 %72, label %76, label %73
73: ; preds = %69
%74 = tail call i32 @perror(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0))
%75 = tail call i32 @exit(i32 1)
unreachable
76: ; preds = %69
%77 = tail call i32 @ReadWrite(i8* %44, i8* %65, i32 %42, i32 %63, i32 %43, i32 %64)
ret i32 0
}