#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 /*<<< orphan*/ time_t;
struct tm {
  int tm_hour;
  int tm_min;
  int tm_mon;
  int tm_mday;
  int tm_year;
};
struct timespec {
  long tv_sec;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ CLOCK_REALTIME;
int /*<<< orphan*/ clock_gettime(int /*<<< orphan*/, struct timespec *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fwrite(char *, int, int /*<<< orphan*/,
                          int /*<<< orphan*/ *);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ sprintf(char *, char *, int, int, ...);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void logRunTime(int heatActive, int coolActive, long int *dayRunTime) {
  static int heatActive_old = 0;
  static int coolActive_old = 0;
  static long int start_time_heat = 0;
  static long int start_time_cool = 0;
  static long int runTimeHeat = 0;
  static long int runTimeCool = 0;
  time_t t;
  struct tm tm;
  static int dayDataLogged;
  FILE *fd = NULL;
  FILE *fdOnOffTime = NULL;
  char buff[81];
  struct timespec gettime_now;
  t = time(NULL);
  tm = *localtime(&t);
  if (tm.tm_hour == 23 && tm.tm_min == 59) {
    if (dayDataLogged == 0) {
      dayDataLogged = 1;
      fdOnOffTime = fopen("/home/pi/c/wiFiThermo/logOnOffTime.txt", "a");
      if (fdOnOffTime != NULL) {
        sprintf(buff, "%d-%d-%d\n", tm.tm_mon + 1, tm.tm_mday,
                tm.tm_year + 1900);
        fwrite(buff, 1, strlen(buff), fdOnOffTime);
      }
      fclose(fdOnOffTime);
      fd = fopen("/home/pi/c/wiFiThermo/logDayData.txt", "a");
      if (fd != NULL) {
        sprintf(buff, "%d-%d-%d ; %d ; %d\n", tm.tm_mon + 1, tm.tm_mday,
                tm.tm_year + 1900, (int)runTimeHeat, (int)runTimeCool);
        fwrite(buff, 1, strlen(buff), fd);
      }
      fclose(fd);
      if (runTimeHeat > runTimeCool)
        *dayRunTime = runTimeHeat;
      else
        *dayRunTime = runTimeCool;
      runTimeHeat = 0;
      runTimeCool = 0;
    }
  } else {
    dayDataLogged = 0;
  }
  if (heatActive == 1) {
    if (heatActive_old == 0) {
      clock_gettime(CLOCK_REALTIME, &gettime_now);
      start_time_heat = gettime_now.tv_sec;
      fdOnOffTime = fopen("/home/pi/c/wiFiThermo/logOnOffTime.txt", "a");
      if (fdOnOffTime != NULL) {
        sprintf(buff, "  Heat ON - %02d:%02d\n", tm.tm_hour, tm.tm_min);
        fwrite(buff, 1, strlen(buff), fdOnOffTime);
      }
      fclose(fdOnOffTime);
    }
  } else {
    if (heatActive_old == 1) {
      clock_gettime(CLOCK_REALTIME, &gettime_now);
      runTimeHeat += gettime_now.tv_sec - start_time_heat;
      fdOnOffTime = fopen("/home/pi/c/wiFiThermo/logOnOffTime.txt", "a");
      if (fdOnOffTime != NULL) {
        sprintf(buff, "  Heat OFF - %02d:%02d, cumulative run time = %ds\n",
                tm.tm_hour, tm.tm_min, (int)runTimeHeat);
        fwrite(buff, 1, strlen(buff), fdOnOffTime);
      }
      fclose(fdOnOffTime);
    }
  }
  if (coolActive == 1) {
    if (coolActive_old == 0) {
      clock_gettime(CLOCK_REALTIME, &gettime_now);
      start_time_cool = gettime_now.tv_sec;
      fdOnOffTime = fopen("/home/pi/c/wiFiThermo/logOnOffTime.txt", "a");
      if (fdOnOffTime != NULL) {
        sprintf(buff, "  AC ON - %02d:%02d\n", tm.tm_hour, tm.tm_min);
        fwrite(buff, 1, strlen(buff), fdOnOffTime);
      }
      fclose(fdOnOffTime);
    }
  } else {
    if (coolActive_old == 1) {
      clock_gettime(CLOCK_REALTIME, &gettime_now);
      runTimeCool += gettime_now.tv_sec - start_time_cool;
      fdOnOffTime = fopen("/home/pi/c/wiFiThermo/logOnOffTime.txt", "a");
      if (fdOnOffTime != NULL) {
        sprintf(buff, "  AC OFF - %02d:%02d, cumulative run time = %ds\n",
                tm.tm_hour, tm.tm_min, (int)runTimeHeat);
        fwrite(buff, 1, strlen(buff), fdOnOffTime);
      }
      fclose(fdOnOffTime);
    }
  }
  heatActive_old = heatActive;
  coolActive_old = coolActive;
}


x86 assembly (clang, -O0):
<logRunTime>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,-0x14(%rbp)
lea    -0x14(%rbp),%rdi
call   1030 <localtime@plt>
mov    (%rax),%rcx
mov    %rcx,-0x28(%rbp)
mov    0x8(%rax),%rcx
mov    %rcx,-0x20(%rbp)
mov    0x10(%rax),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x17,-0x28(%rbp)
jne    1368 <logRunTime+0x1e8>
cmpl   $0x3b,-0x24(%rbp)
jne    1368 <logRunTime+0x1e8>
cmpl   $0x0,0x2ea6(%rip)
jne    1363 <logRunTime+0x1e3>
movl   $0x1,0x2e96(%rip)
lea    0xdff(%rip),%rdi
lea    0xe1f(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     1276 <logRunTime+0xf6>
lea    -0x90(%rbp),%rdi
mov    -0x20(%rbp),%edx
add    $0x1,%edx
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%r8d
add    $0x76c,%r8d
lea    0xdeb(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
lea    -0x90(%rbp),%rax
mov    %rax,-0xa0(%rbp)
lea    -0x90(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0xa0(%rbp),%rdi
mov    %eax,%edx
mov    -0x38(%rbp),%rcx
mov    $0x1,%esi
call   10a0 <fwrite@plt>
mov    -0x38(%rbp),%rdi
call   1050 <fclose@plt>
lea    0xdad(%rip),%rdi
lea    0xd9a(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     130f <logRunTime+0x18f>
lea    -0x90(%rbp),%rdi
mov    -0x20(%rbp),%edx
add    $0x1,%edx
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%r8d
add    $0x76c,%r8d
mov    0x2dbd(%rip),%rax
mov    %eax,%r9d
mov    0x2dbb(%rip),%rax
lea    0xd84(%rip),%rsi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1090 <sprintf@plt>
lea    -0x90(%rbp),%rax
mov    %rax,-0xa8(%rbp)
lea    -0x90(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0xa8(%rbp),%rdi
mov    %eax,%edx
mov    -0x30(%rbp),%rcx
mov    $0x1,%esi
call   10a0 <fwrite@plt>
mov    -0x30(%rbp),%rdi
call   1050 <fclose@plt>
mov    0x2d61(%rip),%rax
cmp    0x2d62(%rip),%rax
jle    133f <logRunTime+0x1bf>
mov    0x2d4d(%rip),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
jmp    134d <logRunTime+0x1cd>
mov    0x2d42(%rip),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
movq   $0x0,0x2d28(%rip)
movq   $0x0,0x2d25(%rip)
jmp    1372 <logRunTime+0x1f2>
movl   $0x0,0x2d1e(%rip)
cmpl   $0x1,-0x4(%rbp)
jne    1428 <logRunTime+0x2a8>
cmpl   $0x0,0x2ce5(%rip)
jne    1423 <logRunTime+0x2a3>
mov    0x2c50(%rip),%rax
mov    (%rax),%edi
lea    -0x98(%rbp),%rsi
call   1040 <clock_gettime@plt>
mov    -0x98(%rbp),%rax
mov    %rax,0x2cc4(%rip)
lea    0xc4d(%rip),%rdi
lea    0xc6d(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     141a <logRunTime+0x29a>
lea    -0x90(%rbp),%rdi
mov    -0x28(%rbp),%edx
mov    -0x24(%rbp),%ecx
lea    0xc8a(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
lea    -0x90(%rbp),%rax
mov    %rax,-0xb0(%rbp)
lea    -0x90(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0xb0(%rbp),%rdi
mov    %eax,%edx
mov    -0x38(%rbp),%rcx
mov    $0x1,%esi
call   10a0 <fwrite@plt>
mov    -0x38(%rbp),%rdi
call   1050 <fclose@plt>
jmp    14ec <logRunTime+0x36c>
cmpl   $0x1,0x2c39(%rip)
jne    14e7 <logRunTime+0x367>
mov    0x2ba4(%rip),%rax
mov    (%rax),%edi
lea    -0x98(%rbp),%rsi
call   1040 <clock_gettime@plt>
mov    -0x98(%rbp),%rax
sub    0x2c18(%rip),%rax
add    0x2c21(%rip),%rax
mov    %rax,0x2c1a(%rip)
lea    0xb93(%rip),%rdi
lea    0xbb3(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     14de <logRunTime+0x35e>
lea    -0x90(%rbp),%rdi
mov    -0x28(%rbp),%edx
mov    -0x24(%rbp),%ecx
mov    0x2be4(%rip),%rax
mov    %eax,%r8d
lea    0xbdd(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
lea    -0x90(%rbp),%rax
mov    %rax,-0xb8(%rbp)
lea    -0x90(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0xb8(%rbp),%rdi
mov    %eax,%edx
mov    -0x38(%rbp),%rcx
mov    $0x1,%esi
call   10a0 <fwrite@plt>
mov    -0x38(%rbp),%rdi
call   1050 <fclose@plt>
jmp    14ec <logRunTime+0x36c>
cmpl   $0x1,-0x8(%rbp)
jne    15a2 <logRunTime+0x422>
cmpl   $0x0,0x2b6f(%rip)
jne    159d <logRunTime+0x41d>
mov    0x2ad6(%rip),%rax
mov    (%rax),%edi
lea    -0x98(%rbp),%rsi
call   1040 <clock_gettime@plt>
mov    -0x98(%rbp),%rax
mov    %rax,0x2b52(%rip)
lea    0xad3(%rip),%rdi
lea    0xaf3(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     1594 <logRunTime+0x414>
lea    -0x90(%rbp),%rdi
mov    -0x28(%rbp),%edx
mov    -0x24(%rbp),%ecx
lea    0xb5a(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
lea    -0x90(%rbp),%rax
mov    %rax,-0xc0(%rbp)
lea    -0x90(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0xc0(%rbp),%rdi
mov    %eax,%edx
mov    -0x38(%rbp),%rcx
mov    $0x1,%esi
call   10a0 <fwrite@plt>
mov    -0x38(%rbp),%rdi
call   1050 <fclose@plt>
jmp    1666 <logRunTime+0x4e6>
cmpl   $0x1,0x2ac3(%rip)
jne    1661 <logRunTime+0x4e1>
mov    0x2a2a(%rip),%rax
mov    (%rax),%edi
lea    -0x98(%rbp),%rsi
call   1040 <clock_gettime@plt>
mov    -0x98(%rbp),%rax
sub    0x2aa6(%rip),%rax
add    0x2aaf(%rip),%rax
mov    %rax,0x2aa8(%rip)
lea    0xa19(%rip),%rdi
lea    0xa39(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     1658 <logRunTime+0x4d8>
lea    -0x90(%rbp),%rdi
mov    -0x28(%rbp),%edx
mov    -0x24(%rbp),%ecx
mov    0x2a6a(%rip),%rax
mov    %eax,%r8d
lea    0xaab(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
lea    -0x90(%rbp),%rax
mov    %rax,-0xc8(%rbp)
lea    -0x90(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0xc8(%rbp),%rdi
mov    %eax,%edx
mov    -0x38(%rbp),%rcx
mov    $0x1,%esi
call   10a0 <fwrite@plt>
mov    -0x38(%rbp),%rdi
call   1050 <fclose@plt>
jmp    1666 <logRunTime+0x4e6>
mov    -0x4(%rbp),%eax
mov    %eax,0x29f9(%rip)
mov    -0x8(%rbp),%eax
mov    %eax,0x29f4(%rip)
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<logRunTime>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %rdx,%rbx
mov    %esi,%r14d
mov    %edi,%r12d
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,0x2c(%rsp)
lea    0x2c(%rsp),%rdi
call   1030 <localtime@plt>
mov    (%rax),%r13d
mov    0x4(%rax),%r15d
cmp    $0x17,%r13d
jne    131a <logRunTime+0x19a>
cmp    $0x3b,%r15d
jne    131a <logRunTime+0x19a>
cmpb   $0x0,0x2ebf(%rip)
jne    1321 <logRunTime+0x1a1>
mov    %r12d,0x1c(%rsp)
mov    %r13d,0x20(%rsp)
mov    %r15d,0x24(%rsp)
mov    %r14d,0x28(%rsp)
mov    0x8(%rax),%r13d
mov    0xc(%rax),%r12d
mov    0x10(%rax),%r14d
movb   $0x1,0x2e92(%rip)
lea    0xdfb(%rip),%rdi
lea    0xe1b(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbp
test   %rax,%rax
je     1257 <logRunTime+0xd7>
lea    0x1(%r13),%edx
lea    0x76c(%r14),%r8d
lea    0xdfe(%rip),%rsi
lea    0x30(%rsp),%r15
mov    %r15,%rdi
mov    %r12d,%ecx
xor    %eax,%eax
call   1090 <sprintf@plt>
mov    %r15,%rdi
call   1060 <strlen@plt>
mov    %r15,%rdi
mov    $0x1,%esi
mov    %eax,%edx
mov    %rbp,%rcx
call   10a0 <fwrite@plt>
mov    %rbp,%rdi
call   1050 <fclose@plt>
lea    0xdcd(%rip),%rdi
lea    0xdba(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r15
test   %rax,%rax
je     12ce <logRunTime+0x14e>
add    $0x1,%r13d
add    $0x76c,%r14d
mov    0x2df4(%rip),%r9d
mov    0x2df6(%rip),%eax
mov    %eax,(%rsp)
lea    0xdbc(%rip),%rsi
lea    0x30(%rsp),%rbp
mov    %rbp,%rdi
mov    %r13d,%edx
mov    %r12d,%ecx
mov    %r14d,%r8d
xor    %eax,%eax
call   1090 <sprintf@plt>
mov    %rbp,%rdi
call   1060 <strlen@plt>
mov    %rbp,%rdi
mov    $0x1,%esi
mov    %eax,%edx
mov    %r15,%rcx
call   10a0 <fwrite@plt>
mov    %r15,%rdi
call   1050 <fclose@plt>
mov    0x2da3(%rip),%rax
mov    0x2da4(%rip),%rcx
cmp    %rcx,%rax
cmovg  %rax,%rcx
mov    %rcx,(%rbx)
movq   $0x0,0x2d87(%rip)
movq   $0x0,0x2d84(%rip)
mov    0x28(%rsp),%r14d
mov    0x24(%rsp),%r15d
mov    0x20(%rsp),%r13d
mov    0x1c(%rsp),%r12d
jmp    1321 <logRunTime+0x1a1>
movb   $0x0,0x2d6f(%rip)
mov    0x2d41(%rip),%eax
cmp    $0x1,%r12d
jne    138e <logRunTime+0x20e>
test   %eax,%eax
jne    141f <logRunTime+0x29f>
mov    0x2ca4(%rip),%rax
mov    (%rax),%edi
lea    0x10(%rsp),%rsi
call   1040 <clock_gettime@plt>
mov    0x10(%rsp),%rax
mov    %rax,0x2d1c(%rip)
lea    0xca5(%rip),%rdi
lea    0xcc5(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1417 <logRunTime+0x297>
lea    0xcf2(%rip),%rsi
lea    0x30(%rsp),%rdi
mov    %r13d,%edx
mov    %r15d,%ecx
xor    %eax,%eax
call   1090 <sprintf@plt>
jmp    13f8 <logRunTime+0x278>
cmp    $0x1,%eax
jne    141f <logRunTime+0x29f>
mov    0x2c42(%rip),%rax
mov    (%rax),%edi
lea    0x10(%rsp),%rsi
call   1040 <clock_gettime@plt>
mov    0x10(%rsp),%rax
sub    0x2cba(%rip),%rax
add    %rax,0x2cc3(%rip)
lea    0xc3c(%rip),%rdi
lea    0xc5c(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1417 <logRunTime+0x297>
mov    0x2ca1(%rip),%r8d
lea    0xc9d(%rip),%rsi
lea    0x30(%rsp),%rdi
mov    %r13d,%edx
mov    %r15d,%ecx
xor    %eax,%eax
call   1090 <sprintf@plt>
lea    0x30(%rsp),%rbp
mov    %rbp,%rdi
call   1060 <strlen@plt>
mov    %rbp,%rdi
mov    $0x1,%esi
mov    %eax,%edx
mov    %rbx,%rcx
call   10a0 <fwrite@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    0x2c47(%rip),%eax
cmp    $0x1,%r14d
jne    148c <logRunTime+0x30c>
test   %eax,%eax
jne    151d <logRunTime+0x39d>
mov    0x2ba6(%rip),%rax
mov    (%rax),%edi
lea    0x10(%rsp),%rsi
call   1040 <clock_gettime@plt>
mov    0x10(%rsp),%rax
mov    %rax,0x2c26(%rip)
lea    0xba7(%rip),%rdi
lea    0xbc7(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1515 <logRunTime+0x395>
lea    0xc3e(%rip),%rsi
lea    0x30(%rsp),%rdi
mov    %r13d,%edx
mov    %r15d,%ecx
xor    %eax,%eax
call   1090 <sprintf@plt>
jmp    14f6 <logRunTime+0x376>
cmp    $0x1,%eax
jne    151d <logRunTime+0x39d>
mov    0x2b44(%rip),%rax
mov    (%rax),%edi
lea    0x10(%rsp),%rsi
call   1040 <clock_gettime@plt>
mov    0x10(%rsp),%rax
sub    0x2bc4(%rip),%rax
add    %rax,0x2bcd(%rip)
lea    0xb3e(%rip),%rdi
lea    0xb5e(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1515 <logRunTime+0x395>
mov    0x2ba3(%rip),%r8d
lea    0xbe7(%rip),%rsi
lea    0x30(%rsp),%rdi
mov    %r13d,%edx
mov    %r15d,%ecx
xor    %eax,%eax
call   1090 <sprintf@plt>
lea    0x30(%rsp),%rbp
mov    %rbp,%rdi
call   1060 <strlen@plt>
mov    %rbp,%rdi
mov    $0x1,%esi
mov    %eax,%edx
mov    %rbx,%rcx
call   10a0 <fwrite@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    %r12d,0x2b44(%rip)
mov    %r14d,0x2b41(%rip)
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32 }
%struct.timespec = type { i64 }
@logRunTime.heatActive_old = internal global i32 0
@logRunTime.coolActive_old = internal global i32 0
@logRunTime.start_time_heat = internal global i64 0
@logRunTime.start_time_cool = internal global i64 0
@logRunTime.runTimeHeat = internal global i64 0
@logRunTime.runTimeCool = internal global i64 0
@logRunTime.dayDataLogged = internal global i32 0
@.str = [39 x i8] c"/home/pi/c/wiFiThermo/logOnOffTime.txt\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [10 x i8] c"%d-%d-%d\0A\00"
@.str.3 = [37 x i8] c"/home/pi/c/wiFiThermo/logDayData.txt\00"
@.str.4 = [20 x i8] c"%d-%d-%d ; %d ; %d\0A\00"
@CLOCK_REALTIME = global i32 0
@.str.5 = [23 x i8] c" Heat ON - %02d:%02d\0A\00"
@.str.6 = [51 x i8] c" Heat OFF - %02d:%02d, cumulative run time = %ds\0A\00"
@.str.7 = [21 x i8] c" AC ON - %02d:%02d\0A\00"
@.str.8 = [49 x i8] c" AC OFF - %02d:%02d, cumulative run time = %ds\0A\00"
define void @logRunTime(i32 %0, i32 %1, i64* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i64*
%7 = alloca i32
%8 = alloca %struct.tm
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca [81 x i8]
%12 = alloca %struct.timespec
store i32 %0, i32* %4
store i32 %1, i32* %5
store i64* %2, i64** %6
store i32* null, i32** %9
store i32* null, i32** %10
%13 = call i32 @time(i32* null)
store i32 %13, i32* %7
%14 = call %struct.tm* @localtime(i32* %7)
%15 = bitcast %struct.tm* %8 to i8*
%16 = bitcast %struct.tm* %14 to i8*
%17 = getelementptr inbounds %struct.tm, %struct.tm* %8, i32 0, i32 0
%18 = load i32, i32* %17
%19 = icmp eq i32 %18, 23
br i1 %19, label %20, label %87
20: ; preds = %3
%21 = getelementptr inbounds %struct.tm, %struct.tm* %8, i32 0, i32 1
%22 = load i32, i32* %21
%23 = icmp eq i32 %22, 59
br i1 %23, label %24, label %87
24: ; preds = %20
%25 = load i32, i32* @logRunTime.dayDataLogged
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %86
27: ; preds = %24
store i32 1, i32* @logRunTime.dayDataLogged
%28 = call i32* @fopen(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %28, i32** %10
%29 = load i32*, i32** %10
%30 = icmp ne i32* %29, null
br i1 %30, label %31, label %47
31: ; preds = %27
%32 = getelementptr inbounds [81 x i8], [81 x i8]* %11, i64 0, i64 0
%33 = getelementptr inbounds %struct.tm, %struct.tm* %8, i32 0, i32 2
%34 = load i32, i32* %33
%35 = add nsw i32 %34, 1
%36 = getelementptr inbounds %struct.tm, %struct.tm* %8, i32 0, i32 3
%37 = load i32, i32* %36
%38 = getelementptr inbounds %struct.tm, %struct.tm* %8, i32 0, i32 4
%39 = load i32, i32* %38
%40 = add nsw i32 %39, 1900
%41 = call i32 (i8*, i8*, i32, i32, ...) @sprintf(i8* %32, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %35, i32 %37, i32 %40)
%42 = getelementptr inbounds [81 x i8], [81 x i8]* %11, i64 0, i64 0
%43 = getelementptr inbounds [81 x i8], [81 x i8]* %11, i64 0, i64 0
%44 = call i32 @strlen(i8* %43)
%45 = load i32*, i32** %10
%46 = call i32 @fwrite(i8* %42, i32 1, i32 %44, i32* %45)
br label %47
47: ; preds = %31, %27
%48 = load i32*, i32** %10
%49 = call i32 @fclose(i32* %48)
%50 = call i32* @fopen(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %50, i32** %9
%51 = load i32*, i32** %9
%52 = icmp ne i32* %51, null
br i1 %52, label %53, label %73
53: ; preds = %47
%54 = getelementptr inbounds [81 x i8], [81 x i8]* %11, i64 0, i64 0
%55 = getelementptr inbounds %struct.tm, %struct.tm* %8, i32 0, i32 2
%56 = load i32, i32* %55
%57 = add nsw i32 %56, 1
%58 = getelementptr inbounds %struct.tm, %struct.tm* %8, i32 0, i32 3
%59 = load i32, i32* %58
%60 = getelementptr inbounds %struct.tm, %struct.tm* %8, i32 0, i32 4
%61 = load i32, i32* %60
%62 = add nsw i32 %61, 1900
%63 = load i64, i64* @logRunTime.runTimeHeat
%64 = trunc i64 %63 to i32
%65 = load i64, i64* @logRunTime.runTimeCool
%66 = trunc i64 %65 to i32
%67 = call i32 (i8*, i8*, i32, i32, ...) @sprintf(i8* %54, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %57, i32 %59, i32 %62, i32 %64, i32 %66)
%68 = getelementptr inbounds [81 x i8], [81 x i8]* %11, i64 0, i64 0
%69 = getelementptr inbounds [81 x i8], [81 x i8]* %11, i64 0, i64 0
%70 = call i32 @strlen(i8* %69)
%71 = load i32*, i32** %9
%72 = call i32 @fwrite(i8* %68, i32 1, i32 %70, i32* %71)
br label %73
73: ; preds = %53, %47
%74 = load i32*, i32** %9
%75 = call i32 @fclose(i32* %74)
%76 = load i64, i64* @logRunTime.runTimeHeat
%77 = load i64, i64* @logRunTime.runTimeCool
%78 = icmp sgt i64 %76, %77
br i1 %78, label %79, label %82
79: ; preds = %73
%80 = load i64, i64* @logRunTime.runTimeHeat
%81 = load i64*, i64** %6
store i64 %80, i64* %81
br label %85
82: ; preds = %73
%83 = load i64, i64* @logRunTime.runTimeCool
%84 = load i64*, i64** %6
store i64 %83, i64* %84
br label %85
85: ; preds = %82, %79
store i64 0, i64* @logRunTime.runTimeHeat
store i64 0, i64* @logRunTime.runTimeCool
br label %86
86: ; preds = %85, %24
br label %88
87: ; preds = %20, %3
store i32 0, i32* @logRunTime.dayDataLogged
br label %88
88: ; preds = %87, %86
%89 = load i32, i32* %4
%90 = icmp eq i32 %89, 1
br i1 %90, label %91, label %118
91: ; preds = %88
%92 = load i32, i32* @logRunTime.heatActive_old
%93 = icmp eq i32 %92, 0
br i1 %93, label %94, label %117
94: ; preds = %91
%95 = load i32, i32* @CLOCK_REALTIME
%96 = call i32 @clock_gettime(i32 %95, %struct.timespec* %12)
%97 = getelementptr inbounds %struct.timespec, %struct.timespec* %12, i32 0, i32 0
%98 = load i64, i64* %97
store i64 %98, i64* @logRunTime.start_time_heat
%99 = call i32* @fopen(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %99, i32** %10
%100 = load i32*, i32** %10
%101 = icmp ne i32* %100, null
br i1 %101, label %102, label %114
102: ; preds = %94
%103 = getelementptr inbounds [81 x i8], [81 x i8]* %11, i64 0, i64 0
%104 = getelementptr inbounds %struct.tm, %struct.tm* %8, i32 0, i32 0
%105 = load i32, i32* %104
%106 = getelementptr inbounds %struct.tm, %struct.tm* %8, i32 0, i32 1
%107 = load i32, i32* %106
%108 = call i32 (i8*, i8*, i32, i32, ...) @sprintf(i8* %103, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %105, i32 %107)
%109 = getelementptr inbounds [81 x i8], [81 x i8]* %11, i64 0, i64 0
%110 = getelementptr inbounds [81 x i8], [81 x i8]* %11, i64 0, i64 0
%111 = call i32 @strlen(i8* %110)
%112 = load i32*, i32** %10
%113 = call i32 @fwrite(i8* %109, i32 1, i32 %111, i32* %112)
br label %114
114: ; preds = %102, %94
%115 = load i32*, i32** %10
%116 = call i32 @fclose(i32* %115)
br label %117
117: ; preds = %114, %91
br label %151
118: ; preds = %88
%119 = load i32, i32* @logRunTime.heatActive_old
%120 = icmp eq i32 %119, 1
br i1 %120, label %121, label %150
121: ; preds = %118
%122 = load i32, i32* @CLOCK_REALTIME
%123 = call i32 @clock_gettime(i32 %122, %struct.timespec* %12)
%124 = getelementptr inbounds %struct.timespec, %struct.timespec* %12, i32 0, i32 0
%125 = load i64, i64* %124
%126 = load i64, i64* @logRunTime.start_time_heat
%127 = sub nsw i64 %125, %126
%128 = load i64, i64* @logRunTime.runTimeHeat
%129 = add nsw i64 %128, %127
store i64 %129, i64* @logRunTime.runTimeHeat
%130 = call i32* @fopen(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %130, i32** %10
%131 = load i32*, i32** %10
%132 = icmp ne i32* %131, null
br i1 %132, label %133, label %147
133: ; preds = %121
%134 = getelementptr inbounds [81 x i8], [81 x i8]* %11, i64 0, i64 0
%135 = getelementptr inbounds %struct.tm, %struct.tm* %8, i32 0, i32 0
%136 = load i32, i32* %135
%137 = getelementptr inbounds %struct.tm, %struct.tm* %8, i32 0, i32 1
%138 = load i32, i32* %137
%139 = load i64, i64* @logRunTime.runTimeHeat
%140 = trunc i64 %139 to i32
%141 = call i32 (i8*, i8*, i32, i32, ...) @sprintf(i8* %134, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.6, i64 0, i64 0), i32 %136, i32 %138, i32 %140)
%142 = getelementptr inbounds [81 x i8], [81 x i8]* %11, i64 0, i64 0
%143 = getelementptr inbounds [81 x i8], [81 x i8]* %11, i64 0, i64 0
%144 = call i32 @strlen(i8* %143)
%145 = load i32*, i32** %10
%146 = call i32 @fwrite(i8* %142, i32 1, i32 %144, i32* %145)
br label %147
147: ; preds = %133, %121
%148 = load i32*, i32** %10
%149 = call i32 @fclose(i32* %148)
br label %150
150: ; preds = %147, %118
br label %151
151: ; preds = %150, %117
%152 = load i32, i32* %5
%153 = icmp eq i32 %152, 1
br i1 %153, label %154, label %181
154: ; preds = %151
%155 = load i32, i32* @logRunTime.coolActive_old
%156 = icmp eq i32 %155, 0
br i1 %156, label %157, label %180
157: ; preds = %154
%158 = load i32, i32* @CLOCK_REALTIME
%159 = call i32 @clock_gettime(i32 %158, %struct.timespec* %12)
%160 = getelementptr inbounds %struct.timespec, %struct.timespec* %12, i32 0, i32 0
%161 = load i64, i64* %160
store i64 %161, i64* @logRunTime.start_time_cool
%162 = call i32* @fopen(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %162, i32** %10
%163 = load i32*, i32** %10
%164 = icmp ne i32* %163, null
br i1 %164, label %165, label %177
165: ; preds = %157
%166 = getelementptr inbounds [81 x i8], [81 x i8]* %11, i64 0, i64 0
%167 = getelementptr inbounds %struct.tm, %struct.tm* %8, i32 0, i32 0
%168 = load i32, i32* %167
%169 = getelementptr inbounds %struct.tm, %struct.tm* %8, i32 0, i32 1
%170 = load i32, i32* %169
%171 = call i32 (i8*, i8*, i32, i32, ...) @sprintf(i8* %166, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i32 %168, i32 %170)
%172 = getelementptr inbounds [81 x i8], [81 x i8]* %11, i64 0, i64 0
%173 = getelementptr inbounds [81 x i8], [81 x i8]* %11, i64 0, i64 0
%174 = call i32 @strlen(i8* %173)
%175 = load i32*, i32** %10
%176 = call i32 @fwrite(i8* %172, i32 1, i32 %174, i32* %175)
br label %177
177: ; preds = %165, %157
%178 = load i32*, i32** %10
%179 = call i32 @fclose(i32* %178)
br label %180
180: ; preds = %177, %154
br label %214
181: ; preds = %151
%182 = load i32, i32* @logRunTime.coolActive_old
%183 = icmp eq i32 %182, 1
br i1 %183, label %184, label %213
184: ; preds = %181
%185 = load i32, i32* @CLOCK_REALTIME
%186 = call i32 @clock_gettime(i32 %185, %struct.timespec* %12)
%187 = getelementptr inbounds %struct.timespec, %struct.timespec* %12, i32 0, i32 0
%188 = load i64, i64* %187
%189 = load i64, i64* @logRunTime.start_time_cool
%190 = sub nsw i64 %188, %189
%191 = load i64, i64* @logRunTime.runTimeCool
%192 = add nsw i64 %191, %190
store i64 %192, i64* @logRunTime.runTimeCool
%193 = call i32* @fopen(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %193, i32** %10
%194 = load i32*, i32** %10
%195 = icmp ne i32* %194, null
br i1 %195, label %196, label %210
196: ; preds = %184
%197 = getelementptr inbounds [81 x i8], [81 x i8]* %11, i64 0, i64 0
%198 = getelementptr inbounds %struct.tm, %struct.tm* %8, i32 0, i32 0
%199 = load i32, i32* %198
%200 = getelementptr inbounds %struct.tm, %struct.tm* %8, i32 0, i32 1
%201 = load i32, i32* %200
%202 = load i64, i64* @logRunTime.runTimeHeat
%203 = trunc i64 %202 to i32
%204 = call i32 (i8*, i8*, i32, i32, ...) @sprintf(i8* %197, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.8, i64 0, i64 0), i32 %199, i32 %201, i32 %203)
%205 = getelementptr inbounds [81 x i8], [81 x i8]* %11, i64 0, i64 0
%206 = getelementptr inbounds [81 x i8], [81 x i8]* %11, i64 0, i64 0
%207 = call i32 @strlen(i8* %206)
%208 = load i32*, i32** %10
%209 = call i32 @fwrite(i8* %205, i32 1, i32 %207, i32* %208)
br label %210
210: ; preds = %196, %184
%211 = load i32*, i32** %10
%212 = call i32 @fclose(i32* %211)
br label %213
213: ; preds = %210, %181
br label %214
214: ; preds = %213, %180
%215 = load i32, i32* %4
store i32 %215, i32* @logRunTime.heatActive_old
%216 = load i32, i32* %5
store i32 %216, i32* @logRunTime.coolActive_old
ret void
}

LLVM IR (-O2):
%struct.timespec = type { i64 }
%struct.tm = type { i32, i32, i32, i32, i32 }
@logRunTime.heatActive_old = internal unnamed_addr global i32 0
@logRunTime.coolActive_old = internal unnamed_addr global i32 0
@logRunTime.start_time_heat = internal unnamed_addr global i64 0
@logRunTime.start_time_cool = internal unnamed_addr global i64 0
@logRunTime.runTimeHeat = internal unnamed_addr global i64 0
@logRunTime.runTimeCool = internal unnamed_addr global i64 0
@logRunTime.dayDataLogged = internal unnamed_addr global i1 false
@.str = [39 x i8] c"/home/pi/c/wiFiThermo/logOnOffTime.txt\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [10 x i8] c"%d-%d-%d\0A\00"
@.str.3 = [37 x i8] c"/home/pi/c/wiFiThermo/logDayData.txt\00"
@.str.4 = [20 x i8] c"%d-%d-%d ; %d ; %d\0A\00"
@CLOCK_REALTIME = global i32 0
@.str.5 = [23 x i8] c" Heat ON - %02d:%02d\0A\00"
@.str.6 = [51 x i8] c" Heat OFF - %02d:%02d, cumulative run time = %ds\0A\00"
@.str.7 = [21 x i8] c" AC ON - %02d:%02d\0A\00"
@.str.8 = [49 x i8] c" AC OFF - %02d:%02d, cumulative run time = %ds\0A\00"
define void @logRunTime(i32 %0, i32 %1, i64* nocapture writeonly %2) {
%4 = alloca i32
%5 = alloca [81 x i8]
%6 = alloca %struct.timespec
%7 = bitcast i32* %4 to i8*
%8 = getelementptr inbounds [81 x i8], [81 x i8]* %5, i64 0, i64 0
%9 = bitcast %struct.timespec* %6 to i8*
%10 = tail call i32 @time(i32* null)
store i32 %10, i32* %4
%11 = call %struct.tm* @localtime(i32* %4)
%12 = getelementptr inbounds %struct.tm, %struct.tm* %11, i64 0, i32 0
%13 = load i32, i32* %12
%14 = getelementptr inbounds %struct.tm, %struct.tm* %11, i64 0, i32 1
%15 = load i32, i32* %14
%16 = getelementptr inbounds %struct.tm, %struct.tm* %11, i64 0, i32 2
%17 = load i32, i32* %16
%18 = getelementptr inbounds %struct.tm, %struct.tm* %11, i64 0, i32 3
%19 = load i32, i32* %18
%20 = getelementptr inbounds %struct.tm, %struct.tm* %11, i64 0, i32 4
%21 = load i32, i32* %20
%22 = icmp eq i32 %13, 23
%23 = icmp eq i32 %15, 59
%24 = select i1 %22, i1 %23, i1 false
br i1 %24, label %25, label %56
25: ; preds = %3
%26 = load i1, i1* @logRunTime.dayDataLogged
br i1 %26, label %57, label %27
27: ; preds = %25
store i1 true, i1* @logRunTime.dayDataLogged
%28 = call i32* @fopen(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%29 = icmp eq i32* %28, null
br i1 %29, label %36, label %30
30: ; preds = %27
%31 = add nsw i32 %17, 1
%32 = add nsw i32 %21, 1900
%33 = call i32 (i8*, i8*, i32, i32, ...) @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %31, i32 %19, i32 %32)
%34 = call i32 @strlen(i8* %8)
%35 = call i32 @fwrite(i8* %8, i32 1, i32 %34, i32* %28)
br label %36
36: ; preds = %30, %27
%37 = call i32 @fclose(i32* %28)
%38 = call i32* @fopen(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%39 = icmp eq i32* %38, null
br i1 %39, label %50, label %40
40: ; preds = %36
%41 = add nsw i32 %17, 1
%42 = add nsw i32 %21, 1900
%43 = load i64, i64* @logRunTime.runTimeHeat
%44 = trunc i64 %43 to i32
%45 = load i64, i64* @logRunTime.runTimeCool
%46 = trunc i64 %45 to i32
%47 = call i32 (i8*, i8*, i32, i32, ...) @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %41, i32 %19, i32 %42, i32 %44, i32 %46)
%48 = call i32 @strlen(i8* %8)
%49 = call i32 @fwrite(i8* %8, i32 1, i32 %48, i32* %38)
br label %50
50: ; preds = %40, %36
%51 = call i32 @fclose(i32* %38)
%52 = load i64, i64* @logRunTime.runTimeHeat
%53 = load i64, i64* @logRunTime.runTimeCool
%54 = icmp sgt i64 %52, %53
%55 = select i1 %54, i64 %52, i64 %53
store i64 %55, i64* %2
store i64 0, i64* @logRunTime.runTimeHeat
store i64 0, i64* @logRunTime.runTimeCool
br label %57
56: ; preds = %3
store i1 false, i1* @logRunTime.dayDataLogged
br label %57
57: ; preds = %25, %50, %56
%58 = icmp eq i32 %0, 1
%59 = load i32, i32* @logRunTime.heatActive_old
br i1 %58, label %60, label %71
60: ; preds = %57
%61 = icmp eq i32 %59, 0
br i1 %61, label %62, label %95
62: ; preds = %60
%63 = load i32, i32* @CLOCK_REALTIME
%64 = call i32 @clock_gettime(i32 %63, %struct.timespec* %6)
%65 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i64 0, i32 0
%66 = load i64, i64* %65
store i64 %66, i64* @logRunTime.start_time_heat
%67 = call i32* @fopen(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%68 = icmp eq i32* %67, null
br i1 %68, label %92, label %69
69: ; preds = %62
%70 = call i32 (i8*, i8*, i32, i32, ...) @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %13, i32 %15)
br label %88
71: ; preds = %57
%72 = icmp eq i32 %59, 1
br i1 %72, label %73, label %95
73: ; preds = %71
%74 = load i32, i32* @CLOCK_REALTIME
%75 = call i32 @clock_gettime(i32 %74, %struct.timespec* %6)
%76 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i64 0, i32 0
%77 = load i64, i64* %76
%78 = load i64, i64* @logRunTime.start_time_heat
%79 = sub i64 %77, %78
%80 = load i64, i64* @logRunTime.runTimeHeat
%81 = add nsw i64 %79, %80
store i64 %81, i64* @logRunTime.runTimeHeat
%82 = call i32* @fopen(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%83 = icmp eq i32* %82, null
br i1 %83, label %92, label %84
84: ; preds = %73
%85 = load i64, i64* @logRunTime.runTimeHeat
%86 = trunc i64 %85 to i32
%87 = call i32 (i8*, i8*, i32, i32, ...) @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.6, i64 0, i64 0), i32 %13, i32 %15, i32 %86)
br label %88
88: ; preds = %69, %84
%89 = phi i32* [ %82, %84 ], [ %67, %69 ]
%90 = call i32 @strlen(i8* %8)
%91 = call i32 @fwrite(i8* %8, i32 1, i32 %90, i32* %89)
br label %92
92: ; preds = %88, %73, %62
%93 = phi i32* [ %67, %62 ], [ %82, %73 ], [ %89, %88 ]
%94 = call i32 @fclose(i32* %93)
br label %95
95: ; preds = %92, %71, %60
%96 = icmp eq i32 %1, 1
%97 = load i32, i32* @logRunTime.coolActive_old
br i1 %96, label %98, label %109
98: ; preds = %95
%99 = icmp eq i32 %97, 0
br i1 %99, label %100, label %133
100: ; preds = %98
%101 = load i32, i32* @CLOCK_REALTIME
%102 = call i32 @clock_gettime(i32 %101, %struct.timespec* %6)
%103 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i64 0, i32 0
%104 = load i64, i64* %103
store i64 %104, i64* @logRunTime.start_time_cool
%105 = call i32* @fopen(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%106 = icmp eq i32* %105, null
br i1 %106, label %130, label %107
107: ; preds = %100
%108 = call i32 (i8*, i8*, i32, i32, ...) @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i32 %13, i32 %15)
br label %126
109: ; preds = %95
%110 = icmp eq i32 %97, 1
br i1 %110, label %111, label %133
111: ; preds = %109
%112 = load i32, i32* @CLOCK_REALTIME
%113 = call i32 @clock_gettime(i32 %112, %struct.timespec* %6)
%114 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i64 0, i32 0
%115 = load i64, i64* %114
%116 = load i64, i64* @logRunTime.start_time_cool
%117 = sub i64 %115, %116
%118 = load i64, i64* @logRunTime.runTimeCool
%119 = add nsw i64 %117, %118
store i64 %119, i64* @logRunTime.runTimeCool
%120 = call i32* @fopen(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%121 = icmp eq i32* %120, null
br i1 %121, label %130, label %122
122: ; preds = %111
%123 = load i64, i64* @logRunTime.runTimeHeat
%124 = trunc i64 %123 to i32
%125 = call i32 (i8*, i8*, i32, i32, ...) @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.8, i64 0, i64 0), i32 %13, i32 %15, i32 %124)
br label %126
126: ; preds = %107, %122
%127 = phi i32* [ %120, %122 ], [ %105, %107 ]
%128 = call i32 @strlen(i8* %8)
%129 = call i32 @fwrite(i8* %8, i32 1, i32 %128, i32* %127)
br label %130
130: ; preds = %126, %111, %100
%131 = phi i32* [ %105, %100 ], [ %120, %111 ], [ %127, %126 ]
%132 = call i32 @fclose(i32* %131)
br label %133
133: ; preds = %130, %109, %98
store i32 %0, i32* @logRunTime.heatActive_old
store i32 %1, i32* @logRunTime.coolActive_old
ret void
}