#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 tolower(char);
unsigned hashfn(char *s) {
  unsigned h = 0;
  while (*s) {
    int c = tolower(*s);
    s++;
    h = h * 67 + (c - 113);
  }
  return h % 37;
}


x86 assembly (clang, -O0):
<hashfn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     115f <hashfn+0x4f>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <tolower@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
imul   $0x43,-0xc(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    $0x71,%ecx
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <hashfn+0x13>
mov    -0xc(%rbp),%eax
mov    $0x25,%ecx
xor    %edx,%edx
div    %ecx
mov    %edx,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hashfn>:
push   %rbp
push   %rbx
push   %rax
mov    (%rdi),%al
test   %al,%al
je     1170 <hashfn+0x60>
mov    %rdi,%rbx
add    $0x1,%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl %al,%edi
call   1030 <tolower@plt>
imul   $0x43,%ebp,%ecx
lea    (%rcx,%rax,1),%ebp
add    $0xffffff8f,%ebp
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <hashfn+0x20>
mov    %ebp,%eax
mov    $0xbacf914d,%ecx
imul   %rax,%rcx
shr    $0x20,%rcx
mov    %ebp,%eax
sub    %ecx,%eax
shr    %eax
add    %ecx,%eax
shr    $0x5,%eax
lea    (%rax,%rax,8),%ecx
lea    (%rax,%rcx,4),%eax
sub    %eax,%ebp
jmp    1172 <hashfn+0x62>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @hashfn(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
br label %5
5: ; preds = %9, %1
%6 = load i8*, i8** %2
%7 = load i8, i8* %6
%8 = icmp ne i8 %7, 0
br i1 %8, label %9, label %20
9: ; preds = %5
%10 = load i8*, i8** %2
%11 = load i8, i8* %10
%12 = call i32 @tolower(i8 signext %11)
store i32 %12, i32* %4
%13 = load i8*, i8** %2
%14 = getelementptr inbounds i8, i8* %13, i32 1
store i8* %14, i8** %2
%15 = load i32, i32* %3
%16 = mul i32 %15, 67
%17 = load i32, i32* %4
%18 = sub nsw i32 %17, 113
%19 = add i32 %16, %18
store i32 %19, i32* %3
br label %5
20: ; preds = %5
%21 = load i32, i32* %3
%22 = urem i32 %21, 37
ret i32 %22
}

LLVM IR (-O2):
define i32 @hashfn(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %17, label %4
4: ; preds = %1, %4
%5 = phi i8 [ %13, %4 ], [ %2, %1 ]
%6 = phi i8* [ %9, %4 ], [ %0, %1 ]
%7 = phi i32 [ %12, %4 ], [ 0, %1 ]
%8 = tail call i32 @tolower(i8 signext %5)
%9 = getelementptr inbounds i8, i8* %6, i64 1
%10 = mul i32 %7, 67
%11 = add i32 %10, -113
%12 = add i32 %11, %8
%13 = load i8, i8* %9
%14 = icmp eq i8 %13, 0
br i1 %14, label %15, label %4
15: ; preds = %4
%16 = urem i32 %12, 37
br label %17
17: ; preds = %15, %1
%18 = phi i32 [ 0, %1 ], [ %16, %15 ]
ret i32 %18
}