#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 /*<<< orphan*/ v;
typedef int /*<<< orphan*/ uint32_t;

/* Variables and functions */
uintptr_t pointer_hash(uintptr_t v) {
  if (sizeof(v) == sizeof(uint32_t)) {
    v += ~(v << 15);
    v ^= v >> 10;
    v += v << 3;
    v ^= v >> 6;
    v += ~(v << 11);
    v ^= v >> 16;
    return v;
  } else {
    v += ~(v << 32);
    v ^= v >> 22;
    v += ~(v << 13);
    v ^= v >> 8;
    v += v << 3;
    v ^= v >> 15;
    v += ~(v << 27);
    v ^= v >> 31;
    return v;
  }
}


x86 assembly (clang, -O0):
<pointer_hash>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
shl    $0x20,%rax
xor    $0xffffffffffffffff,%rax
add    -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
shr    $0x16,%rax
xor    -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
shl    $0xd,%rax
xor    $0xffffffffffffffff,%rax
add    -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
shr    $0x8,%rax
xor    -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
shl    $0x3,%rax
add    -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
shr    $0xf,%rax
xor    -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
shl    $0x1b,%rax
xor    $0xffffffffffffffff,%rax
add    -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
shr    $0x1f,%rax
xor    -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<pointer_hash>:
mov    %rdi,%rax
shl    $0x20,%rax
not    %rax
add    %rdi,%rax
mov    %rax,%rcx
shr    $0x16,%rcx
xor    %rax,%rcx
mov    %rcx,%rax
shl    $0xd,%rax
not    %rax
add    %rcx,%rax
mov    %rax,%rcx
shr    $0x8,%rcx
xor    %rax,%rcx
lea    (%rcx,%rcx,8),%rax
mov    %rax,%rcx
shr    $0xf,%rcx
xor    %rax,%rcx
mov    %rcx,%rdx
shl    $0x1b,%rdx
not    %rdx
add    %rcx,%rdx
mov    %rdx,%rax
shr    $0x1f,%rax
xor    %rdx,%rax
ret

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

LLVM IR (-O2):
define i64 @pointer_hash(i64 %0) {
%2 = shl i64 %0, 32
%3 = xor i64 %2, -1
%4 = add i64 %3, %0
%5 = lshr i64 %4, 22
%6 = xor i64 %5, %4
%7 = shl i64 %6, 13
%8 = xor i64 %7, -1
%9 = add i64 %6, %8
%10 = lshr i64 %9, 8
%11 = xor i64 %10, %9
%12 = mul i64 %11, 9
%13 = lshr i64 %12, 15
%14 = xor i64 %13, %12
%15 = shl i64 %14, 27
%16 = xor i64 %15, -1
%17 = add i64 %14, %16
%18 = lshr i64 %17, 31
%19 = xor i64 %18, %17
ret i64 %19
}