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

/* Variables and functions */
int /*<<< orphan*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ hash_bits_valid(unsigned int);
uint32_t hash_int32(uint32_t n, unsigned int bits) {
  uint32_t hash;
  assert(hash_bits_valid(bits));
  hash = n;
  hash = ~hash + (hash << 15);
  hash ^= (hash >> 12);
  hash += (hash << 2);
  hash ^= (hash >> 4);
  hash += (hash << 3) + (hash << 11);
  hash ^= (hash >> 16);
  return hash >> (32 - bits);
}


x86 assembly (clang, -O0):
<hash_int32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <hash_bits_valid@plt>
mov    %eax,%edi
call   1040 <assert@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
xor    $0xffffffff,%eax
mov    -0xc(%rbp),%ecx
shl    $0xf,%ecx
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sar    $0xc,%eax
xor    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x2,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sar    $0x4,%eax
xor    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x3,%eax
mov    -0xc(%rbp),%ecx
shl    $0xb,%ecx
add    %ecx,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sar    $0x10,%eax
xor    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x20,%ecx
sub    -0x8(%rbp),%ecx
sar    %cl,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hash_int32>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
mov    %esi,%edi
call   1030 <hash_bits_valid@plt>
mov    %eax,%edi
call   1040 <assert@plt>
mov    %ebp,%eax
not    %eax
shl    $0xf,%ebp
add    %eax,%ebp
mov    %ebp,%eax
sar    $0xc,%eax
xor    %ebp,%eax
lea    (%rax,%rax,4),%eax
mov    %eax,%ecx
sar    $0x4,%ecx
xor    %eax,%ecx
imul   $0x809,%ecx,%ecx
mov    %ecx,%eax
sar    $0x10,%eax
xor    %ecx,%eax
neg    %bl
mov    %ebx,%ecx
sar    %cl,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @hash_int32(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = call i32 @hash_bits_valid(i32 %6)
%8 = call i32 @assert(i32 %7)
%9 = load i32, i32* %3
store i32 %9, i32* %5
%10 = load i32, i32* %5
%11 = xor i32 %10, -1
%12 = load i32, i32* %5
%13 = shl i32 %12, 15
%14 = add nsw i32 %11, %13
store i32 %14, i32* %5
%15 = load i32, i32* %5
%16 = ashr i32 %15, 12
%17 = load i32, i32* %5
%18 = xor i32 %17, %16
store i32 %18, i32* %5
%19 = load i32, i32* %5
%20 = shl i32 %19, 2
%21 = load i32, i32* %5
%22 = add nsw i32 %21, %20
store i32 %22, i32* %5
%23 = load i32, i32* %5
%24 = ashr i32 %23, 4
%25 = load i32, i32* %5
%26 = xor i32 %25, %24
store i32 %26, i32* %5
%27 = load i32, i32* %5
%28 = shl i32 %27, 3
%29 = load i32, i32* %5
%30 = shl i32 %29, 11
%31 = add nsw i32 %28, %30
%32 = load i32, i32* %5
%33 = add nsw i32 %32, %31
store i32 %33, i32* %5
%34 = load i32, i32* %5
%35 = ashr i32 %34, 16
%36 = load i32, i32* %5
%37 = xor i32 %36, %35
store i32 %37, i32* %5
%38 = load i32, i32* %5
%39 = load i32, i32* %4
%40 = sub i32 32, %39
%41 = ashr i32 %38, %40
ret i32 %41
}

LLVM IR (-O2):
define i32 @hash_int32(i32 %0, i32 %1) {
%3 = tail call i32 @hash_bits_valid(i32 %1)
%4 = tail call i32 @assert(i32 %3)
%5 = xor i32 %0, -1
%6 = shl i32 %0, 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 i32 %12, 2057
%14 = ashr i32 %13, 16
%15 = xor i32 %14, %13
%16 = sub i32 32, %1
%17 = ashr i32 %15, %16
ret i32 %17
}