#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 */

/* Variables and functions */
float INFINITY;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ isinf(float);
int open(char *, int /*<<< orphan*/);
int read(int, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ write(int, ...);
int main(int argc, char **argv) {
  int i, result, done = 0;
  int fd, temp_int, rate, channels;
  float points[4];
  int ticks = 0;
  long long temp64;
  float temp_float;
  float last[2] = {-5.0, -5.0};
  float prev[4];
  int threshold = 1;
  if (argc > 1) {
    fd = open(argv[1], O_RDONLY);
    if (fd < 1) {
      fprintf(stderr, "Could not open %s\n", argv[1]);
      return -1;
    }
  } else {
    fd = 0;
  }
  read(fd, &temp_int, 4);
  write(1, &temp_int, 4);
  fprintf(stderr, "(* Version %d *)\n", temp_int);
  read(fd, &temp64, 8);
  write(1, &temp64, 8);
  fprintf(stderr, "(* Start Time %lld.", temp64);
  read(fd, &temp64, 8);
  write(1, &temp64, 8);
  fprintf(stderr, "%06lld)\n", temp64);
  read(fd, &temp_int, 4);
  write(1, &temp_int, 4);
  rate = temp_int;
  fprintf(stderr, "(* Rate %d Hz *)\n", rate);
  threshold = rate / 500;
  if (threshold < 1)
    threshold = 1;
  read(fd, &temp_int, 4);
  write(1, &temp_int, 4);
  channels = temp_int;
  fprintf(stderr, "(* Channels %d *)\n", channels);
  while (!done) {
    for (i = 0; i < channels; i++) {
      result = read(fd, &points[i], sizeof(float));
      if (result < sizeof(float)) {
        done = 1;
        break;
      }
      if (isinf(points[i])) {
        done = 1;
        break;
      }
      if (i == 0) {
      }
    }
    if (done)
      break;
    if ((last[0] < 0.0) && (last[1] > 0.0) && (points[3] < 0.0)) {
      fprintf(stderr, "Glitch1!\n");
      prev[3] = -prev[3];
    } else if ((last[0] > 0.0) && (last[1] < 0.0) && (points[3] > 0.0)) {
      fprintf(stderr, "Glitch2!\n");
      prev[3] = -prev[3];
    }
    if (ticks != 0)
      write(1, prev, 4 * sizeof(float));
    for (i = 0; i < 4; i++) {
      prev[i] = points[i];
    }
    last[0] = last[1];
    last[1] = points[3];
    ticks++;
  }
  write(1, prev, 4 * sizeof(float));
  temp_float = INFINITY;
  write(1, &temp_float, sizeof(float));
  read(fd, &temp64, 8);
  write(1, &temp64, 8);
  fprintf(stderr, "(* Stop Time %lld.", temp64);
  read(fd, &temp64, 8);
  write(1, &temp64, 8);
  fprintf(stderr, "%06lld)\n", temp64);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x44(%rbp)
mov    0xe82(%rip),%rax
mov    %rax,-0x5c(%rbp)
movl   $0x1,-0x74(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    11e6 <main+0x96>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e3e(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x1,-0x20(%rbp)
jge    11e1 <main+0x91>
mov    0x2e13(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe3a(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1643 <main+0x4f3>
jmp    11ed <main+0x9d>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%edi
lea    -0x24(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1040 <read@plt>
mov    $0x1,%edi
lea    -0x24(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1030 <write@plt>
mov    0x2db4(%rip),%rax
mov    (%rax),%edi
mov    -0x24(%rbp),%edx
lea    0xdf3(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%edi
lea    -0x50(%rbp),%rsi
mov    $0x8,%edx
mov    $0x0,%al
call   1040 <read@plt>
mov    $0x1,%edi
lea    -0x50(%rbp),%rsi
mov    $0x8,%edx
mov    $0x0,%al
call   1030 <write@plt>
mov    0x2d72(%rip),%rax
mov    (%rax),%edi
mov    -0x50(%rbp),%rdx
lea    0xdc2(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%edi
lea    -0x50(%rbp),%rsi
mov    $0x8,%edx
mov    $0x0,%al
call   1040 <read@plt>
mov    $0x1,%edi
lea    -0x50(%rbp),%rsi
mov    $0x8,%edx
mov    $0x0,%al
call   1030 <write@plt>
mov    0x2d2f(%rip),%rax
mov    (%rax),%edi
mov    -0x50(%rbp),%rdx
lea    0xd93(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%edi
lea    -0x24(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1040 <read@plt>
mov    $0x1,%edi
lea    -0x24(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1030 <write@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    0x2ce6(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%edx
lea    0xd54(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x28(%rbp),%eax
mov    $0x1f4,%ecx
cltd
idiv   %ecx
mov    %eax,-0x74(%rbp)
cmpl   $0x1,-0x74(%rbp)
jge    131c <main+0x1cc>
movl   $0x1,-0x74(%rbp)
mov    -0x20(%rbp),%edi
lea    -0x24(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1040 <read@plt>
mov    $0x1,%edi
lea    -0x24(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1030 <write@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    0x2c7f(%rip),%rax
mov    (%rax),%edi
mov    -0x2c(%rbp),%edx
lea    0xcff(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
cmpl   $0x0,-0x1c(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    137a <main+0x22a>
jmp    157c <main+0x42c>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    140f <main+0x2bf>
mov    -0x20(%rbp),%edi
movslq -0x14(%rbp),%rax
lea    -0x40(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1040 <read@plt>
mov    %eax,-0x18(%rbp)
movslq -0x18(%rbp),%rax
cmp    $0x4,%rax
jae    13c8 <main+0x278>
movl   $0x1,-0x1c(%rbp)
jmp    140f <main+0x2bf>
movslq -0x14(%rbp),%rax
movss  -0x40(%rbp,%rax,4),%xmm0
call   1070 <isinf@plt>
cmp    $0x0,%rax
je     13ed <main+0x29d>
movl   $0x1,-0x1c(%rbp)
jmp    140f <main+0x2bf>
cmpl   $0x0,-0x14(%rbp)
jne    13fc <main+0x2ac>
jmp    13fc <main+0x2ac>
jmp    1401 <main+0x2b1>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1381 <main+0x231>
cmpl   $0x0,-0x1c(%rbp)
je     141e <main+0x2ce>
jmp    157c <main+0x42c>
movss  -0x5c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    1493 <main+0x343>
movss  -0x58(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1493 <main+0x343>
movss  -0x34(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    1493 <main+0x343>
mov    0x2b69(%rip),%rax
mov    (%rax),%edi
lea    0xbff(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movss  -0x64(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x64(%rbp)
jmp    1508 <main+0x3b8>
movss  -0x5c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1503 <main+0x3b3>
movss  -0x58(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    1503 <main+0x3b3>
movss  -0x34(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1503 <main+0x3b3>
mov    0x2af4(%rip),%rax
mov    (%rax),%edi
lea    0xb94(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movss  -0x64(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x64(%rbp)
jmp    1508 <main+0x3b8>
cmpl   $0x0,-0x44(%rbp)
je     1527 <main+0x3d7>
lea    -0x70(%rbp),%rsi
mov    $0x1,%edi
mov    $0x10,%edx
mov    $0x0,%al
call   1030 <write@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jge    155a <main+0x40a>
movslq -0x14(%rbp),%rax
movss  -0x40(%rbp,%rax,4),%xmm0
movslq -0x14(%rbp),%rax
movss  %xmm0,-0x70(%rbp,%rax,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    152e <main+0x3de>
movss  -0x58(%rbp),%xmm0
movss  %xmm0,-0x5c(%rbp)
movss  -0x34(%rbp),%xmm0
movss  %xmm0,-0x58(%rbp)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1364 <main+0x214>
lea    -0x70(%rbp),%rsi
mov    $0x1,%edi
mov    $0x10,%edx
mov    $0x0,%al
call   1030 <write@plt>
mov    0x2a50(%rip),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x54(%rbp)
mov    $0x1,%edi
lea    -0x54(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1030 <write@plt>
mov    -0x20(%rbp),%edi
lea    -0x50(%rbp),%rsi
mov    $0x8,%edx
mov    $0x0,%al
call   1040 <read@plt>
mov    $0x1,%edi
lea    -0x50(%rbp),%rsi
mov    $0x8,%edx
mov    $0x0,%al
call   1030 <write@plt>
mov    0x29eb(%rip),%rax
mov    (%rax),%edi
mov    -0x50(%rbp),%rdx
lea    0xa91(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%edi
lea    -0x50(%rbp),%rsi
mov    $0x8,%edx
mov    $0x0,%al
call   1040 <read@plt>
mov    $0x1,%edi
lea    -0x50(%rbp),%rsi
mov    $0x8,%edx
mov    $0x0,%al
call   1030 <write@plt>
mov    0x29a8(%rip),%rax
mov    (%rax),%edi
mov    -0x50(%rbp),%rdx
lea    0xa0c(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    $0x0,%ebx
cmp    $0x2,%edi
jl     1187 <main+0x37>
mov    %rsi,%rbp
mov    0x8(%rsi),%rdi
mov    0x2e6a(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
mov    %eax,%ebx
test   %eax,%eax
jle    14a9 <main+0x359>
lea    0xc(%rsp),%r14
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x4,%edx
xor    %eax,%eax
call   1040 <read@plt>
mov    $0x1,%edi
mov    %r14,%rsi
mov    $0x4,%edx
xor    %eax,%eax
call   1030 <write@plt>
mov    0x2e18(%rip),%r12
mov    (%r12),%edi
mov    0xc(%rsp),%edx
lea    0xe6c(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0x10(%rsp),%rbp
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x8,%edx
xor    %eax,%eax
call   1040 <read@plt>
mov    $0x1,%edi
mov    %rbp,%rsi
mov    $0x8,%edx
xor    %eax,%eax
call   1030 <write@plt>
mov    (%r12),%edi
mov    0x10(%rsp),%rdx
lea    0xe3d(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x8,%edx
xor    %eax,%eax
call   1040 <read@plt>
mov    $0x1,%edi
mov    %rbp,%rsi
mov    $0x8,%edx
xor    %eax,%eax
call   1030 <write@plt>
mov    (%r12),%edi
mov    0x10(%rsp),%rdx
lea    0xe15(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x4,%edx
xor    %eax,%eax
call   1040 <read@plt>
mov    $0x1,%edi
mov    %r14,%rsi
mov    $0x4,%edx
xor    %eax,%eax
call   1030 <write@plt>
mov    0xc(%rsp),%edx
mov    (%r12),%edi
lea    0xde3(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x4,%edx
xor    %eax,%eax
call   1040 <read@plt>
mov    $0x1,%edi
mov    %r14,%rsi
mov    $0x4,%edx
xor    %eax,%eax
call   1030 <write@plt>
mov    0xc(%rsp),%r13d
mov    (%r12),%edi
lea    0xdb9(%rip),%rsi
mov    %r13d,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
movss  0xd33(%rip),%xmm0
lea    0x30(%rsp),%rbp
xorps  %xmm1,%xmm1
lea    0xdab(%rip),%r14
xor    %r15d,%r15d
movaps %xmm0,%xmm3
movss  %xmm0,0x8(%rsp)
test   %r13d,%r13d
jle    1357 <main+0x207>
movss  %xmm3,0x18(%rsp)
mov    %r13,%r14
mov    %rbp,%r12
nopl   0x0(%rax)
mov    $0x4,%edx
mov    %ebx,%edi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <read@plt>
cmp    $0x4,%eax
jb     13e5 <main+0x295>
movss  0x0(%rbp),%xmm0
call   1070 <isinf@plt>
test   %rax,%rax
jne    13e5 <main+0x295>
add    $0x4,%rbp
add    $0xffffffffffffffff,%r14
jne    1300 <main+0x1b0>
movss  0x3c(%rsp),%xmm0
mov    %r12,%rbp
mov    0x2c89(%rip),%r12
xorps  %xmm1,%xmm1
lea    0xd36(%rip),%r14
movss  0x18(%rsp),%xmm3
ucomiss %xmm3,%xmm1
jbe    136f <main+0x21f>
movss  0x8(%rsp),%xmm2
ucomiss %xmm1,%xmm2
jbe    136f <main+0x21f>
ucomiss %xmm0,%xmm1
mov    %r14,%rsi
ja     1387 <main+0x237>
ucomiss %xmm1,%xmm3
jbe    13a8 <main+0x258>
ucomiss 0x8(%rsp),%xmm1
jbe    13a8 <main+0x258>
ucomiss %xmm1,%xmm0
lea    0xd0c(%rip),%rsi
jbe    13a8 <main+0x258>
mov    (%r12),%edi
xor    %eax,%eax
call   1050 <fprintf@plt>
xorps  %xmm1,%xmm1
movss  0x2c(%rsp),%xmm0
xorps  0xc6e(%rip),%xmm0
movss  %xmm0,0x2c(%rsp)
test   %r15d,%r15d
je     13c6 <main+0x276>
mov    $0x10,%edx
mov    $0x1,%edi
lea    0x20(%rsp),%rsi
xor    %eax,%eax
call   1030 <write@plt>
xorps  %xmm1,%xmm1
movaps 0x30(%rsp),%xmm0
movaps %xmm0,0x20(%rsp)
movss  0x3c(%rsp),%xmm0
add    $0x1,%r15d
movss  0x8(%rsp),%xmm3
jmp    12e2 <main+0x192>
xor    %r14d,%r14d
lea    0x20(%rsp),%rsi
mov    $0x10,%edx
mov    $0x1,%edi
xor    %eax,%eax
call   1030 <write@plt>
mov    0x2be3(%rip),%rax
movss  (%rax),%xmm0
movss  %xmm0,0x1c(%rsp)
lea    0x1c(%rsp),%rsi
mov    $0x4,%edx
mov    $0x1,%edi
xor    %eax,%eax
call   1030 <write@plt>
lea    0x10(%rsp),%r15
mov    %ebx,%edi
mov    %r15,%rsi
mov    $0x8,%edx
xor    %eax,%eax
call   1040 <read@plt>
mov    $0x1,%edi
mov    %r15,%rsi
mov    $0x8,%edx
xor    %eax,%eax
call   1030 <write@plt>
mov    0x2b7a(%rip),%rbp
mov    0x0(%rbp),%edi
mov    0x10(%rsp),%rdx
lea    0xc36(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    $0x8,%edx
xor    %eax,%eax
call   1040 <read@plt>
mov    $0x1,%edi
mov    %r15,%rsi
mov    $0x8,%edx
xor    %eax,%eax
call   1030 <write@plt>
mov    0x0(%rbp),%edi
mov    0x10(%rsp),%rdx
lea    0xbb9(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    14ca <main+0x37a>
mov    0x2b20(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbp),%rdx
lea    0xb63(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.last = [2 x float] [float -5.000000e+00, float -5.000000e+00]
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str = [19 x i8] c"Could not open %s\0A\00"
@.str.1 = [18 x i8] c"(* Version %d *)\0A\00"
@.str.2 = [20 x i8] c"(* Start Time %lld.\00"
@.str.3 = [9 x i8] c"%06lld)\0A\00"
@.str.4 = [18 x i8] c"(* Rate %d Hz *)\0A\00"
@.str.5 = [19 x i8] c"(* Channels %d *)\0A\00"
@.str.6 = [10 x i8] c"Glitch1!\0A\00"
@.str.7 = [10 x i8] c"Glitch2!\0A\00"
@INFINITY = global float 0.000000e+00
@.str.8 = [19 x i8] c"(* Stop Time %lld.\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca [4 x float]
%14 = alloca i32
%15 = alloca i64
%16 = alloca float
%17 = alloca [2 x float]
%18 = alloca [4 x float]
%19 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
store i32 0, i32* %14
%20 = bitcast [2 x float]* %17 to i8*
store i32 1, i32* %19
%21 = load i32, i32* %4
%22 = icmp sgt i32 %21, 1
br i1 %22, label %23, label %38
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = load i32, i32* @O_RDONLY
%28 = call i32 @open(i8* %26, i32 %27)
store i32 %28, i32* %9
%29 = load i32, i32* %9
%30 = icmp slt i32 %29, 1
br i1 %30, label %31, label %37
31: ; preds = %23
%32 = load i32, i32* @stderr
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %35)
store i32 -1, i32* %3
br label %209
37: ; preds = %23
br label %39
38: ; preds = %2
store i32 0, i32* %9
br label %39
39: ; preds = %38, %37
%40 = load i32, i32* %9
%41 = call i32 (i32, ...) @read(i32 %40, i32* %10, i32 4)
%42 = call i32 (i32, ...) @write(i32 1, i32* %10, i32 4)
%43 = load i32, i32* @stderr
%44 = load i32, i32* %10
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %44)
%46 = load i32, i32* %9
%47 = call i32 (i32, ...) @read(i32 %46, i64* %15, i32 8)
%48 = call i32 (i32, ...) @write(i32 1, i64* %15, i32 8)
%49 = load i32, i32* @stderr
%50 = load i64, i64* %15
%51 = call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i64 %50)
%52 = load i32, i32* %9
%53 = call i32 (i32, ...) @read(i32 %52, i64* %15, i32 8)
%54 = call i32 (i32, ...) @write(i32 1, i64* %15, i32 8)
%55 = load i32, i32* @stderr
%56 = load i64, i64* %15
%57 = call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i64 %56)
%58 = load i32, i32* %9
%59 = call i32 (i32, ...) @read(i32 %58, i32* %10, i32 4)
%60 = call i32 (i32, ...) @write(i32 1, i32* %10, i32 4)
%61 = load i32, i32* %10
store i32 %61, i32* %11
%62 = load i32, i32* @stderr
%63 = load i32, i32* %11
%64 = call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %63)
%65 = load i32, i32* %11
%66 = sdiv i32 %65, 500
store i32 %66, i32* %19
%67 = load i32, i32* %19
%68 = icmp slt i32 %67, 1
br i1 %68, label %69, label %70
69: ; preds = %39
store i32 1, i32* %19
br label %70
70: ; preds = %69, %39
%71 = load i32, i32* %9
%72 = call i32 (i32, ...) @read(i32 %71, i32* %10, i32 4)
%73 = call i32 (i32, ...) @write(i32 1, i32* %10, i32 4)
%74 = load i32, i32* %10
store i32 %74, i32* %12
%75 = load i32, i32* @stderr
%76 = load i32, i32* %12
%77 = call i32 (i32, i8*, ...) @fprintf(i32 %75, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %76)
br label %78
78: ; preds = %183, %70
%79 = load i32, i32* %8
%80 = icmp ne i32 %79, 0
%81 = xor i1 %80, true
br i1 %81, label %82, label %192
82: ; preds = %78
store i32 0, i32* %6
br label %83
83: ; preds = %110, %82
%84 = load i32, i32* %6
%85 = load i32, i32* %12
%86 = icmp slt i32 %84, %85
br i1 %86, label %87, label %113
87: ; preds = %83
%88 = load i32, i32* %9
%89 = load i32, i32* %6
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds [4 x float], [4 x float]* %13, i64 0, i64 %90
%92 = call i32 (i32, ...) @read(i32 %88, float* %91, i64 4)
store i32 %92, i32* %7
%93 = load i32, i32* %7
%94 = sext i32 %93 to i64
%95 = icmp ult i64 %94, 4
br i1 %95, label %96, label %97
96: ; preds = %87
store i32 1, i32* %8
br label %113
97: ; preds = %87
%98 = load i32, i32* %6
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds [4 x float], [4 x float]* %13, i64 0, i64 %99
%101 = load float, float* %100
%102 = call i64 @isinf(float %101)
%103 = icmp ne i64 %102, 0
br i1 %103, label %104, label %105
104: ; preds = %97
store i32 1, i32* %8
br label %113
105: ; preds = %97
%106 = load i32, i32* %6
%107 = icmp eq i32 %106, 0
br i1 %107, label %108, label %109
108: ; preds = %105
br label %109
109: ; preds = %108, %105
br label %110
110: ; preds = %109
%111 = load i32, i32* %6
%112 = add nsw i32 %111, 1
store i32 %112, i32* %6
br label %83
113: ; preds = %104, %96, %83
%114 = load i32, i32* %8
%115 = icmp ne i32 %114, 0
br i1 %115, label %116, label %117
116: ; preds = %113
br label %192
117: ; preds = %113
%118 = getelementptr inbounds [2 x float], [2 x float]* %17, i64 0, i64 0
%119 = load float, float* %118
%120 = fpext float %119 to double
%121 = fcmp olt double %120, 0.000000e+00
br i1 %121, label %122, label %139
122: ; preds = %117
%123 = getelementptr inbounds [2 x float], [2 x float]* %17, i64 0, i64 1
%124 = load float, float* %123
%125 = fpext float %124 to double
%126 = fcmp ogt double %125, 0.000000e+00
br i1 %126, label %127, label %139
127: ; preds = %122
%128 = getelementptr inbounds [4 x float], [4 x float]* %13, i64 0, i64 3
%129 = load float, float* %128
%130 = fpext float %129 to double
%131 = fcmp olt double %130, 0.000000e+00
br i1 %131, label %132, label %139
132: ; preds = %127
%133 = load i32, i32* @stderr
%134 = call i32 (i32, i8*, ...) @fprintf(i32 %133, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%135 = getelementptr inbounds [4 x float], [4 x float]* %18, i64 0, i64 3
%136 = load float, float* %135
%137 = fneg float %136
%138 = getelementptr inbounds [4 x float], [4 x float]* %18, i64 0, i64 3
store float %137, float* %138
br label %162
139: ; preds = %127, %122, %117
%140 = getelementptr inbounds [2 x float], [2 x float]* %17, i64 0, i64 0
%141 = load float, float* %140
%142 = fpext float %141 to double
%143 = fcmp ogt double %142, 0.000000e+00
br i1 %143, label %144, label %161
144: ; preds = %139
%145 = getelementptr inbounds [2 x float], [2 x float]* %17, i64 0, i64 1
%146 = load float, float* %145
%147 = fpext float %146 to double
%148 = fcmp olt double %147, 0.000000e+00
br i1 %148, label %149, label %161
149: ; preds = %144
%150 = getelementptr inbounds [4 x float], [4 x float]* %13, i64 0, i64 3
%151 = load float, float* %150
%152 = fpext float %151 to double
%153 = fcmp ogt double %152, 0.000000e+00
br i1 %153, label %154, label %161
154: ; preds = %149
%155 = load i32, i32* @stderr
%156 = call i32 (i32, i8*, ...) @fprintf(i32 %155, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0))
%157 = getelementptr inbounds [4 x float], [4 x float]* %18, i64 0, i64 3
%158 = load float, float* %157
%159 = fneg float %158
%160 = getelementptr inbounds [4 x float], [4 x float]* %18, i64 0, i64 3
store float %159, float* %160
br label %161
161: ; preds = %154, %149, %144, %139
br label %162
162: ; preds = %161, %132
%163 = load i32, i32* %14
%164 = icmp ne i32 %163, 0
br i1 %164, label %165, label %168
165: ; preds = %162
%166 = getelementptr inbounds [4 x float], [4 x float]* %18, i64 0, i64 0
%167 = call i32 (i32, ...) @write(i32 1, float* %166, i64 16)
br label %168
168: ; preds = %165, %162
store i32 0, i32* %6
br label %169
169: ; preds = %180, %168
%170 = load i32, i32* %6
%171 = icmp slt i32 %170, 4
br i1 %171, label %172, label %183
172: ; preds = %169
%173 = load i32, i32* %6
%174 = sext i32 %173 to i64
%175 = getelementptr inbounds [4 x float], [4 x float]* %13, i64 0, i64 %174
%176 = load float, float* %175
%177 = load i32, i32* %6
%178 = sext i32 %177 to i64
%179 = getelementptr inbounds [4 x float], [4 x float]* %18, i64 0, i64 %178
store float %176, float* %179
br label %180
180: ; preds = %172
%181 = load i32, i32* %6
%182 = add nsw i32 %181, 1
store i32 %182, i32* %6
br label %169
183: ; preds = %169
%184 = getelementptr inbounds [2 x float], [2 x float]* %17, i64 0, i64 1
%185 = load float, float* %184
%186 = getelementptr inbounds [2 x float], [2 x float]* %17, i64 0, i64 0
store float %185, float* %186
%187 = getelementptr inbounds [4 x float], [4 x float]* %13, i64 0, i64 3
%188 = load float, float* %187
%189 = getelementptr inbounds [2 x float], [2 x float]* %17, i64 0, i64 1
store float %188, float* %189
%190 = load i32, i32* %14
%191 = add nsw i32 %190, 1
store i32 %191, i32* %14
br label %78
192: ; preds = %116, %78
%193 = getelementptr inbounds [4 x float], [4 x float]* %18, i64 0, i64 0
%194 = call i32 (i32, ...) @write(i32 1, float* %193, i64 16)
%195 = load float, float* @INFINITY
store float %195, float* %16
%196 = call i32 (i32, ...) @write(i32 1, float* %16, i64 4)
%197 = load i32, i32* %9
%198 = call i32 (i32, ...) @read(i32 %197, i64* %15, i32 8)
%199 = call i32 (i32, ...) @write(i32 1, i64* %15, i32 8)
%200 = load i32, i32* @stderr
%201 = load i64, i64* %15
%202 = call i32 (i32, i8*, ...) @fprintf(i32 %200, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i64 %201)
%203 = load i32, i32* %9
%204 = call i32 (i32, ...) @read(i32 %203, i64* %15, i32 8)
%205 = call i32 (i32, ...) @write(i32 1, i64* %15, i32 8)
%206 = load i32, i32* @stderr
%207 = load i64, i64* %15
%208 = call i32 (i32, i8*, ...) @fprintf(i32 %206, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i64 %207)
store i32 0, i32* %3
br label %209
209: ; preds = %192, %31
%210 = load i32, i32* %3
ret i32 %210
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str = [19 x i8] c"Could not open %s\0A\00"
@.str.1 = [18 x i8] c"(* Version %d *)\0A\00"
@.str.2 = [20 x i8] c"(* Start Time %lld.\00"
@.str.3 = [9 x i8] c"%06lld)\0A\00"
@.str.4 = [18 x i8] c"(* Rate %d Hz *)\0A\00"
@.str.5 = [19 x i8] c"(* Channels %d *)\0A\00"
@.str.6 = [10 x i8] c"Glitch1!\0A\00"
@.str.7 = [10 x i8] c"Glitch2!\0A\00"
@INFINITY = global float 0.000000e+00
@.str.8 = [19 x i8] c"(* Stop Time %lld.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca [4 x float]
%5 = bitcast [4 x float]* %4 to i8*
%6 = alloca i64
%7 = alloca float
%8 = alloca [4 x float]
%9 = bitcast [4 x float]* %8 to i8*
%10 = bitcast i32* %3 to i8*
%11 = bitcast i64* %6 to i8*
%12 = bitcast float* %7 to i8*
%13 = icmp sgt i32 %0, 1
br i1 %13, label %14, label %24
14: ; preds = %2
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = load i32, i32* @O_RDONLY
%18 = tail call i32 @open(i8* %16, i32 %17)
%19 = icmp slt i32 %18, 1
br i1 %19, label %20, label %24
20: ; preds = %14
%21 = load i32, i32* @stderr
%22 = load i8*, i8** %15
%23 = tail call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %22)
br label %115
24: ; preds = %2, %14
%25 = phi i32 [ %18, %14 ], [ 0, %2 ]
%26 = call i32 (i32, ...) @read(i32 %25, i32* %3, i32 4)
%27 = call i32 (i32, ...) @write(i32 1, i32* %3, i32 4)
%28 = load i32, i32* @stderr
%29 = load i32, i32* %3
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %29)
%31 = call i32 (i32, ...) @read(i32 %25, i64* %6, i32 8)
%32 = call i32 (i32, ...) @write(i32 1, i64* %6, i32 8)
%33 = load i32, i32* @stderr
%34 = load i64, i64* %6
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i64 %34)
%36 = call i32 (i32, ...) @read(i32 %25, i64* %6, i32 8)
%37 = call i32 (i32, ...) @write(i32 1, i64* %6, i32 8)
%38 = load i32, i32* @stderr
%39 = load i64, i64* %6
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i64 %39)
%41 = call i32 (i32, ...) @read(i32 %25, i32* %3, i32 4)
%42 = call i32 (i32, ...) @write(i32 1, i32* %3, i32 4)
%43 = load i32, i32* %3
%44 = load i32, i32* @stderr
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %43)
%46 = call i32 (i32, ...) @read(i32 %25, i32* %3, i32 4)
%47 = call i32 (i32, ...) @write(i32 1, i32* %3, i32 4)
%48 = load i32, i32* %3
%49 = load i32, i32* @stderr
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %48)
%51 = icmp sgt i32 %48, 0
%52 = getelementptr inbounds [4 x float], [4 x float]* %4, i64 0, i64 3
%53 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 3
%54 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 0
%55 = zext i32 %48 to i64
br label %56
56: ; preds = %98, %24
%57 = phi float [ undef, %24 ], [ %99, %98 ]
%58 = phi i32 [ 0, %24 ], [ %100, %98 ]
%59 = phi float [ -5.000000e+00, %24 ], [ %99, %98 ]
%60 = phi float [ -5.000000e+00, %24 ], [ %59, %98 ]
br i1 %51, label %63, label %75
61: ; preds = %68
%62 = icmp eq i64 %72, %55
br i1 %62, label %73, label %63
63: ; preds = %56, %61
%64 = phi i64 [ %72, %61 ], [ 0, %56 ]
%65 = getelementptr inbounds [4 x float], [4 x float]* %4, i64 0, i64 %64
%66 = call i32 (i32, ...) @read(i32 %25, float* %65, i64 4)
%67 = icmp ult i32 %66, 4
br i1 %67, label %101, label %68
68: ; preds = %63
%69 = load float, float* %65
%70 = call i64 @isinf(float %69)
%71 = icmp eq i64 %70, 0
%72 = add nuw nsw i64 %64, 1
br i1 %71, label %61, label %101
73: ; preds = %61
%74 = load float, float* %52
br label %75
75: ; preds = %73, %56
%76 = phi float [ %74, %73 ], [ %57, %56 ]
%77 = fcmp olt float %60, 0.000000e+00
%78 = fcmp ogt float %59, 0.000000e+00
%79 = select i1 %77, i1 %78, i1 false
%80 = fcmp olt float %76, 0.000000e+00
%81 = select i1 %79, i1 %80, i1 false
br i1 %81, label %88, label %82
82: ; preds = %75
%83 = fcmp ogt float %60, 0.000000e+00
%84 = fcmp olt float %59, 0.000000e+00
%85 = select i1 %83, i1 %84, i1 false
%86 = fcmp ogt float %76, 0.000000e+00
%87 = select i1 %85, i1 %86, i1 false
br i1 %87, label %88, label %94
88: ; preds = %82, %75
%89 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), %75 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), %82 ]
%90 = load i32, i32* @stderr
%91 = call i32 (i32, i8*, ...) @fprintf(i32 %90, i8* %89)
%92 = load float, float* %53
%93 = fneg float %92
store float %93, float* %53
br label %94
94: ; preds = %88, %82
%95 = icmp eq i32 %58, 0
br i1 %95, label %98, label %96
96: ; preds = %94
%97 = call i32 (i32, ...) @write(i32 1, float* %54, i64 16)
br label %98
98: ; preds = %96, %94
%99 = load float, float* %52
%100 = add nuw nsw i32 %58, 1
br label %56
101: ; preds = %63, %68
%102 = call i32 (i32, ...) @write(i32 1, float* %54, i64 16)
%103 = load float, float* @INFINITY
store float %103, float* %7
%104 = call i32 (i32, ...) @write(i32 1, float* %7, i64 4)
%105 = call i32 (i32, ...) @read(i32 %25, i64* %6, i32 8)
%106 = call i32 (i32, ...) @write(i32 1, i64* %6, i32 8)
%107 = load i32, i32* @stderr
%108 = load i64, i64* %6
%109 = call i32 (i32, i8*, ...) @fprintf(i32 %107, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i64 %108)
%110 = call i32 (i32, ...) @read(i32 %25, i64* %6, i32 8)
%111 = call i32 (i32, ...) @write(i32 1, i64* %6, i32 8)
%112 = load i32, i32* @stderr
%113 = load i64, i64* %6
%114 = call i32 (i32, i8*, ...) @fprintf(i32 %112, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i64 %113)
br label %115
115: ; preds = %101, %20
%116 = phi i32 [ -1, %20 ], [ 0, %101 ]
ret i32 %116
}