#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*/);
long hash(char *);
int /*<<< orphan*/ printf(char *, long);
int /*<<< orphan*/ stdin;
int strlen(char *);
int main() {
  char input[200];
  long int output;
  short unsigned int l;
  fgets(input, 200 * sizeof(char), stdin);
  l = strlen(input) - 1;
  input[l] = '\0';
  output = hash(input);
  printf("%ld\n", output);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xd0(%rbp),%rdi
mov    0x2e88(%rip),%rax
mov    (%rax),%edx
mov    $0xc8,%esi
call   1060 <fgets@plt>
lea    -0xd0(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
mov    %ax,-0xda(%rbp)
movzwl -0xda(%rbp),%eax
movb   $0x0,-0xd0(%rbp,%rax,1)
lea    -0xd0(%rbp),%rdi
call   1040 <hash@plt>
mov    %rax,-0xd8(%rbp)
mov    -0xd8(%rbp),%rsi
lea    0xe4e(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0xd0,%rsp
mov    0x2e99(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0xc8,%esi
call   1060 <fgets@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
add    $0xffffffff,%eax
movzwl %ax,%eax
movb   $0x0,(%rsp,%rax,1)
mov    %rbx,%rdi
call   1040 <hash@plt>
lea    0xe7e(%rip),%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [5 x i8] c"%ld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [200 x i8]
%3 = alloca i64
%4 = alloca i16
store i32 0, i32* %1
%5 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%6 = load i32, i32* @stdin
%7 = call i32 @fgets(i8* %5, i32 200, i32 %6)
%8 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%9 = call i32 @strlen(i8* %8)
%10 = sub nsw i32 %9, 1
%11 = trunc i32 %10 to i16
store i16 %11, i16* %4
%12 = load i16, i16* %4
%13 = zext i16 %12 to i64
%14 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 %13
store i8 0, i8* %14
%15 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%16 = call i64 @hash(i8* %15)
store i64 %16, i64* %3
%17 = load i64, i64* %3
%18 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 %17)
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [5 x i8] c"%ld\0A\00"
define i32 @main() {
%1 = alloca [200 x i8]
%2 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @stdin
%4 = call i32 @fgets(i8* %2, i32 200, i32 %3)
%5 = call i32 @strlen(i8* %2)
%6 = add i32 %5, 65535
%7 = and i32 %6, 65535
%8 = zext i32 %7 to i64
%9 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 %8
store i8 0, i8* %9
%10 = call i64 @hash(i8* %2)
%11 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 %10)
ret i32 0
}