#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 {
  double tv_sec;
  double tv_nsec;
};
struct pollfd {
  int events;
  int revents;
  int /*<<< orphan*/ fd;
};

/* Variables and functions */
int /*<<< orphan*/ CLOCK_MONOTONIC;
int /*<<< orphan*/ CLOCK_REALTIME;
int /*<<< orphan*/ O_RDONLY;
int POLLERR;
int POLLHUP;
int POLLIN;
int POLLPRI;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ clock_gettime(int /*<<< orphan*/, struct timespec *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fileno(int /*<<< orphan*/);
int /*<<< orphan*/ lseek(int /*<<< orphan*/, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int /*<<< orphan*/ open(char *, int /*<<< orphan*/);
int poll(struct pollfd *, int, int);
int /*<<< orphan*/ printf(char *, double, ...);
int /*<<< orphan*/ read(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
main(int argc, char *argv[]) {
  struct timespec tmm, tmr, ppsm, ppsr;
  double real, mono, ppsreal, ppsmono;
  struct pollfd pollFDs[2];
  int numFD = 0;
  int i;
  int rv;
  char buf;
  pollFDs[numFD].fd = fileno(stdin);
  pollFDs[numFD++].events = POLLIN;
  if (argc > 1) {
    pollFDs[numFD].fd = open(argv[1], O_RDONLY);
    pollFDs[numFD++].events = POLLPRI;
  }
  for (;;) {
    rv = poll(pollFDs, numFD, -1);
    printf("Poll returned %d\n", rv);
    if (pollFDs[0].revents & (POLLERR | POLLHUP))
      break;
    if (numFD > 1 && pollFDs[1].revents & POLLPRI) {
      clock_gettime(CLOCK_MONOTONIC, &ppsm);
      clock_gettime(CLOCK_REALTIME, &ppsr);
      ppsreal = ppsr.tv_sec + ppsr.tv_nsec / 1.0e9;
      ppsmono = ppsm.tv_sec + ppsm.tv_nsec / 1.0e9;
      lseek(pollFDs[1].fd, 0, SEEK_SET);
      read(pollFDs[1].fd, &buf, 1);
      printf("Got PPS and read of %c\n", buf);
    };
    if (pollFDs[0].revents & POLLIN) {
      clock_gettime(CLOCK_MONOTONIC, &tmm);
      clock_gettime(CLOCK_REALTIME, &tmr);
      real = tmr.tv_sec + tmr.tv_nsec / 1.0e9;
      mono = tmm.tv_sec + tmm.tv_nsec / 1.0e9;
    }
    if (numFD > 1) {
      printf("{\"real\":%.6lf, \"mono\":%.6lf, \"ppsreal:\":%.6lf, "
             "\"ppsmono\":%.6lf}\n",
             real, mono, ppsreal, ppsmono);
    } else {
      printf("{\"real\":%.6lf, \"mono\":%.6lf}\n", real, mono);
    }
    fflush(stdout);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x94(%rbp)
mov    0x2e1e(%rip),%rax
mov    (%rax),%edi
call   1070 <fileno@plt>
mov    %eax,%ecx
movslq -0x94(%rbp),%rdx
lea    -0x90(%rbp),%rax
imul   $0xc,%rdx,%rdx
add    %rdx,%rax
mov    %ecx,0x8(%rax)
mov    0x2de6(%rip),%rax
mov    (%rax),%ecx
mov    -0x94(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x94(%rbp)
movslq %eax,%rdx
lea    -0x90(%rbp),%rax
imul   $0xc,%rdx,%rdx
add    %rdx,%rax
mov    %ecx,(%rax)
cmpl   $0x1,-0x8(%rbp)
jle    125f <main+0xdf>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2dbf(%rip),%rax
mov    (%rax),%esi
call   10a0 <open@plt>
mov    %eax,%ecx
movslq -0x94(%rbp),%rdx
lea    -0x90(%rbp),%rax
imul   $0xc,%rdx,%rdx
add    %rdx,%rax
mov    %ecx,0x8(%rax)
mov    0x2db7(%rip),%rax
mov    (%rax),%ecx
mov    -0x94(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x94(%rbp)
movslq %eax,%rdx
lea    -0x90(%rbp),%rax
imul   $0xc,%rdx,%rdx
add    %rdx,%rax
mov    %ecx,(%rax)
jmp    1264 <main+0xe4>
lea    -0x90(%rbp),%rdi
mov    -0x94(%rbp),%esi
mov    $0xffffffff,%edx
call   1090 <poll@plt>
mov    %eax,-0x9c(%rbp)
cvtsi2sdl -0x9c(%rbp),%xmm0
ff
lea    0xd78(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x8c(%rbp),%eax
mov    0x2d34(%rip),%rcx
mov    (%rcx),%ecx
mov    0x2d33(%rip),%rdx
or     (%rdx),%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     12bf <main+0x13f>
jmp    1454 <main+0x2d4>
cmpl   $0x1,-0x94(%rbp)
jle    137b <main+0x1fb>
mov    -0x80(%rbp),%eax
mov    0x2d1a(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     137b <main+0x1fb>
mov    0x2cd8(%rip),%rax
mov    (%rax),%edi
lea    -0x40(%rbp),%rsi
call   1030 <clock_gettime@plt>
mov    0x2c9e(%rip),%rax
mov    (%rax),%edi
lea    -0x50(%rbp),%rsi
call   1030 <clock_gettime@plt>
movsd  -0x50(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
movsd  0xce9(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    -0x7c(%rbp),%edi
mov    0x2c63(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1050 <lseek@plt>
mov    -0x7c(%rbp),%edi
lea    -0x9d(%rbp),%rsi
mov    $0x1,%edx
call   1060 <read@plt>
movsbl -0x9d(%rbp),%eax
cvtsi2sd %eax,%xmm0
lea    0xca6(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x8c(%rbp),%eax
mov    0x2c30(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     13f5 <main+0x275>
mov    0x2c26(%rip),%rax
mov    (%rax),%edi
lea    -0x20(%rbp),%rsi
call   1030 <clock_gettime@plt>
mov    0x2bec(%rip),%rax
mov    (%rax),%edi
lea    -0x30(%rbp),%rsi
call   1030 <clock_gettime@plt>
movsd  -0x30(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  0xc37(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  0xc18(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
cmpl   $0x1,-0x94(%rbp)
jle    1429 <main+0x2a9>
movsd  -0x58(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm1
movsd  -0x68(%rbp),%xmm2
movsd  -0x70(%rbp),%xmm3
lea    0xc15(%rip),%rdi
mov    $0x4,%al
call   1040 <printf@plt>
jmp    1441 <main+0x2c1>
movsd  -0x58(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm1
lea    0xc39(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    0x2b58(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
jmp    1264 <main+0xe4>
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %rsi,%r14
mov    %edi,%ebx
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
call   1070 <fileno@plt>
mov    %eax,0x18(%rsp)
mov    0x2e09(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
mov    $0x1,%ebp
cmp    $0x2,%ebx
jl     11e7 <main+0x67>
mov    0x8(%r14),%rdi
mov    0x2e06(%rip),%rax
mov    (%rax),%esi
call   10a0 <open@plt>
mov    %eax,0x24(%rsp)
mov    0x2e14(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x1c(%rsp)
mov    $0x2,%ebp
lea    0x10(%rsp),%rdi
mov    %ebp,%esi
mov    $0xffffffff,%edx
call   1090 <poll@plt>
cvtsi2sd %eax,%xmm0
lea    0xe0d(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    0x14(%rsp),%eax
mov    0x2dc3(%rip),%r14
mov    0x2dc4(%rip),%r13
mov    0x0(%r13),%ecx
or     (%r14),%ecx
test   %eax,%ecx
je     123b <main+0xbb>
xor    %eax,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x10(%rsp),%r15
lea    0xdc9(%rip),%r12
jmp    12a7 <main+0x127>
nopl   0x0(%rax)
movaps 0x30(%rsp),%xmm1
movaps %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
lea    0xe18(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    0x2d2f(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
mov    %r15,%rdi
mov    %ebp,%esi
mov    $0xffffffff,%edx
call   1090 <poll@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    %r12,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    0x14(%rsp),%eax
mov    0x0(%r13),%ecx
or     (%r14),%ecx
test   %eax,%ecx
jne    1227 <main+0xa7>
cmp    $0x2,%ebx
jl     135b <main+0x1db>
mov    0x2d39(%rip),%rcx
mov    (%rcx),%ecx
test   %ecx,0x20(%rsp)
je     135b <main+0x1db>
mov    0x2cf6(%rip),%rax
mov    (%rax),%edi
lea    0x40(%rsp),%rsi
call   1030 <clock_gettime@plt>
mov    0x2cbb(%rip),%rax
mov    (%rax),%edi
lea    0x70(%rsp),%rsi
call   1030 <clock_gettime@plt>
movapd 0x70(%rsp),%xmm2
movsd  0x48(%rsp),%xmm0
movapd %xmm2,%xmm1
shufpd $0x1,%xmm0,%xmm1
movhpd 0x40(%rsp),%xmm2
divpd  0xcf4(%rip),%xmm1
addpd  %xmm1,%xmm2
movapd %xmm2,0x60(%rsp)
mov    0x24(%rsp),%edi
mov    0x2c87(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1050 <lseek@plt>
mov    0x24(%rsp),%edi
lea    0xf(%rsp),%rsi
mov    $0x1,%edx
call   1060 <read@plt>
movsbl 0xf(%rsp),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
lea    0xcd2(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    0x14(%rsp),%eax
mov    0x2c56(%rip),%rcx
test   %eax,(%rcx)
je     13bf <main+0x23f>
mov    0x2c53(%rip),%rax
mov    (%rax),%edi
lea    0x80(%rsp),%rsi
call   1030 <clock_gettime@plt>
mov    0x2c15(%rip),%rax
mov    (%rax),%edi
lea    0x50(%rsp),%rsi
call   1030 <clock_gettime@plt>
movapd 0x80(%rsp),%xmm2
movsd  0x58(%rsp),%xmm0
movapd %xmm2,%xmm1
shufpd $0x1,%xmm0,%xmm1
divpd  0xc51(%rip),%xmm1
movhpd 0x50(%rsp),%xmm2
addpd  %xmm1,%xmm2
movapd %xmm2,0x30(%rsp)
cmp    $0x2,%ebx
jl     1250 <main+0xd0>
movaps 0x30(%rsp),%xmm1
movaps %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
movapd 0x60(%rsp),%xmm2
movapd %xmm2,%xmm3
unpckhpd %xmm2,%xmm3
lea    0xc51(%rip),%rdi
mov    $0x4,%al
call   1040 <printf@plt>
jmp    126a <main+0xea>

LLVM IR (-O0):
%struct.timespec = type { double, double }
%struct.pollfd = type { i32, i32, i32 }
@stdin = global i32 0
@POLLIN = global i32 0
@O_RDONLY = global i32 0
@POLLPRI = global i32 0
@.str = [18 x i8] c"Poll returned %d\0A\00"
@POLLERR = global i32 0
@POLLHUP = global i32 0
@CLOCK_MONOTONIC = global i32 0
@CLOCK_REALTIME = global i32 0
@SEEK_SET = global i32 0
@.str.1 = [24 x i8] c"Got PPS and read of %c\0A\00"
@.str.2 = [65 x i8] c"{\22real\22:%.6lf, \22mono\22:%.6lf, \22ppsreal:\22:%.6lf, \22ppsmono\22:%.6lf}\0A\00"
@.str.3 = [30 x i8] c"{\22real\22:%.6lf, \22mono\22:%.6lf}\0A\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.timespec
%7 = alloca %struct.timespec
%8 = alloca %struct.timespec
%9 = alloca %struct.timespec
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca [2 x %struct.pollfd]
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %15
%19 = load i32, i32* @stdin
%20 = call i32 @fileno(i32 %19)
%21 = load i32, i32* %15
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %14, i64 0, i64 %22
%24 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %23, i32 0, i32 2
store i32 %20, i32* %24
%25 = load i32, i32* @POLLIN
%26 = load i32, i32* %15
%27 = add nsw i32 %26, 1
store i32 %27, i32* %15
%28 = sext i32 %26 to i64
%29 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %14, i64 0, i64 %28
%30 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %29, i32 0, i32 0
store i32 %25, i32* %30
%31 = load i32, i32* %4
%32 = icmp sgt i32 %31, 1
br i1 %32, label %33, label %49
33: ; preds = %2
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = load i32, i32* @O_RDONLY
%38 = call i32 @open(i8* %36, i32 %37)
%39 = load i32, i32* %15
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %14, i64 0, i64 %40
%42 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %41, i32 0, i32 2
store i32 %38, i32* %42
%43 = load i32, i32* @POLLPRI
%44 = load i32, i32* %15
%45 = add nsw i32 %44, 1
store i32 %45, i32* %15
%46 = sext i32 %44 to i64
%47 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %14, i64 0, i64 %46
%48 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %47, i32 0, i32 0
store i32 %43, i32* %48
br label %49
49: ; preds = %33, %2
br label %50
50: ; preds = %142, %49
%51 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %14, i64 0, i64 0
%52 = load i32, i32* %15
%53 = call i32 @poll(%struct.pollfd* %51, i32 %52, i32 -1)
store i32 %53, i32* %17
%54 = load i32, i32* %17
%55 = sitofp i32 %54 to double
%56 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), double %55)
%57 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %14, i64 0, i64 0
%58 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %57, i32 0, i32 1
%59 = load i32, i32* %58
%60 = load i32, i32* @POLLERR
%61 = load i32, i32* @POLLHUP
%62 = or i32 %60, %61
%63 = and i32 %59, %62
%64 = icmp ne i32 %63, 0
br i1 %64, label %65, label %66
65: ; preds = %50
br label %145
66: ; preds = %50
%67 = load i32, i32* %15
%68 = icmp sgt i32 %67, 1
br i1 %68, label %69, label %105
69: ; preds = %66
%70 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %14, i64 0, i64 1
%71 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %70, i32 0, i32 1
%72 = load i32, i32* %71
%73 = load i32, i32* @POLLPRI
%74 = and i32 %72, %73
%75 = icmp ne i32 %74, 0
br i1 %75, label %76, label %105
76: ; preds = %69
%77 = load i32, i32* @CLOCK_MONOTONIC
%78 = call i32 @clock_gettime(i32 %77, %struct.timespec* %8)
%79 = load i32, i32* @CLOCK_REALTIME
%80 = call i32 @clock_gettime(i32 %79, %struct.timespec* %9)
%81 = getelementptr inbounds %struct.timespec, %struct.timespec* %9, i32 0, i32 0
%82 = load double, double* %81
%83 = getelementptr inbounds %struct.timespec, %struct.timespec* %9, i32 0, i32 1
%84 = load double, double* %83
%85 = fdiv double %84, 1.000000e+09
%86 = fadd double %82, %85
store double %86, double* %12
%87 = getelementptr inbounds %struct.timespec, %struct.timespec* %8, i32 0, i32 0
%88 = load double, double* %87
%89 = getelementptr inbounds %struct.timespec, %struct.timespec* %8, i32 0, i32 1
%90 = load double, double* %89
%91 = fdiv double %90, 1.000000e+09
%92 = fadd double %88, %91
store double %92, double* %13
%93 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %14, i64 0, i64 1
%94 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %93, i32 0, i32 2
%95 = load i32, i32* %94
%96 = load i32, i32* @SEEK_SET
%97 = call i32 @lseek(i32 %95, i32 0, i32 %96)
%98 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %14, i64 0, i64 1
%99 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %98, i32 0, i32 2
%100 = load i32, i32* %99
%101 = call i32 @read(i32 %100, i8* %18, i32 1)
%102 = load i8, i8* %18
%103 = sitofp i8 %102 to double
%104 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), double %103)
br label %105
105: ; preds = %76, %69, %66
%106 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %14, i64 0, i64 0
%107 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %106, i32 0, i32 1
%108 = load i32, i32* %107
%109 = load i32, i32* @POLLIN
%110 = and i32 %108, %109
%111 = icmp ne i32 %110, 0
br i1 %111, label %112, label %129
112: ; preds = %105
%113 = load i32, i32* @CLOCK_MONOTONIC
%114 = call i32 @clock_gettime(i32 %113, %struct.timespec* %6)
%115 = load i32, i32* @CLOCK_REALTIME
%116 = call i32 @clock_gettime(i32 %115, %struct.timespec* %7)
%117 = getelementptr inbounds %struct.timespec, %struct.timespec* %7, i32 0, i32 0
%118 = load double, double* %117
%119 = getelementptr inbounds %struct.timespec, %struct.timespec* %7, i32 0, i32 1
%120 = load double, double* %119
%121 = fdiv double %120, 1.000000e+09
%122 = fadd double %118, %121
store double %122, double* %10
%123 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i32 0, i32 0
%124 = load double, double* %123
%125 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i32 0, i32 1
%126 = load double, double* %125
%127 = fdiv double %126, 1.000000e+09
%128 = fadd double %124, %127
store double %128, double* %11
br label %129
129: ; preds = %112, %105
%130 = load i32, i32* %15
%131 = icmp sgt i32 %130, 1
br i1 %131, label %132, label %138
132: ; preds = %129
%133 = load double, double* %10
%134 = load double, double* %11
%135 = load double, double* %12
%136 = load double, double* %13
%137 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.2, i64 0, i64 0), double %133, double %134, double %135, double %136)
br label %142
138: ; preds = %129
%139 = load double, double* %10
%140 = load double, double* %11
%141 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), double %139, double %140)
br label %142
142: ; preds = %138, %132
%143 = load i32, i32* @stdout
%144 = call i32 @fflush(i32 %143)
br label %50
145: ; preds = %65
%146 = load i32, i32* %3
ret i32 %146
}

LLVM IR (-O2):
%struct.timespec = type { double, double }
%struct.pollfd = type { i32, i32, i32 }
@stdin = global i32 0
@POLLIN = global i32 0
@O_RDONLY = global i32 0
@POLLPRI = global i32 0
@.str = [18 x i8] c"Poll returned %d\0A\00"
@POLLERR = global i32 0
@POLLHUP = global i32 0
@CLOCK_MONOTONIC = global i32 0
@CLOCK_REALTIME = global i32 0
@SEEK_SET = global i32 0
@.str.1 = [24 x i8] c"Got PPS and read of %c\0A\00"
@.str.2 = [65 x i8] c"{\22real\22:%.6lf, \22mono\22:%.6lf, \22ppsreal:\22:%.6lf, \22ppsmono\22:%.6lf}\0A\00"
@.str.3 = [30 x i8] c"{\22real\22:%.6lf, \22mono\22:%.6lf}\0A\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca <2 x double>
%4 = bitcast <2 x double>* %3 to %struct.timespec*
%5 = alloca %struct.timespec
%6 = alloca %struct.timespec
%7 = alloca <2 x double>
%8 = bitcast <2 x double>* %7 to %struct.timespec*
%9 = alloca [2 x %struct.pollfd]
%10 = alloca i8
%11 = bitcast <2 x double>* %3 to i8*
%12 = bitcast %struct.timespec* %5 to i8*
%13 = bitcast %struct.timespec* %6 to i8*
%14 = bitcast <2 x double>* %7 to i8*
%15 = bitcast [2 x %struct.pollfd]* %9 to i8*
%16 = load i32, i32* @stdin
%17 = tail call i32 @fileno(i32 %16)
%18 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %9, i64 0, i64 0
%19 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %9, i64 0, i64 0, i32 2
store i32 %17, i32* %19
%20 = load i32, i32* @POLLIN
%21 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %9, i64 0, i64 0, i32 0
store i32 %20, i32* %21
%22 = icmp sgt i32 %0, 1
br i1 %22, label %23, label %31
23: ; preds = %2
%24 = getelementptr inbounds i8*, i8** %1, i64 1
%25 = load i8*, i8** %24
%26 = load i32, i32* @O_RDONLY
%27 = tail call i32 @open(i8* %25, i32 %26)
%28 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %9, i64 0, i64 1, i32 2
store i32 %27, i32* %28
%29 = load i32, i32* @POLLPRI
%30 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %9, i64 0, i64 1, i32 0
store i32 %29, i32* %30
br label %31
31: ; preds = %23, %2
%32 = phi i32 [ 2, %23 ], [ 1, %2 ]
%33 = call i32 @poll(%struct.pollfd* %18, i32 %32, i32 -1)
%34 = sitofp i32 %33 to double
%35 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), double %34)
%36 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %9, i64 0, i64 0, i32 1
%37 = load i32, i32* %36
%38 = load i32, i32* @POLLERR
%39 = load i32, i32* @POLLHUP
%40 = or i32 %39, %38
%41 = and i32 %40, %37
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %124
43: ; preds = %31
%44 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %9, i64 0, i64 1, i32 1
%45 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i64 0, i32 0
%46 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i64 0, i32 1
%47 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %9, i64 0, i64 1, i32 2
%48 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i64 0, i32 0
%49 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i64 0, i32 1
br label %50
50: ; preds = %43, %112
%51 = phi i32 [ %37, %43 ], [ %118, %112 ]
%52 = phi <2 x double> [ undef, %43 ], [ %101, %112 ]
%53 = phi <2 x double> [ undef, %43 ], [ %83, %112 ]
br i1 %22, label %54, label %81
54: ; preds = %50
%55 = load i32, i32* %44
%56 = load i32, i32* @POLLPRI
%57 = and i32 %56, %55
%58 = icmp eq i32 %57, 0
br i1 %58, label %81, label %59
59: ; preds = %54
%60 = load i32, i32* @CLOCK_MONOTONIC
%61 = call i32 @clock_gettime(i32 %60, %struct.timespec* %6)
%62 = load i32, i32* @CLOCK_REALTIME
%63 = call i32 @clock_gettime(i32 %62, %struct.timespec* %8)
%64 = load <2 x double>, <2 x double>* %7
%65 = shufflevector <2 x double> %64, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%66 = load double, double* %45
%67 = load double, double* %46
%68 = insertelement <2 x double> %65, double %67, i64 1
%69 = fdiv <2 x double> %68, <double 1.000000e+09, double 1.000000e+09>
%70 = insertelement <2 x double> %64, double %66, i64 1
%71 = fadd <2 x double> %70, %69
%72 = load i32, i32* %47
%73 = load i32, i32* @SEEK_SET
%74 = call i32 @lseek(i32 %72, i32 0, i32 %73)
%75 = load i32, i32* %47
%76 = call i32 @read(i32 %75, i8* %10, i32 1)
%77 = load i8, i8* %10
%78 = sitofp i8 %77 to double
%79 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), double %78)
%80 = load i32, i32* %36
br label %81
81: ; preds = %59, %54, %50
%82 = phi i32 [ %80, %59 ], [ %51, %54 ], [ %51, %50 ]
%83 = phi <2 x double> [ %71, %59 ], [ %53, %54 ], [ %53, %50 ]
%84 = load i32, i32* @POLLIN
%85 = and i32 %84, %82
%86 = icmp eq i32 %85, 0
br i1 %86, label %100, label %87
87: ; preds = %81
%88 = load i32, i32* @CLOCK_MONOTONIC
%89 = call i32 @clock_gettime(i32 %88, %struct.timespec* %4)
%90 = load i32, i32* @CLOCK_REALTIME
%91 = call i32 @clock_gettime(i32 %90, %struct.timespec* %5)
%92 = load double, double* %48
%93 = load double, double* %49
%94 = load <2 x double>, <2 x double>* %3
%95 = shufflevector <2 x double> %94, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%96 = insertelement <2 x double> %95, double %93, i64 1
%97 = fdiv <2 x double> %96, <double 1.000000e+09, double 1.000000e+09>
%98 = insertelement <2 x double> %94, double %92, i64 1
%99 = fadd <2 x double> %98, %97
br label %100
100: ; preds = %87, %81
%101 = phi <2 x double> [ %99, %87 ], [ %52, %81 ]
br i1 %22, label %102, label %108
102: ; preds = %100
%103 = extractelement <2 x double> %101, i64 0
%104 = extractelement <2 x double> %101, i64 1
%105 = extractelement <2 x double> %83, i64 0
%106 = extractelement <2 x double> %83, i64 1
%107 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.2, i64 0, i64 0), double %104, double %103, double %105, double %106)
br label %112
108: ; preds = %100
%109 = extractelement <2 x double> %101, i64 0
%110 = extractelement <2 x double> %101, i64 1
%111 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), double %110, double %109)
br label %112
112: ; preds = %108, %102
%113 = load i32, i32* @stdout
%114 = call i32 @fflush(i32 %113)
%115 = call i32 @poll(%struct.pollfd* %18, i32 %32, i32 -1)
%116 = sitofp i32 %115 to double
%117 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), double %116)
%118 = load i32, i32* %36
%119 = load i32, i32* @POLLERR
%120 = load i32, i32* @POLLHUP
%121 = or i32 %120, %119
%122 = and i32 %121, %118
%123 = icmp eq i32 %122, 0
br i1 %123, label %50, label %124
124: ; preds = %112, %31
ret i32 0
}