#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 random();
int /*<<< orphan*/ srandom(int);
unsigned long HashHash(unsigned long key) {
  unsigned long hash = 0;
  unsigned long tmp = key;
  static int init = 0;
  static unsigned long scatter[256];
  int i;
  if (!init) {
    ;
    srandom(37);
    for (i = 0; i < 256; i++)
      scatter[i] = random();
    ;
    ++init;
  }
  while (tmp) {
    hash = (hash << 1) + scatter[tmp & 0xff];
    tmp >>= 8;
  }
  hash %= 512;
  return hash;
}


x86 assembly (clang, -O0):
<HashHash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x0,0x2efd(%rip)
jne    119d <HashHash+0x7d>
mov    $0x25,%edi
call   1030 <srandom@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x100,-0x1c(%rbp)
jge    118e <HashHash+0x6e>
mov    $0x0,%al
call   1040 <random@plt>
mov    %rax,%rdx
movslq -0x1c(%rbp),%rcx
lea    0x2ed4(%rip),%rax
mov    %rdx,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    115a <HashHash+0x3a>
mov    0x2eac(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2ea3(%rip)
jmp    11a2 <HashHash+0x82>
cmpq   $0x0,-0x18(%rbp)
je     11e0 <HashHash+0xc0>
mov    -0x10(%rbp),%rax
shl    $0x1,%rax
mov    -0x18(%rbp),%rdx
and    $0xff,%rdx
lea    0x2e89(%rip),%rcx
add    (%rcx,%rdx,8),%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
shr    $0x8,%rax
mov    %rax,-0x18(%rbp)
jmp    11a2 <HashHash+0x82>
mov    -0x10(%rbp),%rax
and    $0x1ff,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HashHash>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
cmpl   $0x0,0x2f11(%rip)
jne    116f <HashHash+0x4f>
mov    $0x25,%edi
call   1030 <srandom@plt>
lea    0x2f0e(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1040 <random@plt>
mov    %rax,(%rbx,%r14,1)
add    $0x8,%rbx
cmp    $0x800,%rbx
jne    1150 <HashHash+0x30>
addl   $0x1,0x2ed1(%rip)
xor    %eax,%eax
test   %r15,%r15
je     11a0 <HashHash+0x80>
lea    0x2ed3(%rip),%rcx
mov    %r15,%rdx
add    %rax,%rax
movzbl %r15b,%esi
add    (%rcx,%rsi,8),%rax
shr    $0x8,%rdx
cmp    $0xff,%r15
mov    %rdx,%r15
ja     1180 <HashHash+0x60>
and    $0x1ff,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@HashHash.init = internal global i32 0
@HashHash.scatter = internal global [256 x i64] zeroinitializer
define i64 @HashHash(i64 %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i32
store i64 %0, i64* %2
store i64 0, i64* %3
%6 = load i64, i64* %2
store i64 %6, i64* %4
%7 = load i32, i32* @HashHash.init
%8 = icmp ne i32 %7, 0
br i1 %8, label %25, label %9
9: ; preds = %1
%10 = call i32 @srandom(i32 37)
store i32 0, i32* %5
br label %11
11: ; preds = %19, %9
%12 = load i32, i32* %5
%13 = icmp slt i32 %12, 256
br i1 %13, label %14, label %22
14: ; preds = %11
%15 = call i64 (...) @random()
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [256 x i64], [256 x i64]* @HashHash.scatter, i64 0, i64 %17
store i64 %15, i64* %18
br label %19
19: ; preds = %14
%20 = load i32, i32* %5
%21 = add nsw i32 %20, 1
store i32 %21, i32* %5
br label %11
22: ; preds = %11
%23 = load i32, i32* @HashHash.init
%24 = add nsw i32 %23, 1
store i32 %24, i32* @HashHash.init
br label %25
25: ; preds = %22, %1
br label %26
26: ; preds = %29, %25
%27 = load i64, i64* %4
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %39
29: ; preds = %26
%30 = load i64, i64* %3
%31 = shl i64 %30, 1
%32 = load i64, i64* %4
%33 = and i64 %32, 255
%34 = getelementptr inbounds [256 x i64], [256 x i64]* @HashHash.scatter, i64 0, i64 %33
%35 = load i64, i64* %34
%36 = add i64 %31, %35
store i64 %36, i64* %3
%37 = load i64, i64* %4
%38 = lshr i64 %37, 8
store i64 %38, i64* %4
br label %26
39: ; preds = %26
%40 = load i64, i64* %3
%41 = urem i64 %40, 512
store i64 %41, i64* %3
%42 = load i64, i64* %3
ret i64 %42
}

LLVM IR (-O2):
@HashHash.init = internal unnamed_addr global i32 0
@HashHash.scatter = internal unnamed_addr global [256 x i64] zeroinitializer
define i64 @HashHash(i64 %0) {
%2 = load i32, i32* @HashHash.init
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %15
4: ; preds = %1
%5 = tail call i32 @srandom(i32 37)
br label %6
6: ; preds = %4, %6
%7 = phi i64 [ 0, %4 ], [ %10, %6 ]
%8 = tail call i64 (...) @random()
%9 = getelementptr inbounds [256 x i64], [256 x i64]* @HashHash.scatter, i64 0, i64 %7
store i64 %8, i64* %9
%10 = add nuw nsw i64 %7, 1
%11 = icmp eq i64 %10, 256
br i1 %11, label %12, label %6
12: ; preds = %6
%13 = load i32, i32* @HashHash.init
%14 = add nsw i32 %13, 1
store i32 %14, i32* @HashHash.init
br label %15
15: ; preds = %12, %1
%16 = icmp eq i64 %0, 0
br i1 %16, label %29, label %17
17: ; preds = %15, %17
%18 = phi i64 [ %25, %17 ], [ %0, %15 ]
%19 = phi i64 [ %24, %17 ], [ 0, %15 ]
%20 = shl i64 %19, 1
%21 = and i64 %18, 255
%22 = getelementptr inbounds [256 x i64], [256 x i64]* @HashHash.scatter, i64 0, i64 %21
%23 = load i64, i64* %22
%24 = add i64 %23, %20
%25 = lshr i64 %18, 8
%26 = icmp ult i64 %18, 256
br i1 %26, label %27, label %17
27: ; preds = %17
%28 = and i64 %24, 511
br label %29
29: ; preds = %27, %15
%30 = phi i64 [ 0, %15 ], [ %28, %27 ]
ret i64 %30
}