#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 EOF;
int getchar();
int /*<<< orphan*/ hashit(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ octdigit(int);
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/);
void copystr(void) {
  int c, ch;
  char buf[512];
  char *cp = buf;
  for (;;) {
    c = getchar();
    if (c == EOF)
      break;
    switch (c) {
    case '"':
      *cp++ = 0;
      goto out;
    case '\\':
      c = getchar();
      switch (c) {
      case 'b':
        c = '\b';
        break;
      case 't':
        c = '\t';
        break;
      case 'r':
        c = '\r';
        break;
      case 'n':
        c = '\n';
        break;
      case '\n':
        continue;
      case 'f':
        c = '\f';
        break;
      case '0':
        c = 0;
        break;
      case '\\':
        break;
      default:
        if (!octdigit(c))
          break;
        c -= '0';
        ch = getchar();
        if (!octdigit(ch))
          break;
        c <<= 7, c += ch - '0';
        ch = getchar();
        if (!octdigit(ch))
          break;
        c <<= 3, c += ch - '0', ch = -1;
        break;
      }
    }
    *cp++ = c;
  }
out:
  *cp = 0;
  printf("%ld", hashit(buf, 1, 0));
}


x86 assembly (clang, -O0):
<copystr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
lea    -0x210(%rbp),%rax
mov    %rax,-0x218(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2e7b(%rip),%rcx
cmp    (%rcx),%eax
jne    117a <copystr+0x3a>
jmp    1377 <copystr+0x237>
mov    -0x4(%rbp),%eax
mov    %eax,-0x21c(%rbp)
sub    $0x22,%eax
je     11a5 <copystr+0x65>
jmp    1191 <copystr+0x51>
mov    -0x21c(%rbp),%eax
sub    $0x5c,%eax
je     11c2 <copystr+0x82>
jmp    1356 <copystr+0x216>
mov    -0x218(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x218(%rbp)
movb   $0x0,(%rax)
jmp    137c <copystr+0x23c>
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x220(%rbp)
sub    $0xa,%eax
je     129f <copystr+0x15f>
jmp    11e3 <copystr+0xa3>
mov    -0x220(%rbp),%eax
sub    $0x30,%eax
je     12b0 <copystr+0x170>
jmp    11f7 <copystr+0xb7>
mov    -0x220(%rbp),%eax
sub    $0x5c,%eax
je     12bc <copystr+0x17c>
jmp    120b <copystr+0xcb>
mov    -0x220(%rbp),%eax
sub    $0x62,%eax
je     126f <copystr+0x12f>
jmp    121f <copystr+0xdf>
mov    -0x220(%rbp),%eax
sub    $0x66,%eax
je     12a4 <copystr+0x164>
jmp    1233 <copystr+0xf3>
mov    -0x220(%rbp),%eax
sub    $0x6e,%eax
je     1293 <copystr+0x153>
jmp    1247 <copystr+0x107>
mov    -0x220(%rbp),%eax
sub    $0x72,%eax
je     1287 <copystr+0x147>
jmp    125b <copystr+0x11b>
mov    -0x220(%rbp),%eax
sub    $0x74,%eax
je     127b <copystr+0x13b>
jmp    12c1 <copystr+0x181>
movl   $0x8,-0x4(%rbp)
jmp    1351 <copystr+0x211>
movl   $0x9,-0x4(%rbp)
jmp    1351 <copystr+0x211>
movl   $0xd,-0x4(%rbp)
jmp    1351 <copystr+0x211>
movl   $0xa,-0x4(%rbp)
jmp    1351 <copystr+0x211>
jmp    1159 <copystr+0x19>
movl   $0xc,-0x4(%rbp)
jmp    1351 <copystr+0x211>
movl   $0x0,-0x4(%rbp)
jmp    1351 <copystr+0x211>
jmp    1351 <copystr+0x211>
mov    -0x4(%rbp),%edi
call   1060 <octdigit@plt>
cmp    $0x0,%eax
jne    12d7 <copystr+0x197>
jmp    1351 <copystr+0x211>
mov    -0x4(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x4(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1060 <octdigit@plt>
cmp    $0x0,%eax
jne    1300 <copystr+0x1c0>
jmp    1351 <copystr+0x211>
mov    -0x4(%rbp),%eax
shl    $0x7,%eax
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x30,%eax
add    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1060 <octdigit@plt>
cmp    $0x0,%eax
jne    1335 <copystr+0x1f5>
jmp    1351 <copystr+0x211>
mov    -0x4(%rbp),%eax
shl    $0x3,%eax
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x30,%eax
add    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0xffffffff,-0x8(%rbp)
jmp    1356 <copystr+0x216>
mov    -0x4(%rbp),%eax
mov    %al,%cl
mov    -0x218(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x218(%rbp)
mov    %cl,(%rax)
jmp    1159 <copystr+0x19>
jmp    137c <copystr+0x23c>
mov    -0x218(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x210(%rbp),%rdi
mov    $0x1,%esi
xor    %edx,%edx
call   1050 <hashit@plt>
mov    %eax,%esi
lea    0xc5e(%rip),%rdi
call   1030 <printf@plt>
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<copystr>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x208,%rsp
mov    %rsp,%r15
mov    0x2e8d(%rip),%r12
lea    0xe9e(%rip),%r13
jmp    1177 <copystr+0x37>
mov    $0xc,%r14d
nopw   0x0(%rax,%rax,1)
mov    %r14b,(%r15)
add    $0x1,%r15
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%r12),%eax
je     123f <copystr+0xff>
mov    %eax,%r14d
cmp    $0x5c,%eax
jne    11b5 <copystr+0x75>
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%eax
je     1177 <copystr+0x37>
mov    %eax,%ebx
lea    -0x30(%rbx),%ebp
cmp    $0x44,%ebp
ja     11dd <copystr+0x9d>
movslq 0x0(%r13,%rbp,4),%rax
add    %r13,%rax
jmp    *%rax
xor    %r14d,%r14d
jmp    1170 <copystr+0x30>
cmp    $0x22,%r14d
je     1237 <copystr+0xf7>
jmp    1170 <copystr+0x30>
mov    $0x8,%r14d
jmp    1170 <copystr+0x30>
mov    $0xa,%r14d
jmp    1170 <copystr+0x30>
mov    $0xd,%r14d
jmp    1170 <copystr+0x30>
mov    $0x9,%r14d
jmp    1170 <copystr+0x30>
mov    %ebx,%edi
call   1060 <octdigit@plt>
mov    %ebx,%r14d
test   %eax,%eax
je     1170 <copystr+0x30>
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1060 <octdigit@plt>
test   %eax,%eax
je     122f <copystr+0xef>
shl    $0x7,%ebp
lea    (%rbx,%rbp,1),%r14d
add    $0xffffffd0,%r14d
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1060 <octdigit@plt>
test   %eax,%eax
je     1170 <copystr+0x30>
lea    (%rbx,%r14,8),%r14d
add    $0xffffffd0,%r14d
jmp    1170 <copystr+0x30>
mov    %ebp,%r14d
jmp    1170 <copystr+0x30>
movb   $0x0,(%r15)
add    $0x1,%r15
movb   $0x0,(%r15)
mov    %rsp,%rdi
mov    $0x1,%esi
xor    %edx,%edx
call   1050 <hashit@plt>
lea    0xebb(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
@.str = [4 x i8] c"%ld\00"
define void @copystr() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [512 x i8]
%4 = alloca i8*
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
store i8* %5, i8** %4
br label %6
6: ; preds = %61, %24, %0
%7 = call i32 (...) @getchar()
store i32 %7, i32* %1
%8 = load i32, i32* %1
%9 = load i32, i32* @EOF
%10 = icmp eq i32 %8, %9
br i1 %10, label %11, label %12
11: ; preds = %6
br label %66
12: ; preds = %6
%13 = load i32, i32* %1
switch i32 %13, label %61 [
i32 34, label %14
i32 92, label %17
]
14: ; preds = %12
%15 = load i8*, i8** %4
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %4
store i8 0, i8* %15
br label %67
17: ; preds = %12
%18 = call i32 (...) @getchar()
store i32 %18, i32* %1
%19 = load i32, i32* %1
switch i32 %19, label %28 [
i32 98, label %20
i32 116, label %21
i32 114, label %22
i32 110, label %23
i32 10, label %24
i32 102, label %25
i32 48, label %26
i32 92, label %27
]
20: ; preds = %17
store i32 8, i32* %1
br label %60
21: ; preds = %17
store i32 9, i32* %1
br label %60
22: ; preds = %17
store i32 13, i32* %1
br label %60
23: ; preds = %17
store i32 10, i32* %1
br label %60
24: ; preds = %17
br label %6
25: ; preds = %17
store i32 12, i32* %1
br label %60
26: ; preds = %17
store i32 0, i32* %1
br label %60
27: ; preds = %17
br label %60
28: ; preds = %17
%29 = load i32, i32* %1
%30 = call i32 @octdigit(i32 %29)
%31 = icmp ne i32 %30, 0
br i1 %31, label %33, label %32
32: ; preds = %28
br label %60
33: ; preds = %28
%34 = load i32, i32* %1
%35 = sub nsw i32 %34, 48
store i32 %35, i32* %1
%36 = call i32 (...) @getchar()
store i32 %36, i32* %2
%37 = load i32, i32* %2
%38 = call i32 @octdigit(i32 %37)
%39 = icmp ne i32 %38, 0
br i1 %39, label %41, label %40
40: ; preds = %33
br label %60
41: ; preds = %33
%42 = load i32, i32* %1
%43 = shl i32 %42, 7
store i32 %43, i32* %1
%44 = load i32, i32* %2
%45 = sub nsw i32 %44, 48
%46 = load i32, i32* %1
%47 = add nsw i32 %46, %45
store i32 %47, i32* %1
%48 = call i32 (...) @getchar()
store i32 %48, i32* %2
%49 = load i32, i32* %2
%50 = call i32 @octdigit(i32 %49)
%51 = icmp ne i32 %50, 0
br i1 %51, label %53, label %52
52: ; preds = %41
br label %60
53: ; preds = %41
%54 = load i32, i32* %1
%55 = shl i32 %54, 3
store i32 %55, i32* %1
%56 = load i32, i32* %2
%57 = sub nsw i32 %56, 48
%58 = load i32, i32* %1
%59 = add nsw i32 %58, %57
store i32 %59, i32* %1
store i32 -1, i32* %2
br label %60
60: ; preds = %53, %52, %40, %32, %27, %26, %25, %23, %22, %21, %20
br label %61
61: ; preds = %60, %12
%62 = load i32, i32* %1
%63 = trunc i32 %62 to i8
%64 = load i8*, i8** %4
%65 = getelementptr inbounds i8, i8* %64, i32 1
store i8* %65, i8** %4
store i8 %63, i8* %64
br label %6
66: ; preds = %11
br label %67
67: ; preds = %66, %14
%68 = load i8*, i8** %4
store i8 0, i8* %68
%69 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%70 = call i32 @hashit(i8* %69, i32 1, i32 0)
%71 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %70)
ret void
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [4 x i8] c"%ld\00"
define void @copystr() {
%1 = alloca [512 x i8]
%2 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
br label %3
3: ; preds = %39, %0
%4 = phi i8* [ %42, %39 ], [ %2, %0 ]
br label %5
5: ; preds = %3, %12
%6 = tail call i32 (...) @getchar()
%7 = load i32, i32* @EOF
%8 = icmp eq i32 %6, %7
br i1 %8, label %43, label %9
9: ; preds = %5
switch i32 %6, label %34 [
i32 34, label %10
i32 92, label %12
]
10: ; preds = %9
%11 = getelementptr inbounds i8, i8* %4, i64 1
store i8 0, i8* %4
br label %43
12: ; preds = %9
%13 = tail call i32 (...) @getchar()
switch i32 %13, label %15 [
i32 98, label %35
i32 116, label %36
i32 114, label %37
i32 110, label %38
i32 10, label %5
i32 102, label %39
i32 48, label %14
i32 92, label %34
]
14: ; preds = %12
br label %39
15: ; preds = %12
%16 = tail call i32 @octdigit(i32 %13)
%17 = icmp eq i32 %16, 0
br i1 %17, label %39, label %18
18: ; preds = %15
%19 = add nsw i32 %13, -48
%20 = tail call i32 (...) @getchar()
%21 = tail call i32 @octdigit(i32 %20)
%22 = icmp eq i32 %21, 0
br i1 %22, label %39, label %23
23: ; preds = %18
%24 = shl i32 %19, 7
%25 = add i32 %24, -48
%26 = add i32 %25, %20
%27 = tail call i32 (...) @getchar()
%28 = tail call i32 @octdigit(i32 %27)
%29 = icmp eq i32 %28, 0
br i1 %29, label %39, label %30
30: ; preds = %23
%31 = shl i32 %26, 3
%32 = add i32 %31, -48
%33 = add i32 %32, %27
br label %39
34: ; preds = %9, %12
br label %39
35: ; preds = %12
br label %39
36: ; preds = %12
br label %39
37: ; preds = %12
br label %39
38: ; preds = %12
br label %39
39: ; preds = %12, %38, %37, %36, %35, %34, %14, %30, %15, %18, %23
%40 = phi i32 [ %33, %30 ], [ %26, %23 ], [ %19, %18 ], [ %13, %15 ], [ 0, %14 ], [ %6, %34 ], [ 8, %35 ], [ 9, %36 ], [ 13, %37 ], [ 10, %38 ], [ 12, %12 ]
%41 = trunc i32 %40 to i8
%42 = getelementptr inbounds i8, i8* %4, i64 1
store i8 %41, i8* %4
br label %3
43: ; preds = %5, %10
%44 = phi i8* [ %11, %10 ], [ %4, %5 ]
store i8 0, i8* %44
%45 = call i32 @hashit(i8* %2, i32 1, i32 0)
%46 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %45)
ret void
}