#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 /*<<< orphan*/ CreateHashTableFiles();
int /*<<< orphan*/ PreprocessLSH(char *);
scalar_t__ atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
unsigned int *malloc(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ system(char *);
int main(int argc, char *args[]) {
  unsigned int i, k, ret, queryID;
  unsigned int *ans;
  void *queryCompleteRecord;
  FILE *fin;
  char choice;
  if (argc < 3) {
    printf("usage: inputfile k\n");
    exit(-1);
  }
  if (atoi(args[2]) <= 0) {
    fprintf(stderr, "value of k should be non-zero positive\n");
    exit(-1);
  }
  k = (unsigned int)atoi(args[2]);
  ans = malloc(sizeof(unsigned int) * k);
  if (ans == NULL) {
    perror("ans in main");
    exit(-1);
  }
  system("rm -f *.hash");
  CreateHashTableFiles();
  if (1) {
    fprintf(stderr, "Creation of empty hashtables done\n");
    fflush(stderr);
  }
  PreprocessLSH(args[1]);
  if (1) {
    fprintf(stderr, "Preprocess complete\n\n\n");
    fflush(stderr);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11d6 <main+0x36>
lea    0xe39(%rip),%rdi
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10b0 <atoi@plt>
cmp    $0x0,%rax
jg     120c <main+0x6c>
mov    0x2dec(%rip),%rax
mov    (%rax),%edi
lea    0xe17(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
shl    $0x2,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    124f <main+0xaf>
lea    0xdfc(%rip),%rdi
call   10a0 <perror@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
lea    0xdf2(%rip),%rdi
call   1030 <system@plt>
mov    $0x0,%al
call   1060 <CreateHashTableFiles@plt>
mov    0x2d77(%rip),%rax
mov    (%rax),%edi
lea    0xde3(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2d62(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <PreprocessLSH@plt>
mov    0x2d47(%rip),%rax
mov    (%rax),%edi
lea    0xdd6(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2d32(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
jle    1228 <main+0x88>
mov    %rsi,%r14
mov    0x10(%rsi),%rdi
call   10b0 <atoi@plt>
test   %rax,%rax
jle    123e <main+0x9e>
shl    $0x2,%eax
mov    %eax,%edi
call   1070 <malloc@plt>
test   %rax,%rax
je     125d <main+0xbd>
lea    0xe5c(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
call   1060 <CreateHashTableFiles@plt>
mov    0x2df5(%rip),%rbx
mov    (%rbx),%edi
lea    0xe4d(%rip),%rsi
call   1050 <fprintf@plt>
mov    (%rbx),%edi
call   1080 <fflush@plt>
mov    0x8(%r14),%rdi
call   1090 <PreprocessLSH@plt>
mov    (%rbx),%edi
lea    0xe52(%rip),%rsi
call   1050 <fprintf@plt>
mov    (%rbx),%edi
call   1080 <fflush@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe4c(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
mov    0x2d9b(%rip),%rax
mov    (%rax),%edi
lea    0xdb2(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
lea    0xdc4(%rip),%rdi
call   10a0 <perror@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"usage: inputfile k\0A\00"
@stderr = global i32 0
@.str.1 = [40 x i8] c"value of k should be non-zero positive\0A\00"
@.str.2 = [12 x i8] c"ans in main\00"
@.str.3 = [13 x i8] c"rm -f *.hash\00"
@.str.4 = [35 x i8] c"Creation of empty hashtables done\0A\00"
@.str.5 = [23 x i8] c"Preprocess complete\0A\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i8*
%12 = alloca i32*
%13 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 3
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @exit(i32 -1)
unreachable
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 2
%22 = load i8*, i8** %21
%23 = call i64 @atoi(i8* %22)
%24 = icmp sle i64 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %19
%26 = load i32, i32* @stderr
%27 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%28 = call i32 @exit(i32 -1)
unreachable
29: ; preds = %19
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 2
%32 = load i8*, i8** %31
%33 = call i64 @atoi(i8* %32)
%34 = trunc i64 %33 to i32
store i32 %34, i32* %7
%35 = load i32, i32* %7
%36 = zext i32 %35 to i64
%37 = mul i64 4, %36
%38 = trunc i64 %37 to i32
%39 = call i32* @malloc(i32 %38)
store i32* %39, i32** %10
%40 = load i32*, i32** %10
%41 = icmp eq i32* %40, null
br i1 %41, label %42, label %45
42: ; preds = %29
%43 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%44 = call i32 @exit(i32 -1)
unreachable
45: ; preds = %29
%46 = call i32 @system(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%47 = call i32 (...) @CreateHashTableFiles()
%48 = load i32, i32* @stderr
%49 = call i32 @fprintf(i32 %48, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0))
%50 = load i32, i32* @stderr
%51 = call i32 @fflush(i32 %50)
%52 = load i8**, i8*** %5
%53 = getelementptr inbounds i8*, i8** %52, i64 1
%54 = load i8*, i8** %53
%55 = call i32 @PreprocessLSH(i8* %54)
%56 = load i32, i32* @stderr
%57 = call i32 @fprintf(i32 %56, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
%58 = load i32, i32* @stderr
%59 = call i32 @fflush(i32 %58)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str.1 = [40 x i8] c"value of k should be non-zero positive\0A\00"
@.str.2 = [12 x i8] c"ans in main\00"
@.str.3 = [13 x i8] c"rm -f *.hash\00"
@.str.4 = [35 x i8] c"Creation of empty hashtables done\0A\00"
@.str.5 = [23 x i8] c"Preprocess complete\0A\0A\0A\00"
@str = [19 x i8] c"usage: inputfile k\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @exit(i32 -1)
unreachable
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 2
%9 = load i8*, i8** %8
%10 = tail call i64 @atoi(i8* %9)
%11 = icmp slt i64 %10, 1
br i1 %11, label %12, label %16
12: ; preds = %7
%13 = load i32, i32* @stderr
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%15 = tail call i32 @exit(i32 -1)
unreachable
16: ; preds = %7
%17 = trunc i64 %10 to i32
%18 = shl i32 %17, 2
%19 = tail call i32* @malloc(i32 %18)
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %24
21: ; preds = %16
%22 = tail call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%23 = tail call i32 @exit(i32 -1)
unreachable
24: ; preds = %16
%25 = tail call i32 @system(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%26 = tail call i32 (...) @CreateHashTableFiles()
%27 = load i32, i32* @stderr
%28 = tail call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0))
%29 = load i32, i32* @stderr
%30 = tail call i32 @fflush(i32 %29)
%31 = getelementptr inbounds i8*, i8** %1, i64 1
%32 = load i8*, i8** %31
%33 = tail call i32 @PreprocessLSH(i8* %32)
%34 = load i32, i32* @stderr
%35 = tail call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
%36 = load i32, i32* @stderr
%37 = tail call i32 @fflush(i32 %36)
ret i32 0
}