#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 uint64_t;

/* Variables and functions */
int quickhash_64bit_hash(const void *k, int table_size) {
  uint64_t key = *(const uint64_t *)k;
  key = (~key) + (key << 18);
  key = key ^ (key >> 31);
  key = key * 21;
  key = key ^ (key >> 11);
  key = key + (key << 6);
  key = key ^ (key >> 22);
  return (int)(key & ((uint64_t)(table_size - 1)));
}


x86 assembly (clang, -O0):
<quickhash_64bit_hash>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
xor    $0xffffffff,%eax
mov    -0x10(%rbp),%ecx
shl    $0x12,%ecx
add    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x10(%rbp),%ecx
sar    $0x1f,%ecx
xor    %ecx,%eax
mov    %eax,-0x10(%rbp)
imul   $0x15,-0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x10(%rbp),%ecx
sar    $0xb,%ecx
xor    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x10(%rbp),%ecx
shl    $0x6,%ecx
add    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x10(%rbp),%ecx
sar    $0x16,%ecx
xor    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
and    %ecx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<quickhash_64bit_hash>:
mov    (%rdi),%eax
mov    %eax,%ecx
not    %ecx
shl    $0x12,%eax
add    %ecx,%eax
mov    %eax,%ecx
sar    $0x1f,%ecx
xor    %eax,%ecx
lea    (%rcx,%rcx,4),%eax
lea    (%rcx,%rax,4),%eax
mov    %eax,%ecx
sar    $0xb,%ecx
xor    %eax,%ecx
mov    %ecx,%eax
shl    $0x6,%eax
add    %ecx,%eax
mov    %eax,%ecx
sar    $0x16,%ecx
xor    %eax,%ecx
lea    -0x1(%rsi),%eax
and    %ecx,%eax
ret

LLVM IR (-O0):
define i32 @quickhash_64bit_hash(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i8*, i8** %3
%7 = bitcast i8* %6 to i32*
%8 = load i32, i32* %7
store i32 %8, i32* %5
%9 = load i32, i32* %5
%10 = xor i32 %9, -1
%11 = load i32, i32* %5
%12 = shl i32 %11, 18
%13 = add nsw i32 %10, %12
store i32 %13, i32* %5
%14 = load i32, i32* %5
%15 = load i32, i32* %5
%16 = ashr i32 %15, 31
%17 = xor i32 %14, %16
store i32 %17, i32* %5
%18 = load i32, i32* %5
%19 = mul nsw i32 %18, 21
store i32 %19, i32* %5
%20 = load i32, i32* %5
%21 = load i32, i32* %5
%22 = ashr i32 %21, 11
%23 = xor i32 %20, %22
store i32 %23, i32* %5
%24 = load i32, i32* %5
%25 = load i32, i32* %5
%26 = shl i32 %25, 6
%27 = add nsw i32 %24, %26
store i32 %27, i32* %5
%28 = load i32, i32* %5
%29 = load i32, i32* %5
%30 = ashr i32 %29, 22
%31 = xor i32 %28, %30
store i32 %31, i32* %5
%32 = load i32, i32* %5
%33 = load i32, i32* %4
%34 = sub nsw i32 %33, 1
%35 = and i32 %32, %34
ret i32 %35
}

LLVM IR (-O2):
define i32 @quickhash_64bit_hash(i8* nocapture %0, i32 %1) {
%3 = bitcast i8* %0 to i32*
%4 = load i32, i32* %3
%5 = xor i32 %4, -1
%6 = shl i32 %4, 18
%7 = add nsw i32 %6, %5
%8 = ashr i32 %7, 31
%9 = xor i32 %8, %7
%10 = mul nsw i32 %9, 21
%11 = ashr i32 %10, 11
%12 = xor i32 %11, %10
%13 = mul i32 %12, 65
%14 = ashr i32 %13, 22
%15 = xor i32 %14, %13
%16 = add nsw i32 %1, -1
%17 = and i32 %15, %16
ret i32 %17
}