#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 uint8_t;
typedef int uint32_t;
struct timespec {
  double tv_sec;
  double tv_nsec;
};

/* Variables and functions */
int /*<<< orphan*/ CLOCK_REALTIME;
int /*<<< orphan*/ clock_gettime(int /*<<< orphan*/, struct timespec *);
int crc8(int, int, int);
int /*<<< orphan*/ generate_lookup(int *, int);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
scalar_t__ strtol(char *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ time(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  uint8_t lookup[256];
  uint8_t crc;
  uint8_t data[65536];
  uint32_t i;
  uint8_t s;
  uint8_t p;
  double elapsed;
  struct timespec start, stop;
  if (argc < 2) {
    p = 0x31;
  } else {
    p = (uint8_t)strtol(argv[1], NULL, 16);
  }
  srand(time(0));
  for (i = 0; i < 65536; i++)
    data[i] = rand() % 256;
  clock_gettime(CLOCK_REALTIME, &start);
  generate_lookup(lookup, p);
  clock_gettime(CLOCK_REALTIME, &stop);
  elapsed = (stop.tv_sec - start.tv_sec) +
            (stop.tv_nsec - start.tv_nsec) / 1000000000.0;
  printf("/* polynomial 0x%02X */\n", p);
  printf("static const uint8_t lookup[] = {\n\t");
  s = 0;
  for (i = 0; i < 256; i++) {
    printf("0x%02X", lookup[i]);
    if (i == 255) {
      printf("\n");
      break;
    }
    s++;
    if (s == 16) {
      printf(",\n\t");
      s = 0;
    } else
      printf(", ");
  }
  printf("};\n");
  printf("lookup generated at %lfs\n", elapsed);
  crc = 0;
  clock_gettime(CLOCK_REALTIME, &start);
  for (i = 0; i < 65536; i++)
    crc = crc8(data[i], crc, p);
  clock_gettime(CLOCK_REALTIME, &stop);
  elapsed = (stop.tv_sec - start.tv_sec) +
            (stop.tv_nsec - start.tv_nsec) / 1000000000.0;
  printf("calculated crc8 [0x%02X] by bits at %lfs\n", crc, elapsed);
  crc = 0;
  clock_gettime(CLOCK_REALTIME, &start);
  for (i = 0; i < 65536; i++)
    crc = lookup[data[i] ^ crc];
  clock_gettime(CLOCK_REALTIME, &stop);
  elapsed = (stop.tv_sec - start.tv_sec) +
            (stop.tv_nsec - start.tv_nsec) / 1000000000.0;
  printf("calculated crc8 [0x%02X] by lookup at %lfs\n", crc, elapsed);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40460,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11b2 <main+0x32>
movl   $0x31,-0x4042c(%rbp)
jmp    11ce <main+0x4e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1070 <strtol@plt>
mov    %eax,-0x4042c(%rbp)
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
movl   $0x0,-0x40424(%rbp)
cmpl   $0x10000,-0x40424(%rbp)
jge    1227 <main+0xa7>
mov    $0x0,%al
call   10a0 <rand@plt>
mov    $0x100,%ecx
cltd
idiv   %ecx
movslq -0x40424(%rbp),%rax
mov    %edx,-0x40420(%rbp,%rax,4)
mov    -0x40424(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40424(%rbp)
jmp    11e6 <main+0x66>
mov    0x2db2(%rip),%rax
mov    (%rax),%edi
lea    -0x40448(%rbp),%rsi
call   1030 <clock_gettime@plt>
lea    -0x410(%rbp),%rdi
mov    -0x4042c(%rbp),%esi
call   1050 <generate_lookup@plt>
mov    0x2d8b(%rip),%rax
mov    (%rax),%edi
lea    -0x40458(%rbp),%rsi
call   1030 <clock_gettime@plt>
movsd  -0x40458(%rbp),%xmm0
ff
subsd  -0x40448(%rbp),%xmm0
ff
movsd  -0x40450(%rbp),%xmm1
ff
subsd  -0x40440(%rbp),%xmm1
ff
movsd  0xd75(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40438(%rbp)
ff
mov    -0x4042c(%rbp),%esi
lea    0xd60(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd6b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x40428(%rbp)
movl   $0x0,-0x40424(%rbp)
cmpl   $0x100,-0x40424(%rbp)
jge    1380 <main+0x200>
movslq -0x40424(%rbp),%rax
mov    -0x410(%rbp,%rax,4),%esi
lea    0xd4f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0xff,-0x40424(%rbp)
jne    1320 <main+0x1a0>
lea    0xd0b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1380 <main+0x200>
mov    -0x40428(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40428(%rbp)
cmpl   $0x10,-0x40428(%rbp)
jne    1359 <main+0x1d9>
lea    0xd09(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x40428(%rbp)
jmp    1367 <main+0x1e7>
lea    0xcf0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    136c <main+0x1ec>
mov    -0x40424(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40424(%rbp)
jmp    12d1 <main+0x151>
lea    0xccc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  -0x40438(%rbp),%xmm0
ff
lea    0xcba(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movl   $0x0,-0x414(%rbp)
mov    0x2c2b(%rip),%rax
mov    (%rax),%edi
lea    -0x40448(%rbp),%rsi
call   1030 <clock_gettime@plt>
movl   $0x0,-0x40424(%rbp)
cmpl   $0x10000,-0x40424(%rbp)
jge    1416 <main+0x296>
movslq -0x40424(%rbp),%rax
mov    -0x40420(%rbp,%rax,4),%edi
mov    -0x414(%rbp),%esi
mov    -0x4042c(%rbp),%edx
call   1090 <crc8@plt>
mov    %eax,-0x414(%rbp)
mov    -0x40424(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40424(%rbp)
jmp    13cd <main+0x24d>
mov    0x2bc3(%rip),%rax
mov    (%rax),%edi
lea    -0x40458(%rbp),%rsi
call   1030 <clock_gettime@plt>
movsd  -0x40458(%rbp),%xmm0
ff
subsd  -0x40448(%rbp),%xmm0
ff
movsd  -0x40450(%rbp),%xmm1
ff
subsd  -0x40440(%rbp),%xmm1
ff
movsd  0xbad(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40438(%rbp)
ff
mov    -0x414(%rbp),%esi
movsd  -0x40438(%rbp),%xmm0
ff
lea    0xbf9(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movl   $0x0,-0x414(%rbp)
mov    0x2b50(%rip),%rax
mov    (%rax),%edi
lea    -0x40448(%rbp),%rsi
call   1030 <clock_gettime@plt>
movl   $0x0,-0x40424(%rbp)
cmpl   $0x10000,-0x40424(%rbp)
jge    14ef <main+0x36f>
movslq -0x40424(%rbp),%rax
mov    -0x40420(%rbp,%rax,4),%eax
xor    -0x414(%rbp),%eax
cltq
mov    -0x410(%rbp,%rax,4),%eax
mov    %eax,-0x414(%rbp)
mov    -0x40424(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40424(%rbp)
jmp    14a8 <main+0x328>
mov    0x2aea(%rip),%rax
mov    (%rax),%edi
lea    -0x40458(%rbp),%rsi
call   1030 <clock_gettime@plt>
movsd  -0x40458(%rbp),%xmm0
ff
subsd  -0x40448(%rbp),%xmm0
ff
movsd  -0x40450(%rbp),%xmm1
ff
subsd  -0x40440(%rbp),%xmm1
ff
movsd  0xad4(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40438(%rbp)
ff
mov    -0x414(%rbp),%esi
movsd  -0x40438(%rbp),%xmm0
ff
lea    0xb4a(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40460,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x40458,%rsp
mov    $0x31,%ebp
cmp    $0x2,%edi
jl     11ce <main+0x2e>
mov    0x8(%rsi),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1090 <strtol@plt>
mov    %rax,%rbp
xor    %edi,%edi
call   10a0 <time@plt>
mov    %eax,%edi
call   1080 <srand@plt>
xor    %ebx,%ebx
xchg   %ax,%ax
xor    %eax,%eax
call   10c0 <rand@plt>
lea    0xff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffffff00,%ecx
sub    %ecx,%eax
mov    %eax,0x450(%rsp,%rbx,4)
add    $0x1,%rbx
cmp    $0x10000,%rbx
jne    11e0 <main+0x40>
mov    0x2dcb(%rip),%rbx
mov    (%rbx),%edi
lea    0x20(%rsp),%rsi
call   1050 <clock_gettime@plt>
lea    0x50(%rsp),%rdi
mov    %ebp,%esi
call   1070 <generate_lookup@plt>
mov    (%rbx),%edi
lea    0x10(%rsp),%rsi
call   1050 <clock_gettime@plt>
movsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x18(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
movsd  %xmm1,0x38(%rsp)
subsd  0x28(%rsp),%xmm0
divsd  0xd9b(%rip),%xmm0
movsd  %xmm0,0x40(%rsp)
lea    0xd96(%rip),%rdi
xor    %r12d,%r12d
mov    %rbp,0x48(%rsp)
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xd97(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x50(%rsp),%esi
lea    0xda9(%rip),%r13
mov    %r13,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%ebp
lea    0xd9a(%rip),%rbx
lea    0xd97(%rip),%r15
xor    %r14d,%r14d
nopl   0x0(%rax)
add    $0x1,%r14d
cmp    $0x10,%r14d
mov    %r15,%rdi
cmove  %rbx,%rdi
cmove  %r12d,%r14d
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x50(%rsp,%rbp,4),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%rbp
cmp    $0x100,%rbp
jne    12c0 <main+0x120>
movsd  0x8(%rsp),%xmm0
subsd  0x38(%rsp),%xmm0
addsd  0x40(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xda5(%rip),%rdi
call   1040 <puts@plt>
lea    0xd29(%rip),%rdi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1060 <printf@plt>
mov    0x2ca2(%rip),%r14
mov    (%r14),%edi
lea    0x20(%rsp),%rsi
call   1050 <clock_gettime@plt>
xor    %ebp,%ebp
xor    %ebx,%ebx
mov    0x48(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x450(%rsp,%rbp,4),%edi
mov    %ebx,%esi
mov    %r15d,%edx
call   10b0 <crc8@plt>
mov    %eax,%ebx
add    $0x1,%rbp
cmp    $0x10000,%rbp
jne    1360 <main+0x1c0>
mov    (%r14),%edi
lea    0x10(%rsp),%rsi
call   1050 <clock_gettime@plt>
movapd 0x10(%rsp),%xmm1
subpd  0x20(%rsp),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
divsd  0xc57(%rip),%xmm0
addsd  %xmm1,%xmm0
lea    0xcb9(%rip),%rdi
mov    %ebx,%esi
mov    $0x1,%al
call   1060 <printf@plt>
mov    (%r14),%edi
lea    0x20(%rsp),%rsi
call   1050 <clock_gettime@plt>
xor    %eax,%eax
xor    %ebx,%ebx
xchg   %ax,%ax
xor    0x450(%rsp,%rax,4),%ebx
movslq %ebx,%rcx
mov    0x454(%rsp,%rax,4),%edx
xor    0x50(%rsp,%rcx,4),%edx
mov    0x458(%rsp,%rax,4),%ecx
movslq %edx,%rdx
xor    0x50(%rsp,%rdx,4),%ecx
movslq %ecx,%rcx
mov    0x45c(%rsp,%rax,4),%edx
xor    0x50(%rsp,%rcx,4),%edx
movslq %edx,%rcx
mov    0x50(%rsp,%rcx,4),%ebx
add    $0x4,%rax
cmp    $0x10000,%rax
jne    13d0 <main+0x230>
mov    (%r14),%edi
lea    0x10(%rsp),%rsi
call   1050 <clock_gettime@plt>
movapd 0x10(%rsp),%xmm1
subpd  0x20(%rsp),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
divsd  0xbc3(%rip),%xmm0
addsd  %xmm1,%xmm0
lea    0xc4f(%rip),%rdi
mov    %ebx,%esi
mov    $0x1,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x40458,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timespec = type { double, double }
@CLOCK_REALTIME = global i32 0
@.str = [25 x i8] c"/* polynomial 0x%02X */\0A\00"
@.str.1 = [36 x i8] c"static const uint8_t lookup[] = {\0A\09\00"
@.str.2 = [7 x i8] c"0x%02X\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [4 x i8] c",\0A\09\00"
@.str.5 = [3 x i8] c", \00"
@.str.6 = [4 x i8] c"};\0A\00"
@.str.7 = [26 x i8] c"lookup generated at %lfs\0A\00"
@.str.8 = [42 x i8] c"calculated crc8 [0x%02X] by bits at %lfs\0A\00"
@.str.9 = [44 x i8] c"calculated crc8 [0x%02X] by lookup at %lfs\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [256 x i32]
%7 = alloca i32
%8 = alloca [65536 x i32]
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca double
%13 = alloca %struct.timespec
%14 = alloca %struct.timespec
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = load i32, i32* %4
%16 = icmp slt i32 %15, 2
br i1 %16, label %17, label %18
17: ; preds = %2
store i32 49, i32* %11
br label %24
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i64 @strtol(i8* %21, i32* null, i32 16)
%23 = trunc i64 %22 to i32
store i32 %23, i32* %11
br label %24
24: ; preds = %18, %17
%25 = call i32 @time(i32 0)
%26 = call i32 @srand(i32 %25)
store i32 0, i32* %9
br label %27
27: ; preds = %36, %24
%28 = load i32, i32* %9
%29 = icmp slt i32 %28, 65536
br i1 %29, label %30, label %39
30: ; preds = %27
%31 = call i32 (...) @rand()
%32 = srem i32 %31, 256
%33 = load i32, i32* %9
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [65536 x i32], [65536 x i32]* %8, i64 0, i64 %34
store i32 %32, i32* %35
br label %36
36: ; preds = %30
%37 = load i32, i32* %9
%38 = add nsw i32 %37, 1
store i32 %38, i32* %9
br label %27
39: ; preds = %27
%40 = load i32, i32* @CLOCK_REALTIME
%41 = call i32 @clock_gettime(i32 %40, %struct.timespec* %13)
%42 = getelementptr inbounds [256 x i32], [256 x i32]* %6, i64 0, i64 0
%43 = load i32, i32* %11
%44 = call i32 @generate_lookup(i32* %42, i32 %43)
%45 = load i32, i32* @CLOCK_REALTIME
%46 = call i32 @clock_gettime(i32 %45, %struct.timespec* %14)
%47 = getelementptr inbounds %struct.timespec, %struct.timespec* %14, i32 0, i32 0
%48 = load double, double* %47
%49 = getelementptr inbounds %struct.timespec, %struct.timespec* %13, i32 0, i32 0
%50 = load double, double* %49
%51 = fsub double %48, %50
%52 = getelementptr inbounds %struct.timespec, %struct.timespec* %14, i32 0, i32 1
%53 = load double, double* %52
%54 = getelementptr inbounds %struct.timespec, %struct.timespec* %13, i32 0, i32 1
%55 = load double, double* %54
%56 = fsub double %53, %55
%57 = fdiv double %56, 1.000000e+09
%58 = fadd double %51, %57
store double %58, double* %12
%59 = load i32, i32* %11
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %59)
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %10
store i32 0, i32* %9
br label %62
62: ; preds = %85, %39
%63 = load i32, i32* %9
%64 = icmp slt i32 %63, 256
br i1 %64, label %65, label %88
65: ; preds = %62
%66 = load i32, i32* %9
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds [256 x i32], [256 x i32]* %6, i64 0, i64 %67
%69 = load i32, i32* %68
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %69)
%71 = load i32, i32* %9
%72 = icmp eq i32 %71, 255
br i1 %72, label %73, label %75
73: ; preds = %65
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %88
75: ; preds = %65
%76 = load i32, i32* %10
%77 = add nsw i32 %76, 1
store i32 %77, i32* %10
%78 = load i32, i32* %10
%79 = icmp eq i32 %78, 16
br i1 %79, label %80, label %82
80: ; preds = %75
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %10
br label %84
82: ; preds = %75
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %84
84: ; preds = %82, %80
br label %85
85: ; preds = %84
%86 = load i32, i32* %9
%87 = add nsw i32 %86, 1
store i32 %87, i32* %9
br label %62
88: ; preds = %73, %62
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%90 = load double, double* %12
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), double %90)
store i32 0, i32* %7
%92 = load i32, i32* @CLOCK_REALTIME
%93 = call i32 @clock_gettime(i32 %92, %struct.timespec* %13)
store i32 0, i32* %9
br label %94
94: ; preds = %105, %88
%95 = load i32, i32* %9
%96 = icmp slt i32 %95, 65536
br i1 %96, label %97, label %108
97: ; preds = %94
%98 = load i32, i32* %9
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds [65536 x i32], [65536 x i32]* %8, i64 0, i64 %99
%101 = load i32, i32* %100
%102 = load i32, i32* %7
%103 = load i32, i32* %11
%104 = call i32 @crc8(i32 %101, i32 %102, i32 %103)
store i32 %104, i32* %7
br label %105
105: ; preds = %97
%106 = load i32, i32* %9
%107 = add nsw i32 %106, 1
store i32 %107, i32* %9
br label %94
108: ; preds = %94
%109 = load i32, i32* @CLOCK_REALTIME
%110 = call i32 @clock_gettime(i32 %109, %struct.timespec* %14)
%111 = getelementptr inbounds %struct.timespec, %struct.timespec* %14, i32 0, i32 0
%112 = load double, double* %111
%113 = getelementptr inbounds %struct.timespec, %struct.timespec* %13, i32 0, i32 0
%114 = load double, double* %113
%115 = fsub double %112, %114
%116 = getelementptr inbounds %struct.timespec, %struct.timespec* %14, i32 0, i32 1
%117 = load double, double* %116
%118 = getelementptr inbounds %struct.timespec, %struct.timespec* %13, i32 0, i32 1
%119 = load double, double* %118
%120 = fsub double %117, %119
%121 = fdiv double %120, 1.000000e+09
%122 = fadd double %115, %121
store double %122, double* %12
%123 = load i32, i32* %7
%124 = load double, double* %12
%125 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.8, i64 0, i64 0), i32 %123, double %124)
store i32 0, i32* %7
%126 = load i32, i32* @CLOCK_REALTIME
%127 = call i32 @clock_gettime(i32 %126, %struct.timespec* %13)
store i32 0, i32* %9
br label %128
128: ; preds = %141, %108
%129 = load i32, i32* %9
%130 = icmp slt i32 %129, 65536
br i1 %130, label %131, label %144
131: ; preds = %128
%132 = load i32, i32* %9
%133 = sext i32 %132 to i64
%134 = getelementptr inbounds [65536 x i32], [65536 x i32]* %8, i64 0, i64 %133
%135 = load i32, i32* %134
%136 = load i32, i32* %7
%137 = xor i32 %135, %136
%138 = sext i32 %137 to i64
%139 = getelementptr inbounds [256 x i32], [256 x i32]* %6, i64 0, i64 %138
%140 = load i32, i32* %139
store i32 %140, i32* %7
br label %141
141: ; preds = %131
%142 = load i32, i32* %9
%143 = add nsw i32 %142, 1
store i32 %143, i32* %9
br label %128
144: ; preds = %128
%145 = load i32, i32* @CLOCK_REALTIME
%146 = call i32 @clock_gettime(i32 %145, %struct.timespec* %14)
%147 = getelementptr inbounds %struct.timespec, %struct.timespec* %14, i32 0, i32 0
%148 = load double, double* %147
%149 = getelementptr inbounds %struct.timespec, %struct.timespec* %13, i32 0, i32 0
%150 = load double, double* %149
%151 = fsub double %148, %150
%152 = getelementptr inbounds %struct.timespec, %struct.timespec* %14, i32 0, i32 1
%153 = load double, double* %152
%154 = getelementptr inbounds %struct.timespec, %struct.timespec* %13, i32 0, i32 1
%155 = load double, double* %154
%156 = fsub double %153, %155
%157 = fdiv double %156, 1.000000e+09
%158 = fadd double %151, %157
store double %158, double* %12
%159 = load i32, i32* %7
%160 = load double, double* %12
%161 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.9, i64 0, i64 0), i32 %159, double %160)
ret i32 0
}

LLVM IR (-O2):
%struct.timespec = type { double, double }
@CLOCK_REALTIME = global i32 0
@.str = [25 x i8] c"/* polynomial 0x%02X */\0A\00"
@.str.1 = [36 x i8] c"static const uint8_t lookup[] = {\0A\09\00"
@.str.2 = [7 x i8] c"0x%02X\00"
@.str.4 = [4 x i8] c",\0A\09\00"
@.str.5 = [3 x i8] c", \00"
@.str.7 = [26 x i8] c"lookup generated at %lfs\0A\00"
@.str.8 = [42 x i8] c"calculated crc8 [0x%02X] by bits at %lfs\0A\00"
@.str.9 = [44 x i8] c"calculated crc8 [0x%02X] by lookup at %lfs\0A\00"
@str = [3 x i8] c"};\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i32]
%4 = alloca [65536 x i32]
%5 = alloca <2 x double>
%6 = bitcast <2 x double>* %5 to %struct.timespec*
%7 = alloca <2 x double>
%8 = bitcast <2 x double>* %7 to %struct.timespec*
%9 = bitcast [256 x i32]* %3 to i8*
%10 = bitcast [65536 x i32]* %4 to i8*
%11 = bitcast <2 x double>* %5 to i8*
%12 = bitcast <2 x double>* %7 to i8*
%13 = icmp slt i32 %0, 2
br i1 %13, label %19, label %14
14: ; preds = %2
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = tail call i64 @strtol(i8* nocapture %16, i32* null, i32 16)
%18 = trunc i64 %17 to i32
br label %19
19: ; preds = %2, %14
%20 = phi i32 [ %18, %14 ], [ 49, %2 ]
%21 = tail call i32 @time(i32 0)
%22 = tail call i32 @srand(i32 %21)
br label %23
23: ; preds = %19, %23
%24 = phi i64 [ 0, %19 ], [ %28, %23 ]
%25 = tail call i32 (...) @rand()
%26 = srem i32 %25, 256
%27 = getelementptr inbounds [65536 x i32], [65536 x i32]* %4, i64 0, i64 %24
store i32 %26, i32* %27
%28 = add nuw nsw i64 %24, 1
%29 = icmp eq i64 %28, 65536
br i1 %29, label %30, label %23
30: ; preds = %23
%31 = load i32, i32* @CLOCK_REALTIME
%32 = call i32 @clock_gettime(i32 %31, %struct.timespec* %6)
%33 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 0
%34 = call i32 @generate_lookup(i32* %33, i32 %20)
%35 = load i32, i32* @CLOCK_REALTIME
%36 = call i32 @clock_gettime(i32 %35, %struct.timespec* %8)
%37 = getelementptr inbounds <2 x double>, <2 x double>* %7, i64 0, i64 0
%38 = load double, double* %37
%39 = getelementptr inbounds <2 x double>, <2 x double>* %5, i64 0, i64 0
%40 = load double, double* %39
%41 = getelementptr inbounds <2 x double>, <2 x double>* %7, i64 0, i64 1
%42 = load double, double* %41
%43 = getelementptr inbounds <2 x double>, <2 x double>* %5, i64 0, i64 1
%44 = load double, double* %43
%45 = fsub double %42, %44
%46 = fdiv double %45, 1.000000e+09
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %20)
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%49 = load i32, i32* %33
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %49)
br label %51
51: ; preds = %30, %51
%52 = phi i64 [ 0, %30 ], [ %59, %51 ]
%53 = phi i32 [ 0, %30 ], [ %57, %51 ]
%54 = add nsw i32 %53, 1
%55 = icmp eq i32 %54, 16
%56 = select i1 %55, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0)
%57 = select i1 %55, i32 0, i32 %54
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %56)
%59 = add nuw nsw i64 %52, 1
%60 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 %59
%61 = load i32, i32* %60
%62 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %61)
%63 = icmp eq i64 %59, 255
br i1 %63, label %64, label %51
64: ; preds = %51
%65 = fsub double %38, %40
%66 = fadd double %65, %46
%67 = call i32 @putchar(i32 10)
%68 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
%69 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), double %66)
%70 = load i32, i32* @CLOCK_REALTIME
%71 = call i32 @clock_gettime(i32 %70, %struct.timespec* %6)
br label %72
72: ; preds = %64, %72
%73 = phi i64 [ 0, %64 ], [ %78, %72 ]
%74 = phi i32 [ 0, %64 ], [ %77, %72 ]
%75 = getelementptr inbounds [65536 x i32], [65536 x i32]* %4, i64 0, i64 %73
%76 = load i32, i32* %75
%77 = call i32 @crc8(i32 %76, i32 %74, i32 %20)
%78 = add nuw nsw i64 %73, 1
%79 = icmp eq i64 %78, 65536
br i1 %79, label %80, label %72
80: ; preds = %72
%81 = load i32, i32* @CLOCK_REALTIME
%82 = call i32 @clock_gettime(i32 %81, %struct.timespec* %8)
%83 = load <2 x double>, <2 x double>* %7
%84 = load <2 x double>, <2 x double>* %5
%85 = fsub <2 x double> %83, %84
%86 = extractelement <2 x double> %85, i64 1
%87 = fdiv double %86, 1.000000e+09
%88 = extractelement <2 x double> %85, i64 0
%89 = fadd double %88, %87
%90 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.8, i64 0, i64 0), i32 %77, double %89)
%91 = load i32, i32* @CLOCK_REALTIME
%92 = call i32 @clock_gettime(i32 %91, %struct.timespec* %6)
br label %93
93: ; preds = %93, %80
%94 = phi i64 [ 0, %80 ], [ %123, %93 ]
%95 = phi i32 [ 0, %80 ], [ %122, %93 ]
%96 = getelementptr inbounds [65536 x i32], [65536 x i32]* %4, i64 0, i64 %94
%97 = load i32, i32* %96
%98 = xor i32 %97, %95
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 %99
%101 = load i32, i32* %100
%102 = or i64 %94, 1
%103 = getelementptr inbounds [65536 x i32], [65536 x i32]* %4, i64 0, i64 %102
%104 = load i32, i32* %103
%105 = xor i32 %104, %101
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 %106
%108 = load i32, i32* %107
%109 = or i64 %94, 2
%110 = getelementptr inbounds [65536 x i32], [65536 x i32]* %4, i64 0, i64 %109
%111 = load i32, i32* %110
%112 = xor i32 %111, %108
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 %113
%115 = load i32, i32* %114
%116 = or i64 %94, 3
%117 = getelementptr inbounds [65536 x i32], [65536 x i32]* %4, i64 0, i64 %116
%118 = load i32, i32* %117
%119 = xor i32 %118, %115
%120 = sext i32 %119 to i64
%121 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 %120
%122 = load i32, i32* %121
%123 = add nuw nsw i64 %94, 4
%124 = icmp eq i64 %123, 65536
br i1 %124, label %125, label %93
125: ; preds = %93
%126 = load i32, i32* @CLOCK_REALTIME
%127 = call i32 @clock_gettime(i32 %126, %struct.timespec* %8)
%128 = load <2 x double>, <2 x double>* %7
%129 = load <2 x double>, <2 x double>* %5
%130 = fsub <2 x double> %128, %129
%131 = extractelement <2 x double> %130, i64 1
%132 = fdiv double %131, 1.000000e+09
%133 = extractelement <2 x double> %130, i64 0
%134 = fadd double %133, %132
%135 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.9, i64 0, i64 0), i32 %122, double %134)
ret i32 0
}