#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(char const *);
scalar_t__ tolower(char const);
unsigned int jw_strcase_hashcode(const void *key) {
  const char *s = (const char *)key;
  unsigned long h = 0;
  const char *p;
  assert(s);
  for (p = (const char *)s; *p != '\0'; p += 1) {
    h = (h << 5) - h + (unsigned long)tolower(*p);
  }
  return (unsigned int)h;
}


x86 assembly (clang, -O0):
<jw_strcase_hashcode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <assert@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1198 <jw_strcase_hashcode+0x78>
mov    -0x18(%rbp),%rax
shl    $0x5,%rax
sub    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1040 <tolower@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    114d <jw_strcase_hashcode+0x2d>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jw_strcase_hashcode>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1030 <assert@plt>
mov    (%r14),%cl
test   %cl,%cl
je     1163 <jw_strcase_hashcode+0x43>
add    $0x1,%r14
xor    %eax,%eax
nopl   0x0(%rax)
mov    %rax,%rbx
shl    $0x5,%rbx
sub    %rax,%rbx
movsbl %cl,%edi
call   1040 <tolower@plt>
add    %rbx,%rax
movzbl (%r14),%ecx
add    $0x1,%r14
test   %cl,%cl
jne    1140 <jw_strcase_hashcode+0x20>
jmp    1165 <jw_strcase_hashcode+0x45>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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