#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*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int strlen(char *);
long djb2hash() {
  char input[11];
  fgets(input, 10, stdin);
  size_t nl = strlen(input) - 1;
  input[nl] = '\0';
  unsigned char *str = input;
  unsigned long hash = 5381;
  int c;
  while (c = *str++) {
    hash = ((hash << 5) + hash) + c;
  }
  long int deliverable = hash;
  return hash;
}


x86 assembly (clang, -O0):
<djb2hash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    -0xb(%rbp),%rdi
mov    0x2eb5(%rip),%rax
mov    (%rax),%edx
mov    $0xa,%esi
call   1040 <fgets@plt>
lea    -0xb(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
cltq
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movb   $0x0,-0xb(%rbp,%rax,1)
lea    -0xb(%rbp),%rax
mov    %rax,-0x20(%rbp)
movq   $0x1505,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movzbl (%rax),%eax
mov    %eax,-0x2c(%rbp)
cmp    $0x0,%eax
je     11a4 <djb2hash+0x84>
mov    -0x28(%rbp),%rax
shl    $0x5,%rax
add    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
jmp    116a <djb2hash+0x4a>
mov    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<djb2hash>:
push   %rbx
sub    $0x10,%rsp
mov    0x2ebc(%rip),%rax
mov    (%rax),%edx
lea    0x5(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xa,%esi
call   1040 <fgets@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    0x5(%rsp),%dl
test   %dl,%dl
je     118d <djb2hash+0x6d>
lea    0x6(%rsp),%rcx
mov    $0x1505,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rax,%rsi
shl    $0x5,%rsi
add    %rax,%rsi
movzbl %dl,%eax
add    %rsi,%rax
movzbl (%rcx),%edx
add    $0x1,%rcx
test   %dl,%dl
jne    1170 <djb2hash+0x50>
jmp    1192 <djb2hash+0x72>
mov    $0x1505,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@stdin = global i32 0
define i64 @djb2hash() {
%1 = alloca [11 x i8]
%2 = alloca i64
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
%6 = alloca i64
%7 = getelementptr inbounds [11 x i8], [11 x i8]* %1, i64 0, i64 0
%8 = load i32, i32* @stdin
%9 = call i32 @fgets(i8* %7, i32 10, i32 %8)
%10 = getelementptr inbounds [11 x i8], [11 x i8]* %1, i64 0, i64 0
%11 = call i32 @strlen(i8* %10)
%12 = sub nsw i32 %11, 1
%13 = sext i32 %12 to i64
store i64 %13, i64* %2
%14 = load i64, i64* %2
%15 = getelementptr inbounds [11 x i8], [11 x i8]* %1, i64 0, i64 %14
store i8 0, i8* %15
%16 = getelementptr inbounds [11 x i8], [11 x i8]* %1, i64 0, i64 0
store i8* %16, i8** %3
store i64 5381, i64* %4
br label %17
17: ; preds = %23, %0
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %3
%20 = load i8, i8* %18
%21 = zext i8 %20 to i32
store i32 %21, i32* %5
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %31
23: ; preds = %17
%24 = load i64, i64* %4
%25 = shl i64 %24, 5
%26 = load i64, i64* %4
%27 = add i64 %25, %26
%28 = load i32, i32* %5
%29 = sext i32 %28 to i64
%30 = add i64 %27, %29
store i64 %30, i64* %4
br label %17
31: ; preds = %17
%32 = load i64, i64* %4
store i64 %32, i64* %6
%33 = load i64, i64* %4
ret i64 %33
}

LLVM IR (-O2):
@stdin = global i32 0
define i64 @djb2hash() {
%1 = alloca [11 x i8]
%2 = getelementptr inbounds [11 x i8], [11 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @stdin
%4 = call i32 @fgets(i8* %2, i32 10, i32 %3)
%5 = call i32 @strlen(i8* %2)
%6 = add nsw i32 %5, -1
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds [11 x i8], [11 x i8]* %1, i64 0, i64 %7
store i8 0, i8* %8
%9 = load i8, i8* %2
%10 = icmp eq i8 %9, 0
br i1 %10, label %21, label %11
11: ; preds = %0, %11
%12 = phi i8 [ %19, %11 ], [ %9, %0 ]
%13 = phi i8* [ %15, %11 ], [ %2, %0 ]
%14 = phi i64 [ %18, %11 ], [ 5381, %0 ]
%15 = getelementptr inbounds i8, i8* %13, i64 1
%16 = mul i64 %14, 33
%17 = zext i8 %12 to i64
%18 = add i64 %16, %17
%19 = load i8, i8* %15
%20 = icmp eq i8 %19, 0
br i1 %20, label %21, label %11
21: ; preds = %11, %0
%22 = phi i64 [ 5381, %0 ], [ %18, %11 ]
ret i64 %22
}