#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 /*<<< orphan*/ FILE;

/* Variables and functions */
int BKDRHash(char *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, int, char *);
scalar_t__ strlen(char *);
int main(int argc, char *argv[]) {
  char line[1024];
  FILE *fin = fopen(argv[1], "r");
  while (fgets(line, 1024, fin) != NULL && strlen(line))
    printf("%010d\t%s", BKDRHash(line), line);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe88(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x418(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x418(%rbp),%rdx
mov    $0x400,%esi
call   1050 <fgets@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x419(%rbp)
je     11ca <main+0x7a>
lea    -0x410(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x419(%rbp)
mov    -0x419(%rbp),%al
test   $0x1,%al
jne    11dd <main+0x8d>
jmp    1203 <main+0xb3>
lea    -0x410(%rbp),%rdi
call   1070 <BKDRHash@plt>
mov    %eax,%esi
lea    -0x410(%rbp),%rdx
lea    0xe09(%rip),%rdi
call   1040 <printf@plt>
jmp    1184 <main+0x34>
xor    %eax,%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    0x8(%rsi),%rdi
lea    0xea9(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%r14
mov    %rsp,%rdi
mov    $0x400,%esi
mov    %rax,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     11c0 <main+0x80>
cmpb   $0x0,(%rsp)
je     11c0 <main+0x80>
mov    %rsp,%rbx
lea    0xe7e(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
call   1060 <BKDRHash@plt>
mov    %r15,%rdi
mov    %eax,%esi
mov    %rbx,%rdx
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %r14,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     11c0 <main+0x80>
cmpb   $0x0,(%rsp)
jne    1190 <main+0x50>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [9 x i8] c"%010d\09%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1024 x i8]
%7 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i8**, i8*** %5
%9 = getelementptr inbounds i8*, i8** %8, i64 1
%10 = load i8*, i8** %9
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %7
br label %12
12: ; preds = %23, %2
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%14 = load i32*, i32** %7
%15 = call i32* @fgets(i8* %13, i32 1024, i32* %14)
%16 = icmp ne i32* %15, null
br i1 %16, label %17, label %21
17: ; preds = %12
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%19 = call i64 @strlen(i8* %18)
%20 = icmp ne i64 %19, 0
br label %21
21: ; preds = %17, %12
%22 = phi i1 [ false, %12 ], [ %20, %17 ]
br i1 %22, label %23, label %28
23: ; preds = %21
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%25 = call i32 @BKDRHash(i8* %24)
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%27 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %25, i8* %26)
br label %12
28: ; preds = %21
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [9 x i8] c"%010d\09%s\00"
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 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = call i32* @fgets(i8* %4, i32 1024, i32* %7)
%9 = icmp eq i32* %8, null
%10 = load i8, i8* %4
%11 = icmp eq i8 %10, 0
%12 = select i1 %9, i1 true, i1 %11
br i1 %12, label %21, label %13
13: ; preds = %2, %13
%14 = call i32 @BKDRHash(i8* %4)
%15 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %14, i8* %4)
%16 = call i32* @fgets(i8* %4, i32 1024, i32* %7)
%17 = icmp eq i32* %16, null
%18 = load i8, i8* %4
%19 = icmp eq i8 %18, 0
%20 = select i1 %17, i1 true, i1 %19
br i1 %20, label %21, label %13
21: ; preds = %13, %2
ret i32 0
}