#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 */
scalar_t__ EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/);
int /*<<< orphan*/ freopen(char *, char *, int /*<<< orphan*/);
int gen(char *, int, int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ scanf(char *, char *);
int /*<<< orphan*/ stdin;
int main(void) {
  int primers[168] = {
      2,   3,   5,   7,   11,  13,  17,  19,  23,  29,  31,  37,  41,  43,
      47,  53,  59,  61,  67,  71,  73,  79,  83,  89,  97,  101, 103, 107,
      109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181,
      191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263,
      269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349,
      353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433,
      439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521,
      523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613,
      617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701,
      709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809,
      811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887,
      907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997};
  freopen("headers.txt", "r", stdin);
  char str[100] = {0};
  int table[100];
  for (int k = 0; k < 100; ++k) {
    table[k] = -1;
  }
  int i = 0;
  while (scanf("%s", str) != EOF) {
    int hash = gen(str, 131, 3);
    printf("%s: %d\n", str, hash);
    table[i++] = hash;
  }
  for (i = 0; i < 100; ++i) {
    for (int j = i + 1; j < 100; ++j) {
      if (table[i] != -1 && table[i] == table[j]) {
        printf("collision: %d, %d: %d\n", i, j, table[i]);
      }
    }
  }
end:
  fclose(stdin);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4c0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x2b0(%rbp),%rdi
lea    0xe70(%rip),%rsi
mov    $0x2a0,%edx
call   1070 <memcpy@plt>
mov    0x2e47(%rip),%rax
mov    (%rax),%edx
lea    0x10f6(%rip),%rdi
lea    0x10fb(%rip),%rsi
call   1060 <freopen@plt>
lea    -0x320(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1050 <memset@plt>
movl   $0x0,-0x4b4(%rbp)
cmpl   $0x64,-0x4b4(%rbp)
jge    1206 <main+0x96>
movslq -0x4b4(%rbp),%rax
movl   $0xffffffff,-0x4b0(%rbp,%rax,4)
ff ff ff ff
mov    -0x4b4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4b4(%rbp)
jmp    11d3 <main+0x63>
movl   $0x0,-0x4b8(%rbp)
lea    -0x320(%rbp),%rsi
lea    0x1090(%rip),%rdi
call   1090 <scanf@plt>
mov    0x2db6(%rip),%rcx
cmp    (%rcx),%rax
je     128f <main+0x11f>
lea    -0x320(%rbp),%rdi
mov    $0x83,%esi
mov    $0x3,%edx
call   1080 <gen@plt>
mov    %eax,-0x4bc(%rbp)
lea    -0x320(%rbp),%rsi
mov    -0x4bc(%rbp),%edx
lea    0x104e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4bc(%rbp),%ecx
mov    -0x4b8(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x4b8(%rbp)
cltq
mov    %ecx,-0x4b0(%rbp,%rax,4)
jmp    1210 <main+0xa0>
movl   $0x0,-0x4b8(%rbp)
cmpl   $0x64,-0x4b8(%rbp)
jge    1353 <main+0x1e3>
mov    -0x4b8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c0(%rbp)
cmpl   $0x64,-0x4c0(%rbp)
jge    133a <main+0x1ca>
movslq -0x4b8(%rbp),%rax
cmpl   $0xffffffff,-0x4b0(%rbp,%rax,4)
ff
je     1321 <main+0x1b1>
movslq -0x4b8(%rbp),%rax
mov    -0x4b0(%rbp,%rax,4),%eax
movslq -0x4c0(%rbp),%rcx
cmp    -0x4b0(%rbp,%rcx,4),%eax
jne    1321 <main+0x1b1>
mov    -0x4b8(%rbp),%esi
mov    -0x4c0(%rbp),%edx
movslq -0x4b8(%rbp),%rax
mov    -0x4b0(%rbp,%rax,4),%ecx
lea    0xf9f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1326 <main+0x1b6>
mov    -0x4c0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c0(%rbp)
jmp    12b5 <main+0x145>
jmp    133f <main+0x1cf>
mov    -0x4b8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4b8(%rbp)
jmp    1299 <main+0x129>
jmp    1358 <main+0x1e8>
mov    0x2c89(%rip),%rax
mov    (%rax),%edi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x4c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x208,%rsp
mov    0x2e70(%rip),%rax
mov    (%rax),%edx
lea    0xe7f(%rip),%rdi
lea    0xe84(%rip),%rsi
call   1060 <freopen@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movl   $0x0,0x60(%rsp)
lea    0x70(%rsp),%rbx
mov    $0x190,%edx
mov    %rbx,%rdi
mov    $0xff,%esi
call   1050 <memset@plt>
lea    0xe3b(%rip),%rdi
mov    %rsp,%rsi
call   1080 <scanf@plt>
mov    0x2dfe(%rip),%r13
cmp    0x0(%r13),%rax
je     123a <main+0xda>
mov    %rsp,%r14
lea    0xe1f(%rip),%r15
lea    0xe15(%rip),%r12
nopl   0x0(%rax)
mov    %r14,%rdi
mov    $0x83,%esi
mov    $0x3,%edx
call   1070 <gen@plt>
mov    %eax,%ebp
mov    %r15,%rdi
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,(%rbx)
mov    %r12,%rdi
mov    %r14,%rsi
call   1080 <scanf@plt>
add    $0x4,%rbx
cmp    0x0(%r13),%rax
jne    1200 <main+0xa0>
mov    $0x1,%r12d
lea    0xdd2(%rip),%r14
xor    %r13d,%r13d
jmp    125a <main+0xfa>
nopl   0x0(%rax)
add    $0x1,%r12
cmp    $0x64,%r13
je     12a8 <main+0x148>
mov    %r13,%r15
add    $0x1,%r13
cmp    $0x62,%r15
ja     1250 <main+0xf0>
mov    0x70(%rsp,%r15,4),%ebp
mov    %r12,%rbx
jmp    128a <main+0x12a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    $0x64,%rbx
je     1250 <main+0xf0>
cmp    $0xffffffff,%ebp
je     1280 <main+0x120>
cmp    0x70(%rsp,%rbx,4),%ebp
jne    1280 <main+0x120>
mov    %r14,%rdi
mov    %r15d,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1280 <main+0x120>
mov    0x2d39(%rip),%rax
mov    (%rax),%edi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.primers = [168 x i32] [i32 2, i32 3, i32 5, i32 7, i32 11, i32 13, i32 17, i32 19, i32 23, i32 29, i32 31, i32 37, i32 41, i32 43, i32 47, i32 53, i32 59, i32 61, i32 67, i32 71, i32 73, i32 79, i32 83, i32 89, i32 97, i32 101, i32 103, i32 107, i32 109, i32 113, i32 127, i32 131, i32 137, i32 139, i32 149, i32 151, i32 157, i32 163, i32 167, i32 173, i32 179, i32 181, i32 191, i32 193, i32 197, i32 199, i32 211, i32 223, i32 227, i32 229, i32 233, i32 239, i32 241, i32 251, i32 257, i32 263, i32 269, i32 271, i32 277, i32 281, i32 283, i32 293, i32 307, i32 311, i32 313, i32 317, i32 331, i32 337, i32 347, i32 349, i32 353, i32 359, i32 367, i32 373, i32 379, i32 383, i32 389, i32 397, i32 401, i32 409, i32 419, i32 421, i32 431, i32 433, i32 439, i32 443, i32 449, i32 457, i32 461, i32 463, i32 467, i32 479, i32 487, i32 491, i32 499, i32 503, i32 509, i32 521, i32 523, i32 541, i32 547, i32 557, i32 563, i32 569, i32 571, i32 577, i32 587, i32 593, i32 599, i32 601, i32 607, i32 613, i32 617, i32 619, i32 631, i32 641, i32 643, i32 647, i32 653, i32 659, i32 661, i32 673, i32 677, i32 683, i32 691, i32 701, i32 709, i32 719, i32 727, i32 733, i32 739, i32 743, i32 751, i32 757, i32 761, i32 769, i32 773, i32 787, i32 797, i32 809, i32 811, i32 821, i32 823, i32 827, i32 829, i32 839, i32 853, i32 857, i32 859, i32 863, i32 877, i32 881, i32 883, i32 887, i32 907, i32 911, i32 919, i32 929, i32 937, i32 941, i32 947, i32 953, i32 967, i32 971, i32 977, i32 983, i32 991, i32 997]
@.str = [12 x i8] c"headers.txt\00"
@.str.1 = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.2 = [3 x i8] c"%s\00"
@EOF = global i64 0
@.str.3 = [8 x i8] c"%s: %d\0A\00"
@.str.4 = [23 x i8] c"collision: %d, %d: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [168 x i32]
%3 = alloca [100 x i8]
%4 = alloca [100 x i32]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
%9 = bitcast [168 x i32]* %2 to i8*
%10 = load i32, i32* @stdin
%11 = call i32 @freopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = bitcast [100 x i8]* %3 to i8*
store i32 0, i32* %5
br label %13
13: ; preds = %20, %0
%14 = load i32, i32* %5
%15 = icmp slt i32 %14, 100
br i1 %15, label %16, label %23
16: ; preds = %13
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 %18
store i32 -1, i32* %19
br label %20
20: ; preds = %16
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
br label %13
23: ; preds = %13
store i32 0, i32* %6
br label %24
24: ; preds = %29, %23
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%26 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %25)
%27 = load i64, i64* @EOF
%28 = icmp ne i64 %26, %27
br i1 %28, label %29, label %40
29: ; preds = %24
%30 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%31 = call i32 @gen(i8* %30, i32 131, i32 3)
store i32 %31, i32* %7
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%33 = load i32, i32* %7
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %32, i32 %33)
%35 = load i32, i32* %7
%36 = load i32, i32* %6
%37 = add nsw i32 %36, 1
store i32 %37, i32* %6
%38 = sext i32 %36 to i64
%39 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 %38
store i32 %35, i32* %39
br label %24
40: ; preds = %24
store i32 0, i32* %6
br label %41
41: ; preds = %79, %40
%42 = load i32, i32* %6
%43 = icmp slt i32 %42, 100
br i1 %43, label %44, label %82
44: ; preds = %41
%45 = load i32, i32* %6
%46 = add nsw i32 %45, 1
store i32 %46, i32* %8
br label %47
47: ; preds = %75, %44
%48 = load i32, i32* %8
%49 = icmp slt i32 %48, 100
br i1 %49, label %50, label %78
50: ; preds = %47
%51 = load i32, i32* %6
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 %52
%54 = load i32, i32* %53
%55 = icmp ne i32 %54, -1
br i1 %55, label %56, label %74
56: ; preds = %50
%57 = load i32, i32* %6
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 %58
%60 = load i32, i32* %59
%61 = load i32, i32* %8
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 %62
%64 = load i32, i32* %63
%65 = icmp eq i32 %60, %64
br i1 %65, label %66, label %74
66: ; preds = %56
%67 = load i32, i32* %6
%68 = load i32, i32* %8
%69 = load i32, i32* %6
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 %70
%72 = load i32, i32* %71
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %67, i32 %68, i32 %72)
br label %74
74: ; preds = %66, %56, %50
br label %75
75: ; preds = %74
%76 = load i32, i32* %8
%77 = add nsw i32 %76, 1
store i32 %77, i32* %8
br label %47
78: ; preds = %47
br label %79
79: ; preds = %78
%80 = load i32, i32* %6
%81 = add nsw i32 %80, 1
store i32 %81, i32* %6
br label %41
82: ; preds = %41
br label %83
83: ; preds = %82
%84 = load i32, i32* @stdin
%85 = call i32 @fclose(i32 %84)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"headers.txt\00"
@.str.1 = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.2 = [3 x i8] c"%s\00"
@EOF = global i64 0
@.str.3 = [8 x i8] c"%s: %d\0A\00"
@.str.4 = [23 x i8] c"collision: %d, %d: %d\0A\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i32]
%3 = bitcast [100 x i32]* %2 to i8*
%4 = load i32, i32* @stdin
%5 = tail call i32 @freopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %4)
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%7 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%8 = load i64, i64* @EOF
%9 = icmp eq i64 %7, %8
br i1 %9, label %19, label %10
10: ; preds = %0, %10
%11 = phi i64 [ %14, %10 ], [ 0, %0 ]
%12 = call i32 @gen(i8* %6, i32 131, i32 3)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %6, i32 %12)
%14 = add nuw i64 %11, 1
%15 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %11
store i32 %12, i32* %15
%16 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%17 = load i64, i64* @EOF
%18 = icmp eq i64 %16, %17
br i1 %18, label %19, label %10
19: ; preds = %10, %0
br label %23
20: ; preds = %42, %23
%21 = add nuw nsw i64 %25, 1
%22 = icmp eq i64 %26, 100
br i1 %22, label %45, label %23
23: ; preds = %19, %20
%24 = phi i64 [ %26, %20 ], [ 0, %19 ]
%25 = phi i64 [ %21, %20 ], [ 1, %19 ]
%26 = add nuw nsw i64 %24, 1
%27 = icmp ult i64 %24, 99
br i1 %27, label %28, label %20
28: ; preds = %23
%29 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %24
%30 = load i32, i32* %29
%31 = icmp eq i32 %30, -1
%32 = trunc i64 %24 to i32
br label %33
33: ; preds = %28, %42
%34 = phi i64 [ %25, %28 ], [ %43, %42 ]
br i1 %31, label %42, label %35
35: ; preds = %33
%36 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %34
%37 = load i32, i32* %36
%38 = icmp eq i32 %30, %37
br i1 %38, label %39, label %42
39: ; preds = %35
%40 = trunc i64 %34 to i32
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %32, i32 %40, i32 %30)
br label %42
42: ; preds = %33, %35, %39
%43 = add nuw nsw i64 %34, 1
%44 = icmp eq i64 %43, 100
br i1 %44, label %20, label %33
45: ; preds = %20
%46 = load i32, i32* @stdin
%47 = call i32 @fclose(i32 %46)
ret i32 0
}