#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 /*<<< orphan*/ strings;

/* Variables and functions */
int fhtw_hash(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strlen(char *);
int main(int argc, char *argv[]) {
  printf("\nTest 2, testing hash function...\n\n");
  char *strings[] = {
      "bing bang boom we're going to the moon",
      "hello world",
      "q",
      "q",
      "seven!!",
      "seven!!",
      "a",
      "a",
      "davidad!",
      "knock knock who's there boo boo hoo don't cry it's only me",
      "",
      "hello world",
      "",
      "davidad!"};
  for (int i = 0; i < sizeof(strings) / sizeof(char *); i++) {
    printf("'%s' hashes to ", strings[i]);
    printf("%x\n", fhtw_hash(strings[i], strlen(strings[i])));
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x80(%rbp),%rdi
lea    0x2c3e(%rip),%rsi
mov    $0x70,%edx
call   1060 <memcpy@plt>
movl   $0x0,-0x84(%rbp)
movslq -0x84(%rbp),%rax
cmp    $0xe,%rax
jae    1207 <main+0xc7>
movslq -0x84(%rbp),%rax
mov    -0x80(%rbp,%rax,8),%rsi
lea    0xefd(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movslq -0x84(%rbp),%rax
mov    -0x80(%rbp,%rax,8),%rax
mov    %rax,-0x90(%rbp)
movslq -0x84(%rbp),%rax
mov    -0x80(%rbp,%rax,8),%rdi
call   1030 <strlen@plt>
mov    -0x90(%rbp),%rdi
mov    %eax,%esi
call   1040 <fhtw_hash@plt>
mov    %eax,%esi
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    1186 <main+0x46>
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
lea    0xf47(%rip),%rdi
call   1030 <puts@plt>
lea    0x2c54(%rip),%r12
lea    0xf20(%rip),%r14
lea    0xf29(%rip),%r15
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    (%rbx,%r12,1),%r13
mov    %r14,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r13,%rdi
call   1040 <strlen@plt>
mov    %r13,%rdi
mov    %eax,%esi
call   1050 <fhtw_hash@plt>
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x8,%rbx
cmp    $0x70,%rbx
jne    1170 <main+0x30>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [36 x i8] c"\0ATest 2, testing hash function...\0A\0A\00"
@.str.1 = [39 x i8] c"bing bang boom we're going to the moon\00"
@.str.2 = [12 x i8] c"hello world\00"
@.str.3 = [2 x i8] c"q\00"
@.str.4 = [8 x i8] c"seven!!\00"
@.str.5 = [2 x i8] c"a\00"
@.str.6 = [9 x i8] c"davidad!\00"
@.str.7 = [59 x i8] c"knock knock who's there boo boo hoo don't cry it's only me\00"
@.str.8 = [1 x i8] zeroinitializer
@__const.main.strings = [14 x i8*] [i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i32 0, i32 0)]
@.str.9 = [16 x i8] c"'%s' hashes to \00"
@.str.10 = [4 x i8] c"%x\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [14 x i8*]
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%9 = bitcast [14 x i8*]* %6 to i8*
store i32 0, i32* %7
br label %10
10: ; preds = %31, %2
%11 = load i32, i32* %7
%12 = sext i32 %11 to i64
%13 = icmp ult i64 %12, 14
br i1 %13, label %14, label %34
14: ; preds = %10
%15 = load i32, i32* %7
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [14 x i8*], [14 x i8*]* %6, i64 0, i64 %16
%18 = load i8*, i8** %17
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), i8* %18)
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [14 x i8*], [14 x i8*]* %6, i64 0, i64 %21
%23 = load i8*, i8** %22
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [14 x i8*], [14 x i8*]* %6, i64 0, i64 %25
%27 = load i8*, i8** %26
%28 = call i32 @strlen(i8* %27)
%29 = call i32 @fhtw_hash(i8* %23, i32 %28)
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 %29)
br label %31
31: ; preds = %14
%32 = load i32, i32* %7
%33 = add nsw i32 %32, 1
store i32 %33, i32* %7
br label %10
34: ; preds = %10
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
@.str.1 = [39 x i8] c"bing bang boom we're going to the moon\00"
@.str.2 = [12 x i8] c"hello world\00"
@.str.3 = [2 x i8] c"q\00"
@.str.4 = [8 x i8] c"seven!!\00"
@.str.5 = [2 x i8] c"a\00"
@.str.6 = [9 x i8] c"davidad!\00"
@.str.7 = [59 x i8] c"knock knock who's there boo boo hoo don't cry it's only me\00"
@.str.8 = [1 x i8] zeroinitializer
@__const.main.strings = [14 x i8*] [i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i32 0, i32 0)]
@.str.9 = [16 x i8] c"'%s' hashes to \00"
@.str.10 = [4 x i8] c"%x\0A\00"
@str = [35 x i8] c"\0ATest 2, testing hash function...\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
br label %5
4: ; preds = %5
ret i32 0
5: ; preds = %2, %5
%6 = phi i64 [ 0, %2 ], [ %13, %5 ]
%7 = getelementptr inbounds [14 x i8*], [14 x i8*]* @__const.main.strings, i64 0, i64 %6
%8 = load i8*, i8** %7
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), i8* %8)
%10 = tail call i32 @strlen(i8* %8)
%11 = tail call i32 @fhtw_hash(i8* %8, i32 %10)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 %11)
%13 = add nuw nsw i64 %6, 1
%14 = icmp eq i64 %13, 14
br i1 %14, label %4, label %5
}