#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 const);
unsigned int dd_hashFunction(const char *name) {
  int code = 0, loop;
  const char *p = name;
  while (*p != '\0') {
    code = (code << 4) + tolower(*p);
    if ((loop = (code & 0xF0000000)) != 0) {
      code = code ^ (loop >> 24);
      code = code ^ loop;
    }
    ++p;
  }
  return code;
}


x86 assembly (clang, -O0):
<dd_hashFunction>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1196 <dd_hashFunction+0x86>
mov    -0xc(%rbp),%eax
shl    $0x4,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <tolower@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0xf0000000,%eax
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
je     1185 <dd_hashFunction+0x75>
mov    -0xc(%rbp),%eax
mov    -0x10(%rbp),%ecx
sar    $0x18,%ecx
xor    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
xor    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    112b <dd_hashFunction+0x1b>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dd_hashFunction>:
push   %rbp
push   %rbx
push   %rax
mov    (%rdi),%al
test   %al,%al
je     1166 <dd_hashFunction+0x56>
mov    %rdi,%rbx
add    $0x1,%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
shl    $0x4,%ebp
movsbl %al,%edi
call   1030 <tolower@plt>
add    %ebp,%eax
mov    %eax,%ecx
and    $0xf0000000,%ecx
mov    %ecx,%edx
sar    $0x18,%edx
mov    %eax,%ebp
and    $0xfffffff,%ebp
xor    %edx,%ebp
test   %ecx,%ecx
cmove  %eax,%ebp
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <dd_hashFunction+0x20>
jmp    1168 <dd_hashFunction+0x58>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @dd_hashFunction(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %20, label %4
4: ; preds = %1, %4
%5 = phi i8 [ %18, %4 ], [ %2, %1 ]
%6 = phi i8* [ %17, %4 ], [ %0, %1 ]
%7 = phi i32 [ %16, %4 ], [ 0, %1 ]
%8 = shl i32 %7, 4
%9 = tail call i32 @tolower(i8 signext %5)
%10 = add nsw i32 %9, %8
%11 = and i32 %10, -268435456
%12 = icmp eq i32 %11, 0
%13 = ashr exact i32 %11, 24
%14 = and i32 %10, 268435455
%15 = xor i32 %14, %13
%16 = select i1 %12, i32 %10, i32 %15
%17 = getelementptr inbounds i8, i8* %6, i64 1
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 0
br i1 %19, label %20, label %4
20: ; preds = %4, %1
%21 = phi i32 [ 0, %1 ], [ %16, %4 ]
ret i32 %21
}