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

/* Variables and functions */
uint8_t hash_symbol(const char *name) {
  int hash = 0;
  uint8_t n = 0;
  while (*name && n++ < 16)
    hash += *name++;
  return (hash & (64 - 1));
}


x86 assembly (clang, -O0):
<hash_symbol>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x11(%rbp)
je     113f <hash_symbol+0x3f>
mov    -0x10(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x10(%rbp)
cmp    $0x10,%eax
setl   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    114f <hash_symbol+0x4f>
jmp    116c <hash_symbol+0x6c>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movsbl (%rax),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1116 <hash_symbol+0x16>
mov    -0xc(%rbp),%eax
and    $0x3f,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<hash_symbol>:
mov    (%rdi),%cl
test   %cl,%cl
je     1130 <hash_symbol+0x30>
xor    %edx,%edx
xor    %eax,%eax
nopw   0x0(%rax,%rax,1)
mov    %eax,%esi
movzbl %cl,%eax
add    %esi,%eax
movzbl 0x1(%rdi,%rdx,1),%ecx
test   %cl,%cl
je     112c <hash_symbol+0x2c>
lea    0x1(%rdx),%rsi
cmp    $0xf,%edx
mov    %rsi,%rdx
jb     1110 <hash_symbol+0x10>
and    $0x3f,%eax
ret
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @hash_symbol(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
store i32 0, i32* %4
br label %5
5: ; preds = %16, %1
%6 = load i8*, i8** %2
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %5
%11 = load i32, i32* %4
%12 = add nsw i32 %11, 1
store i32 %12, i32* %4
%13 = icmp slt i32 %11, 16
br label %14
14: ; preds = %10, %5
%15 = phi i1 [ false, %5 ], [ %13, %10 ]
br i1 %15, label %16, label %23
16: ; preds = %14
%17 = load i8*, i8** %2
%18 = getelementptr inbounds i8, i8* %17, i32 1
store i8* %18, i8** %2
%19 = load i8, i8* %17
%20 = sext i8 %19 to i32
%21 = load i32, i32* %3
%22 = add nsw i32 %21, %20
store i32 %22, i32* %3
br label %5
23: ; preds = %14
%24 = load i32, i32* %3
%25 = and i32 %24, 63
ret i32 %25
}

LLVM IR (-O2):
define i32 @hash_symbol(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %19, label %4
4: ; preds = %1, %4
%5 = phi i8 [ %13, %4 ], [ %2, %1 ]
%6 = phi i32 [ %10, %4 ], [ 0, %1 ]
%7 = phi i32 [ %12, %4 ], [ 0, %1 ]
%8 = phi i8* [ %11, %4 ], [ %0, %1 ]
%9 = zext i8 %5 to i32
%10 = add nuw nsw i32 %6, 1
%11 = getelementptr inbounds i8, i8* %8, i64 1
%12 = add i32 %7, %9
%13 = load i8, i8* %11
%14 = icmp ne i8 %13, 0
%15 = icmp ult i32 %6, 15
%16 = select i1 %14, i1 %15, i1 false
br i1 %16, label %4, label %17
17: ; preds = %4
%18 = and i32 %12, 63
br label %19
19: ; preds = %17, %1
%20 = phi i32 [ 0, %1 ], [ %18, %17 ]
ret i32 %20
}