#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 dictGenCaseHashFunction(const unsigned char *buf, int len) {
  unsigned int hash = 5381;
  while (len--)
    hash = ((hash << 5) + hash) + (tolower(*buf++));
  return hash;
}


x86 assembly (clang, -O0):
<dictGenCaseHashFunction>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x1505,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x0,%eax
je     116c <dictGenCaseHashFunction+0x5c>
mov    -0x10(%rbp),%eax
shl    $0x5,%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movzbl (%rax),%edi
call   1030 <tolower@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <dictGenCaseHashFunction+0x16>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dictGenCaseHashFunction>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %esi,%esi
je     114e <dictGenCaseHashFunction+0x3e>
mov    %rdi,%r14
mov    %esi,%r15d
mov    $0x1505,%eax
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    %eax,%ebp
shl    $0x5,%ebp
add    %eax,%ebp
movzbl (%r14,%rbx,1),%edi
call   1030 <tolower@plt>
add    %ebp,%eax
add    $0x1,%rbx
cmp    %ebx,%r15d
jne    1130 <dictGenCaseHashFunction+0x20>
jmp    1153 <dictGenCaseHashFunction+0x43>
mov    $0x1505,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @dictGenCaseHashFunction(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 5381, i32* %5
br label %6
6: ; preds = %10, %2
%7 = load i32, i32* %4
%8 = add nsw i32 %7, -1
store i32 %8, i32* %4
%9 = icmp ne i32 %7, 0
br i1 %9, label %10, label %21
10: ; preds = %6
%11 = load i32, i32* %5
%12 = shl i32 %11, 5
%13 = load i32, i32* %5
%14 = add i32 %12, %13
%15 = load i8*, i8** %3
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %3
%17 = load i8, i8* %15
%18 = zext i8 %17 to i32
%19 = call i32 @tolower(i32 %18)
%20 = add i32 %14, %19
store i32 %20, i32* %5
br label %6
21: ; preds = %6
%22 = load i32, i32* %5
ret i32 %22
}

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