#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 */
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ strcmp(char const *, char const *);
int dumb_hash_contains(const char *filename) {
  static const char *hash_table[2039] = {
      0,
  };
  const signed char *p = filename;
  uint32_t h = *p;
  for (p += 1; *p != '\0'; p++)
    h = (h << 5) - h + *p;
  h %= 2039;
  if (hash_table[h])
    return !strcmp(hash_table[h], filename);
  hash_table[h] = filename;
  return 0;
}


x86 assembly (clang, -O0):
<dumb_hash_contains>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1170 <dumb_hash_contains+0x60>
mov    -0x1c(%rbp),%eax
shl    $0x5,%eax
sub    -0x1c(%rbp),%eax
mov    -0x18(%rbp),%rcx
movsbl (%rcx),%ecx
add    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    113a <dumb_hash_contains+0x2a>
mov    -0x1c(%rbp),%eax
mov    $0x7f7,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
movslq -0x1c(%rbp),%rcx
lea    0x2eb7(%rip),%rax
cmpq   $0x0,(%rax,%rcx,8)
je     11c1 <dumb_hash_contains+0xb1>
movslq -0x1c(%rbp),%rcx
lea    0x2ea1(%rip),%rax
mov    (%rax,%rcx,8),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    11db <dumb_hash_contains+0xcb>
mov    -0x10(%rbp),%rdx
movslq -0x1c(%rbp),%rcx
lea    0x2e70(%rip),%rax
mov    %rdx,(%rax,%rcx,8)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dumb_hash_contains>:
push   %rax
mov    %rdi,%rsi
movsbl (%rdi),%edi
mov    0x1(%rsi),%dl
test   %dl,%dl
je     1149 <dumb_hash_contains+0x39>
lea    0x2(%rsi),%rcx
mov    %edi,%eax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl %dl,%edx
shl    $0x5,%eax
sub    %edi,%eax
add    %edx,%eax
movzbl (%rcx),%edx
add    $0x1,%rcx
mov    %eax,%edi
test   %dl,%dl
jne    1130 <dumb_hash_contains+0x20>
jmp    114b <dumb_hash_contains+0x3b>
mov    %edi,%eax
cltq
imul   $0x10121457,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x27,%rcx
add    %edx,%ecx
imul   $0x7f7,%ecx,%ecx
sub    %ecx,%eax
cltq
lea    0x2ece(%rip),%rcx
mov    (%rcx,%rax,8),%rdi
test   %rdi,%rdi
je     118b <dumb_hash_contains+0x7b>
call   1030 <strcmp@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
sete   %al
pop    %rcx
ret
mov    %rsi,(%rcx,%rax,8)
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@dumb_hash_contains.hash_table = internal global [2039 x i8*] zeroinitializer
define i32 @dumb_hash_contains(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i8*, i8** %3
store i8* %6, i8** %4
%7 = load i8*, i8** %4
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
store i32 %9, i32* %5
%10 = load i8*, i8** %4
%11 = getelementptr inbounds i8, i8* %10, i64 1
store i8* %11, i8** %4
br label %12
12: ; preds = %26, %1
%13 = load i8*, i8** %4
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %29
17: ; preds = %12
%18 = load i32, i32* %5
%19 = shl i32 %18, 5
%20 = load i32, i32* %5
%21 = sub nsw i32 %19, %20
%22 = load i8*, i8** %4
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = add nsw i32 %21, %24
store i32 %25, i32* %5
br label %26
26: ; preds = %17
%27 = load i8*, i8** %4
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %4
br label %12
29: ; preds = %12
%30 = load i32, i32* %5
%31 = srem i32 %30, 2039
store i32 %31, i32* %5
%32 = load i32, i32* %5
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [2039 x i8*], [2039 x i8*]* @dumb_hash_contains.hash_table, i64 0, i64 %33
%35 = load i8*, i8** %34
%36 = icmp ne i8* %35, null
br i1 %36, label %37, label %47
37: ; preds = %29
%38 = load i32, i32* %5
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [2039 x i8*], [2039 x i8*]* @dumb_hash_contains.hash_table, i64 0, i64 %39
%41 = load i8*, i8** %40
%42 = load i8*, i8** %3
%43 = call i32 @strcmp(i8* %41, i8* %42)
%44 = icmp ne i32 %43, 0
%45 = xor i1 %44, true
%46 = zext i1 %45 to i32
store i32 %46, i32* %2
br label %52
47: ; preds = %29
%48 = load i8*, i8** %3
%49 = load i32, i32* %5
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [2039 x i8*], [2039 x i8*]* @dumb_hash_contains.hash_table, i64 0, i64 %50
store i8* %48, i8** %51
store i32 0, i32* %2
br label %52
52: ; preds = %47, %37
%53 = load i32, i32* %2
ret i32 %53
}

LLVM IR (-O2):
@dumb_hash_contains.hash_table = internal unnamed_addr global [2039 x i8*] zeroinitializer
define i32 @dumb_hash_contains(i8* %0) {
%2 = load i8, i8* %0
%3 = sext i8 %2 to i32
%4 = getelementptr inbounds i8, i8* %0, i64 1
%5 = load i8, i8* %4
%6 = icmp eq i8 %5, 0
br i1 %6, label %17, label %7
7: ; preds = %1, %7
%8 = phi i8 [ %15, %7 ], [ %5, %1 ]
%9 = phi i8* [ %14, %7 ], [ %4, %1 ]
%10 = phi i32 [ %13, %7 ], [ %3, %1 ]
%11 = sext i8 %8 to i32
%12 = mul i32 %10, 31
%13 = add nsw i32 %12, %11
%14 = getelementptr inbounds i8, i8* %9, i64 1
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
br i1 %16, label %17, label %7
17: ; preds = %7, %1
%18 = phi i32 [ %3, %1 ], [ %13, %7 ]
%19 = srem i32 %18, 2039
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [2039 x i8*], [2039 x i8*]* @dumb_hash_contains.hash_table, i64 0, i64 %20
%22 = load i8*, i8** %21
%23 = icmp eq i8* %22, null
br i1 %23, label %28, label %24
24: ; preds = %17
%25 = tail call i32 @strcmp(i8* %22, i8* %0)
%26 = icmp eq i32 %25, 0
%27 = zext i1 %26 to i32
br label %29
28: ; preds = %17
store i8* %0, i8** %21
br label %29
29: ; preds = %28, %24
%30 = phi i32 [ %27, %24 ], [ 0, %28 ]
ret i32 %30
}