#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*/ pthread_t;

/* Variables and functions */
unsigned int _thread_hash(const void *thread) {
  size_t size;
  const char *buf;
  unsigned int hval;
  buf = (const char *)thread;
  size = sizeof(pthread_t);
  hval = 1;
  while (size--) {
    hval += *buf++;
    hval += (hval << 10);
    hval ^= (hval >> 6);
    hval &= 0x0fffffff;
  }
  hval += (hval << 3);
  hval ^= (hval >> 11);
  hval += (hval << 15);
  return hval;
}


x86 assembly (clang, -O0):
<_thread_hash>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movq   $0x4,-0x10(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x10(%rbp)
cmp    $0x0,%rax
je     1178 <_thread_hash+0x78>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movsbl (%rax),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
shl    $0xa,%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
shr    $0x6,%eax
xor    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
and    $0xfffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    111f <_thread_hash+0x1f>
mov    -0x1c(%rbp),%eax
shl    $0x3,%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
shr    $0xb,%eax
xor    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
shl    $0xf,%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<_thread_hash>:
movsbl (%rdi),%eax
mov    %eax,%ecx
shl    $0xa,%ecx
add    %ecx,%eax
add    $0x401,%eax
mov    %eax,%ecx
shr    $0x6,%ecx
and    $0xfffffff,%eax
xor    %ecx,%eax
movsbl 0x1(%rdi),%ecx
add    %eax,%ecx
mov    %ecx,%eax
shl    $0xa,%eax
add    %ecx,%eax
mov    %eax,%ecx
shr    $0x6,%ecx
and    $0xfffffff,%eax
xor    %ecx,%eax
movsbl 0x2(%rdi),%ecx
add    %eax,%ecx
mov    %ecx,%eax
shl    $0xa,%eax
add    %ecx,%eax
mov    %eax,%ecx
shr    $0x6,%ecx
and    $0xfffffff,%eax
xor    %ecx,%eax
movsbl 0x3(%rdi),%ecx
add    %eax,%ecx
mov    %ecx,%eax
shl    $0xa,%eax
add    %ecx,%eax
mov    %eax,%ecx
shr    $0x6,%ecx
and    $0xfffffff,%eax
xor    %ecx,%eax
lea    (%rax,%rax,8),%eax
mov    %eax,%ecx
shr    $0xb,%ecx
xor    %eax,%ecx
mov    %ecx,%eax
shl    $0xf,%eax
add    %ecx,%eax
ret

LLVM IR (-O0):
define i32 @_thread_hash(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i8*, i8** %2
store i8* %6, i8** %4
store i64 4, i64* %3
store i32 1, i32* %5
br label %7
7: ; preds = %11, %1
%8 = load i64, i64* %3
%9 = add i64 %8, -1
store i64 %9, i64* %3
%10 = icmp ne i64 %8, 0
br i1 %10, label %11, label %28
11: ; preds = %7
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i32 1
store i8* %13, i8** %4
%14 = load i8, i8* %12
%15 = sext i8 %14 to i32
%16 = load i32, i32* %5
%17 = add i32 %16, %15
store i32 %17, i32* %5
%18 = load i32, i32* %5
%19 = shl i32 %18, 10
%20 = load i32, i32* %5
%21 = add i32 %20, %19
store i32 %21, i32* %5
%22 = load i32, i32* %5
%23 = lshr i32 %22, 6
%24 = load i32, i32* %5
%25 = xor i32 %24, %23
store i32 %25, i32* %5
%26 = load i32, i32* %5
%27 = and i32 %26, 268435455
store i32 %27, i32* %5
br label %7
28: ; preds = %7
%29 = load i32, i32* %5
%30 = shl i32 %29, 3
%31 = load i32, i32* %5
%32 = add i32 %31, %30
store i32 %32, i32* %5
%33 = load i32, i32* %5
%34 = lshr i32 %33, 11
%35 = load i32, i32* %5
%36 = xor i32 %35, %34
store i32 %36, i32* %5
%37 = load i32, i32* %5
%38 = shl i32 %37, 15
%39 = load i32, i32* %5
%40 = add i32 %39, %38
store i32 %40, i32* %5
%41 = load i32, i32* %5
ret i32 %41
}

LLVM IR (-O2):
define i32 @_thread_hash(i8* nocapture %0) {
%2 = getelementptr inbounds i8, i8* %0, i64 1
%3 = load i8, i8* %0
%4 = sext i8 %3 to i32
%5 = mul nsw i32 %4, 1025
%6 = add nsw i32 %5, 1025
%7 = lshr i32 %6, 6
%8 = and i32 %6, 268435455
%9 = xor i32 %8, %7
%10 = getelementptr inbounds i8, i8* %0, i64 2
%11 = load i8, i8* %2
%12 = sext i8 %11 to i32
%13 = add nsw i32 %9, %12
%14 = mul i32 %13, 1025
%15 = lshr i32 %14, 6
%16 = and i32 %14, 268435455
%17 = xor i32 %16, %15
%18 = getelementptr inbounds i8, i8* %0, i64 3
%19 = load i8, i8* %10
%20 = sext i8 %19 to i32
%21 = add nsw i32 %17, %20
%22 = mul i32 %21, 1025
%23 = lshr i32 %22, 6
%24 = and i32 %22, 268435455
%25 = xor i32 %24, %23
%26 = load i8, i8* %18
%27 = sext i8 %26 to i32
%28 = add nsw i32 %25, %27
%29 = mul i32 %28, 1025
%30 = lshr i32 %29, 6
%31 = and i32 %29, 268435455
%32 = xor i32 %31, %30
%33 = mul nuw i32 %32, 9
%34 = lshr i32 %33, 11
%35 = xor i32 %34, %33
%36 = mul i32 %35, 32769
ret i32 %36
}