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

/* Variables and functions */
int /*<<< orphan*/ chartoByte(char, char *);
float decodeFloat(char *);
int decodeIntsixteen(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char, char, float,
                           int);
int myAtoi(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *, char *, int);
int main(int argc, char *argv[]) {
  int trial = myAtoi(argv[3]);
  printf("\n%d\n", trial);
  char input[50];
  char output[50];
  sprintf(input, "%s/%s_Subject_%s.%d_data.txt", argv[1], argv[1], argv[2],
          trial);
  sprintf(output, "%s/%s_Subject_%s.%d_Res.txt", argv[1], argv[1], argv[2],
          trial);
  printf("%s", input);
  printf("%s\n", output);
  FILE *logFile = fopen(input, "rb");
  FILE *decodedFile = fopen(output, "wb");
  char tapbuzz[8];
  float time = 0;
  int16_t encoder_counts = 0;
  char buff[7];
  int skip = myAtoi(argv[4]);
  for (int i = 0; i < skip; i++) {
    fgetc(logFile);
  }
  while (!feof(logFile)) {
    for (int i = 0; i < 7; i++) {
      buff[i] = fgetc(logFile);
    }
    chartoByte(buff[0], tapbuzz);
    time = decodeFloat(&(buff[1]));
    encoder_counts = decodeIntsixteen(&(buff[5]));
    fprintf(decodedFile, "%c %c %f %d\n", tapbuzz[0], tapbuzz[1], time,
            encoder_counts);
  }
  fclose(logFile);
  fclose(decodedFile);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   10d0 <myAtoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x50(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%r8
mov    -0x14(%rbp),%r9d
lea    0xdf4(%rip),%rsi
call   10c0 <sprintf@plt>
lea    -0x90(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%r8
mov    -0x14(%rbp),%r9d
lea    0xde2(%rip),%rsi
call   10c0 <sprintf@plt>
lea    -0x50(%rbp),%rsi
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x90(%rbp),%rsi
lea    0xddc(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x50(%rbp),%rdi
lea    0xdce(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x98(%rbp)
lea    -0x90(%rbp),%rdi
lea    0xdb7(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0xa0(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xac(%rbp)
ff
movl   $0x0,-0xb0(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   10d0 <myAtoi@plt>
mov    %eax,-0xbc(%rbp)
movl   $0x0,-0xc0(%rbp)
mov    -0xc0(%rbp),%eax
cmp    -0xbc(%rbp),%eax
jge    1301 <main+0x151>
mov    -0x98(%rbp),%rdi
call   1070 <fgetc@plt>
mov    -0xc0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc0(%rbp)
jmp    12cf <main+0x11f>
jmp    1306 <main+0x156>
mov    -0x98(%rbp),%rdi
call   10a0 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1327 <main+0x177>
jmp    13ea <main+0x23a>
movl   $0x0,-0xc4(%rbp)
cmpl   $0x7,-0xc4(%rbp)
jge    136e <main+0x1be>
mov    -0x98(%rbp),%rdi
call   1070 <fgetc@plt>
mov    %al,%cl
movslq -0xc4(%rbp),%rax
mov    %cl,-0xb7(%rbp,%rax,1)
mov    -0xc4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc4(%rbp)
jmp    1331 <main+0x181>
mov    -0xb7(%rbp),%al
lea    -0xa8(%rbp),%rsi
movsbl %al,%edi
call   1050 <chartoByte@plt>
lea    -0xb7(%rbp),%rdi
add    $0x1,%rdi
call   1080 <decodeFloat@plt>
movss  %xmm0,-0xac(%rbp)
ff
lea    -0xb7(%rbp),%rdi
add    $0x5,%rdi
call   1040 <decodeIntsixteen@plt>
mov    %eax,-0xb0(%rbp)
mov    -0xa0(%rbp),%rdi
mov    -0xa8(%rbp),%cl
mov    -0xa7(%rbp),%al
movss  -0xac(%rbp),%xmm0
ff
mov    -0xb0(%rbp),%r8d
lea    0xc71(%rip),%rsi
movsbl %cl,%edx
movsbl %al,%ecx
call   1090 <fprintf@plt>
jmp    1306 <main+0x156>
mov    -0x98(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0xa0(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %rsi,%rbp
mov    0x18(%rsi),%rdi
call   10e0 <myAtoi@plt>
mov    %eax,%ebx
lea    0xe1a(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x8(%rbp),%rcx
mov    0x10(%rbp),%r8
lea    0xe07(%rip),%rsi
lea    0x60(%rsp),%r14
mov    %r14,%rdi
mov    %rcx,%rdx
mov    %ebx,%r9d
call   10d0 <sprintf@plt>
mov    0x8(%rbp),%rcx
mov    0x10(%rbp),%r8
lea    0xe02(%rip),%rsi
lea    0x20(%rsp),%r15
mov    %r15,%rdi
mov    %rcx,%rdx
mov    %ebx,%r9d
call   10d0 <sprintf@plt>
lea    0xe04(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
lea    0xdee(%rip),%rsi
mov    %r14,%rdi
call   10c0 <fopen@plt>
mov    %rax,%rbx
lea    0xddf(%rip),%rsi
mov    %r15,%rdi
call   10c0 <fopen@plt>
mov    %rax,%r14
mov    0x20(%rbp),%rdi
call   10e0 <myAtoi@plt>
test   %eax,%eax
jle    128d <main+0xcd>
mov    %eax,%ebp
nop
mov    %rbx,%rdi
call   1080 <fgetc@plt>
add    $0xffffffff,%ebp
jne    1280 <main+0xc0>
mov    %rbx,%rdi
call   10b0 <feof@plt>
test   %eax,%eax
jne    1365 <main+0x1a5>
lea    0xe(%rsp),%r15
lea    0x12(%rsp),%r12
lea    0x18(%rsp),%r13
lea    0xd94(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
call   1080 <fgetc@plt>
mov    %al,0xd(%rsp)
mov    %rbx,%rdi
call   1080 <fgetc@plt>
mov    %al,0xe(%rsp)
mov    %rbx,%rdi
call   1080 <fgetc@plt>
mov    %al,0xf(%rsp)
mov    %rbx,%rdi
call   1080 <fgetc@plt>
mov    %al,0x10(%rsp)
mov    %rbx,%rdi
call   1080 <fgetc@plt>
mov    %al,0x11(%rsp)
mov    %rbx,%rdi
call   1080 <fgetc@plt>
mov    %al,0x12(%rsp)
mov    %rbx,%rdi
call   1080 <fgetc@plt>
mov    %al,0x13(%rsp)
movsbl 0xd(%rsp),%edi
mov    %r13,%rsi
call   1060 <chartoByte@plt>
mov    %r15,%rdi
call   1090 <decodeFloat@plt>
movss  %xmm0,0x14(%rsp)
mov    %r12,%rdi
call   1050 <decodeIntsixteen@plt>
movsbl 0x18(%rsp),%edx
movsbl 0x19(%rsp),%ecx
mov    %r14,%rdi
mov    %rbp,%rsi
movss  0x14(%rsp),%xmm0
mov    %eax,%r8d
call   10a0 <fprintf@plt>
mov    %rbx,%rdi
call   10b0 <feof@plt>
test   %eax,%eax
je     12c0 <main+0x100>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"\0A%d\0A\00"
@.str.1 = [29 x i8] c"%s/%s_Subject_%s.%d_data.txt\00"
@.str.2 = [28 x i8] c"%s/%s_Subject_%s.%d_Res.txt\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [4 x i8] c"%s\0A\00"
@.str.5 = [3 x i8] c"rb\00"
@.str.6 = [3 x i8] c"wb\00"
@.str.7 = [13 x i8] c"%c %c %f %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [50 x i8]
%8 = alloca [50 x i8]
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca [8 x i8]
%12 = alloca float
%13 = alloca i32
%14 = alloca [7 x i8]
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 3
%20 = load i8*, i8** %19
%21 = call i32 @myAtoi(i8* %20)
store i32 %21, i32* %6
%22 = load i32, i32* %6
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %22)
%24 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 2
%33 = load i8*, i8** %32
%34 = load i32, i32* %6
%35 = call i32 @sprintf(i8* %24, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %27, i8* %30, i8* %33, i32 %34)
%36 = getelementptr inbounds [50 x i8], [50 x i8]* %8, i64 0, i64 0
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 1
%39 = load i8*, i8** %38
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 1
%42 = load i8*, i8** %41
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 2
%45 = load i8*, i8** %44
%46 = load i32, i32* %6
%47 = call i32 @sprintf(i8* %36, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %39, i8* %42, i8* %45, i32 %46)
%48 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %48)
%50 = getelementptr inbounds [50 x i8], [50 x i8]* %8, i64 0, i64 0
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %50)
%52 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%53 = call i32* @fopen(i8* %52, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
store i32* %53, i32** %9
%54 = getelementptr inbounds [50 x i8], [50 x i8]* %8, i64 0, i64 0
%55 = call i32* @fopen(i8* %54, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
store i32* %55, i32** %10
store float 0.000000e+00, float* %12
store i32 0, i32* %13
%56 = load i8**, i8*** %5
%57 = getelementptr inbounds i8*, i8** %56, i64 4
%58 = load i8*, i8** %57
%59 = call i32 @myAtoi(i8* %58)
store i32 %59, i32* %15
store i32 0, i32* %16
br label %60
60: ; preds = %67, %2
%61 = load i32, i32* %16
%62 = load i32, i32* %15
%63 = icmp slt i32 %61, %62
br i1 %63, label %64, label %70
64: ; preds = %60
%65 = load i32*, i32** %9
%66 = call signext i8 @fgetc(i32* %65)
br label %67
67: ; preds = %64
%68 = load i32, i32* %16
%69 = add nsw i32 %68, 1
store i32 %69, i32* %16
br label %60
70: ; preds = %60
br label %71
71: ; preds = %89, %70
%72 = load i32*, i32** %9
%73 = call i32 @feof(i32* %72)
%74 = icmp ne i32 %73, 0
%75 = xor i1 %74, true
br i1 %75, label %76, label %106
76: ; preds = %71
store i32 0, i32* %17
br label %77
77: ; preds = %86, %76
%78 = load i32, i32* %17
%79 = icmp slt i32 %78, 7
br i1 %79, label %80, label %89
80: ; preds = %77
%81 = load i32*, i32** %9
%82 = call signext i8 @fgetc(i32* %81)
%83 = load i32, i32* %17
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds [7 x i8], [7 x i8]* %14, i64 0, i64 %84
store i8 %82, i8* %85
br label %86
86: ; preds = %80
%87 = load i32, i32* %17
%88 = add nsw i32 %87, 1
store i32 %88, i32* %17
br label %77
89: ; preds = %77
%90 = getelementptr inbounds [7 x i8], [7 x i8]* %14, i64 0, i64 0
%91 = load i8, i8* %90
%92 = getelementptr inbounds [8 x i8], [8 x i8]* %11, i64 0, i64 0
%93 = call i32 @chartoByte(i8 signext %91, i8* %92)
%94 = getelementptr inbounds [7 x i8], [7 x i8]* %14, i64 0, i64 1
%95 = call float @decodeFloat(i8* %94)
store float %95, float* %12
%96 = getelementptr inbounds [7 x i8], [7 x i8]* %14, i64 0, i64 5
%97 = call i32 @decodeIntsixteen(i8* %96)
store i32 %97, i32* %13
%98 = load i32*, i32** %10
%99 = getelementptr inbounds [8 x i8], [8 x i8]* %11, i64 0, i64 0
%100 = load i8, i8* %99
%101 = getelementptr inbounds [8 x i8], [8 x i8]* %11, i64 0, i64 1
%102 = load i8, i8* %101
%103 = load float, float* %12
%104 = load i32, i32* %13
%105 = call i32 @fprintf(i32* %98, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8 signext %100, i8 signext %102, float %103, i32 %104)
br label %71
106: ; preds = %71
%107 = load i32*, i32** %9
%108 = call i32 @fclose(i32* %107)
%109 = load i32*, i32** %10
%110 = call i32 @fclose(i32* %109)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"\0A%d\0A\00"
@.str.1 = [29 x i8] c"%s/%s_Subject_%s.%d_data.txt\00"
@.str.2 = [28 x i8] c"%s/%s_Subject_%s.%d_Res.txt\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.5 = [3 x i8] c"rb\00"
@.str.6 = [3 x i8] c"wb\00"
@.str.7 = [13 x i8] c"%c %c %f %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [50 x i8]
%4 = alloca [50 x i8]
%5 = alloca [8 x i8]
%6 = alloca [7 x i8]
%7 = getelementptr inbounds i8*, i8** %1, i64 3
%8 = load i8*, i8** %7
%9 = tail call i32 @myAtoi(i8* %8)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%12 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = call i32 @sprintf(i8* %11, i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %14, i8* %14, i8* %16, i32 %9)
%18 = load i8*, i8** %13
%19 = load i8*, i8** %15
%20 = call i32 @sprintf(i8* %12, i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %18, i8* %18, i8* %19, i32 %9)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %11)
%22 = call i32 @puts(i8* %12)
%23 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%24 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%25 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%26 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 0
%27 = getelementptr inbounds i8*, i8** %1, i64 4
%28 = load i8*, i8** %27
%29 = call i32 @myAtoi(i8* %28)
%30 = icmp sgt i32 %29, 0
br i1 %30, label %42, label %31
31: ; preds = %42, %2
%32 = call i32 @feof(i32* %23)
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %64
34: ; preds = %31
%35 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 1
%36 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 5
%37 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 1
%38 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 2
%39 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 3
%40 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 4
%41 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 6
br label %47
42: ; preds = %2, %42
%43 = phi i32 [ %45, %42 ], [ 0, %2 ]
%44 = call signext i8 @fgetc(i32* %23)
%45 = add nuw nsw i32 %43, 1
%46 = icmp eq i32 %45, %29
br i1 %46, label %31, label %42
47: ; preds = %34, %47
%48 = call signext i8 @fgetc(i32* %23)
store i8 %48, i8* %26
%49 = call signext i8 @fgetc(i32* %23)
store i8 %49, i8* %35
%50 = call signext i8 @fgetc(i32* %23)
store i8 %50, i8* %38
%51 = call signext i8 @fgetc(i32* %23)
store i8 %51, i8* %39
%52 = call signext i8 @fgetc(i32* %23)
store i8 %52, i8* %40
%53 = call signext i8 @fgetc(i32* %23)
store i8 %53, i8* %36
%54 = call signext i8 @fgetc(i32* %23)
store i8 %54, i8* %41
%55 = load i8, i8* %26
%56 = call i32 @chartoByte(i8 signext %55, i8* %25)
%57 = call float @decodeFloat(i8* %35)
%58 = call i32 @decodeIntsixteen(i8* %36)
%59 = load i8, i8* %25
%60 = load i8, i8* %37
%61 = call i32 @fprintf(i32* %24, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8 signext %59, i8 signext %60, float %57, i32 %58)
%62 = call i32 @feof(i32* %23)
%63 = icmp eq i32 %62, 0
br i1 %63, label %47, label %64
64: ; preds = %47, %31
%65 = call i32 @fclose(i32* %23)
%66 = call i32 @fclose(i32* %24)
ret i32 0
}