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

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ close(int);
double getTimestamp();
int /*<<< orphan*/ hex_dump(char *, int, int, char *, char *);
int open(char const *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char const *);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
int main(int argc, char *argv[]) {
  int rc, fd;
  const char *path;
  if (argc < 2) {
    return -1;
  }
  path = argv[1];
  fd = open(path, O_RDONLY);
  if (fd < 0) {
    perror(path);
    close(fd);
    return -1;
  }
  {
    unsigned int num = 0;
    double start = getTimestamp();
    double previous = start;
    while (1) {
      char buffer[256];
      int len = read(fd, buffer, sizeof(buffer));
      double now = getTimestamp();
      int i;
      if (len < 0) {
        perror(path);
        close(fd);
        return -1;
      }
      num++;
      printf("#%-5d t: %5.3f dt: %5.4f len: %2d", num, now - start,
             now - previous, len);
      if (len == 0) {
        printf(" EOF\n");
        return 0;
      }
      if (len <= 16) {
        hex_dump(buffer, len, 0, " | ", "");
      } else {
        hex_dump(buffer, len, 1, "\n    >>> ", "    ... ");
      }
      previous = now;
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    119f <main+0x2f>
movl   $0xffffffff,-0x4(%rbp)
jmp    1323 <main+0x1b3>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2e32(%rip),%rax
mov    (%rax),%esi
call   1070 <open@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    11e7 <main+0x77>
mov    -0x20(%rbp),%rdi
call   1080 <perror@plt>
mov    -0x18(%rbp),%edi
call   1050 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1323 <main+0x1b3>
movl   $0x0,-0x24(%rbp)
mov    $0x0,%al
call   1030 <getTimestamp@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x18(%rbp),%edi
lea    -0x140(%rbp),%rsi
mov    $0x100,%edx
call   1060 <read@plt>
mov    %eax,-0x144(%rbp)
mov    $0x0,%al
call   1030 <getTimestamp@plt>
movsd  %xmm0,-0x150(%rbp)
ff
cmpl   $0x0,-0x144(%rbp)
jge    1257 <main+0xe7>
mov    -0x20(%rbp),%rdi
call   1080 <perror@plt>
mov    -0x18(%rbp),%edi
call   1050 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1323 <main+0x1b3>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%esi
movsd  -0x150(%rbp),%xmm0
ff
subsd  -0x30(%rbp),%xmm0
movsd  -0x150(%rbp),%xmm1
ff
subsd  -0x38(%rbp),%xmm1
mov    -0x144(%rbp),%edx
lea    0xd76(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x144(%rbp)
jne    12b8 <main+0x148>
lea    0xd7d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1323 <main+0x1b3>
cmpl   $0x10,-0x144(%rbp)
jg     12ec <main+0x17c>
lea    -0x140(%rbp),%rdi
mov    -0x144(%rbp),%esi
xor    %edx,%edx
lea    0xd4d(%rip),%rcx
lea    0xd45(%rip),%r8
call   1090 <hex_dump@plt>
jmp    1311 <main+0x1a1>
lea    -0x140(%rbp),%rdi
mov    -0x144(%rbp),%esi
mov    $0x1,%edx
lea    0xd27(%rip),%rcx
lea    0xd2a(%rip),%r8
call   1090 <hex_dump@plt>
movsd  -0x150(%rbp),%xmm0
ff
movsd  %xmm0,-0x38(%rbp)
jmp    1204 <main+0x94>
mov    -0x4(%rbp),%eax
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x128,%rsp
mov    $0xffffffff,%ebx
cmp    $0x2,%edi
jl     12af <main+0x12f>
mov    0x8(%rsi),%r14
mov    0x2e3e(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   1080 <open@plt>
mov    %eax,%ebp
test   %eax,%eax
js     12db <main+0x15b>
mov    %r14,0x10(%rsp)
xor    %eax,%eax
call   1030 <getTimestamp@plt>
movsd  %xmm0,0x8(%rsp)
lea    0x20(%rsp),%rsi
mov    %ebp,%edi
mov    $0x100,%edx
call   1070 <read@plt>
mov    %eax,%r13d
xor    %eax,%eax
call   1030 <getTimestamp@plt>
test   %r13d,%r13d
js     12c3 <main+0x143>
mov    $0x1,%ebx
lea    0xe00(%rip),%r12
lea    0x20(%rsp),%r15
lea    0xe24(%rip),%r14
movsd  0x8(%rsp),%xmm2
jmp    125b <main+0xdb>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x1,%edx
lea    0xdfa(%rip),%rcx
mov    %r14,%r8
call   10a0 <hex_dump@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    $0x100,%edx
call   1070 <read@plt>
mov    %eax,%r13d
xor    %eax,%eax
call   1030 <getTimestamp@plt>
add    $0x1,%ebx
test   %r13d,%r13d
movsd  0x18(%rsp),%xmm2
js     12c3 <main+0x143>
movapd %xmm0,%xmm1
subsd  0x8(%rsp),%xmm0
movsd  %xmm1,0x18(%rsp)
subsd  %xmm2,%xmm1
mov    %r12,%rdi
mov    %ebx,%esi
mov    %r13d,%edx
mov    $0x2,%al
call   1050 <printf@plt>
test   %r13d,%r13d
je     12a1 <main+0x121>
mov    %r15,%rdi
mov    %r13d,%esi
cmp    $0x10,%r13d
ja     1220 <main+0xa0>
xor    %edx,%edx
lea    0xd8a(%rip),%rcx
lea    0xd99(%rip),%r8
jmp    122f <main+0xaf>
lea    0xd91(%rip),%rdi
call   1040 <puts@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x128,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x10(%rsp),%rdi
call   1090 <perror@plt>
mov    %ebp,%edi
call   1060 <close@plt>
mov    $0xffffffff,%ebx
jmp    12af <main+0x12f>
mov    %r14,%rdi
call   1090 <perror@plt>
mov    %ebp,%edi
call   1060 <close@plt>
jmp    12af <main+0x12f>

LLVM IR (-O0):
@O_RDONLY = global i32 0
@.str = [34 x i8] c"#%-5d t: %5.3f dt: %5.4f len: %2d\00"
@.str.1 = [6 x i8] c" EOF\0A\00"
@.str.2 = [4 x i8] c" | \00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [10 x i8] c"\0A >>> \00"
@.str.5 = [9 x i8] c" ... \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 i8*
%9 = alloca i32
%10 = alloca double
%11 = alloca double
%12 = alloca [256 x i8]
%13 = alloca i32
%14 = alloca double
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = load i32, i32* %4
%17 = icmp slt i32 %16, 2
br i1 %17, label %18, label %19
18: ; preds = %2
store i32 -1, i32* %3
br label %77
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
store i8* %22, i8** %8
%23 = load i8*, i8** %8
%24 = load i32, i32* @O_RDONLY
%25 = call i32 @open(i8* %23, i32 %24)
store i32 %25, i32* %7
%26 = load i32, i32* %7
%27 = icmp slt i32 %26, 0
br i1 %27, label %28, label %33
28: ; preds = %19
%29 = load i8*, i8** %8
%30 = call i32 @perror(i8* %29)
%31 = load i32, i32* %7
%32 = call i32 @close(i32 %31)
store i32 -1, i32* %3
br label %77
33: ; preds = %19
store i32 0, i32* %9
%34 = call double (...) @getTimestamp()
store double %34, double* %10
%35 = load double, double* %10
store double %35, double* %11
br label %36
36: ; preds = %33, %75
%37 = load i32, i32* %7
%38 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%39 = call i32 @read(i32 %37, i8* %38, i32 256)
store i32 %39, i32* %13
%40 = call double (...) @getTimestamp()
store double %40, double* %14
%41 = load i32, i32* %13
%42 = icmp slt i32 %41, 0
br i1 %42, label %43, label %48
43: ; preds = %36
%44 = load i8*, i8** %8
%45 = call i32 @perror(i8* %44)
%46 = load i32, i32* %7
%47 = call i32 @close(i32 %46)
store i32 -1, i32* %3
br label %77
48: ; preds = %36
%49 = load i32, i32* %9
%50 = add i32 %49, 1
store i32 %50, i32* %9
%51 = load i32, i32* %9
%52 = load double, double* %14
%53 = load double, double* %10
%54 = fsub double %52, %53
%55 = load double, double* %14
%56 = load double, double* %11
%57 = fsub double %55, %56
%58 = load i32, i32* %13
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %51, double %54, double %57, i32 %58)
%60 = load i32, i32* %13
%61 = icmp eq i32 %60, 0
br i1 %61, label %62, label %64
62: ; preds = %48
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %77
64: ; preds = %48
%65 = load i32, i32* %13
%66 = icmp sle i32 %65, 16
br i1 %66, label %67, label %71
67: ; preds = %64
%68 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%69 = load i32, i32* %13
%70 = call i32 @hex_dump(i8* %68, i32 %69, i32 0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
br label %75
71: ; preds = %64
%72 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%73 = load i32, i32* %13
%74 = call i32 @hex_dump(i8* %72, i32 %73, i32 1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
br label %75
75: ; preds = %71, %67
%76 = load double, double* %14
store double %76, double* %11
br label %36
77: ; preds = %62, %43, %28, %18
%78 = load i32, i32* %3
ret i32 %78
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@.str = [34 x i8] c"#%-5d t: %5.3f dt: %5.4f len: %2d\00"
@.str.2 = [4 x i8] c" | \00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [10 x i8] c"\0A >>> \00"
@.str.5 = [9 x i8] c" ... \00"
@str = [5 x i8] c" EOF\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i8]
%4 = icmp slt i32 %0, 2
br i1 %4, label %47, label %5
5: ; preds = %2
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = load i32, i32* @O_RDONLY
%9 = tail call i32 @open(i8* %7, i32 %8)
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %5
%12 = tail call i32 @perror(i8* %7)
%13 = tail call i32 @close(i32 %9)
br label %47
14: ; preds = %5
%15 = tail call double (...) @getTimestamp()
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%17 = call i32 @read(i32 %9, i8* %16, i32 256)
%18 = call double (...) @getTimestamp()
%19 = icmp slt i32 %17, 0
br i1 %19, label %20, label %23
20: ; preds = %43, %14
%21 = call i32 @perror(i8* %7)
%22 = call i32 @close(i32 %9)
br label %41
23: ; preds = %14, %43
%24 = phi double [ %45, %43 ], [ %18, %14 ]
%25 = phi i32 [ %44, %43 ], [ %17, %14 ]
%26 = phi i32 [ %28, %43 ], [ 0, %14 ]
%27 = phi double [ %24, %43 ], [ %15, %14 ]
%28 = add i32 %26, 1
%29 = fsub double %24, %15
%30 = fsub double %24, %27
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %28, double %29, double %30, i32 %25)
%32 = icmp eq i32 %25, 0
br i1 %32, label %33, label %35
33: ; preds = %23
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
br label %41
35: ; preds = %23
%36 = icmp ult i32 %25, 17
br i1 %36, label %37, label %39
37: ; preds = %35
%38 = call i32 @hex_dump(i8* %16, i32 %25, i32 0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
br label %43
39: ; preds = %35
%40 = call i32 @hex_dump(i8* %16, i32 %25, i32 1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
br label %43
41: ; preds = %20, %33
%42 = phi i32 [ 0, %33 ], [ -1, %20 ]
br label %47
43: ; preds = %37, %39
%44 = call i32 @read(i32 %9, i8* %16, i32 256)
%45 = call double (...) @getTimestamp()
%46 = icmp slt i32 %44, 0
br i1 %46, label %20, label %23
47: ; preds = %41, %2, %11
%48 = phi i32 [ -1, %11 ], [ -1, %2 ], [ %42, %41 ]
ret i32 %48
}