#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 */
unsigned int tolower(char const);
unsigned int _hash(unsigned int size, const char *k) {
  unsigned int result = 0x3505;
  size_t i;
  for (i = 0; k[i]; i++)
    result = result * 37 + tolower(k[i]);
  return result % size;
}


x86 assembly (clang, -O0):
<_hash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x3505,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     1173 <_hash+0x63>
imul   $0x25,-0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <tolower@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    112e <_hash+0x1e>
mov    -0x14(%rbp),%eax
xor    %edx,%edx
divl   -0x4(%rbp)
mov    %edx,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_hash>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%r14d
mov    (%rsi),%cl
test   %cl,%cl
je     114d <_hash+0x3d>
mov    %rsi,%rbx
add    $0x1,%rbx
mov    $0x3505,%eax
nopl   0x0(%rax)
lea    (%rax,%rax,8),%edx
lea    (%rax,%rdx,4),%ebp
movsbl %cl,%edi
call   1030 <tolower@plt>
add    %ebp,%eax
movzbl (%rbx),%ecx
add    $0x1,%rbx
test   %cl,%cl
jne    1130 <_hash+0x20>
jmp    1152 <_hash+0x42>
mov    $0x3505,%eax
xor    %edx,%edx
div    %r14d
mov    %edx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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