#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 atoi(char *);
int hash_index_file(char *, int, int);
int /*<<< orphan*/ printf(char *, char *);
int main(int argc, char *argv[]) {
  if (argc < 2) {
    printf("Usage %s fbin_file [chunk_size [--skip_sort]]\n\n", argv[0]);
    return -1;
  }
  int chunk_size = 10000;
  int skip_sort = 0;
  if (argc == 3) {
    chunk_size = atoi(argv[2]);
  }
  if (argc == 4) {
    skip_sort = 1;
  }
  int res = hash_index_file(argv[1], chunk_size, skip_sort);
  return res;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    116f <main+0x3f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xea2(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c4 <main+0x94>
movl   $0x2710,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x3,-0x8(%rbp)
jne    1197 <main+0x67>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x4,-0x8(%rbp)
jne    11a8 <main+0x78>
movl   $0x1,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1040 <hash_index_file@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x1,%edi
jg     1156 <main+0x26>
mov    (%rbx),%rsi
lea    0xebb(%rip),%rdi
call   1030 <printf@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    %edi,%ebp
mov    $0x2710,%esi
cmp    $0x3,%edi
jne    116d <main+0x3d>
mov    0x10(%rbx),%rdi
call   1050 <atoi@plt>
mov    %eax,%esi
xor    %edx,%edx
cmp    $0x4,%ebp
sete   %dl
mov    0x8(%rbx),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <hash_index_file@plt>

LLVM IR (-O0):
@.str = [48 x i8] c"Usage %s fbin_file [chunk_size [--skip_sort]]\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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i8* %14)
store i32 -1, i32* %3
br label %36
16: ; preds = %2
store i32 10000, i32* %6
store i32 0, i32* %7
%17 = load i32, i32* %4
%18 = icmp eq i32 %17, 3
br i1 %18, label %19, label %24
19: ; preds = %16
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 2
%22 = load i8*, i8** %21
%23 = call i32 @atoi(i8* %22)
store i32 %23, i32* %6
br label %24
24: ; preds = %19, %16
%25 = load i32, i32* %4
%26 = icmp eq i32 %25, 4
br i1 %26, label %27, label %28
27: ; preds = %24
store i32 1, i32* %7
br label %28
28: ; preds = %27, %24
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = load i32, i32* %6
%33 = load i32, i32* %7
%34 = call i32 @hash_index_file(i8* %31, i32 %32, i32 %33)
store i32 %34, i32* %8
%35 = load i32, i32* %8
store i32 %35, i32* %3
br label %36
36: ; preds = %28, %11
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
@.str = [48 x i8] c"Usage %s fbin_file [chunk_size [--skip_sort]]\0A\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %20
7: ; preds = %2
%8 = icmp eq i32 %0, 3
br i1 %8, label %9, label %13
9: ; preds = %7
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
br label %13
13: ; preds = %9, %7
%14 = phi i32 [ %12, %9 ], [ 10000, %7 ]
%15 = icmp eq i32 %0, 4
%16 = zext i1 %15 to i32
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = load i8*, i8** %17
%19 = tail call i32 @hash_index_file(i8* %18, i32 %14, i32 %16)
br label %20
20: ; preds = %13, %4
%21 = phi i32 [ -1, %4 ], [ %19, %13 ]
ret i32 %21
}