#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;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int TG_Connect(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ TG_FreeConnection(int);
int TG_GetDriverVersion();
int TG_GetNewConnectionId();
scalar_t__ TG_GetValue(int, int);
scalar_t__ TG_GetValueStatus(int, int);
int TG_ReadPackets(int, int);
int TG_SetDataLog(int, char *);
int TG_SetStreamLog(int, char *);
char *ctime(int /*<<< orphan*/ *);
double difftime(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int /*<<< orphan*/ wait();
int main(void) {
  char *comPortName = NULL;
  int dllVersion = 0;
  int connectionId = 0;
  int packetsRead = 0;
  int errCode = 0;
  double secondsToRun = 0;
  time_t startTime = 0;
  time_t currTime = 0;
  char *currTimeStr = NULL;
  dllVersion = TG_GetDriverVersion();
  printf("ThinkGear DLL version: %d\n", dllVersion);
  connectionId = TG_GetNewConnectionId();
  if (connectionId < 0) {
    fprintf(stderr, "ERROR: TG_GetNewConnectionId() returned %d.\n",
            connectionId);
    wait();
    exit(EXIT_FAILURE);
  }
  errCode = TG_SetStreamLog(connectionId, "streamLog.txt");
  if (errCode < 0) {
    fprintf(stderr, "ERROR: TG_SetStreamLog() returned %d.\n", errCode);
    wait();
    exit(EXIT_FAILURE);
  }
  errCode = TG_SetDataLog(connectionId, "dataLog.txt");
  if (errCode < 0) {
    fprintf(stderr, "ERROR: TG_SetDataLog() returned %d.\n", errCode);
    wait();
    exit(EXIT_FAILURE);
  }
  comPortName = "\\\\.\\COM5";
  errCode = TG_Connect(connectionId, comPortName, 57600, 0);
  if (errCode < 0) {
    fprintf(stderr, "ERROR: TG_Connect() returned %d.\n", errCode);
    wait();
    exit(EXIT_FAILURE);
  }
  secondsToRun = 5;
  startTime = time(NULL);
  while (difftime(time(NULL), startTime) < secondsToRun) {
    do {
      packetsRead = TG_ReadPackets(connectionId, 1);
      if (packetsRead == 1) {
        if (TG_GetValueStatus(connectionId, 4) != 0) {
          currTime = time(NULL);
          currTimeStr = ctime(&currTime);
          fprintf(stdout, "%s: raw: %d\n", currTimeStr,
                  (int)TG_GetValue(connectionId, 4));
          fflush(stdout);
        }
      }
    } while (packetsRead > 0);
  }
  TG_FreeConnection(connectionId);
  wait();
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    $0x0,%al
call   1100 <TG_GetDriverVersion@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xd93(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   10c0 <TG_GetNewConnectionId@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    12bd <main+0xad>
mov    0x2d4b(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%edx
lea    0xd82(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x0,%al
call   1130 <wait@plt>
mov    0x2d22(%rip),%rax
mov    (%rax),%edi
call   1120 <exit@plt>
mov    -0x18(%rbp),%edi
lea    0xd89(%rip),%rsi
call   10a0 <TG_SetStreamLog@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jge    1308 <main+0xf8>
mov    0x2d00(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%edx
lea    0xd72(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x0,%al
call   1130 <wait@plt>
mov    0x2cd7(%rip),%rax
mov    (%rax),%edi
call   1120 <exit@plt>
mov    -0x18(%rbp),%edi
lea    0xd73(%rip),%rsi
call   1060 <TG_SetDataLog@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jge    1353 <main+0x143>
mov    0x2cb5(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%edx
lea    0xd5a(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x0,%al
call   1130 <wait@plt>
mov    0x2c8c(%rip),%rax
mov    (%rax),%edi
call   1120 <exit@plt>
lea    0xd5c(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    $0xe100,%edx
xor    %ecx,%ecx
call   1070 <TG_Connect@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jge    13ad <main+0x19d>
mov    0x2c5b(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%edx
lea    0xd2e(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x0,%al
call   1130 <wait@plt>
mov    0x2c32(%rip),%rax
mov    (%rax),%edi
call   1120 <exit@plt>
movsd  0xc4b(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <time@plt>
mov    %eax,-0x2c(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <time@plt>
mov    %eax,%edi
mov    -0x2c(%rbp),%esi
call   1050 <difftime@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1499 <main+0x289>
jmp    13f0 <main+0x1e0>
mov    -0x18(%rbp),%edi
mov    $0x1,%esi
call   1110 <TG_ReadPackets@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jne    1485 <main+0x275>
mov    -0x18(%rbp),%edi
mov    $0x4,%esi
call   1080 <TG_GetValueStatus@plt>
cmp    $0x0,%rax
je     1480 <main+0x270>
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <time@plt>
mov    %eax,-0x30(%rbp)
lea    -0x30(%rbp),%rdi
call   1030 <ctime@plt>
mov    %rax,-0x38(%rbp)
mov    0x2b8f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%edi
mov    $0x4,%esi
call   10f0 <TG_GetValue@plt>
mov    -0x44(%rbp),%edi
mov    -0x40(%rbp),%rdx
mov    %eax,%ecx
lea    0xc76(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2b57(%rip),%rax
mov    (%rax),%edi
call   10d0 <fflush@plt>
jmp    1485 <main+0x275>
jmp    148a <main+0x27a>
cmpl   $0x0,-0x1c(%rbp)
jg     13f0 <main+0x1e0>
jmp    13c6 <main+0x1b6>
mov    -0x18(%rbp),%edi
call   10e0 <TG_FreeConnection@plt>
mov    $0x0,%al
call   1130 <wait@plt>
mov    0x2b19(%rip),%rax
mov    (%rax),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
xor    %eax,%eax
call   1100 <TG_GetDriverVersion@plt>
lea    0xdd7(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %eax,%eax
call   10c0 <TG_GetNewConnectionId@plt>
mov    %eax,%r13d
test   %eax,%eax
js     139a <main+0x18a>
lea    0xdff(%rip),%rsi
mov    %r13d,%edi
call   10a0 <TG_SetStreamLog@plt>
test   %eax,%eax
js     13af <main+0x19f>
lea    0xe1d(%rip),%rsi
mov    %r13d,%edi
call   1060 <TG_SetDataLog@plt>
test   %eax,%eax
js     13c1 <main+0x1b1>
lea    0xe37(%rip),%rsi
mov    %r13d,%edi
mov    $0xe100,%edx
xor    %ecx,%ecx
call   1070 <TG_Connect@plt>
test   %eax,%eax
js     13d3 <main+0x1c3>
xor    %edi,%edi
call   10b0 <time@plt>
mov    %eax,%r12d
xor    %edi,%edi
call   10b0 <time@plt>
mov    %eax,%edi
mov    %r12d,%esi
call   1050 <difftime@plt>
movsd  0xd47(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1373 <main+0x163>
mov    0x2d06(%rip),%r15
jmp    12d4 <main+0xc4>
nopl   0x0(%rax)
test   %ebp,%ebp
jle    1350 <main+0x140>
mov    %r13d,%edi
mov    $0x1,%esi
call   1110 <TG_ReadPackets@plt>
mov    %eax,%ebp
cmp    $0x1,%eax
jne    12d0 <main+0xc0>
mov    %r13d,%edi
mov    $0x4,%esi
call   1080 <TG_GetValueStatus@plt>
test   %rax,%rax
je     12d0 <main+0xc0>
xor    %edi,%edi
call   10b0 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1030 <ctime@plt>
mov    %rax,%rbx
mov    (%r15),%r14d
mov    %r13d,%edi
mov    $0x4,%esi
call   10f0 <TG_GetValue@plt>
mov    %r14d,%edi
lea    0xdb5(%rip),%rsi
mov    %rbx,%rdx
mov    %eax,%ecx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    (%r15),%edi
call   10d0 <fflush@plt>
jmp    12d0 <main+0xc0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %edi,%edi
call   10b0 <time@plt>
mov    %eax,%edi
mov    %r12d,%esi
call   1050 <difftime@plt>
movsd  0xc97(%rip),%xmm1
ucomisd %xmm0,%xmm1
ja     12d4 <main+0xc4>
mov    %r13d,%edi
call   10e0 <TG_FreeConnection@plt>
xor    %eax,%eax
call   1130 <wait@plt>
mov    0x2c3f(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c3f(%rip),%rax
mov    (%rax),%edi
lea    0xc79(%rip),%rsi
mov    %r13d,%edx
jmp    13e5 <main+0x1d5>
mov    0x2c2a(%rip),%rcx
mov    (%rcx),%edi
lea    0xc9f(%rip),%rsi
jmp    13e3 <main+0x1d3>
mov    0x2c18(%rip),%rcx
mov    (%rcx),%edi
lea    0xcc0(%rip),%rsi
jmp    13e3 <main+0x1d3>
mov    0x2c06(%rip),%rcx
mov    (%rcx),%edi
lea    0xcdc(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1090 <fprintf@plt>
xor    %eax,%eax
call   1130 <wait@plt>
mov    0x2bde(%rip),%rax
mov    (%rax),%edi
call   1120 <exit@plt>

LLVM IR (-O0):
@.str = [27 x i8] c"ThinkGear DLL version: %d\0A\00"
@stderr = global i32 0
@.str.1 = [45 x i8] c"ERROR: TG_GetNewConnectionId() returned %d.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [14 x i8] c"streamLog.txt\00"
@.str.3 = [39 x i8] c"ERROR: TG_SetStreamLog() returned %d.\0A\00"
@.str.4 = [12 x i8] c"dataLog.txt\00"
@.str.5 = [37 x i8] c"ERROR: TG_SetDataLog() returned %d.\0A\00"
@.str.6 = [9 x i8] c"\\\\.\\COM5\00"
@.str.7 = [34 x i8] c"ERROR: TG_Connect() returned %d.\0A\00"
@stdout = global i32 0
@.str.8 = [13 x i8] c"%s: raw: %d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
store i32 0, i32* %1
store i8* null, i8** %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
store double 0.000000e+00, double* %7
store i32 0, i32* %8
store i32 0, i32* %9
store i8* null, i8** %10
%11 = call i32 (...) @TG_GetDriverVersion()
store i32 %11, i32* %3
%12 = load i32, i32* %3
%13 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = call i32 (...) @TG_GetNewConnectionId()
store i32 %14, i32* %4
%15 = load i32, i32* %4
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %24
17: ; preds = %0
%18 = load i32, i32* @stderr
%19 = load i32, i32* %4
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = call i32 (...) @wait()
%22 = load i32, i32* @EXIT_FAILURE
%23 = call i32 @exit(i32 %22)
unreachable
24: ; preds = %0
%25 = load i32, i32* %4
%26 = call i32 @TG_SetStreamLog(i32 %25, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
store i32 %26, i32* %6
%27 = load i32, i32* %6
%28 = icmp slt i32 %27, 0
br i1 %28, label %29, label %36
29: ; preds = %24
%30 = load i32, i32* @stderr
%31 = load i32, i32* %6
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i32 %31)
%33 = call i32 (...) @wait()
%34 = load i32, i32* @EXIT_FAILURE
%35 = call i32 @exit(i32 %34)
unreachable
36: ; preds = %24
%37 = load i32, i32* %4
%38 = call i32 @TG_SetDataLog(i32 %37, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
store i32 %38, i32* %6
%39 = load i32, i32* %6
%40 = icmp slt i32 %39, 0
br i1 %40, label %41, label %48
41: ; preds = %36
%42 = load i32, i32* @stderr
%43 = load i32, i32* %6
%44 = call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), i32 %43)
%45 = call i32 (...) @wait()
%46 = load i32, i32* @EXIT_FAILURE
%47 = call i32 @exit(i32 %46)
unreachable
48: ; preds = %36
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8** %2
%49 = load i32, i32* %4
%50 = load i8*, i8** %2
%51 = call i32 @TG_Connect(i32 %49, i8* %50, i32 57600, i32 0)
store i32 %51, i32* %6
%52 = load i32, i32* %6
%53 = icmp slt i32 %52, 0
br i1 %53, label %54, label %61
54: ; preds = %48
%55 = load i32, i32* @stderr
%56 = load i32, i32* %6
%57 = call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0), i32 %56)
%58 = call i32 (...) @wait()
%59 = load i32, i32* @EXIT_FAILURE
%60 = call i32 @exit(i32 %59)
unreachable
61: ; preds = %48
store double 5.000000e+00, double* %7
%62 = call i32 @time(i32* null)
store i32 %62, i32* %8
br label %63
63: ; preds = %95, %61
%64 = call i32 @time(i32* null)
%65 = load i32, i32* %8
%66 = call double @difftime(i32 %64, i32 %65)
%67 = load double, double* %7
%68 = fcmp olt double %66, %67
br i1 %68, label %69, label %96
69: ; preds = %63
br label %70
70: ; preds = %92, %69
%71 = load i32, i32* %4
%72 = call i32 @TG_ReadPackets(i32 %71, i32 1)
store i32 %72, i32* %5
%73 = load i32, i32* %5
%74 = icmp eq i32 %73, 1
br i1 %74, label %75, label %91
75: ; preds = %70
%76 = load i32, i32* %4
%77 = call i64 @TG_GetValueStatus(i32 %76, i32 4)
%78 = icmp ne i64 %77, 0
br i1 %78, label %79, label %90
79: ; preds = %75
%80 = call i32 @time(i32* null)
store i32 %80, i32* %9
%81 = call i8* @ctime(i32* %9)
store i8* %81, i8** %10
%82 = load i32, i32* @stdout
%83 = load i8*, i8** %10
%84 = load i32, i32* %4
%85 = call i64 @TG_GetValue(i32 %84, i32 4)
%86 = trunc i64 %85 to i32
%87 = call i32 (i32, i8*, ...) @fprintf(i32 %82, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8* %83, i32 %86)
%88 = load i32, i32* @stdout
%89 = call i32 @fflush(i32 %88)
br label %90
90: ; preds = %79, %75
br label %91
91: ; preds = %90, %70
br label %92
92: ; preds = %91
%93 = load i32, i32* %5
%94 = icmp sgt i32 %93, 0
br i1 %94, label %70, label %95
95: ; preds = %92
br label %63
96: ; preds = %63
%97 = load i32, i32* %4
%98 = call i32 @TG_FreeConnection(i32 %97)
%99 = call i32 (...) @wait()
%100 = load i32, i32* @EXIT_SUCCESS
ret i32 %100
}

LLVM IR (-O2):
@.str = [27 x i8] c"ThinkGear DLL version: %d\0A\00"
@stderr = global i32 0
@.str.1 = [45 x i8] c"ERROR: TG_GetNewConnectionId() returned %d.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [14 x i8] c"streamLog.txt\00"
@.str.3 = [39 x i8] c"ERROR: TG_SetStreamLog() returned %d.\0A\00"
@.str.4 = [12 x i8] c"dataLog.txt\00"
@.str.5 = [37 x i8] c"ERROR: TG_SetDataLog() returned %d.\0A\00"
@.str.6 = [9 x i8] c"\\\\.\\COM5\00"
@.str.7 = [34 x i8] c"ERROR: TG_Connect() returned %d.\0A\00"
@stdout = global i32 0
@.str.8 = [13 x i8] c"%s: raw: %d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = tail call i32 (...) @TG_GetDriverVersion()
%4 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = tail call i32 (...) @TG_GetNewConnectionId()
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %13
7: ; preds = %0
%8 = load i32, i32* @stderr
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%10 = tail call i32 (...) @wait()
%11 = load i32, i32* @EXIT_FAILURE
%12 = tail call i32 @exit(i32 %11)
unreachable
13: ; preds = %0
%14 = tail call i32 @TG_SetStreamLog(i32 %5, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %22
16: ; preds = %13
%17 = load i32, i32* @stderr
%18 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i32 %14)
%19 = tail call i32 (...) @wait()
%20 = load i32, i32* @EXIT_FAILURE
%21 = tail call i32 @exit(i32 %20)
unreachable
22: ; preds = %13
%23 = tail call i32 @TG_SetDataLog(i32 %5, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%24 = icmp slt i32 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %22
%26 = load i32, i32* @stderr
%27 = tail call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), i32 %23)
%28 = tail call i32 (...) @wait()
%29 = load i32, i32* @EXIT_FAILURE
%30 = tail call i32 @exit(i32 %29)
unreachable
31: ; preds = %22
%32 = tail call i32 @TG_Connect(i32 %5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 57600, i32 0)
%33 = icmp slt i32 %32, 0
br i1 %33, label %34, label %40
34: ; preds = %31
%35 = load i32, i32* @stderr
%36 = tail call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0), i32 %32)
%37 = tail call i32 (...) @wait()
%38 = load i32, i32* @EXIT_FAILURE
%39 = tail call i32 @exit(i32 %38)
unreachable
40: ; preds = %31
%41 = tail call i32 @time(i32* null)
%42 = call i32 @time(i32* null)
%43 = call double @difftime(i32 %42, i32 %41)
%44 = fcmp olt double %43, 5.000000e+00
br i1 %44, label %49, label %67
45: ; preds = %64
%46 = call i32 @time(i32* null)
%47 = call double @difftime(i32 %46, i32 %41)
%48 = fcmp olt double %47, 5.000000e+00
br i1 %48, label %66, label %67
49: ; preds = %40, %66
%50 = call i32 @TG_ReadPackets(i32 %5, i32 1)
%51 = icmp eq i32 %50, 1
br i1 %51, label %52, label %64
52: ; preds = %49
%53 = call i64 @TG_GetValueStatus(i32 %5, i32 4)
%54 = icmp eq i64 %53, 0
br i1 %54, label %64, label %55
55: ; preds = %52
%56 = call i32 @time(i32* null)
store i32 %56, i32* %1
%57 = call i8* @ctime(i32* %1)
%58 = load i32, i32* @stdout
%59 = call i64 @TG_GetValue(i32 %5, i32 4)
%60 = trunc i64 %59 to i32
%61 = call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8* %57, i32 %60)
%62 = load i32, i32* @stdout
%63 = call i32 @fflush(i32 %62)
br label %64
64: ; preds = %49, %55, %52
%65 = icmp sgt i32 %50, 0
br i1 %65, label %66, label %45
66: ; preds = %64, %45
br label %49
67: ; preds = %45, %40
%68 = call i32 @TG_FreeConnection(i32 %5)
%69 = call i32 (...) @wait()
%70 = load i32, i32* @EXIT_SUCCESS
ret i32 %70
}