#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 *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *, char *, int);
int main(int argc, char *argv[]) {
  int trials = myAtoi(argv[3]);
  for (int i = 1; i <= trials; i++) {
    char input[50];
    char output[50];
    sprintf(input, "%s/%s_Subject_%s.%d_data.txt", argv[1], argv[1], argv[2],
            i);
    sprintf(output, "%s/%s_Subject_%s.%d_Res.txt", argv[1], argv[1], argv[2],
            i);
    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];
    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    $0xc0,%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)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     13ba <main+0x20a>
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    -0x18(%rbp),%r9d
lea    0xded(%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    -0x18(%rbp),%r9d
lea    0xddb(%rip),%rsi
call   10c0 <sprintf@plt>
lea    -0x50(%rbp),%rsi
lea    0xde7(%rip),%rdi
call   1060 <printf@plt>
lea    -0x90(%rbp),%rsi
lea    0xdd7(%rip),%rdi
call   1060 <printf@plt>
lea    -0x50(%rbp),%rdi
lea    0xdcb(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x98(%rbp)
lea    -0x90(%rbp),%rdi
lea    0xdb4(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0xa0(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xac(%rbp)
ff
movl   $0x0,-0xb0(%rbp)
mov    -0x98(%rbp),%rdi
call   10a0 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    12d1 <main+0x121>
jmp    1394 <main+0x1e4>
movl   $0x0,-0xbc(%rbp)
cmpl   $0x7,-0xbc(%rbp)
jge    1318 <main+0x168>
mov    -0x98(%rbp),%rdi
call   1070 <fgetc@plt>
mov    %al,%cl
movslq -0xbc(%rbp),%rax
mov    %cl,-0xb7(%rbp,%rax,1)
mov    -0xbc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xbc(%rbp)
jmp    12db <main+0x12b>
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    0xcc2(%rip),%rsi
movsbl %cl,%edx
movsbl %al,%ecx
call   1090 <fprintf@plt>
jmp    12b0 <main+0x100>
mov    -0x98(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0xa0(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11e0 <main+0x30>
xor    %eax,%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
mov    %rsi,0x20(%rsp)
mov    0x18(%rsi),%rdi
call   10d0 <myAtoi@plt>
mov    %eax,0x10(%rsp)
test   %eax,%eax
jle    135c <main+0x1ac>
mov    $0x1,%eax
lea    0xe(%rsp),%r13
lea    0x18(%rsp),%rbp
jmp    1212 <main+0x62>
nopl   0x0(%rax)
mov    %r15,%rdi
call   1030 <fclose@plt>
mov    %r12,%rdi
call   1030 <fclose@plt>
mov    0x28(%rsp),%rcx
lea    0x1(%rcx),%eax
cmp    0x10(%rsp),%ecx
je     135c <main+0x1ac>
mov    0x20(%rsp),%rbx
mov    0x8(%rbx),%rcx
mov    0x10(%rbx),%r8
lea    0x30(%rsp),%rdi
lea    0xdd5(%rip),%rsi
mov    %rcx,%rdx
mov    %rax,%r12
mov    %r12d,%r9d
call   10c0 <sprintf@plt>
mov    0x8(%rbx),%rcx
mov    0x10(%rbx),%r8
lea    0x70(%rsp),%r14
mov    %r14,%rdi
lea    0xdcd(%rip),%rsi
mov    %rcx,%rdx
mov    %r12,0x28(%rsp)
mov    %r12d,%r9d
call   10c0 <sprintf@plt>
lea    0xdd2(%rip),%rdi
lea    0x30(%rsp),%rbx
mov    %rbx,%rsi
call   1060 <printf@plt>
lea    0xdc1(%rip),%rdi
mov    %r14,%rsi
call   1060 <printf@plt>
mov    %rbx,%rdi
lea    0xdb3(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,%r15
mov    %r14,%rdi
lea    0xda7(%rip),%rbx
lea    0xd9d(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,%r12
xchg   %ax,%ax
mov    %r15,%rdi
call   10a0 <feof@plt>
test   %eax,%eax
jne    11f0 <main+0x40>
mov    %r15,%rdi
call   1070 <fgetc@plt>
mov    %al,0x9(%rsp)
mov    %r15,%rdi
call   1070 <fgetc@plt>
mov    %al,0xa(%rsp)
mov    %r15,%rdi
call   1070 <fgetc@plt>
mov    %al,0xb(%rsp)
mov    %r15,%rdi
call   1070 <fgetc@plt>
mov    %al,0xc(%rsp)
mov    %r15,%rdi
call   1070 <fgetc@plt>
mov    %al,0xd(%rsp)
mov    %r15,%rdi
call   1070 <fgetc@plt>
mov    %al,0xe(%rsp)
mov    %r15,%rdi
call   1070 <fgetc@plt>
mov    %al,0xf(%rsp)
movsbl 0x9(%rsp),%edi
mov    %rbp,%rsi
call   1050 <chartoByte@plt>
lea    0xa(%rsp),%rdi
call   1080 <decodeFloat@plt>
movss  %xmm0,0x14(%rsp)
mov    %r13,%rdi
call   1040 <decodeIntsixteen@plt>
movsbl 0x18(%rsp),%edx
movsbl 0x19(%rsp),%ecx
mov    %r12,%rdi
mov    %rbx,%rsi
movss  0x14(%rsp),%xmm0
mov    %eax,%r8d
call   1090 <fprintf@plt>
jmp    12b0 <main+0x100>
xor    %eax,%eax
add    $0xa8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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