#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 scalar_t__ uint8_t;
typedef unsigned int uint64_t;

/* Variables and functions */
uint64_t crc64_ecma_norm_ref(uint64_t seed, const uint8_t *buf, uint64_t len) {
  uint64_t rem = ~seed;
  unsigned int i, j;
  uint64_t poly = 0x42F0E1EBA9EA3693ULL;
  for (i = 0; i < len; i++) {
    rem = rem ^ ((uint64_t)buf[i] << 56);
    for (j = 0; j < 8; j++) {
      rem = (rem & 0x8000000000000000ULL ? poly : 0) ^ (rem << 1);
    }
  }
  return ~rem;
}


x86 assembly (clang, -O0):
<crc64_ecma_norm_ref>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x4(%rbp),%eax
xor    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
movl   $0xa9ea3693,-0x24(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    11be <crc64_ecma_norm_ref+0xbe>
mov    -0x18(%rbp),%eax
mov    -0x10(%rbp),%rcx
mov    -0x1c(%rbp),%edx
mov    (%rcx,%rdx,8),%rcx
mov    %ecx,%edx
mov    $0x38,%ecx
shl    %cl,%edx
mov    %edx,%ecx
xor    %ecx,%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x8,-0x20(%rbp)
jae    11ab <crc64_ecma_norm_ref+0xab>
mov    -0x18(%rbp),%eax
movabs $0x8000000000000000,%rcx
and    %rcx,%rax
cmp    $0x0,%rax
je     1185 <crc64_ecma_norm_ref+0x85>
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    118f <crc64_ecma_norm_ref+0x8f>
xor    %eax,%eax
mov    %eax,-0x28(%rbp)
jmp    118f <crc64_ecma_norm_ref+0x8f>
mov    -0x28(%rbp),%eax
mov    -0x18(%rbp),%ecx
shl    $0x1,%ecx
xor    %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1156 <crc64_ecma_norm_ref+0x56>
jmp    11b0 <crc64_ecma_norm_ref+0xb0>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1125 <crc64_ecma_norm_ref+0x25>
mov    -0x18(%rbp),%eax
xor    $0xffffffff,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<crc64_ecma_norm_ref>:
mov    %edi,%eax
ret

LLVM IR (-O0):
define i32 @crc64_ecma_norm_ref(i32 %0, i64* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i64*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %4
store i64* %1, i64** %5
store i32 %2, i32* %6
%11 = load i32, i32* %4
%12 = xor i32 %11, -1
store i32 %12, i32* %7
store i32 -1444268397, i32* %10
store i32 0, i32* %8
br label %13
13: ; preds = %47, %3
%14 = load i32, i32* %8
%15 = load i32, i32* %6
%16 = icmp ult i32 %14, %15
br i1 %16, label %17, label %50
17: ; preds = %13
%18 = load i32, i32* %7
%19 = load i64*, i64** %5
%20 = load i32, i32* %8
%21 = zext i32 %20 to i64
%22 = getelementptr inbounds i64, i64* %19, i64 %21
%23 = load i64, i64* %22
%24 = trunc i64 %23 to i32
%25 = shl i32 %24, 56
%26 = xor i32 %18, %25
store i32 %26, i32* %7
store i32 0, i32* %9
br label %27
27: ; preds = %43, %17
%28 = load i32, i32* %9
%29 = icmp ult i32 %28, 8
br i1 %29, label %30, label %46
30: ; preds = %27
%31 = load i32, i32* %7
%32 = zext i32 %31 to i64
%33 = and i64 %32, -9223372036854775808
%34 = icmp ne i64 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %30
%36 = load i32, i32* %10
br label %38
37: ; preds = %30
br label %38
38: ; preds = %37, %35
%39 = phi i32 [ %36, %35 ], [ 0, %37 ]
%40 = load i32, i32* %7
%41 = shl i32 %40, 1
%42 = xor i32 %39, %41
store i32 %42, i32* %7
br label %43
43: ; preds = %38
%44 = load i32, i32* %9
%45 = add i32 %44, 1
store i32 %45, i32* %9
br label %27
46: ; preds = %27
br label %47
47: ; preds = %46
%48 = load i32, i32* %8
%49 = add i32 %48, 1
store i32 %49, i32* %8
br label %13
50: ; preds = %13
%51 = load i32, i32* %7
%52 = xor i32 %51, -1
ret i32 %52
}

LLVM IR (-O2):
define i32 @crc64_ecma_norm_ref(i32 %0, i64* nocapture readnone %1, i32 %2) {
ret i32 %0
}