#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 */
int /*<<< orphan*/ exit(int);
int fread(unsigned int *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int main(int argc, char *argv[]) {
  unsigned tl0;
  unsigned tl1;
  unsigned cursor = 1;
  unsigned prev_error = 0;
  int errors = 0;
  if (fread(&tl0, sizeof(unsigned), 1, stdin) != 1) {
    perror("unable to fread stdin");
    exit(1);
  }
  printf("%10s/%-10s %10s %10s %10s %s\n", "errors", "total", "since", "tl0",
         "tl1", "missed");
  for (cursor = 1; fread(&tl1, sizeof(unsigned), 1, stdin) == 1;
       ++cursor, tl0 = tl1) {
    if (tl1 != tl0 + 1) {
      ++errors;
      printf("%10d/%-10d %10d 0x%08x 0x%08x %d\n", errors, cursor,
             cursor - prev_error, tl0, tl1, tl1 - tl0 - 1);
      prev_error = cursor;
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    0x2e76(%rip),%rax
mov    (%rax),%ecx
lea    -0x14(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x1,%eax
je     11a6 <main+0x66>
lea    0xe69(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
lea    0xe69(%rip),%rdi
lea    0xe80(%rip),%rsi
lea    0xe80(%rip),%rdx
lea    0xe7f(%rip),%rcx
lea    0xe7e(%rip),%r8
lea    0xe7b(%rip),%r9
lea    0xe78(%rip),%rax
mov    %rax,(%rsp)
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x1c(%rbp)
mov    0x2df8(%rip),%rax
mov    (%rax),%ecx
lea    -0x18(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x1,%eax
jne    1275 <main+0x135>
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
je     125c <main+0x11c>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x1c(%rbp),%ecx
sub    -0x20(%rbp),%ecx
mov    -0x14(%rbp),%r8d
mov    -0x18(%rbp),%r9d
mov    -0x18(%rbp),%eax
sub    -0x14(%rbp),%eax
sub    $0x1,%eax
lea    0xe0a(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    1261 <main+0x121>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    11e9 <main+0xa9>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    0x2e93(%rip),%r12
mov    (%r12),%ecx
lea    0x14(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x1,%eax
jne    1262 <main+0x122>
lea    0xed2(%rip),%rax
mov    %rax,(%rsp)
lea    0xe8e(%rip),%rdi
lea    0xea5(%rip),%rsi
lea    0xea5(%rip),%rdx
lea    0xea4(%rip),%rcx
lea    0xea3(%rip),%r8
lea    0xea0(%rip),%r9
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r12),%ecx
lea    0x10(%rsp),%rdi
mov    $0x1,%ebx
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x1,%eax
jne    1251 <main+0x111>
lea    0x10(%rsp),%r14
lea    0xe72(%rip),%r15
xor    %ebp,%ebp
xor    %r13d,%r13d
jmp    1213 <main+0xd3>
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebx
mov    %r9d,0x14(%rsp)
mov    (%r12),%ecx
mov    %r14,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x1,%eax
jne    1251 <main+0x111>
mov    0x10(%rsp),%r9d
mov    0x14(%rsp),%r8d
lea    0x1(%r8),%eax
cmp    %eax,%r9d
je     11f0 <main+0xb0>
add    $0x1,%ebp
mov    %ebx,%ecx
sub    %r13d,%ecx
mov    %r8d,%eax
not    %eax
add    %r9d,%eax
mov    %eax,(%rsp)
mov    %r15,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%r9d
mov    %ebx,%r13d
jmp    11f0 <main+0xb0>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd97(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stdin = global i32 0
@.str = [22 x i8] c"unable to fread stdin\00"
@.str.1 = [30 x i8] c"%10s/%-10s %10s %10s %10s %s\0A\00"
@.str.2 = [7 x i8] c"errors\00"
@.str.3 = [6 x i8] c"total\00"
@.str.4 = [6 x i8] c"since\00"
@.str.5 = [4 x i8] c"tl0\00"
@.str.6 = [4 x i8] c"tl1\00"
@.str.7 = [7 x i8] c"missed\00"
@.str.8 = [34 x i8] c"%10d/%-10d %10d 0x%08x 0x%08x %d\0A\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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
%11 = load i32, i32* @stdin
%12 = call i32 @fread(i32* %6, i32 4, i32 1, i32 %11)
%13 = icmp ne i32 %12, 1
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %2
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %8
br label %19
19: ; preds = %45, %17
%20 = load i32, i32* @stdin
%21 = call i32 @fread(i32* %7, i32 4, i32 1, i32 %20)
%22 = icmp eq i32 %21, 1
br i1 %22, label %23, label %49
23: ; preds = %19
%24 = load i32, i32* %7
%25 = load i32, i32* %6
%26 = add i32 %25, 1
%27 = icmp ne i32 %24, %26
br i1 %27, label %28, label %44
28: ; preds = %23
%29 = load i32, i32* %10
%30 = add nsw i32 %29, 1
store i32 %30, i32* %10
%31 = load i32, i32* %10
%32 = load i32, i32* %8
%33 = load i32, i32* %8
%34 = load i32, i32* %9
%35 = sub i32 %33, %34
%36 = load i32, i32* %6
%37 = load i32, i32* %7
%38 = load i32, i32* %7
%39 = load i32, i32* %6
%40 = sub i32 %38, %39
%41 = sub i32 %40, 1
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.8, i64 0, i64 0), i32 %31, i32 %32, i32 %35, i32 %36, i32 %37, i32 %41)
%43 = load i32, i32* %8
store i32 %43, i32* %9
br label %44
44: ; preds = %28, %23
br label %45
45: ; preds = %44
%46 = load i32, i32* %8
%47 = add i32 %46, 1
store i32 %47, i32* %8
%48 = load i32, i32* %7
store i32 %48, i32* %6
br label %19
49: ; preds = %19
%50 = load i32, i32* %3
ret i32 %50
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [22 x i8] c"unable to fread stdin\00"
@.str.1 = [30 x i8] c"%10s/%-10s %10s %10s %10s %s\0A\00"
@.str.2 = [7 x i8] c"errors\00"
@.str.3 = [6 x i8] c"total\00"
@.str.4 = [6 x i8] c"since\00"
@.str.5 = [4 x i8] c"tl0\00"
@.str.6 = [4 x i8] c"tl1\00"
@.str.7 = [7 x i8] c"missed\00"
@.str.8 = [34 x i8] c"%10d/%-10d %10d 0x%08x 0x%08x %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = load i32, i32* @stdin
%8 = call i32 @fread(i32* %3, i32 4, i32 1, i32 %7)
%9 = icmp eq i32 %8, 1
br i1 %9, label %13, label %10
10: ; preds = %2
%11 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %2
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%15 = load i32, i32* @stdin
%16 = call i32 @fread(i32* %4, i32 4, i32 1, i32 %15)
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %41
18: ; preds = %13, %33
%19 = phi i32 [ %36, %33 ], [ 0, %13 ]
%20 = phi i32 [ %35, %33 ], [ 0, %13 ]
%21 = phi i32 [ %37, %33 ], [ 1, %13 ]
%22 = load i32, i32* %4
%23 = load i32, i32* %3
%24 = add i32 %23, 1
%25 = icmp eq i32 %22, %24
br i1 %25, label %33, label %26
26: ; preds = %18
%27 = add nsw i32 %19, 1
%28 = sub i32 %21, %20
%29 = xor i32 %23, -1
%30 = add i32 %22, %29
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.8, i64 0, i64 0), i32 %27, i32 %21, i32 %28, i32 %23, i32 %22, i32 %30)
%32 = load i32, i32* %4
br label %33
33: ; preds = %18, %26
%34 = phi i32 [ %32, %26 ], [ %22, %18 ]
%35 = phi i32 [ %21, %26 ], [ %20, %18 ]
%36 = phi i32 [ %27, %26 ], [ %19, %18 ]
%37 = add i32 %21, 1
store i32 %34, i32* %3
%38 = load i32, i32* @stdin
%39 = call i32 @fread(i32* %4, i32 4, i32 1, i32 %38)
%40 = icmp eq i32 %39, 1
br i1 %40, label %18, label %41
41: ; preds = %33, %13
ret i32 0
}