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

/* Variables and functions */
int quickhash_32bit_hash(const void *k, int table_size) {
  int32_t key = *(const int32_t *)k;
  key = ~key + (key << 15);
  key = key ^ (key >> 12);
  key = key + (key << 2);
  key = key ^ (key >> 4);
  key = key * 2057;
  key = key ^ (key >> 16);
  return (int)(key & (table_size - 1));
}


x86 assembly (clang, -O0):
<quickhash_32bit_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    $0xf,%ecx
add    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x10(%rbp),%ecx
sar    $0xc,%ecx
xor    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x10(%rbp),%ecx
shl    $0x2,%ecx
add    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x10(%rbp),%ecx
sar    $0x4,%ecx
xor    %ecx,%eax
mov    %eax,-0x10(%rbp)
imul   $0x809,-0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x10(%rbp),%ecx
sar    $0x10,%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_32bit_hash>:
mov    (%rdi),%eax
mov    %eax,%ecx
not    %ecx
shl    $0xf,%eax
add    %ecx,%eax
mov    %eax,%ecx
sar    $0xc,%ecx
xor    %eax,%ecx
lea    (%rcx,%rcx,4),%eax
mov    %eax,%ecx
sar    $0x4,%ecx
xor    %eax,%ecx
imul   $0x809,%ecx,%eax
mov    %eax,%ecx
sar    $0x10,%ecx
xor    %eax,%ecx
lea    -0x1(%rsi),%eax
and    %ecx,%eax
ret

LLVM IR (-O0):
define i32 @quickhash_32bit_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, 15
%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, 12
%17 = xor i32 %14, %16
store i32 %17, i32* %5
%18 = load i32, i32* %5
%19 = load i32, i32* %5
%20 = shl i32 %19, 2
%21 = add nsw i32 %18, %20
store i32 %21, i32* %5
%22 = load i32, i32* %5
%23 = load i32, i32* %5
%24 = ashr i32 %23, 4
%25 = xor i32 %22, %24
store i32 %25, i32* %5
%26 = load i32, i32* %5
%27 = mul nsw i32 %26, 2057
store i32 %27, i32* %5
%28 = load i32, i32* %5
%29 = load i32, i32* %5
%30 = ashr i32 %29, 16
%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_32bit_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, 15
%7 = add nsw i32 %6, %5
%8 = ashr i32 %7, 12
%9 = xor i32 %8, %7
%10 = mul i32 %9, 5
%11 = ashr i32 %10, 4
%12 = xor i32 %11, %10
%13 = mul nsw i32 %12, 2057
%14 = ashr i32 %13, 16
%15 = xor i32 %14, %13
%16 = add nsw i32 %1, -1
%17 = and i32 %15, %16
ret i32 %17
}