#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(int /*<<< orphan*/);
unsigned int hash_table_get_hash_value(char *key, int cell_array_size) {
  unsigned int hash_value = 0;
  while (*key)
    hash_value = (hash_value << 5) + tolower(*key++);
  return hash_value % cell_array_size;
}


x86 assembly (clang, -O0):
<hash_table_get_hash_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     1162 <hash_table_get_hash_value+0x52>
mov    -0x10(%rbp),%eax
shl    $0x5,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movsbl (%rax),%edi
call   1030 <tolower@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <hash_table_get_hash_value+0x16>
mov    -0x10(%rbp),%eax
xor    %edx,%edx
divl   -0xc(%rbp)
mov    %edx,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hash_table_get_hash_value>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    (%rdi),%al
test   %al,%al
je     114a <hash_table_get_hash_value+0x3a>
mov    %rdi,%rbx
add    $0x1,%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
shl    $0x5,%ebp
movsbl %al,%edi
call   1030 <tolower@plt>
add    %eax,%ebp
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <hash_table_get_hash_value+0x20>
jmp    114c <hash_table_get_hash_value+0x3c>
xor    %ebp,%ebp
mov    %ebp,%eax
xor    %edx,%edx
div    %r14d
mov    %edx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @hash_table_get_hash_value(i8* nocapture %0, i32 %1) {
%3 = load i8, i8* %0
%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 i32 [ %13, %5 ], [ 0, %2 ]
%8 = phi i8* [ %10, %5 ], [ %0, %2 ]
%9 = shl i32 %7, 5
%10 = getelementptr inbounds i8, i8* %8, i64 1
%11 = sext i8 %6 to i32
%12 = tail call i32 @tolower(i32 %11)
%13 = add i32 %12, %9
%14 = load i8, i8* %10
%15 = icmp eq i8 %14, 0
br i1 %15, label %16, label %5
16: ; preds = %5, %2
%17 = phi i32 [ 0, %2 ], [ %13, %5 ]
%18 = urem i32 %17, %1
ret i32 %18
}