#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 size_t uint8_t;

/* Variables and functions */
int CHAR_BIT;
size_t UINT32_C(int);
size_t UINT64_C(int);
size_t hsearch_hash(size_t offset_basis, const char *str) {
  size_t hash;
  hash = offset_basis;
  while (*str != '\0') {
    hash ^= (uint8_t)*str++;
    if (sizeof(size_t) * CHAR_BIT <= 32)
      hash *= UINT32_C(16777619);
    else
      hash *= UINT64_C(1099511628211);
  }
  return (hash);
}


x86 assembly (clang, -O0):
<hsearch_hash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11ab <hsearch_hash+0x8b>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbq (%rax),%rax
xor    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    0x2e76(%rip),%rax
movslq (%rax),%rax
shl    $0x3,%rax
cmp    $0x20,%rax
ja     1193 <hsearch_hash+0x73>
mov    $0x1000193,%edi
call   1040 <UINT32_C@plt>
imul   -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    11a6 <hsearch_hash+0x86>
mov    $0x1b3,%edi
call   1030 <UINT64_C@plt>
imul   -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    1138 <hsearch_hash+0x18>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hsearch_hash>:
push   %r15
push   %r14
push   %rbx
mov    (%rsi),%al
test   %al,%al
je     117d <hsearch_hash+0x5d>
mov    %rsi,%r14
add    $0x1,%r14
mov    0x2ea7(%rip),%r15
jmp    115d <hsearch_hash+0x3d>
nopl   0x0(%rax,%rax,1)
mov    $0x1b3,%edi
call   1030 <UINT64_C@plt>
imul   %rax,%rbx
movzbl (%r14),%eax
add    $0x1,%r14
mov    %rbx,%rdi
test   %al,%al
je     1180 <hsearch_hash+0x60>
movsbq %al,%rbx
xor    %rdi,%rbx
movslq (%r15),%rax
shl    $0x3,%rax
cmp    $0x20,%rax
ja     1140 <hsearch_hash+0x20>
mov    $0x1000193,%edi
call   1040 <UINT32_C@plt>
jmp    114a <hsearch_hash+0x2a>
mov    %rdi,%rbx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@CHAR_BIT = global i32 0
define i64 @hsearch_hash(i64 %0, i8* %1) {
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i64
store i64 %0, i64* %3
store i8* %1, i8** %4
%6 = load i64, i64* %3
store i64 %6, i64* %5
br label %7
7: ; preds = %31, %2
%8 = load i8*, i8** %4
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %32
12: ; preds = %7
%13 = load i8*, i8** %4
%14 = getelementptr inbounds i8, i8* %13, i32 1
store i8* %14, i8** %4
%15 = load i8, i8* %13
%16 = sext i8 %15 to i64
%17 = load i64, i64* %5
%18 = xor i64 %17, %16
store i64 %18, i64* %5
%19 = load i32, i32* @CHAR_BIT
%20 = sext i32 %19 to i64
%21 = mul i64 8, %20
%22 = icmp ule i64 %21, 32
br i1 %22, label %23, label %27
23: ; preds = %12
%24 = call i64 @UINT32_C(i32 16777619)
%25 = load i64, i64* %5
%26 = mul i64 %25, %24
store i64 %26, i64* %5
br label %31
27: ; preds = %12
%28 = call i64 @UINT64_C(i32 435)
%29 = load i64, i64* %5
%30 = mul i64 %29, %28
store i64 %30, i64* %5
br label %31
31: ; preds = %27, %23
br label %7
32: ; preds = %7
%33 = load i64, i64* %5
ret i64 %33
}

LLVM IR (-O2):
@CHAR_BIT = global i32 0
define i64 @hsearch_hash(i64 %0, i8* nocapture %1) {
%3 = load i8, i8* %1
%4 = icmp eq i8 %3, 0
br i1 %4, label %25, label %5
5: ; preds = %2, %20
%6 = phi i8 [ %23, %20 ], [ %3, %2 ]
%7 = phi i64 [ %22, %20 ], [ %0, %2 ]
%8 = phi i8* [ %9, %20 ], [ %1, %2 ]
%9 = getelementptr inbounds i8, i8* %8, i64 1
%10 = sext i8 %6 to i64
%11 = xor i64 %7, %10
%12 = load i32, i32* @CHAR_BIT
%13 = sext i32 %12 to i64
%14 = shl nsw i64 %13, 3
%15 = icmp ult i64 %14, 33
br i1 %15, label %16, label %18
16: ; preds = %5
%17 = tail call i64 @UINT32_C(i32 16777619)
br label %20
18: ; preds = %5
%19 = tail call i64 @UINT64_C(i32 435)
br label %20
20: ; preds = %18, %16
%21 = phi i64 [ %17, %16 ], [ %19, %18 ]
%22 = mul i64 %21, %11
%23 = load i8, i8* %9
%24 = icmp eq i8 %23, 0
br i1 %24, label %25, label %5
25: ; preds = %20, %2
%26 = phi i64 [ %0, %2 ], [ %22, %20 ]
ret i64 %26
}