#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 */
long hash(char *);
int /*<<< orphan*/ printf(char *, long);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
int main() {
  char word[200] = {0};
  long sum = 0;
  do {
    scanf("%s", word);
  } while (strlen(word) > 200);
  sum = hash(word);
  printf("\n%ld", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xd0(%rbp),%rdi
xor    %esi,%esi
mov    $0xc8,%edx
call   1060 <memset@plt>
movq   $0x0,-0xd8(%rbp)
lea    -0xd0(%rbp),%rsi
lea    0xe72(%rip),%rdi
call   1070 <scanf@plt>
lea    -0xd0(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0xc8,%eax
jg     1180 <main+0x30>
lea    -0xd0(%rbp),%rdi
call   1040 <hash@plt>
mov    %rax,-0xd8(%rbp)
mov    -0xd8(%rbp),%rsi
lea    0xe38(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xc8,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movq   $0x0,0xc0(%rsp)
lea    0xe59(%rip),%r14
mov    %rsp,%rbx
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0xc8,%eax
jg     11b0 <main+0x70>
mov    %rsp,%rdi
call   1040 <hash@plt>
lea    0xe2a(%rip),%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0xc8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [5 x i8] c"\0A%ld\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [200 x i8]
%3 = alloca i64
store i32 0, i32* %1
%4 = bitcast [200 x i8]* %2 to i8*
store i64 0, i64* %3
br label %5
5: ; preds = %8, %0
%6 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %8
8: ; preds = %5
%9 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%10 = call i32 @strlen(i8* %9)
%11 = icmp sgt i32 %10, 200
br i1 %11, label %5, label %12
12: ; preds = %8
%13 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%14 = call i64 @hash(i8* %13)
store i64 %14, i64* %3
%15 = load i64, i64* %3
%16 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %15)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [5 x i8] c"\0A%ld\00"
define i32 @main() {
%1 = alloca [200 x i8]
%2 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 0
br label %3
3: ; preds = %3, %0
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%5 = call i32 @strlen(i8* %2)
%6 = icmp sgt i32 %5, 200
br i1 %6, label %3, label %7
7: ; preds = %3
%8 = call i64 @hash(i8* %2)
%9 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %8)
ret i32 0
}