#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 int UINTPTR_MAX;
int /*<<< orphan*/ assert(int);
int hamt_get_symbol(unsigned int hash, int lvl) {
  int left = lvl * 5;
  int left_plus_chunk = left + 5;
  int right = 32 - left_plus_chunk;
  if (left_plus_chunk > 32)
    right = 0;
  unsigned int symbol = hash << left;
  assert((symbol & UINTPTR_MAX) == symbol);
  symbol >>= (right + left);
  assert(symbol < 32);
  return symbol;
}


x86 assembly (clang, -O0):
<hamt_get_symbol>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
imul   $0x5,-0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x5,%eax
mov    %eax,-0x10(%rbp)
mov    $0x20,%eax
sub    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x20,-0x10(%rbp)
jle    114a <hamt_get_symbol+0x3a>
movl   $0x0,-0x14(%rbp)
mov    -0x4(%rbp),%eax
mov    -0xc(%rbp),%ecx
shl    %cl,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    0x2e81(%rip),%rcx
and    (%rcx),%eax
cmp    -0x18(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x14(%rbp),%ecx
add    -0xc(%rbp),%ecx
mov    -0x18(%rbp),%eax
shr    %cl,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x20,-0x18(%rbp)
setb   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hamt_get_symbol>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
lea    (%rsi,%rsi,4),%ebp
mov    %ebp,%ecx
shl    %cl,%ebx
mov    0x2ebd(%rip),%rax
mov    (%rax),%eax
not    %eax
xor    %edi,%edi
test   %eax,%ebx
sete   %dil
call   1030 <assert@plt>
cmp    $0x1c,%ebp
mov    $0x1b,%ecx
cmovge %ebp,%ecx
shr    %cl,%ebx
mov    $0x1,%edi
call   1030 <assert@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@UINTPTR_MAX = global i32 0
define i32 @hamt_get_symbol(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%9 = load i32, i32* %4
%10 = mul nsw i32 %9, 5
store i32 %10, i32* %5
%11 = load i32, i32* %5
%12 = add nsw i32 %11, 5
store i32 %12, i32* %6
%13 = load i32, i32* %6
%14 = sub nsw i32 32, %13
store i32 %14, i32* %7
%15 = load i32, i32* %6
%16 = icmp sgt i32 %15, 32
br i1 %16, label %17, label %18
17: ; preds = %2
store i32 0, i32* %7
br label %18
18: ; preds = %17, %2
%19 = load i32, i32* %3
%20 = load i32, i32* %5
%21 = shl i32 %19, %20
store i32 %21, i32* %8
%22 = load i32, i32* %8
%23 = load i32, i32* @UINTPTR_MAX
%24 = and i32 %22, %23
%25 = load i32, i32* %8
%26 = icmp eq i32 %24, %25
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
%29 = load i32, i32* %7
%30 = load i32, i32* %5
%31 = add nsw i32 %29, %30
%32 = load i32, i32* %8
%33 = lshr i32 %32, %31
store i32 %33, i32* %8
%34 = load i32, i32* %8
%35 = icmp ult i32 %34, 32
%36 = zext i1 %35 to i32
%37 = call i32 @assert(i32 %36)
%38 = load i32, i32* %8
ret i32 %38
}

LLVM IR (-O2):
@UINTPTR_MAX = global i32 0
define i32 @hamt_get_symbol(i32 %0, i32 %1) {
%3 = mul nsw i32 %1, 5
%4 = icmp sgt i32 %3, 27
%5 = shl i32 %0, %3
%6 = load i32, i32* @UINTPTR_MAX
%7 = and i32 %6, %5
%8 = icmp eq i32 %7, %5
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
%11 = select i1 %4, i32 %3, i32 27
%12 = lshr i32 %5, %11
%13 = tail call i32 @assert(i32 1)
ret i32 %12
}