#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 timespec {
  long tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ CLOCK_REALTIME;
int /*<<< orphan*/ clock_gettime(int /*<<< orphan*/, struct timespec *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ setTempCtrlSource(int);
void tempCtrl(int tempCtrlMode, float tempSetPoint, float temperature,
              int *heatActive, int *coolActive) {
  static int tempCtrlCurrState = 0;
  static long int startTime;
  static long int timeDelay;
  static long int timeDifference = 0;
  struct timespec gettime_now;
  switch (tempCtrlCurrState) {
  case 0:
    printf("TEMP_OFF_STATE\n");
    setTempCtrlSource(0);
    *heatActive = 0;
    *coolActive = 0;
    switch (tempCtrlMode) {
    case 1:
      if (temperature < tempSetPoint - 0.5f) {
        tempCtrlCurrState = 5;
        timeDelay = 20;
        clock_gettime(CLOCK_REALTIME, &gettime_now);
        startTime = gettime_now.tv_sec;
      }
      break;
    case 2:
      if (temperature > tempSetPoint + 0.5f) {
        tempCtrlCurrState = 5;
        timeDelay = 20;
        clock_gettime(CLOCK_REALTIME, &gettime_now);
        startTime = gettime_now.tv_sec;
      }
      break;
    case 3:
      tempCtrlCurrState = 6;
      break;
    default:
      tempCtrlCurrState = 0;
      break;
    }
    break;
  case 3:
    printf("TEMP_HEAT_STATE\n");
    setTempCtrlSource(1);
    *heatActive = 1;
    timeDifference = 0;
    switch (tempCtrlMode) {
    case 1:
      if (temperature > tempSetPoint) {
        tempCtrlCurrState = 6;
        timeDelay = 300;
        clock_gettime(CLOCK_REALTIME, &gettime_now);
        startTime = gettime_now.tv_sec;
      }
      break;
    case 0:
    case 2:
      tempCtrlCurrState = 6;
      timeDelay = 300;
      clock_gettime(CLOCK_REALTIME, &gettime_now);
      startTime = gettime_now.tv_sec;
      break;
    case 3:
      tempCtrlCurrState = 6;
      break;
    default:
      tempCtrlCurrState = 0;
      break;
    }
    break;
  case 4:
    printf("TEMP_COOL_STATE\n");
    setTempCtrlSource(2);
    *coolActive = 1;
    timeDifference = 0;
    switch (tempCtrlMode) {
    case 2:
      if (temperature < tempSetPoint) {
        tempCtrlCurrState = 6;
        timeDelay = 300;
        clock_gettime(CLOCK_REALTIME, &gettime_now);
        startTime = gettime_now.tv_sec;
      }
      break;
    case 0:
    case 1:
      tempCtrlCurrState = 6;
      clock_gettime(CLOCK_REALTIME, &gettime_now);
      startTime = gettime_now.tv_sec;
      timeDelay = 300;
      break;
    case 3:
      tempCtrlCurrState = 6;
      break;
    default:
      tempCtrlCurrState = 0;
      break;
    }
    break;
  case 5:
    printf("TEMP_FAN_START_STATE\n");
    setTempCtrlSource(3);
    *heatActive = 0;
    *coolActive = 0;
    switch (tempCtrlMode) {
    case 3:
      tempCtrlCurrState = 6;
      break;
    case 2:
    case 0:
    case 1:
      if (timeDifference >= timeDelay) {
        switch (tempCtrlMode) {
        case 2:
          tempCtrlCurrState = 1;
          break;
        case 1:
          tempCtrlCurrState = 2;
          break;
        default:
          tempCtrlCurrState = 7;
          break;
        }
        timeDifference = 0;
        timeDelay = 60;
        clock_gettime(CLOCK_REALTIME, &gettime_now);
        startTime = gettime_now.tv_sec;
      } else {
        clock_gettime(CLOCK_REALTIME, &gettime_now);
        timeDifference = gettime_now.tv_sec - startTime;
      }
      break;
    default:
      tempCtrlCurrState = 0;
      break;
    }
    break;
  case 6:
    printf("TEMP_FAN_STOP_STATE\n");
    setTempCtrlSource(3);
    *heatActive = 0;
    *coolActive = 0;
    switch (tempCtrlMode) {
    case 3:
      tempCtrlCurrState = 6;
      break;
    case 2:
    case 0:
    case 1:
      if (timeDifference >= timeDelay) {
        tempCtrlCurrState = 7;
        timeDifference = 0;
        timeDelay = 5;
        clock_gettime(CLOCK_REALTIME, &gettime_now);
        startTime = gettime_now.tv_sec;
      } else {
        clock_gettime(CLOCK_REALTIME, &gettime_now);
        timeDifference = gettime_now.tv_sec - startTime;
      }
      break;
    default:
      tempCtrlCurrState = 0;
      break;
    }
    break;
  case 7:
    printf("TEMP_OFF_DELAY_STATE\n");
    setTempCtrlSource(0);
    *heatActive = 0;
    *coolActive = 0;
    if (timeDifference >= timeDelay)
      tempCtrlCurrState = 0;
    else {
      clock_gettime(CLOCK_REALTIME, &gettime_now);
      timeDifference = gettime_now.tv_sec - startTime;
    }
    break;
  case 1:
    printf("TEMP_COOL_START_STATE\n");
    setTempCtrlSource(2);
    *coolActive = 1;
    if (timeDifference >= timeDelay)
      tempCtrlCurrState = 4;
    else {
      clock_gettime(CLOCK_REALTIME, &gettime_now);
      timeDifference = gettime_now.tv_sec - startTime;
    }
    break;
  case 2:
    printf("TEMP_HEAT_START_STATE\n");
    setTempCtrlSource(1);
    *heatActive = 1;
    if (timeDifference >= timeDelay)
      tempCtrlCurrState = 3;
    else {
      clock_gettime(CLOCK_REALTIME, &gettime_now);
      timeDifference = gettime_now.tv_sec - startTime;
    }
    break;
  default:
    tempCtrlCurrState = 0;
    *heatActive = 0;
    *coolActive = 0;
    break;
  }
}


x86 assembly (clang, -O0):
<tempCtrl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    0x2eed(%rip),%eax
mov    %rax,-0x30(%rbp)
sub    $0x7,%rax
ja     17e9 <tempCtrl+0x6b9>
mov    -0x30(%rbp),%rax
lea    0xe98(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xeb8(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1050 <setTempCtrlSource@plt>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x4(%rbp),%eax
mov    %eax,-0x34(%rbp)
sub    $0x1,%eax
je     11d2 <tempCtrl+0xa2>
jmp    11b0 <tempCtrl+0x80>
mov    -0x34(%rbp),%eax
sub    $0x2,%eax
je     1228 <tempCtrl+0xf8>
jmp    11c1 <tempCtrl+0x91>
mov    -0x34(%rbp),%eax
sub    $0x3,%eax
je     127a <tempCtrl+0x14a>
jmp    1289 <tempCtrl+0x159>
movss  -0xc(%rbp),%xmm1
movss  -0x8(%rbp),%xmm0
movss  0xe1c(%rip),%xmm2
subss  %xmm2,%xmm0
ucomiss %xmm1,%xmm0
jbe    1223 <tempCtrl+0xf3>
movl   $0x5,0x2e45(%rip)
movq   $0x14,0x2e4a(%rip)
mov    0x2dd3(%rip),%rax
mov    (%rax),%edi
lea    -0x28(%rbp),%rsi
call   1030 <clock_gettime@plt>
mov    -0x28(%rbp),%rax
mov    %rax,0x2e25(%rip)
jmp    1293 <tempCtrl+0x163>
movss  -0xc(%rbp),%xmm0
movss  0xdcb(%rip),%xmm1
addss  -0x8(%rbp),%xmm1
ucomiss %xmm1,%xmm0
jbe    1275 <tempCtrl+0x145>
movl   $0x5,0x2df3(%rip)
movq   $0x14,0x2df8(%rip)
mov    0x2d81(%rip),%rax
mov    (%rax),%edi
lea    -0x28(%rbp),%rsi
call   1030 <clock_gettime@plt>
mov    -0x28(%rbp),%rax
mov    %rax,0x2dd3(%rip)
jmp    1293 <tempCtrl+0x163>
movl   $0x6,0x2dbc(%rip)
jmp    1293 <tempCtrl+0x163>
movl   $0x0,0x2dad(%rip)
jmp    1807 <tempCtrl+0x6d7>
lea    0xda5(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1050 <setTempCtrlSource@plt>
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
movq   $0x0,0x2d95(%rip)
mov    -0x4(%rbp),%eax
mov    %rax,-0x40(%rbp)
sub    $0x3,%rax
ja     1374 <tempCtrl+0x244>
mov    -0x40(%rbp),%rax
lea    0xd45(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  -0xc(%rbp),%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    1329 <tempCtrl+0x1f9>
movl   $0x6,0x2d3f(%rip)
movq   $0x12c,0x2d44(%rip)
mov    0x2ccd(%rip),%rax
mov    (%rax),%edi
lea    -0x28(%rbp),%rsi
call   1030 <clock_gettime@plt>
mov    -0x28(%rbp),%rax
mov    %rax,0x2d1f(%rip)
jmp    137e <tempCtrl+0x24e>
movl   $0x6,0x2d08(%rip)
movq   $0x12c,0x2d0d(%rip)
mov    0x2c96(%rip),%rax
mov    (%rax),%edi
lea    -0x28(%rbp),%rsi
call   1030 <clock_gettime@plt>
mov    -0x28(%rbp),%rax
mov    %rax,0x2ce8(%rip)
jmp    137e <tempCtrl+0x24e>
movl   $0x6,0x2cd1(%rip)
jmp    137e <tempCtrl+0x24e>
movl   $0x0,0x2cc2(%rip)
jmp    1807 <tempCtrl+0x6d7>
lea    0xccb(%rip),%rdi
call   1040 <printf@plt>
mov    $0x2,%edi
call   1050 <setTempCtrlSource@plt>
mov    -0x20(%rbp),%rax
movl   $0x1,(%rax)
movq   $0x0,0x2caa(%rip)
mov    -0x4(%rbp),%eax
mov    %eax,-0x44(%rbp)
sub    $0x2,%eax
jb     142e <tempCtrl+0x2fe>
jmp    13c2 <tempCtrl+0x292>
mov    -0x44(%rbp),%eax
sub    $0x2,%eax
je     13e4 <tempCtrl+0x2b4>
jmp    13d3 <tempCtrl+0x2a3>
mov    -0x44(%rbp),%eax
sub    $0x3,%eax
je     1465 <tempCtrl+0x335>
jmp    1474 <tempCtrl+0x344>
movss  -0xc(%rbp),%xmm1
movss  -0x8(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    1429 <tempCtrl+0x2f9>
movl   $0x6,0x2c3f(%rip)
movq   $0x12c,0x2c44(%rip)
mov    0x2bcd(%rip),%rax
mov    (%rax),%edi
lea    -0x28(%rbp),%rsi
call   1030 <clock_gettime@plt>
mov    -0x28(%rbp),%rax
mov    %rax,0x2c1f(%rip)
jmp    147e <tempCtrl+0x34e>
movl   $0x6,0x2c08(%rip)
mov    0x2ba1(%rip),%rax
mov    (%rax),%edi
lea    -0x28(%rbp),%rsi
call   1030 <clock_gettime@plt>
mov    -0x28(%rbp),%rax
mov    %rax,0x2bf3(%rip)
movq   $0x12c,0x2bf0(%rip)
jmp    147e <tempCtrl+0x34e>
movl   $0x6,0x2bd1(%rip)
jmp    147e <tempCtrl+0x34e>
movl   $0x0,0x2bc2(%rip)
jmp    1807 <tempCtrl+0x6d7>
lea    0xbdc(%rip),%rdi
call   1040 <printf@plt>
mov    $0x3,%edi
call   1050 <setTempCtrlSource@plt>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x4(%rbp),%eax
mov    %eax,-0x48(%rbp)
sub    $0x3,%eax
jb     14e1 <tempCtrl+0x3b1>
jmp    14c1 <tempCtrl+0x391>
mov    -0x48(%rbp),%eax
sub    $0x3,%eax
jne    15a3 <tempCtrl+0x473>
jmp    14d2 <tempCtrl+0x3a2>
movl   $0x6,0x2b64(%rip)
jmp    15ad <tempCtrl+0x47d>
mov    0x2b70(%rip),%rax
cmp    0x2b61(%rip),%rax
jl     157a <tempCtrl+0x44a>
mov    -0x4(%rbp),%eax
mov    %eax,-0x4c(%rbp)
sub    $0x1,%eax
je     1529 <tempCtrl+0x3f9>
jmp    1509 <tempCtrl+0x3d9>
mov    -0x4c(%rbp),%eax
sub    $0x2,%eax
jne    1538 <tempCtrl+0x408>
jmp    151a <tempCtrl+0x3ea>
movl   $0x1,0x2b1c(%rip)
jmp    1542 <tempCtrl+0x412>
movl   $0x2,0x2b0d(%rip)
jmp    1542 <tempCtrl+0x412>
movl   $0x7,0x2afe(%rip)
movq   $0x0,0x2b0b(%rip)
movq   $0x3c,0x2af8(%rip)
mov    0x2a81(%rip),%rax
mov    (%rax),%edi
lea    -0x28(%rbp),%rsi
call   1030 <clock_gettime@plt>
mov    -0x28(%rbp),%rax
mov    %rax,0x2ad3(%rip)
jmp    159e <tempCtrl+0x46e>
mov    0x2a5f(%rip),%rax
mov    (%rax),%edi
lea    -0x28(%rbp),%rsi
call   1030 <clock_gettime@plt>
mov    -0x28(%rbp),%rax
sub    0x2ab1(%rip),%rax
mov    %rax,0x2aba(%rip)
jmp    15ad <tempCtrl+0x47d>
movl   $0x0,0x2a93(%rip)
jmp    1807 <tempCtrl+0x6d7>
lea    0xac3(%rip),%rdi
call   1040 <printf@plt>
mov    $0x3,%edi
call   1050 <setTempCtrlSource@plt>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x4(%rbp),%eax
mov    %eax,-0x50(%rbp)
sub    $0x3,%eax
jb     1610 <tempCtrl+0x4e0>
jmp    15f0 <tempCtrl+0x4c0>
mov    -0x50(%rbp),%eax
sub    $0x3,%eax
jne    168f <tempCtrl+0x55f>
jmp    1601 <tempCtrl+0x4d1>
movl   $0x6,0x2a35(%rip)
jmp    1699 <tempCtrl+0x569>
mov    0x2a41(%rip),%rax
cmp    0x2a32(%rip),%rax
jl     1666 <tempCtrl+0x536>
movl   $0x7,0x2a12(%rip)
movq   $0x0,0x2a1f(%rip)
movq   $0x5,0x2a0c(%rip)
mov    0x2995(%rip),%rax
mov    (%rax),%edi
lea    -0x28(%rbp),%rsi
call   1030 <clock_gettime@plt>
mov    -0x28(%rbp),%rax
mov    %rax,0x29e7(%rip)
jmp    168a <tempCtrl+0x55a>
mov    0x2973(%rip),%rax
mov    (%rax),%edi
lea    -0x28(%rbp),%rsi
call   1030 <clock_gettime@plt>
mov    -0x28(%rbp),%rax
sub    0x29c5(%rip),%rax
mov    %rax,0x29ce(%rip)
jmp    1699 <tempCtrl+0x569>
movl   $0x0,0x29a7(%rip)
jmp    1807 <tempCtrl+0x6d7>
lea    0x9ec(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1050 <setTempCtrlSource@plt>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    0x298c(%rip),%rax
cmp    0x297d(%rip),%rax
jl     16e8 <tempCtrl+0x5b8>
movl   $0x0,0x295d(%rip)
jmp    170c <tempCtrl+0x5dc>
mov    0x28f1(%rip),%rax
mov    (%rax),%edi
lea    -0x28(%rbp),%rsi
call   1030 <clock_gettime@plt>
mov    -0x28(%rbp),%rax
sub    0x2943(%rip),%rax
mov    %rax,0x294c(%rip)
jmp    1807 <tempCtrl+0x6d7>
lea    0x98f(%rip),%rdi
call   1040 <printf@plt>
mov    $0x2,%edi
call   1050 <setTempCtrlSource@plt>
mov    -0x20(%rbp),%rax
movl   $0x1,(%rax)
mov    0x2920(%rip),%rax
cmp    0x2911(%rip),%rax
jl     1754 <tempCtrl+0x624>
movl   $0x4,0x28f1(%rip)
jmp    1778 <tempCtrl+0x648>
mov    0x2885(%rip),%rax
mov    (%rax),%edi
lea    -0x28(%rbp),%rsi
call   1030 <clock_gettime@plt>
mov    -0x28(%rbp),%rax
sub    0x28d7(%rip),%rax
mov    %rax,0x28e0(%rip)
jmp    1807 <tempCtrl+0x6d7>
lea    0x93a(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1050 <setTempCtrlSource@plt>
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
mov    0x28b4(%rip),%rax
cmp    0x28a5(%rip),%rax
jl     17c0 <tempCtrl+0x690>
movl   $0x3,0x2885(%rip)
jmp    17e4 <tempCtrl+0x6b4>
mov    0x2819(%rip),%rax
mov    (%rax),%edi
lea    -0x28(%rbp),%rsi
call   1030 <clock_gettime@plt>
mov    -0x28(%rbp),%rax
sub    0x286b(%rip),%rax
mov    %rax,0x2874(%rip)
jmp    1807 <tempCtrl+0x6d7>
movl   $0x0,0x284d(%rip)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tempCtrl>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%rbx
mov    %rsi,%rbp
mov    0x2efc(%rip),%eax
cmp    $0x7,%rax
ja     11c5 <tempCtrl+0x95>
mov    %edi,%r14d
lea    0xeb4(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  %xmm0,0x8(%rsp)
movss  %xmm1,0xc(%rsp)
lea    0xf52(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1050 <setTempCtrlSource@plt>
movl   $0x0,0x0(%rbp)
movl   $0x0,(%rbx)
cmp    $0x3,%r14d
je     147c <tempCtrl+0x34c>
cmp    $0x2,%r14d
je     14ca <tempCtrl+0x39a>
cmp    $0x1,%r14d
jne    148b <tempCtrl+0x35b>
movss  0x8(%rsp),%xmm0
addss  0xe4f(%rip),%xmm0
ucomiss 0xc(%rsp),%xmm0
ja     14e3 <tempCtrl+0x3b3>
jmp    1514 <tempCtrl+0x3e4>
movl   $0x0,0x2e71(%rip)
movl   $0x0,0x0(%rbp)
movl   $0x0,(%rbx)
jmp    1514 <tempCtrl+0x3e4>
lea    0xe66(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2,%edi
call   1050 <setTempCtrlSource@plt>
movl   $0x1,(%rbx)
mov    0x2e54(%rip),%rax
cmp    0x2e45(%rip),%rax
jl     1452 <tempCtrl+0x322>
movl   $0x4,0x2e25(%rip)
jmp    1514 <tempCtrl+0x3e4>
lea    0xe11(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1050 <setTempCtrlSource@plt>
movl   $0x1,0x0(%rbp)
mov    0x2e14(%rip),%rax
cmp    0x2e05(%rip),%rax
jl     1452 <tempCtrl+0x322>
movl   $0x3,0x2de5(%rip)
jmp    1514 <tempCtrl+0x3e4>
movss  %xmm0,0x8(%rsp)
movss  %xmm1,0xc(%rsp)
lea    0xe3f(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1050 <setTempCtrlSource@plt>
movl   $0x1,0x0(%rbp)
movq   $0x0,0x2dc4(%rip)
cmp    $0x3,%r14d
ja     148b <tempCtrl+0x35b>
mov    %r14d,%eax
lea    0xd80(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  0xc(%rsp),%xmm0
ucomiss 0x8(%rsp),%xmm0
ja     1329 <tempCtrl+0x1f9>
jmp    1514 <tempCtrl+0x3e4>
movss  %xmm0,0x8(%rsp)
movss  %xmm1,0xc(%rsp)
lea    0xdcc(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2,%edi
call   1050 <setTempCtrlSource@plt>
movl   $0x1,(%rbx)
movq   $0x0,0x2d62(%rip)
cmp    $0x2,%r14d
jb     1497 <tempCtrl+0x367>
cmp    $0x3,%r14d
movss  0xc(%rsp),%xmm0
je     147c <tempCtrl+0x34c>
cmp    $0x2,%r14d
jne    148b <tempCtrl+0x35b>
movss  0x8(%rsp),%xmm1
ucomiss %xmm0,%xmm1
jbe    1514 <tempCtrl+0x3e4>
movl   $0x6,0x2d0d(%rip)
movq   $0x12c,0x2d12(%rip)
jmp    14f8 <tempCtrl+0x3c8>
lea    0xd43(%rip),%rdi
call   1030 <puts@plt>
mov    $0x3,%edi
call   1050 <setTempCtrlSource@plt>
movl   $0x0,0x0(%rbp)
movl   $0x0,(%rbx)
cmp    $0x3,%r14d
jae    147a <tempCtrl+0x34a>
mov    0x2ce1(%rip),%rax
cmp    0x2cd2(%rip),%rax
jl     1452 <tempCtrl+0x322>
xor    %eax,%eax
cmp    $0x1,%r14d
setne  %al
lea    (%rax,%rax,4),%eax
add    $0x2,%eax
cmp    $0x2,%r14d
mov    $0x1,%ecx
cmovne %eax,%ecx
mov    %ecx,0x2c9b(%rip)
movq   $0x0,0x2ca8(%rip)
movq   $0x3c,0x2c95(%rip)
jmp    14f8 <tempCtrl+0x3c8>
lea    0xcb2(%rip),%rdi
call   1030 <puts@plt>
mov    $0x3,%edi
call   1050 <setTempCtrlSource@plt>
movl   $0x0,0x0(%rbp)
movl   $0x0,(%rbx)
cmp    $0x3,%r14d
jae    147a <tempCtrl+0x34a>
mov    0x2c64(%rip),%rax
cmp    0x2c55(%rip),%rax
jl     1452 <tempCtrl+0x322>
movl   $0x7,0x2c39(%rip)
movq   $0x0,0x2c46(%rip)
movq   $0x5,0x2c33(%rip)
jmp    14f8 <tempCtrl+0x3c8>
lea    0xc3b(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1050 <setTempCtrlSource@plt>
movl   $0x0,0x0(%rbp)
movl   $0x0,(%rbx)
mov    0x2c0f(%rip),%rax
cmp    0x2c00(%rip),%rax
jge    148b <tempCtrl+0x35b>
mov    0x2b87(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
call   1040 <clock_gettime@plt>
mov    (%rsp),%rax
sub    0x2bda(%rip),%rax
mov    %rax,0x2be3(%rip)
jmp    1514 <tempCtrl+0x3e4>
jne    148b <tempCtrl+0x35b>
movl   $0x6,0x2bba(%rip)
jmp    1514 <tempCtrl+0x3e4>
movl   $0x0,0x2bab(%rip)
jmp    1514 <tempCtrl+0x3e4>
movl   $0x6,0x2b9f(%rip)
mov    0x2b38(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
call   1040 <clock_gettime@plt>
mov    (%rsp),%rax
mov    %rax,0x2b8b(%rip)
movq   $0x12c,0x2b88(%rip)
jmp    1514 <tempCtrl+0x3e4>
movss  0x8(%rsp),%xmm1
addss  0xb28(%rip),%xmm1
movss  0xc(%rsp),%xmm0
ucomiss %xmm1,%xmm0
jbe    1514 <tempCtrl+0x3e4>
movl   $0x5,0x2b53(%rip)
movq   $0x14,0x2b58(%rip)
mov    0x2ae1(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
call   1040 <clock_gettime@plt>
mov    (%rsp),%rax
mov    %rax,0x2b34(%rip)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.timespec = type { i64 }
@tempCtrl.tempCtrlCurrState = internal global i32 0
@tempCtrl.startTime = internal global i64 0
@tempCtrl.timeDelay = internal global i64 0
@tempCtrl.timeDifference = internal global i64 0
@.str = [16 x i8] c"TEMP_OFF_STATE\0A\00"
@CLOCK_REALTIME = global i32 0
@.str.1 = [17 x i8] c"TEMP_HEAT_STATE\0A\00"
@.str.2 = [17 x i8] c"TEMP_COOL_STATE\0A\00"
@.str.3 = [22 x i8] c"TEMP_FAN_START_STATE\0A\00"
@.str.4 = [21 x i8] c"TEMP_FAN_STOP_STATE\0A\00"
@.str.5 = [22 x i8] c"TEMP_OFF_DELAY_STATE\0A\00"
@.str.6 = [23 x i8] c"TEMP_COOL_START_STATE\0A\00"
@.str.7 = [23 x i8] c"TEMP_HEAT_START_STATE\0A\00"
define void @tempCtrl(i32 %0, float %1, float %2, i32* %3, i32* %4) {
%6 = alloca i32
%7 = alloca float
%8 = alloca float
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca %struct.timespec
store i32 %0, i32* %6
store float %1, float* %7
store float %2, float* %8
store i32* %3, i32** %9
store i32* %4, i32** %10
%12 = load i32, i32* @tempCtrl.tempCtrlCurrState
switch i32 %12, label %196 [
i32 0, label %13
i32 3, label %44
i32 4, label %67
i32 5, label %90
i32 6, label %121
i32 7, label %147
i32 1, label %164
i32 2, label %180
]
13: ; preds = %5
%14 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @setTempCtrlSource(i32 0)
%16 = load i32*, i32** %9
store i32 0, i32* %16
%17 = load i32*, i32** %10
store i32 0, i32* %17
%18 = load i32, i32* %6
switch i32 %18, label %42 [
i32 1, label %19
i32 2, label %30
i32 3, label %41
]
19: ; preds = %13
%20 = load float, float* %8
%21 = load float, float* %7
%22 = fsub float %21, 5.000000e-01
%23 = fcmp olt float %20, %22
br i1 %23, label %24, label %29
24: ; preds = %19
store i32 5, i32* @tempCtrl.tempCtrlCurrState
store i64 20, i64* @tempCtrl.timeDelay
%25 = load i32, i32* @CLOCK_REALTIME
%26 = call i32 @clock_gettime(i32 %25, %struct.timespec* %11)
%27 = getelementptr inbounds %struct.timespec, %struct.timespec* %11, i32 0, i32 0
%28 = load i64, i64* %27
store i64 %28, i64* @tempCtrl.startTime
br label %29
29: ; preds = %24, %19
br label %43
30: ; preds = %13
%31 = load float, float* %8
%32 = load float, float* %7
%33 = fadd float %32, 5.000000e-01
%34 = fcmp ogt float %31, %33
br i1 %34, label %35, label %40
35: ; preds = %30
store i32 5, i32* @tempCtrl.tempCtrlCurrState
store i64 20, i64* @tempCtrl.timeDelay
%36 = load i32, i32* @CLOCK_REALTIME
%37 = call i32 @clock_gettime(i32 %36, %struct.timespec* %11)
%38 = getelementptr inbounds %struct.timespec, %struct.timespec* %11, i32 0, i32 0
%39 = load i64, i64* %38
store i64 %39, i64* @tempCtrl.startTime
br label %40
40: ; preds = %35, %30
br label %43
41: ; preds = %13
store i32 6, i32* @tempCtrl.tempCtrlCurrState
br label %43
42: ; preds = %13
store i32 0, i32* @tempCtrl.tempCtrlCurrState
br label %43
43: ; preds = %42, %41, %40, %29
br label %199
44: ; preds = %5
%45 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%46 = call i32 @setTempCtrlSource(i32 1)
%47 = load i32*, i32** %9
store i32 1, i32* %47
store i64 0, i64* @tempCtrl.timeDifference
%48 = load i32, i32* %6
switch i32 %48, label %65 [
i32 1, label %49
i32 0, label %59
i32 2, label %59
i32 3, label %64
]
49: ; preds = %44
%50 = load float, float* %8
%51 = load float, float* %7
%52 = fcmp ogt float %50, %51
br i1 %52, label %53, label %58
53: ; preds = %49
store i32 6, i32* @tempCtrl.tempCtrlCurrState
store i64 300, i64* @tempCtrl.timeDelay
%54 = load i32, i32* @CLOCK_REALTIME
%55 = call i32 @clock_gettime(i32 %54, %struct.timespec* %11)
%56 = getelementptr inbounds %struct.timespec, %struct.timespec* %11, i32 0, i32 0
%57 = load i64, i64* %56
store i64 %57, i64* @tempCtrl.startTime
br label %58
58: ; preds = %53, %49
br label %66
59: ; preds = %44, %44
store i32 6, i32* @tempCtrl.tempCtrlCurrState
store i64 300, i64* @tempCtrl.timeDelay
%60 = load i32, i32* @CLOCK_REALTIME
%61 = call i32 @clock_gettime(i32 %60, %struct.timespec* %11)
%62 = getelementptr inbounds %struct.timespec, %struct.timespec* %11, i32 0, i32 0
%63 = load i64, i64* %62
store i64 %63, i64* @tempCtrl.startTime
br label %66
64: ; preds = %44
store i32 6, i32* @tempCtrl.tempCtrlCurrState
br label %66
65: ; preds = %44
store i32 0, i32* @tempCtrl.tempCtrlCurrState
br label %66
66: ; preds = %65, %64, %59, %58
br label %199
67: ; preds = %5
%68 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%69 = call i32 @setTempCtrlSource(i32 2)
%70 = load i32*, i32** %10
store i32 1, i32* %70
store i64 0, i64* @tempCtrl.timeDifference
%71 = load i32, i32* %6
switch i32 %71, label %88 [
i32 2, label %72
i32 0, label %82
i32 1, label %82
i32 3, label %87
]
72: ; preds = %67
%73 = load float, float* %8
%74 = load float, float* %7
%75 = fcmp olt float %73, %74
br i1 %75, label %76, label %81
76: ; preds = %72
store i32 6, i32* @tempCtrl.tempCtrlCurrState
store i64 300, i64* @tempCtrl.timeDelay
%77 = load i32, i32* @CLOCK_REALTIME
%78 = call i32 @clock_gettime(i32 %77, %struct.timespec* %11)
%79 = getelementptr inbounds %struct.timespec, %struct.timespec* %11, i32 0, i32 0
%80 = load i64, i64* %79
store i64 %80, i64* @tempCtrl.startTime
br label %81
81: ; preds = %76, %72
br label %89
82: ; preds = %67, %67
store i32 6, i32* @tempCtrl.tempCtrlCurrState
%83 = load i32, i32* @CLOCK_REALTIME
%84 = call i32 @clock_gettime(i32 %83, %struct.timespec* %11)
%85 = getelementptr inbounds %struct.timespec, %struct.timespec* %11, i32 0, i32 0
%86 = load i64, i64* %85
store i64 %86, i64* @tempCtrl.startTime
store i64 300, i64* @tempCtrl.timeDelay
br label %89
87: ; preds = %67
store i32 6, i32* @tempCtrl.tempCtrlCurrState
br label %89
88: ; preds = %67
store i32 0, i32* @tempCtrl.tempCtrlCurrState
br label %89
89: ; preds = %88, %87, %82, %81
br label %199
90: ; preds = %5
%91 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%92 = call i32 @setTempCtrlSource(i32 3)
%93 = load i32*, i32** %9
store i32 0, i32* %93
%94 = load i32*, i32** %10
store i32 0, i32* %94
%95 = load i32, i32* %6
switch i32 %95, label %119 [
i32 3, label %96
i32 2, label %97
i32 0, label %97
i32 1, label %97
]
96: ; preds = %90
store i32 6, i32* @tempCtrl.tempCtrlCurrState
br label %120
97: ; preds = %90, %90, %90
%98 = load i64, i64* @tempCtrl.timeDifference
%99 = load i64, i64* @tempCtrl.timeDelay
%100 = icmp sge i64 %98, %99
br i1 %100, label %101, label %111
101: ; preds = %97
%102 = load i32, i32* %6
switch i32 %102, label %105 [
i32 2, label %103
i32 1, label %104
]
103: ; preds = %101
store i32 1, i32* @tempCtrl.tempCtrlCurrState
br label %106
104: ; preds = %101
store i32 2, i32* @tempCtrl.tempCtrlCurrState
br label %106
105: ; preds = %101
store i32 7, i32* @tempCtrl.tempCtrlCurrState
br label %106
106: ; preds = %105, %104, %103
store i64 0, i64* @tempCtrl.timeDifference
store i64 60, i64* @tempCtrl.timeDelay
%107 = load i32, i32* @CLOCK_REALTIME
%108 = call i32 @clock_gettime(i32 %107, %struct.timespec* %11)
%109 = getelementptr inbounds %struct.timespec, %struct.timespec* %11, i32 0, i32 0
%110 = load i64, i64* %109
store i64 %110, i64* @tempCtrl.startTime
br label %118
111: ; preds = %97
%112 = load i32, i32* @CLOCK_REALTIME
%113 = call i32 @clock_gettime(i32 %112, %struct.timespec* %11)
%114 = getelementptr inbounds %struct.timespec, %struct.timespec* %11, i32 0, i32 0
%115 = load i64, i64* %114
%116 = load i64, i64* @tempCtrl.startTime
%117 = sub nsw i64 %115, %116
store i64 %117, i64* @tempCtrl.timeDifference
br label %118
118: ; preds = %111, %106
br label %120
119: ; preds = %90
store i32 0, i32* @tempCtrl.tempCtrlCurrState
br label %120
120: ; preds = %119, %118, %96
br label %199
121: ; preds = %5
%122 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%123 = call i32 @setTempCtrlSource(i32 3)
%124 = load i32*, i32** %9
store i32 0, i32* %124
%125 = load i32*, i32** %10
store i32 0, i32* %125
%126 = load i32, i32* %6
switch i32 %126, label %145 [
i32 3, label %127
i32 2, label %128
i32 0, label %128
i32 1, label %128
]
127: ; preds = %121
store i32 6, i32* @tempCtrl.tempCtrlCurrState
br label %146
128: ; preds = %121, %121, %121
%129 = load i64, i64* @tempCtrl.timeDifference
%130 = load i64, i64* @tempCtrl.timeDelay
%131 = icmp sge i64 %129, %130
br i1 %131, label %132, label %137
132: ; preds = %128
store i32 7, i32* @tempCtrl.tempCtrlCurrState
store i64 0, i64* @tempCtrl.timeDifference
store i64 5, i64* @tempCtrl.timeDelay
%133 = load i32, i32* @CLOCK_REALTIME
%134 = call i32 @clock_gettime(i32 %133, %struct.timespec* %11)
%135 = getelementptr inbounds %struct.timespec, %struct.timespec* %11, i32 0, i32 0
%136 = load i64, i64* %135
store i64 %136, i64* @tempCtrl.startTime
br label %144
137: ; preds = %128
%138 = load i32, i32* @CLOCK_REALTIME
%139 = call i32 @clock_gettime(i32 %138, %struct.timespec* %11)
%140 = getelementptr inbounds %struct.timespec, %struct.timespec* %11, i32 0, i32 0
%141 = load i64, i64* %140
%142 = load i64, i64* @tempCtrl.startTime
%143 = sub nsw i64 %141, %142
store i64 %143, i64* @tempCtrl.timeDifference
br label %144
144: ; preds = %137, %132
br label %146
145: ; preds = %121
store i32 0, i32* @tempCtrl.tempCtrlCurrState
br label %146
146: ; preds = %145, %144, %127
br label %199
147: ; preds = %5
%148 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
%149 = call i32 @setTempCtrlSource(i32 0)
%150 = load i32*, i32** %9
store i32 0, i32* %150
%151 = load i32*, i32** %10
store i32 0, i32* %151
%152 = load i64, i64* @tempCtrl.timeDifference
%153 = load i64, i64* @tempCtrl.timeDelay
%154 = icmp sge i64 %152, %153
br i1 %154, label %155, label %156
155: ; preds = %147
store i32 0, i32* @tempCtrl.tempCtrlCurrState
br label %163
156: ; preds = %147
%157 = load i32, i32* @CLOCK_REALTIME
%158 = call i32 @clock_gettime(i32 %157, %struct.timespec* %11)
%159 = getelementptr inbounds %struct.timespec, %struct.timespec* %11, i32 0, i32 0
%160 = load i64, i64* %159
%161 = load i64, i64* @tempCtrl.startTime
%162 = sub nsw i64 %160, %161
store i64 %162, i64* @tempCtrl.timeDifference
br label %163
163: ; preds = %156, %155
br label %199
164: ; preds = %5
%165 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
%166 = call i32 @setTempCtrlSource(i32 2)
%167 = load i32*, i32** %10
store i32 1, i32* %167
%168 = load i64, i64* @tempCtrl.timeDifference
%169 = load i64, i64* @tempCtrl.timeDelay
%170 = icmp sge i64 %168, %169
br i1 %170, label %171, label %172
171: ; preds = %164
store i32 4, i32* @tempCtrl.tempCtrlCurrState
br label %179
172: ; preds = %164
%173 = load i32, i32* @CLOCK_REALTIME
%174 = call i32 @clock_gettime(i32 %173, %struct.timespec* %11)
%175 = getelementptr inbounds %struct.timespec, %struct.timespec* %11, i32 0, i32 0
%176 = load i64, i64* %175
%177 = load i64, i64* @tempCtrl.startTime
%178 = sub nsw i64 %176, %177
store i64 %178, i64* @tempCtrl.timeDifference
br label %179
179: ; preds = %172, %171
br label %199
180: ; preds = %5
%181 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
%182 = call i32 @setTempCtrlSource(i32 1)
%183 = load i32*, i32** %9
store i32 1, i32* %183
%184 = load i64, i64* @tempCtrl.timeDifference
%185 = load i64, i64* @tempCtrl.timeDelay
%186 = icmp sge i64 %184, %185
br i1 %186, label %187, label %188
187: ; preds = %180
store i32 3, i32* @tempCtrl.tempCtrlCurrState
br label %195
188: ; preds = %180
%189 = load i32, i32* @CLOCK_REALTIME
%190 = call i32 @clock_gettime(i32 %189, %struct.timespec* %11)
%191 = getelementptr inbounds %struct.timespec, %struct.timespec* %11, i32 0, i32 0
%192 = load i64, i64* %191
%193 = load i64, i64* @tempCtrl.startTime
%194 = sub nsw i64 %192, %193
store i64 %194, i64* @tempCtrl.timeDifference
br label %195
195: ; preds = %188, %187
br label %199
196: ; preds = %5
store i32 0, i32* @tempCtrl.tempCtrlCurrState
%197 = load i32*, i32** %9
store i32 0, i32* %197
%198 = load i32*, i32** %10
store i32 0, i32* %198
br label %199
199: ; preds = %196, %195, %179, %163, %146, %120, %89, %66, %43
ret void
}

LLVM IR (-O2):
%struct.timespec = type { i64 }
@tempCtrl.tempCtrlCurrState = internal unnamed_addr global i32 0
@tempCtrl.startTime = internal unnamed_addr global i64 0
@tempCtrl.timeDelay = internal unnamed_addr global i64 0
@tempCtrl.timeDifference = internal unnamed_addr global i64 0
@CLOCK_REALTIME = global i32 0
@str = [22 x i8] c"TEMP_HEAT_START_STATE\00"
@str.8 = [22 x i8] c"TEMP_COOL_START_STATE\00"
@str.9 = [21 x i8] c"TEMP_OFF_DELAY_STATE\00"
@str.10 = [20 x i8] c"TEMP_FAN_STOP_STATE\00"
@str.11 = [21 x i8] c"TEMP_FAN_START_STATE\00"
@str.12 = [16 x i8] c"TEMP_COOL_STATE\00"
@str.13 = [16 x i8] c"TEMP_HEAT_STATE\00"
@str.14 = [15 x i8] c"TEMP_OFF_STATE\00"
define void @tempCtrl(i32 %0, float %1, float %2, i32* nocapture writeonly %3, i32* nocapture writeonly %4) {
%6 = alloca %struct.timespec
%7 = bitcast %struct.timespec* %6 to i8*
%8 = load i32, i32* @tempCtrl.tempCtrlCurrState
switch i32 %8, label %152 [
i32 0, label %9
i32 3, label %30
i32 4, label %47
i32 5, label %64
i32 6, label %89
i32 7, label %110
i32 1, label %124
i32 2, label %138
]
9: ; preds = %5
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.14, i64 0, i64 0))
%11 = tail call i32 @setTempCtrlSource(i32 0)
store i32 0, i32* %3
store i32 0, i32* %4
switch i32 %0, label %29 [
i32 1, label %12
i32 2, label %20
i32 3, label %28
]
12: ; preds = %9
%13 = fadd float %1, -5.000000e-01
%14 = fcmp ogt float %13, %2
br i1 %14, label %15, label %153
15: ; preds = %12
store i32 5, i32* @tempCtrl.tempCtrlCurrState
store i64 20, i64* @tempCtrl.timeDelay
%16 = load i32, i32* @CLOCK_REALTIME
%17 = call i32 @clock_gettime(i32 %16, %struct.timespec* %6)
%18 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i64 0, i32 0
%19 = load i64, i64* %18
store i64 %19, i64* @tempCtrl.startTime
br label %153
20: ; preds = %9
%21 = fadd float %1, 5.000000e-01
%22 = fcmp olt float %21, %2
br i1 %22, label %23, label %153
23: ; preds = %20
store i32 5, i32* @tempCtrl.tempCtrlCurrState
store i64 20, i64* @tempCtrl.timeDelay
%24 = load i32, i32* @CLOCK_REALTIME
%25 = call i32 @clock_gettime(i32 %24, %struct.timespec* %6)
%26 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i64 0, i32 0
%27 = load i64, i64* %26
store i64 %27, i64* @tempCtrl.startTime
br label %153
28: ; preds = %9
store i32 6, i32* @tempCtrl.tempCtrlCurrState
br label %153
29: ; preds = %9
store i32 0, i32* @tempCtrl.tempCtrlCurrState
br label %153
30: ; preds = %5
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.13, i64 0, i64 0))
%32 = tail call i32 @setTempCtrlSource(i32 1)
store i32 1, i32* %3
store i64 0, i64* @tempCtrl.timeDifference
switch i32 %0, label %46 [
i32 1, label %33
i32 0, label %40
i32 2, label %40
i32 3, label %45
]
33: ; preds = %30
%34 = fcmp ogt float %2, %1
br i1 %34, label %35, label %153
35: ; preds = %33
store i32 6, i32* @tempCtrl.tempCtrlCurrState
store i64 300, i64* @tempCtrl.timeDelay
%36 = load i32, i32* @CLOCK_REALTIME
%37 = call i32 @clock_gettime(i32 %36, %struct.timespec* %6)
%38 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i64 0, i32 0
%39 = load i64, i64* %38
store i64 %39, i64* @tempCtrl.startTime
br label %153
40: ; preds = %30, %30
store i32 6, i32* @tempCtrl.tempCtrlCurrState
store i64 300, i64* @tempCtrl.timeDelay
%41 = load i32, i32* @CLOCK_REALTIME
%42 = call i32 @clock_gettime(i32 %41, %struct.timespec* %6)
%43 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i64 0, i32 0
%44 = load i64, i64* %43
store i64 %44, i64* @tempCtrl.startTime
br label %153
45: ; preds = %30
store i32 6, i32* @tempCtrl.tempCtrlCurrState
br label %153
46: ; preds = %30
store i32 0, i32* @tempCtrl.tempCtrlCurrState
br label %153
47: ; preds = %5
%48 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.12, i64 0, i64 0))
%49 = tail call i32 @setTempCtrlSource(i32 2)
store i32 1, i32* %4
store i64 0, i64* @tempCtrl.timeDifference
switch i32 %0, label %63 [
i32 2, label %50
i32 0, label %57
i32 1, label %57
i32 3, label %62
]
50: ; preds = %47
%51 = fcmp olt float %2, %1
br i1 %51, label %52, label %153
52: ; preds = %50
store i32 6, i32* @tempCtrl.tempCtrlCurrState
store i64 300, i64* @tempCtrl.timeDelay
%53 = load i32, i32* @CLOCK_REALTIME
%54 = call i32 @clock_gettime(i32 %53, %struct.timespec* %6)
%55 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i64 0, i32 0
%56 = load i64, i64* %55
store i64 %56, i64* @tempCtrl.startTime
br label %153
57: ; preds = %47, %47
store i32 6, i32* @tempCtrl.tempCtrlCurrState
%58 = load i32, i32* @CLOCK_REALTIME
%59 = call i32 @clock_gettime(i32 %58, %struct.timespec* %6)
%60 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i64 0, i32 0
%61 = load i64, i64* %60
store i64 %61, i64* @tempCtrl.startTime
store i64 300, i64* @tempCtrl.timeDelay
br label %153
62: ; preds = %47
store i32 6, i32* @tempCtrl.tempCtrlCurrState
br label %153
63: ; preds = %47
store i32 0, i32* @tempCtrl.tempCtrlCurrState
br label %153
64: ; preds = %5
%65 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.11, i64 0, i64 0))
%66 = tail call i32 @setTempCtrlSource(i32 3)
store i32 0, i32* %3
store i32 0, i32* %4
switch i32 %0, label %88 [
i32 3, label %67
i32 2, label %68
i32 0, label %68
i32 1, label %68
]
67: ; preds = %64
store i32 6, i32* @tempCtrl.tempCtrlCurrState
br label %153
68: ; preds = %64, %64, %64
%69 = load i64, i64* @tempCtrl.timeDifference
%70 = load i64, i64* @tempCtrl.timeDelay
%71 = icmp slt i64 %69, %70
br i1 %71, label %81, label %72
72: ; preds = %68
%73 = icmp eq i32 %0, 1
%74 = select i1 %73, i32 2, i32 7
%75 = icmp eq i32 %0, 2
%76 = select i1 %75, i32 1, i32 %74
store i32 %76, i32* @tempCtrl.tempCtrlCurrState
store i64 0, i64* @tempCtrl.timeDifference
store i64 60, i64* @tempCtrl.timeDelay
%77 = load i32, i32* @CLOCK_REALTIME
%78 = call i32 @clock_gettime(i32 %77, %struct.timespec* %6)
%79 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i64 0, i32 0
%80 = load i64, i64* %79
store i64 %80, i64* @tempCtrl.startTime
br label %153
81: ; preds = %68
%82 = load i32, i32* @CLOCK_REALTIME
%83 = call i32 @clock_gettime(i32 %82, %struct.timespec* %6)
%84 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i64 0, i32 0
%85 = load i64, i64* %84
%86 = load i64, i64* @tempCtrl.startTime
%87 = sub nsw i64 %85, %86
store i64 %87, i64* @tempCtrl.timeDifference
br label %153
88: ; preds = %64
store i32 0, i32* @tempCtrl.tempCtrlCurrState
br label %153
89: ; preds = %5
%90 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.10, i64 0, i64 0))
%91 = tail call i32 @setTempCtrlSource(i32 3)
store i32 0, i32* %3
store i32 0, i32* %4
switch i32 %0, label %109 [
i32 3, label %92
i32 2, label %93
i32 0, label %93
i32 1, label %93
]
92: ; preds = %89
store i32 6, i32* @tempCtrl.tempCtrlCurrState
br label %153
93: ; preds = %89, %89, %89
%94 = load i64, i64* @tempCtrl.timeDifference
%95 = load i64, i64* @tempCtrl.timeDelay
%96 = icmp slt i64 %94, %95
br i1 %96, label %102, label %97
97: ; preds = %93
store i32 7, i32* @tempCtrl.tempCtrlCurrState
store i64 0, i64* @tempCtrl.timeDifference
store i64 5, i64* @tempCtrl.timeDelay
%98 = load i32, i32* @CLOCK_REALTIME
%99 = call i32 @clock_gettime(i32 %98, %struct.timespec* %6)
%100 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i64 0, i32 0
%101 = load i64, i64* %100
store i64 %101, i64* @tempCtrl.startTime
br label %153
102: ; preds = %93
%103 = load i32, i32* @CLOCK_REALTIME
%104 = call i32 @clock_gettime(i32 %103, %struct.timespec* %6)
%105 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i64 0, i32 0
%106 = load i64, i64* %105
%107 = load i64, i64* @tempCtrl.startTime
%108 = sub nsw i64 %106, %107
store i64 %108, i64* @tempCtrl.timeDifference
br label %153
109: ; preds = %89
store i32 0, i32* @tempCtrl.tempCtrlCurrState
br label %153
110: ; preds = %5
%111 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.9, i64 0, i64 0))
%112 = tail call i32 @setTempCtrlSource(i32 0)
store i32 0, i32* %3
store i32 0, i32* %4
%113 = load i64, i64* @tempCtrl.timeDifference
%114 = load i64, i64* @tempCtrl.timeDelay
%115 = icmp slt i64 %113, %114
br i1 %115, label %117, label %116
116: ; preds = %110
store i32 0, i32* @tempCtrl.tempCtrlCurrState
br label %153
117: ; preds = %110
%118 = load i32, i32* @CLOCK_REALTIME
%119 = call i32 @clock_gettime(i32 %118, %struct.timespec* %6)
%120 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i64 0, i32 0
%121 = load i64, i64* %120
%122 = load i64, i64* @tempCtrl.startTime
%123 = sub nsw i64 %121, %122
store i64 %123, i64* @tempCtrl.timeDifference
br label %153
124: ; preds = %5
%125 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.8, i64 0, i64 0))
%126 = tail call i32 @setTempCtrlSource(i32 2)
store i32 1, i32* %4
%127 = load i64, i64* @tempCtrl.timeDifference
%128 = load i64, i64* @tempCtrl.timeDelay
%129 = icmp slt i64 %127, %128
br i1 %129, label %131, label %130
130: ; preds = %124
store i32 4, i32* @tempCtrl.tempCtrlCurrState
br label %153
131: ; preds = %124
%132 = load i32, i32* @CLOCK_REALTIME
%133 = call i32 @clock_gettime(i32 %132, %struct.timespec* %6)
%134 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i64 0, i32 0
%135 = load i64, i64* %134
%136 = load i64, i64* @tempCtrl.startTime
%137 = sub nsw i64 %135, %136
store i64 %137, i64* @tempCtrl.timeDifference
br label %153
138: ; preds = %5
%139 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%140 = tail call i32 @setTempCtrlSource(i32 1)
store i32 1, i32* %3
%141 = load i64, i64* @tempCtrl.timeDifference
%142 = load i64, i64* @tempCtrl.timeDelay
%143 = icmp slt i64 %141, %142
br i1 %143, label %145, label %144
144: ; preds = %138
store i32 3, i32* @tempCtrl.tempCtrlCurrState
br label %153
145: ; preds = %138
%146 = load i32, i32* @CLOCK_REALTIME
%147 = call i32 @clock_gettime(i32 %146, %struct.timespec* %6)
%148 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i64 0, i32 0
%149 = load i64, i64* %148
%150 = load i64, i64* @tempCtrl.startTime
%151 = sub nsw i64 %149, %150
store i64 %151, i64* @tempCtrl.timeDifference
br label %153
152: ; preds = %5
store i32 0, i32* @tempCtrl.tempCtrlCurrState
store i32 0, i32* %3
store i32 0, i32* %4
br label %153
153: ; preds = %144, %145, %130, %131, %116, %117, %92, %109, %102, %97, %67, %88, %81, %72, %57, %62, %63, %52, %50, %40, %45, %46, %35, %33, %28, %29, %15, %12, %23, %20, %152
ret void
}