#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 */
typedef int uint32_t;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int EXIT_SUCCESS;
scalar_t__ fgets(char *, int, int /*<<< orphan*/);
int hash_fnv1a_64(char *, int);
int /*<<< orphan*/ printf(char *, char *, int, int);
int /*<<< orphan*/ stdin;
int strlen(char *);
int main(int argc, char **argv) {
  int i;
  uint32_t fnv64;
  char buf[1024];
  if (argc >= 2) {
    for (i = 1; i < argc; i++) {
      fnv64 = hash_fnv1a_64(argv[i], strlen(argv[i]));
      printf("%s fnv64 %u slot %d\n", argv[i], fnv64, (fnv64 % 420000));
    }
  } else {
    while (fgets(buf, sizeof(buf), stdin)) {
      if (buf[strlen(buf) - 1] == '\n')
        buf[strlen(buf) - 1] = '\0';
      fnv64 = hash_fnv1a_64(buf, strlen(buf));
      printf("%s fnv64 %u slot %d\n", buf, fnv64, (fnv64 % 420000));
    }
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     11f2 <main+0xb2>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11ed <main+0xad>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x430(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
mov    -0x430(%rbp),%rdi
mov    %eax,%esi
call   1030 <hash_fnv1a_64@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x18(%rbp),%eax
mov    %eax,-0x424(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x668a0,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
mov    -0x424(%rbp),%edx
lea    0xe26(%rip),%rdi
call   1050 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116a <main+0x2a>
jmp    12ba <main+0x17a>
jmp    11f7 <main+0xb7>
lea    -0x420(%rbp),%rdi
mov    0x2de3(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     12b5 <main+0x175>
lea    -0x420(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0x420(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
jne    1256 <main+0x116>
lea    -0x420(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x420(%rbp,%rax,1)
lea    -0x420(%rbp),%rax
mov    %rax,-0x440(%rbp)
lea    -0x420(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x440(%rbp),%rdi
mov    %eax,%esi
call   1030 <hash_fnv1a_64@plt>
mov    %eax,-0x18(%rbp)
lea    -0x420(%rbp),%rsi
mov    -0x18(%rbp),%eax
mov    %eax,-0x434(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x668a0,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
mov    -0x434(%rbp),%edx
lea    0xd55(%rip),%rdi
call   1050 <printf@plt>
jmp    11f7 <main+0xb7>
jmp    12ba <main+0x17a>
mov    0x2d17(%rip),%rax
mov    (%rax),%eax
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x400,%rsp
cmp    $0x2,%edi
jl     11c1 <main+0x81>
mov    %rsi,%r15
mov    %edi,%r12d
mov    $0x1,%ebx
lea    0xe99(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    (%r15,%rbx,8),%r13
mov    %r13,%rdi
call   1040 <strlen@plt>
mov    %r13,%rdi
mov    %eax,%esi
call   1030 <hash_fnv1a_64@plt>
mov    (%r15,%rbx,8),%rsi
movslq %eax,%rdx
imul   $0x9fc8735,%rdx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x2e,%rax
add    %ecx,%eax
imul   $0x668a0,%eax,%eax
mov    %edx,%ecx
sub    %eax,%ecx
mov    %r14,%rdi
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1170 <main+0x30>
jmp    1265 <main+0x125>
mov    0x2e20(%rip),%r15
mov    (%r15),%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1060 <fgets@plt>
test   %rax,%rax
je     1265 <main+0x125>
lea    0xe15(%rip),%r14
jmp    1243 <main+0x103>
nopl   (%rax)
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <hash_fnv1a_64@plt>
movslq %eax,%rdx
imul   $0x9fc8735,%rdx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x2e,%rax
add    %ecx,%eax
imul   $0x668a0,%eax,%eax
mov    %edx,%ecx
sub    %eax,%ecx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
mov    (%r15),%edx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1060 <fgets@plt>
test   %rax,%rax
je     1265 <main+0x125>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%rbx,1)
jne    11f0 <main+0xb0>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
jmp    11f0 <main+0xb0>
mov    0x2d6c(%rip),%rax
mov    (%rax),%eax
add    $0x400,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [21 x i8] c"%s fnv64 %u slot %d\0A\00"
@stdin = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca [1024 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp sge i32 %9, 2
br i1 %10, label %11, label %42
11: ; preds = %2
store i32 1, i32* %6
br label %12
12: ; preds = %38, %11
%13 = load i32, i32* %6
%14 = load i32, i32* %4
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %41
16: ; preds = %12
%17 = load i8**, i8*** %5
%18 = load i32, i32* %6
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8*, i8** %17, i64 %19
%21 = load i8*, i8** %20
%22 = load i8**, i8*** %5
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8*, i8** %22, i64 %24
%26 = load i8*, i8** %25
%27 = call i32 @strlen(i8* %26)
%28 = call i32 @hash_fnv1a_64(i8* %21, i32 %27)
store i32 %28, i32* %7
%29 = load i8**, i8*** %5
%30 = load i32, i32* %6
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %29, i64 %31
%33 = load i8*, i8** %32
%34 = load i32, i32* %7
%35 = load i32, i32* %7
%36 = srem i32 %35, 420000
%37 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %33, i32 %34, i32 %36)
br label %38
38: ; preds = %16
%39 = load i32, i32* %6
%40 = add nsw i32 %39, 1
store i32 %40, i32* %6
br label %12
41: ; preds = %12
br label %74
42: ; preds = %2
br label %43
43: ; preds = %63, %42
%44 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%45 = load i32, i32* @stdin
%46 = call i64 @fgets(i8* %44, i32 1024, i32 %45)
%47 = icmp ne i64 %46, 0
br i1 %47, label %48, label %73
48: ; preds = %43
%49 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%50 = call i32 @strlen(i8* %49)
%51 = sub nsw i32 %50, 1
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 %52
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = icmp eq i32 %55, 10
br i1 %56, label %57, label %63
57: ; preds = %48
%58 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%59 = call i32 @strlen(i8* %58)
%60 = sub nsw i32 %59, 1
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 %61
store i8 0, i8* %62
br label %63
63: ; preds = %57, %48
%64 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%65 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%66 = call i32 @strlen(i8* %65)
%67 = call i32 @hash_fnv1a_64(i8* %64, i32 %66)
store i32 %67, i32* %7
%68 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%69 = load i32, i32* %7
%70 = load i32, i32* %7
%71 = srem i32 %70, 420000
%72 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %68, i32 %69, i32 %71)
br label %43
73: ; preds = %43
br label %74
74: ; preds = %73, %41
%75 = load i32, i32* @EXIT_SUCCESS
ret i32 %75
}

LLVM IR (-O2):
@.str = [21 x i8] c"%s fnv64 %u slot %d\0A\00"
@stdin = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = zext i32 %0 to i64
br label %12
8: ; preds = %2
%9 = load i32, i32* @stdin
%10 = call i64 @fgets(i8* %4, i32 1024, i32 %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %43, label %23
12: ; preds = %6, %12
%13 = phi i64 [ 1, %6 ], [ %21, %12 ]
%14 = getelementptr inbounds i8*, i8** %1, i64 %13
%15 = load i8*, i8** %14
%16 = tail call i32 @strlen(i8* %15)
%17 = tail call i32 @hash_fnv1a_64(i8* %15, i32 %16)
%18 = load i8*, i8** %14
%19 = srem i32 %17, 420000
%20 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %18, i32 %17, i32 %19)
%21 = add nuw nsw i64 %13, 1
%22 = icmp eq i64 %21, %7
br i1 %22, label %43, label %12
23: ; preds = %8, %35
%24 = call i32 @strlen(i8* %4)
%25 = add nsw i32 %24, -1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = icmp eq i8 %28, 10
br i1 %29, label %30, label %35
30: ; preds = %23
%31 = call i32 @strlen(i8* %4)
%32 = add nsw i32 %31, -1
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %33
store i8 0, i8* %34
br label %35
35: ; preds = %30, %23
%36 = call i32 @strlen(i8* %4)
%37 = call i32 @hash_fnv1a_64(i8* %4, i32 %36)
%38 = srem i32 %37, 420000
%39 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %4, i32 %37, i32 %38)
%40 = load i32, i32* @stdin
%41 = call i64 @fgets(i8* %4, i32 1024, i32 %40)
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %23
43: ; preds = %35, %12, %8
%44 = load i32, i32* @EXIT_SUCCESS
ret i32 %44
}