#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 */
struct timeval {
  double tv_sec;
  double tv_usec;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
double atof(char *);
double fabs(double);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, ...);
char *strtok(char *, char *);
int /*<<< orphan*/ system(char *);
double voltage_check(double difference) {
  int token_count = 0;
  int changed[6];
  int v[6] = {0, 1, 3, 4, 5, 7};
  int loop_count = 0;
  char temp[1024];
  double time = 0, voltage[6], current[6], prev_voltage[6], prev_current[6];
  char line[1024];
  char *tok = NULL;
  struct timeval tts, ttf, ttemp;
  FILE *file;
  gettimeofday(&tts, NULL);
  while (loop_count < 6) {
    changed[loop_count] = 0;
    sprintf(temp, "voltage_level_%d.txt", v[loop_count]);
    file = fopen(temp, "r");
    if (file != NULL) {
      if (fgets(line, sizeof line, file) != NULL) {
        token_count = 0;
        tok = strtok(line, " ");
        while (token_count < 4) {
          if (token_count == 2) {
            prev_voltage[loop_count] = atof(tok);
          }
          token_count++;
          tok = strtok(NULL, " ");
        }
      } else {
        printf("could not locate file\n");
        return -1;
      }
    }
    loop_count++;
    fclose(file);
  }
  int external_loop_count = 0;
  while (external_loop_count < 6) {
    sprintf(temp, "./execute_sccBmc.sh");
    if (!system(temp)) {
      loop_count = 0;
      while (loop_count < 6) {
        if (!changed[loop_count]) {
          sprintf(temp, "voltage_level_%d.txt", v[loop_count]);
          file = fopen(temp, "r");
          if (file != NULL) {
            if (fgets(line, sizeof line, file) != NULL) {
              token_count = 0;
              tok = strtok(line, " ");
              while (token_count < 4) {
                if (token_count == 2) {
                  voltage[loop_count] = atof(tok);
                }
                token_count++;
                tok = strtok(NULL, " ");
              }
              if ((fabs(prev_voltage[loop_count] - voltage[loop_count]) >
                   difference)) {
                printf("changed loop_count=%d\n", loop_count);
                changed[loop_count] = 1;
                external_loop_count++;
              }
            } else {
              printf("nothing was written on test_voltage_change.txt\n");
            }
          } else {
            printf("could not locate file\n");
            return -1;
          }
          fclose(file);
        }
        loop_count++;
      }
    } else {
      printf("sccBmc command failed....trying again\n");
    }
  }
  gettimeofday(&ttf, NULL);
  time = (ttf.tv_sec - tts.tv_sec) + (ttf.tv_usec - tts.tv_usec) * 0.000001;
  return time;
}


x86 assembly (clang, -O0):
<voltage_check>:
push   %rbp
mov    %rsp,%rbp
sub    $0x980,%rsp
movsd  %xmm0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    0xe72(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xe6f(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    0xe6c(%rip),%rax
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x54(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x468(%rbp)
ff
movq   $0x0,-0x938(%rbp)
lea    -0x948(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1070 <gettimeofday@plt>
cmpl   $0x6,-0x54(%rbp)
jge    1329 <voltage_check+0x199>
movslq -0x54(%rbp),%rax
movl   $0x0,-0x30(%rbp,%rax,4)
lea    -0x460(%rbp),%rdi
movslq -0x54(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%edx
lea    0xe17(%rip),%rsi
mov    $0x0,%al
call   10b0 <sprintf@plt>
lea    -0x460(%rbp),%rdi
lea    0xe17(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x970(%rbp)
cmpq   $0x0,-0x970(%rbp)
je     130f <voltage_check+0x17f>
lea    -0x930(%rbp),%rdi
mov    -0x970(%rbp),%rdx
mov    $0x400,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     12ea <voltage_check+0x15a>
movl   $0x0,-0x14(%rbp)
lea    -0x930(%rbp),%rdi
lea    0xdc8(%rip),%rsi
call   10a0 <strtok@plt>
mov    %rax,-0x938(%rbp)
cmpl   $0x4,-0x14(%rbp)
jge    12e5 <voltage_check+0x155>
cmpl   $0x2,-0x14(%rbp)
jne    12c0 <voltage_check+0x130>
mov    -0x938(%rbp),%rdi
call   1030 <atof@plt>
movslq -0x54(%rbp),%rax
movsd  %xmm0,-0x500(%rbp,%rax,8)
ff ff
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xd7b(%rip),%rsi
call   10a0 <strtok@plt>
mov    %rax,-0x938(%rbp)
jmp    1293 <voltage_check+0x103>
jmp    130a <voltage_check+0x17a>
lea    0xd60(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movsd  0xd08(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    157f <voltage_check+0x3ef>
jmp    130f <voltage_check+0x17f>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
mov    -0x970(%rbp),%rdi
call   1040 <fclose@plt>
jmp    11f5 <voltage_check+0x65>
movl   $0x0,-0x974(%rbp)
cmpl   $0x6,-0x974(%rbp)
jge    152a <voltage_check+0x39a>
lea    -0x460(%rbp),%rdi
lea    0xd1a(%rip),%rsi
mov    $0x0,%al
call   10b0 <sprintf@plt>
lea    -0x460(%rbp),%rdi
call   1050 <system@plt>
cmp    $0x0,%eax
jne    1517 <voltage_check+0x387>
movl   $0x0,-0x54(%rbp)
cmpl   $0x6,-0x54(%rbp)
jge    1512 <voltage_check+0x382>
movslq -0x54(%rbp),%rax
cmpl   $0x0,-0x30(%rbp,%rax,4)
jne    1504 <voltage_check+0x374>
lea    -0x460(%rbp),%rdi
movslq -0x54(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%edx
lea    0xc98(%rip),%rsi
mov    $0x0,%al
call   10b0 <sprintf@plt>
lea    -0x460(%rbp),%rdi
lea    0xc98(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x970(%rbp)
cmpq   $0x0,-0x970(%rbp)
je     14d8 <voltage_check+0x348>
lea    -0x930(%rbp),%rdi
mov    -0x970(%rbp),%rdx
mov    $0x400,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     14c5 <voltage_check+0x335>
movl   $0x0,-0x14(%rbp)
lea    -0x930(%rbp),%rdi
lea    0xc49(%rip),%rsi
call   10a0 <strtok@plt>
mov    %rax,-0x938(%rbp)
cmpl   $0x4,-0x14(%rbp)
jge    1464 <voltage_check+0x2d4>
cmpl   $0x2,-0x14(%rbp)
jne    143f <voltage_check+0x2af>
mov    -0x938(%rbp),%rdi
call   1030 <atof@plt>
movslq -0x54(%rbp),%rax
movsd  %xmm0,-0x4a0(%rbp,%rax,8)
ff ff
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xbfc(%rip),%rsi
call   10a0 <strtok@plt>
mov    %rax,-0x938(%rbp)
jmp    1412 <voltage_check+0x282>
movslq -0x54(%rbp),%rax
movsd  -0x500(%rbp,%rax,8),%xmm0
ff ff
movslq -0x54(%rbp),%rax
subsd  -0x4a0(%rbp,%rax,8),%xmm0
ff ff
movaps 0xb8b(%rip),%xmm1
pand   %xmm1,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    14c0 <voltage_check+0x330>
mov    -0x54(%rbp),%esi
lea    0xbde(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movslq -0x54(%rbp),%rax
movl   $0x1,-0x30(%rbp,%rax,4)
mov    -0x974(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x974(%rbp)
jmp    14d3 <voltage_check+0x343>
lea    0xbc7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    14f8 <voltage_check+0x368>
lea    0xb72(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movsd  0xb1a(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    157f <voltage_check+0x3ef>
mov    -0x970(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1371 <voltage_check+0x1e1>
jmp    1525 <voltage_check+0x395>
lea    0xba5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1333 <voltage_check+0x1a3>
lea    -0x958(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1070 <gettimeofday@plt>
movsd  -0x958(%rbp),%xmm1
ff
subsd  -0x948(%rbp),%xmm1
ff
movsd  -0x950(%rbp),%xmm0
ff
subsd  -0x940(%rbp),%xmm0
ff
movsd  0xa9e(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x468(%rbp)
ff
movsd  -0x468(%rbp),%xmm0
ff
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x980,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<voltage_check>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x898,%rsp
movsd  %xmm0,0x10(%rsp)
lea    0x30(%rsp),%rdi
xor    %esi,%esi
call   1080 <gettimeofday@plt>
lea    0x90(%rsp),%r13
lea    0xe7b(%rip),%r15
lea    0x490(%rsp),%r12
lea    0xe6e(%rip),%rbx
xor    %r14d,%r14d
jmp    1206 <voltage_check+0x66>
cs nopw 0x0(%rax,%rax,1)
mov    %rbp,%rdi
call   1050 <fclose@plt>
add    $0x4,%r14
cmp    $0x18,%r14
je     129e <voltage_check+0xfe>
movl   $0x0,0x40(%rsp,%r14,1)
lea    0xe0a(%rip),%rax
mov    (%r14,%rax,1),%edx
mov    %r13,%rdi
lea    0xe14(%rip),%rsi
xor    %eax,%eax
call   10c0 <sprintf@plt>
mov    %r13,%rdi
mov    %r15,%rsi
call   10a0 <fopen@plt>
mov    %rax,%rbp
test   %rax,%rax
je     11f0 <voltage_check+0x50>
mov    %r12,%rdi
mov    $0x400,%esi
mov    %rbp,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     1407 <voltage_check+0x267>
mov    %r12,%rdi
mov    %rbx,%rsi
call   10b0 <strtok@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   10b0 <strtok@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   10b0 <strtok@plt>
mov    %rax,%rdi
call   1040 <atof@plt>
movsd  %xmm0,0x60(%rsp,%r14,2)
xor    %edi,%edi
mov    %rbx,%rsi
call   10b0 <strtok@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   10b0 <strtok@plt>
jmp    11f0 <voltage_check+0x50>
lea    0x490(%rsp),%rbx
movl   $0x0,0xc(%rsp)
jmp    12c7 <voltage_check+0x127>
lea    0xdf4(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x6,0xc(%rsp)
jge    142d <voltage_check+0x28d>
movupd 0xd82(%rip),%xmm0
movapd %xmm0,0x90(%rsp)
movl   $0x68732e,0xa0(%rsp)
lea    0x90(%rsp),%rdi
call   1060 <system@plt>
test   %eax,%eax
jne    12b0 <voltage_check+0x110>
lea    0xd25(%rip),%r12
xor    %r13d,%r13d
jmp    1322 <voltage_check+0x182>
lea    0xd75(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
add    $0x1,%r13
add    $0x4,%r12
cmp    $0x6,%r13
je     12bc <voltage_check+0x11c>
cmpl   $0x0,0x40(%rsp,%r13,4)
jne    1314 <voltage_check+0x174>
mov    (%r12),%edx
lea    0x90(%rsp),%rbp
mov    %rbp,%rdi
lea    0xcf8(%rip),%rsi
xor    %eax,%eax
call   10c0 <sprintf@plt>
mov    %rbp,%rdi
lea    0xcfc(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1407 <voltage_check+0x267>
mov    %rax,%r14
mov    %rbx,%r15
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %rax,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     1300 <voltage_check+0x160>
mov    %r15,%rdi
lea    0xccb(%rip),%rbp
mov    %rbp,%rsi
call   10b0 <strtok@plt>
xor    %edi,%edi
mov    %rbp,%rsi
call   10b0 <strtok@plt>
xor    %edi,%edi
mov    %rbp,%rsi
call   10b0 <strtok@plt>
mov    %rax,%rdi
call   1040 <atof@plt>
movsd  %xmm0,0x18(%rsp)
xor    %edi,%edi
mov    %rbp,%rsi
call   10b0 <strtok@plt>
xor    %edi,%edi
mov    %rbp,%rsi
call   10b0 <strtok@plt>
movsd  0x60(%rsp,%r13,8),%xmm0
subsd  0x18(%rsp),%xmm0
andpd  0xc39(%rip),%xmm0
ucomisd 0x10(%rsp),%xmm0
jbe    130c <voltage_check+0x16c>
lea    0xc7b(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1070 <printf@plt>
movl   $0x1,0x40(%rsp,%r13,4)
addl   $0x1,0xc(%rsp)
jmp    130c <voltage_check+0x16c>
lea    0xcc3(%rip),%rdi
call   1030 <puts@plt>
movsd  0xbe5(%rip),%xmm0
add    $0x898,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x20(%rsp),%rdi
xor    %esi,%esi
call   1080 <gettimeofday@plt>
movsd  0x20(%rsp),%xmm1
movsd  0x28(%rsp),%xmm0
subsd  0x30(%rsp),%xmm1
subsd  0x38(%rsp),%xmm0
mulsd  0xbaf(%rip),%xmm0
addsd  %xmm1,%xmm0
jmp    141b <voltage_check+0x27b>

LLVM IR (-O0):
%struct.timeval = type { double, double }
@__const.voltage_check.v = [6 x i32] [i32 0, i32 1, i32 3, i32 4, i32 5, i32 7]
@.str = [21 x i8] c"voltage_level_%d.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [23 x i8] c"could not locate file\0A\00"
@.str.4 = [20 x i8] c"./execute_sccBmc.sh\00"
@.str.5 = [23 x i8] c"changed loop_count=%d\0A\00"
@.str.6 = [48 x i8] c"nothing was written on test_voltage_change.txt\0A\00"
@.str.7 = [39 x i8] c"sccBmc command failed....trying again\0A\00"
define double @voltage_check(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca i32
%5 = alloca [6 x i32]
%6 = alloca [6 x i32]
%7 = alloca i32
%8 = alloca [1024 x i8]
%9 = alloca double
%10 = alloca [6 x double]
%11 = alloca [6 x double]
%12 = alloca [6 x double]
%13 = alloca [6 x double]
%14 = alloca [1024 x i8]
%15 = alloca i8*
%16 = alloca %struct.timeval
%17 = alloca %struct.timeval
%18 = alloca %struct.timeval
%19 = alloca i32*
%20 = alloca i32
store double %0, double* %3
store i32 0, i32* %4
%21 = bitcast [6 x i32]* %6 to i8*
store i32 0, i32* %7
store double 0.000000e+00, double* %9
store i8* null, i8** %15
%22 = call i32 @gettimeofday(%struct.timeval* %16, i32* null)
br label %23
23: ; preds = %68, %1
%24 = load i32, i32* %7
%25 = icmp slt i32 %24, 6
br i1 %25, label %26, label %73
26: ; preds = %23
%27 = load i32, i32* %7
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [6 x i32], [6 x i32]* %5, i64 0, i64 %28
store i32 0, i32* %29
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%31 = load i32, i32* %7
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [6 x i32], [6 x i32]* %6, i64 0, i64 %32
%34 = load i32, i32* %33
%35 = call i32 (i8*, i8*, ...) @sprintf(i8* %30, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %34)
%36 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%37 = call i32* @fopen(i8* %36, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %37, i32** %19
%38 = load i32*, i32** %19
%39 = icmp ne i32* %38, null
br i1 %39, label %40, label %68
40: ; preds = %26
%41 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
%42 = load i32*, i32** %19
%43 = call i32* @fgets(i8* %41, i32 1024, i32* %42)
%44 = icmp ne i32* %43, null
br i1 %44, label %45, label %65
45: ; preds = %40
store i32 0, i32* %4
%46 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
%47 = call i8* @strtok(i8* %46, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %47, i8** %15
br label %48
48: ; preds = %60, %45
%49 = load i32, i32* %4
%50 = icmp slt i32 %49, 4
br i1 %50, label %51, label %64
51: ; preds = %48
%52 = load i32, i32* %4
%53 = icmp eq i32 %52, 2
br i1 %53, label %54, label %60
54: ; preds = %51
%55 = load i8*, i8** %15
%56 = call double @atof(i8* %55)
%57 = load i32, i32* %7
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [6 x double], [6 x double]* %12, i64 0, i64 %58
store double %56, double* %59
br label %60
60: ; preds = %54, %51
%61 = load i32, i32* %4
%62 = add nsw i32 %61, 1
store i32 %62, i32* %4
%63 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %63, i8** %15
br label %48
64: ; preds = %48
br label %67
65: ; preds = %40
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
store double -1.000000e+00, double* %2
br label %179
67: ; preds = %64
br label %68
68: ; preds = %67, %26
%69 = load i32, i32* %7
%70 = add nsw i32 %69, 1
store i32 %70, i32* %7
%71 = load i32*, i32** %19
%72 = call i32 @fclose(i32* %71)
br label %23
73: ; preds = %23
store i32 0, i32* %20
br label %74
74: ; preds = %164, %73
%75 = load i32, i32* %20
%76 = icmp slt i32 %75, 6
br i1 %76, label %77, label %165
77: ; preds = %74
%78 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%79 = call i32 (i8*, i8*, ...) @sprintf(i8* %78, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%80 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%81 = call i32 @system(i8* %80)
%82 = icmp ne i32 %81, 0
br i1 %82, label %162, label %83
83: ; preds = %77
store i32 0, i32* %7
br label %84
84: ; preds = %158, %83
%85 = load i32, i32* %7
%86 = icmp slt i32 %85, 6
br i1 %86, label %87, label %161
87: ; preds = %84
%88 = load i32, i32* %7
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds [6 x i32], [6 x i32]* %5, i64 0, i64 %89
%91 = load i32, i32* %90
%92 = icmp ne i32 %91, 0
br i1 %92, label %158, label %93
93: ; preds = %87
%94 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%95 = load i32, i32* %7
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds [6 x i32], [6 x i32]* %6, i64 0, i64 %96
%98 = load i32, i32* %97
%99 = call i32 (i8*, i8*, ...) @sprintf(i8* %94, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %98)
%100 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%101 = call i32* @fopen(i8* %100, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %101, i32** %19
%102 = load i32*, i32** %19
%103 = icmp ne i32* %102, null
br i1 %103, label %104, label %153
104: ; preds = %93
%105 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
%106 = load i32*, i32** %19
%107 = call i32* @fgets(i8* %105, i32 1024, i32* %106)
%108 = icmp ne i32* %107, null
br i1 %108, label %109, label %150
109: ; preds = %104
store i32 0, i32* %4
%110 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
%111 = call i8* @strtok(i8* %110, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %111, i8** %15
br label %112
112: ; preds = %124, %109
%113 = load i32, i32* %4
%114 = icmp slt i32 %113, 4
br i1 %114, label %115, label %128
115: ; preds = %112
%116 = load i32, i32* %4
%117 = icmp eq i32 %116, 2
br i1 %117, label %118, label %124
118: ; preds = %115
%119 = load i8*, i8** %15
%120 = call double @atof(i8* %119)
%121 = load i32, i32* %7
%122 = sext i32 %121 to i64
%123 = getelementptr inbounds [6 x double], [6 x double]* %10, i64 0, i64 %122
store double %120, double* %123
br label %124
124: ; preds = %118, %115
%125 = load i32, i32* %4
%126 = add nsw i32 %125, 1
store i32 %126, i32* %4
%127 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %127, i8** %15
br label %112
128: ; preds = %112
%129 = load i32, i32* %7
%130 = sext i32 %129 to i64
%131 = getelementptr inbounds [6 x double], [6 x double]* %12, i64 0, i64 %130
%132 = load double, double* %131
%133 = load i32, i32* %7
%134 = sext i32 %133 to i64
%135 = getelementptr inbounds [6 x double], [6 x double]* %10, i64 0, i64 %134
%136 = load double, double* %135
%137 = fsub double %132, %136
%138 = call double @llvm.fabs.f64(double %137)
%139 = load double, double* %3
%140 = fcmp ogt double %138, %139
br i1 %140, label %141, label %149
141: ; preds = %128
%142 = load i32, i32* %7
%143 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %142)
%144 = load i32, i32* %7
%145 = sext i32 %144 to i64
%146 = getelementptr inbounds [6 x i32], [6 x i32]* %5, i64 0, i64 %145
store i32 1, i32* %146
%147 = load i32, i32* %20
%148 = add nsw i32 %147, 1
store i32 %148, i32* %20
br label %149
149: ; preds = %141, %128
br label %152
150: ; preds = %104
%151 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.6, i64 0, i64 0))
br label %152
152: ; preds = %150, %149
br label %155
153: ; preds = %93
%154 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
store double -1.000000e+00, double* %2
br label %179
155: ; preds = %152
%156 = load i32*, i32** %19
%157 = call i32 @fclose(i32* %156)
br label %158
158: ; preds = %155, %87
%159 = load i32, i32* %7
%160 = add nsw i32 %159, 1
store i32 %160, i32* %7
br label %84
161: ; preds = %84
br label %164
162: ; preds = %77
%163 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i64 0, i64 0))
br label %164
164: ; preds = %162, %161
br label %74
165: ; preds = %74
%166 = call i32 @gettimeofday(%struct.timeval* %17, i32* null)
%167 = getelementptr inbounds %struct.timeval, %struct.timeval* %17, i32 0, i32 0
%168 = load double, double* %167
%169 = getelementptr inbounds %struct.timeval, %struct.timeval* %16, i32 0, i32 0
%170 = load double, double* %169
%171 = fsub double %168, %170
%172 = getelementptr inbounds %struct.timeval, %struct.timeval* %17, i32 0, i32 1
%173 = load double, double* %172
%174 = getelementptr inbounds %struct.timeval, %struct.timeval* %16, i32 0, i32 1
%175 = load double, double* %174
%176 = fsub double %173, %175
%177 = call double @llvm.fmuladd.f64(double %176, double 0x3EB0C6F7A0B5ED8D, double %171)
store double %177, double* %9
%178 = load double, double* %9
store double %178, double* %2
br label %179
179: ; preds = %165, %153, %65
%180 = load double, double* %2
ret double %180
}

LLVM IR (-O2):
%struct.timeval = type { double, double }
@__const.voltage_check.v = [6 x i32] [i32 0, i32 1, i32 3, i32 4, i32 5, i32 7]
@.str = [21 x i8] c"voltage_level_%d.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c" \00"
@.str.4 = [20 x i8] c"./execute_sccBmc.sh\00"
@.str.5 = [23 x i8] c"changed loop_count=%d\0A\00"
@str.8 = [47 x i8] c"nothing was written on test_voltage_change.txt\00"
@str.9 = [38 x i8] c"sccBmc command failed....trying again\00"
@str.10 = [22 x i8] c"could not locate file\00"
define double @voltage_check(double %0) {
%2 = alloca [6 x i32]
%3 = alloca [1024 x i8]
%4 = alloca [6 x double]
%5 = alloca [1024 x i8]
%6 = alloca %struct.timeval
%7 = alloca %struct.timeval
%8 = bitcast [6 x i32]* %2 to i8*
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%10 = bitcast [6 x double]* %4 to i8*
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%12 = bitcast %struct.timeval* %6 to i8*
%13 = bitcast %struct.timeval* %7 to i8*
%14 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
br label %15
15: ; preds = %1, %36
%16 = phi i64 [ 0, %1 ], [ %37, %36 ]
%17 = getelementptr inbounds [6 x i32], [6 x i32]* %2, i64 0, i64 %16
store i32 0, i32* %17
%18 = getelementptr inbounds [6 x i32], [6 x i32]* @__const.voltage_check.v, i64 0, i64 %16
%19 = load i32, i32* %18
%20 = call i32 (i8*, i8*, ...) @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%22 = icmp eq i32* %21, null
br i1 %22, label %36, label %23
23: ; preds = %15
%24 = call i32* @fgets(i8* %11, i32 1024, i32* %21)
%25 = icmp eq i32* %24, null
br i1 %25, label %34, label %26
26: ; preds = %23
%27 = call i8* @strtok(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%28 = getelementptr inbounds [6 x double], [6 x double]* %4, i64 0, i64 %16
%29 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%30 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%31 = call double @atof(i8* %30)
store double %31, double* %28
%32 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%33 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %36
34: ; preds = %23
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.10, i64 0, i64 0))
br label %104
36: ; preds = %26, %15
%37 = add nuw nsw i64 %16, 1
%38 = call i32 @fclose(i32* %21)
%39 = icmp eq i64 %37, 6
br i1 %39, label %40, label %15
40: ; preds = %36, %88
%41 = phi i32 [ %89, %88 ], [ 0, %36 ]
%42 = call i32 @system(i8* %9)
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %86
44: ; preds = %40, %82
%45 = phi i64 [ %84, %82 ], [ 0, %40 ]
%46 = phi i32 [ %83, %82 ], [ %41, %40 ]
%47 = getelementptr inbounds [6 x i32], [6 x i32]* %2, i64 0, i64 %45
%48 = load i32, i32* %47
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %82
50: ; preds = %44
%51 = getelementptr inbounds [6 x i32], [6 x i32]* @__const.voltage_check.v, i64 0, i64 %45
%52 = load i32, i32* %51
%53 = call i32 (i8*, i8*, ...) @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %52)
%54 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%55 = icmp eq i32* %54, null
br i1 %55, label %77, label %56
56: ; preds = %50
%57 = call i32* @fgets(i8* %11, i32 1024, i32* %54)
%58 = icmp eq i32* %57, null
br i1 %58, label %75, label %59
59: ; preds = %56
%60 = call i8* @strtok(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%61 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%62 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%63 = call double @atof(i8* %62)
%64 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%65 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%66 = getelementptr inbounds [6 x double], [6 x double]* %4, i64 0, i64 %45
%67 = load double, double* %66
%68 = fsub double %67, %63
%69 = call double @llvm.fabs.f64(double %68)
%70 = fcmp ogt double %69, %0
br i1 %70, label %71, label %79
71: ; preds = %59
%72 = trunc i64 %45 to i32
%73 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %72)
store i32 1, i32* %47
%74 = add nsw i32 %46, 1
br label %79
75: ; preds = %56
%76 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str.8, i64 0, i64 0))
br label %79
77: ; preds = %50
%78 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.10, i64 0, i64 0))
br label %104
79: ; preds = %75, %71, %59
%80 = phi i32 [ %74, %71 ], [ %46, %59 ], [ %46, %75 ]
%81 = call i32 @fclose(i32* %54)
br label %82
82: ; preds = %79, %44
%83 = phi i32 [ %46, %44 ], [ %80, %79 ]
%84 = add nuw nsw i64 %45, 1
%85 = icmp eq i64 %84, 6
br i1 %85, label %88, label %44
86: ; preds = %40
%87 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.9, i64 0, i64 0))
br label %88
88: ; preds = %82, %86
%89 = phi i32 [ %41, %86 ], [ %83, %82 ]
%90 = icmp slt i32 %89, 6
br i1 %90, label %40, label %91
91: ; preds = %88
%92 = call i32 @gettimeofday(%struct.timeval* %7, i32* null)
%93 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i64 0, i32 0
%94 = load double, double* %93
%95 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0, i32 0
%96 = load double, double* %95
%97 = fsub double %94, %96
%98 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i64 0, i32 1
%99 = load double, double* %98
%100 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0, i32 1
%101 = load double, double* %100
%102 = fsub double %99, %101
%103 = call double @llvm.fmuladd.f64(double %102, double 0x3EB0C6F7A0B5ED8D, double %97)
br label %104
104: ; preds = %77, %91, %34
%105 = phi double [ -1.000000e+00, %34 ], [ -1.000000e+00, %77 ], [ %103, %91 ]
ret double %105
}