#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 */
int /*<<< orphan*/ assert(int /*<<< orphan*/);
unsigned long rs_symtab_hash(const char *sym) {
  assert(sym != NULL);
  unsigned long hashval;
  for (hashval = 5381; *sym != '\0'; sym++) {
    hashval = ((hashval << 5) + hashval) + (unsigned long)*sym;
  }
  return hashval % 1439;
}


x86 assembly (clang, -O0):
<rs_symtab_hash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movq   $0x1505,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1172 <rs_symtab_hash+0x62>
mov    -0x10(%rbp),%rax
shl    $0x5,%rax
add    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
movsbq (%rcx),%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1136 <rs_symtab_hash+0x26>
mov    -0x10(%rbp),%rax
mov    $0x59f,%ecx
xor    %edx,%edx
div    %rcx
mov    %rdx,%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rs_symtab_hash>:
push   %rbx
mov    %rdi,%rbx
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1030 <assert@plt>
mov    (%rbx),%al
test   %al,%al
je     117c <rs_symtab_hash+0x6c>
add    $0x1,%rbx
mov    $0x1505,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rcx,%rdx
shl    $0x5,%rdx
add    %rcx,%rdx
movsbq %al,%rcx
add    %rdx,%rcx
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1140 <rs_symtab_hash+0x30>
movabs $0xb62bc38378155921,%rdx
c3 2b b6
mov    %rcx,%rax
mul    %rdx
shr    $0xa,%rdx
imul   $0x59f,%rdx,%rax
sub    %rax,%rcx
jmp    1181 <rs_symtab_hash+0x71>
mov    $0x428,%ecx
mov    %rcx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i64 @rs_symtab_hash(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = icmp ne i8* %4, null
%6 = zext i1 %5 to i32
%7 = call i32 @assert(i32 %6)
store i64 5381, i64* %3
br label %8
8: ; preds = %22, %1
%9 = load i8*, i8** %2
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %25
13: ; preds = %8
%14 = load i64, i64* %3
%15 = shl i64 %14, 5
%16 = load i64, i64* %3
%17 = add i64 %15, %16
%18 = load i8*, i8** %2
%19 = load i8, i8* %18
%20 = sext i8 %19 to i64
%21 = add i64 %17, %20
store i64 %21, i64* %3
br label %22
22: ; preds = %13
%23 = load i8*, i8** %2
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %2
br label %8
25: ; preds = %8
%26 = load i64, i64* %3
%27 = urem i64 %26, 1439
ret i64 %27
}

LLVM IR (-O2):
define i64 @rs_symtab_hash(i8* %0) {
%2 = icmp ne i8* %0, null
%3 = zext i1 %2 to i32
%4 = tail call i32 @assert(i32 %3)
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 0
br i1 %6, label %19, label %7
7: ; preds = %1, %7
%8 = phi i8 [ %15, %7 ], [ %5, %1 ]
%9 = phi i64 [ %13, %7 ], [ 5381, %1 ]
%10 = phi i8* [ %14, %7 ], [ %0, %1 ]
%11 = mul i64 %9, 33
%12 = sext i8 %8 to i64
%13 = add i64 %11, %12
%14 = getelementptr inbounds i8, i8* %10, i64 1
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
br i1 %16, label %17, label %7
17: ; preds = %7
%18 = urem i64 %13, 1439
br label %19
19: ; preds = %17, %1
%20 = phi i64 [ 1064, %1 ], [ %18, %17 ]
ret i64 %20
}