#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 */
unsigned long crc32(unsigned char *, int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char *);
int _hash(char *keystring) {
  unsigned long key = crc32((unsigned char *)(keystring), strlen(keystring));
  key += (key << 12);
  key ^= (key >> 22);
  key += (key << 4);
  key ^= (key >> 9);
  key += (key << 10);
  key ^= (key >> 2);
  key += (key << 7);
  key ^= (key >> 12);
  key = (key >> 3) * 2654435761;
  return key;
}


x86 assembly (clang, -O0):
<_hash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x18(%rbp),%rdi
mov    %eax,%esi
call   1030 <crc32@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
shl    $0xc,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
shr    $0x16,%rax
xor    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
shl    $0x4,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
shr    $0x9,%rax
xor    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
shl    $0xa,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
shr    $0x2,%rax
xor    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
shl    $0x7,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
shr    $0xc,%rax
xor    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
shr    $0x3,%rax
movabs $0x9e3779b1,%rcx
imul   %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_hash>:
push   %rbx
mov    %rdi,%rbx
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <crc32@plt>
mov    %rax,%rcx
shl    $0xc,%rcx
add    %rax,%rcx
mov    %rcx,%rax
shr    $0x16,%rax
xor    %rcx,%rax
mov    %rax,%rcx
shl    $0x4,%rcx
add    %rax,%rcx
mov    %rcx,%rax
shr    $0x9,%rax
xor    %rcx,%rax
mov    %rax,%rcx
shl    $0xa,%rcx
add    %rax,%rcx
mov    %rcx,%rax
shr    $0x2,%rax
xor    %rcx,%rax
mov    %rax,%rcx
shl    $0x7,%rcx
add    %rax,%rcx
mov    %rcx,%rax
shr    $0xf,%rax
shr    $0x3,%rcx
xor    %ecx,%eax
imul   $0x9e3779b1,%eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @_hash(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @strlen(i8* %5)
%7 = call i64 @crc32(i8* %4, i32 %6)
store i64 %7, i64* %3
%8 = load i64, i64* %3
%9 = shl i64 %8, 12
%10 = load i64, i64* %3
%11 = add i64 %10, %9
store i64 %11, i64* %3
%12 = load i64, i64* %3
%13 = lshr i64 %12, 22
%14 = load i64, i64* %3
%15 = xor i64 %14, %13
store i64 %15, i64* %3
%16 = load i64, i64* %3
%17 = shl i64 %16, 4
%18 = load i64, i64* %3
%19 = add i64 %18, %17
store i64 %19, i64* %3
%20 = load i64, i64* %3
%21 = lshr i64 %20, 9
%22 = load i64, i64* %3
%23 = xor i64 %22, %21
store i64 %23, i64* %3
%24 = load i64, i64* %3
%25 = shl i64 %24, 10
%26 = load i64, i64* %3
%27 = add i64 %26, %25
store i64 %27, i64* %3
%28 = load i64, i64* %3
%29 = lshr i64 %28, 2
%30 = load i64, i64* %3
%31 = xor i64 %30, %29
store i64 %31, i64* %3
%32 = load i64, i64* %3
%33 = shl i64 %32, 7
%34 = load i64, i64* %3
%35 = add i64 %34, %33
store i64 %35, i64* %3
%36 = load i64, i64* %3
%37 = lshr i64 %36, 12
%38 = load i64, i64* %3
%39 = xor i64 %38, %37
store i64 %39, i64* %3
%40 = load i64, i64* %3
%41 = lshr i64 %40, 3
%42 = mul i64 %41, 2654435761
store i64 %42, i64* %3
%43 = load i64, i64* %3
%44 = trunc i64 %43 to i32
ret i32 %44
}

LLVM IR (-O2):
define i32 @_hash(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = tail call i64 @crc32(i8* %0, i32 %2)
%4 = mul i64 %3, 4097
%5 = lshr i64 %4, 22
%6 = xor i64 %5, %4
%7 = mul i64 %6, 17
%8 = lshr i64 %7, 9
%9 = xor i64 %8, %7
%10 = mul i64 %9, 1025
%11 = lshr i64 %10, 2
%12 = xor i64 %11, %10
%13 = mul i64 %12, 129
%14 = lshr i64 %13, 15
%15 = lshr i64 %13, 3
%16 = xor i64 %14, %15
%17 = trunc i64 %16 to i32
%18 = mul i32 %17, -1640531535
ret i32 %18
}