#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*/ tmp;
typedef int /*<<< orphan*/ *gzFile;

/* Variables and functions */
scalar_t__ Z_NULL;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ gzclose(int /*<<< orphan*/ *);
char *gzerror(int /*<<< orphan*/ *, int *);
scalar_t__ gzgets(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ *gzopen(char *, char *);
int gzprintf(int /*<<< orphan*/ *, char *, ...);
long long gztell(int /*<<< orphan*/ *);
long long last_chunk_file(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int /*<<< orphan*/ sscanf(char *, char *, char *, long long *, long long *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ system(char *);
int hash_index_file(char *filename, int chunk_size, int skip_sort) {
  char hash_file_name[512];
  char indexname[512];
  char sorted_indexname[512];
  char sname[1024];
  long long beginH, gz_chunk = 0;
  char tmp[10000];
  int res = 0;
  int error;
  char min_name[1024];
  char max_name[1024];
  long long current_chunk = 0;
  long long count = 0;
  strcpy(min_name, "");
  strcpy(max_name, "");
  snprintf(indexname, 512, "%s.index", filename);
  snprintf(hash_file_name, 512, "%s.index.hash", filename);
  if (skip_sort == 0) {
    char cmd[10000];
    snprintf(cmd, 10000, "sort_index %s", indexname);
    system(cmd);
  }
  snprintf(sorted_indexname, 512, "%s.index.sorted", filename);
  gzFile gzhash_file = gzopen(hash_file_name, "wb");
  gzFile gzsorted_file_index = gzopen(sorted_indexname, "r");
  gzFile gzfile_index = gzopen(indexname, "w");
  gzprintf(gzfile_index,
           "UMACOMPRESSEDFORMAT 1 0 0 999999999999 999999999999\n");
  gzclose(gzfile_index);
  gzfile_index = gzopen(indexname, "ab");
  if (gzsorted_file_index == NULL) {
    fprintf(stderr, "error opening gzsorted_file_index :%s\n",
            gzerror(gzsorted_file_index, &error));
    return -2;
  }
  if (gzfile_index == NULL) {
    fprintf(stderr, "error opening gzfile_index :%s\n",
            gzerror(gzfile_index, &error));
    return -2;
  }
  if (gzhash_file == NULL) {
    fprintf(stderr, "error opening gzhash_file :%s\n",
            gzerror(gzhash_file, &error));
    return -2;
  }
  while (gzgets(gzsorted_file_index, tmp, sizeof(tmp)) != Z_NULL) {
    sscanf(tmp, "%s %lld %lld", sname, &gz_chunk, &beginH);
    if (strcmp(sname, "UMACOMPRESSEDFORMAT") != 0) {
      if ((count % chunk_size) == 0) {
        if (strcmp(min_name, "") != 0) {
          res = gzprintf(gzhash_file, "%s %s %lld\n", min_name, max_name,
                         current_chunk);
        }
        strcpy(min_name, "");
        strcpy(max_name, "");
        current_chunk = gztell(gzfile_index);
        gzclose(gzfile_index);
        current_chunk = last_chunk_file(indexname);
        gzfile_index = gzopen(indexname, "ab");
      }
      gzprintf(gzfile_index, tmp);
      if ((strcmp(min_name, "") == 0) || (strcmp(sname, min_name) < 0)) {
        strcpy(min_name, sname);
      }
      if ((strcmp(max_name, "") == 0) || (strcmp(sname, max_name) > 0)) {
        strcpy(max_name, sname);
      }
      count++;
    }
  }
  if (strcmp(min_name, "") != 0) {
    res = gzprintf(gzhash_file, "%s %s %lld\n", min_name, max_name,
                   current_chunk);
  }
  gzclose(gzhash_file);
  gzclose(gzfile_index);
  gzclose(gzsorted_file_index);
  return 0;
}


x86 assembly (clang, -O0):
<hash_index_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60a0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
movq   $0x0,-0xa30(%rbp)
movl   $0x0,-0x3144(%rbp)
movq   $0x0,-0x3958(%rbp)
movq   $0x0,-0x3960(%rbp)
lea    -0x3550(%rbp),%rdi
lea    0xe52(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x3950(%rbp),%rdi
lea    0xe3f(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x200,%esi
lea    0xdb3(%rip),%rdx
call   1080 <snprintf@plt>
lea    -0x220(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x200,%esi
lea    0xda0(%rip),%rdx
call   1080 <snprintf@plt>
cmpl   $0x0,-0x18(%rbp)
jne    12a3 <hash_index_file+0xd3>
lea    -0x6070(%rbp),%rdi
lea    -0x420(%rbp),%rcx
mov    $0x2710,%esi
lea    0xd85(%rip),%rdx
call   1080 <snprintf@plt>
lea    -0x6070(%rbp),%rdi
call   1070 <system@plt>
lea    -0x620(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x200,%esi
lea    0xd6b(%rip),%rdx
call   1080 <snprintf@plt>
lea    -0x220(%rbp),%rdi
lea    0xd68(%rip),%rsi
call   10e0 <gzopen@plt>
mov    %rax,-0x6078(%rbp)
lea    -0x620(%rbp),%rdi
lea    0xd51(%rip),%rsi
call   10e0 <gzopen@plt>
mov    %rax,-0x6080(%rbp)
lea    -0x420(%rbp),%rdi
lea    0xd39(%rip),%rsi
call   10e0 <gzopen@plt>
mov    %rax,-0x6088(%rbp)
mov    -0x6088(%rbp),%rdi
lea    0xd21(%rip),%rsi
mov    $0x0,%al
call   1060 <gzprintf@plt>
mov    -0x6088(%rbp),%rdi
call   1030 <gzclose@plt>
lea    -0x420(%rbp),%rdi
lea    0xd35(%rip),%rsi
call   10e0 <gzopen@plt>
mov    %rax,-0x6088(%rbp)
cmpq   $0x0,-0x6080(%rbp)
jne    1399 <hash_index_file+0x1c9>
mov    0x2c83(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x608c(%rbp)
mov    -0x6080(%rbp),%rdi
lea    -0x3148(%rbp),%rsi
call   10c0 <gzerror@plt>
mov    -0x608c(%rbp),%edi
mov    %rax,%rdx
lea    0xcec(%rip),%rsi
call   10b0 <fprintf@plt>
movl   $0xfffffffe,-0x4(%rbp)
jmp    16c4 <hash_index_file+0x4f4>
cmpq   $0x0,-0x6088(%rbp)
jne    13ea <hash_index_file+0x21a>
mov    0x2c32(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x6090(%rbp)
mov    -0x6088(%rbp),%rdi
lea    -0x3148(%rbp),%rsi
call   10c0 <gzerror@plt>
mov    -0x6090(%rbp),%edi
mov    %rax,%rdx
lea    0xcc2(%rip),%rsi
call   10b0 <fprintf@plt>
movl   $0xfffffffe,-0x4(%rbp)
jmp    16c4 <hash_index_file+0x4f4>
cmpq   $0x0,-0x6078(%rbp)
jne    143b <hash_index_file+0x26b>
mov    0x2be1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x6094(%rbp)
mov    -0x6078(%rbp),%rdi
lea    -0x3148(%rbp),%rsi
call   10c0 <gzerror@plt>
mov    -0x6094(%rbp),%edi
mov    %rax,%rdx
lea    0xc91(%rip),%rsi
call   10b0 <fprintf@plt>
movl   $0xfffffffe,-0x4(%rbp)
jmp    16c4 <hash_index_file+0x4f4>
jmp    1440 <hash_index_file+0x270>
mov    -0x6080(%rbp),%rdi
lea    -0x3140(%rbp),%rsi
mov    $0x2710,%edx
call   1050 <gzgets@plt>
mov    0x2b79(%rip),%rcx
cmp    (%rcx),%rax
je     164c <hash_index_file+0x47c>
lea    -0x3140(%rbp),%rdi
lea    -0xa20(%rbp),%rdx
lea    0xc5d(%rip),%rsi
lea    -0xa30(%rbp),%rcx
lea    -0xa28(%rbp),%r8
call   10d0 <sscanf@plt>
lea    -0xa20(%rbp),%rdi
lea    0xc49(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
je     1647 <hash_index_file+0x477>
mov    -0x3960(%rbp),%rax
movslq -0x14(%rbp),%rcx
cqto
idiv   %rcx
cmp    $0x0,%rdx
jne    1586 <hash_index_file+0x3b6>
lea    -0x3550(%rbp),%rdi
lea    0xb9b(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
je     1514 <hash_index_file+0x344>
mov    -0x6078(%rbp),%rdi
lea    -0x3550(%rbp),%rdx
lea    -0x3950(%rbp),%rcx
mov    -0x3958(%rbp),%r8
lea    0xbf4(%rip),%rsi
mov    $0x0,%al
call   1060 <gzprintf@plt>
mov    %eax,-0x3144(%rbp)
lea    -0x3550(%rbp),%rdi
lea    0xb4e(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x3950(%rbp),%rdi
lea    0xb3b(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x6088(%rbp),%rdi
call   10f0 <gztell@plt>
mov    %rax,-0x3958(%rbp)
mov    -0x6088(%rbp),%rdi
call   1030 <gzclose@plt>
lea    -0x420(%rbp),%rdi
call   1090 <last_chunk_file@plt>
mov    %rax,-0x3958(%rbp)
lea    -0x420(%rbp),%rdi
lea    0xaf7(%rip),%rsi
call   10e0 <gzopen@plt>
mov    %rax,-0x6088(%rbp)
mov    -0x6088(%rbp),%rdi
lea    -0x3140(%rbp),%rsi
mov    $0x0,%al
call   1060 <gzprintf@plt>
lea    -0x3550(%rbp),%rdi
lea    0xac7(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
je     15d5 <hash_index_file+0x405>
lea    -0xa20(%rbp),%rdi
lea    -0x3550(%rbp),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jge    15e8 <hash_index_file+0x418>
lea    -0x3550(%rbp),%rdi
lea    -0xa20(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x3950(%rbp),%rdi
lea    0xa7a(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
je     1622 <hash_index_file+0x452>
lea    -0xa20(%rbp),%rdi
lea    -0x3950(%rbp),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jle    1635 <hash_index_file+0x465>
lea    -0x3950(%rbp),%rdi
lea    -0xa20(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x3960(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x3960(%rbp)
jmp    1440 <hash_index_file+0x270>
lea    -0x3550(%rbp),%rdi
lea    0xa16(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
je     1699 <hash_index_file+0x4c9>
mov    -0x6078(%rbp),%rdi
lea    -0x3550(%rbp),%rdx
lea    -0x3950(%rbp),%rcx
mov    -0x3958(%rbp),%r8
lea    0xa6f(%rip),%rsi
mov    $0x0,%al
call   1060 <gzprintf@plt>
mov    %eax,-0x3144(%rbp)
mov    -0x6078(%rbp),%rdi
call   1030 <gzclose@plt>
mov    -0x6088(%rbp),%rdi
call   1030 <gzclose@plt>
mov    -0x6080(%rbp),%rdi
call   1030 <gzclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hash_index_file>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3958,%rsp
mov    %edx,%r14d
mov    %esi,%r15d
mov    %rdi,%rbx
movq   $0x0,0x30(%rsp)
lea    0xe76(%rip),%rbp
lea    0x240(%rsp),%rdi
mov    %rbp,%rsi
call   1040 <strcpy@plt>
lea    0x640(%rsp),%rdi
mov    %rbp,%rsi
call   1040 <strcpy@plt>
lea    0xddf(%rip),%rdx
lea    0x40(%rsp),%rdi
mov    $0x200,%esi
mov    %rbx,%rcx
call   1080 <snprintf@plt>
lea    0xdcf(%rip),%rdx
lea    0xa40(%rsp),%rdi
mov    $0x200,%esi
mov    %rbx,%rcx
call   1080 <snprintf@plt>
test   %r14d,%r14d
jne    127d <hash_index_file+0xad>
lea    0xdbc(%rip),%rdx
lea    0x1240(%rsp),%rbp
lea    0x40(%rsp),%rcx
mov    %rbp,%rdi
mov    $0x2710,%esi
call   1080 <snprintf@plt>
mov    %rbp,%rdi
call   1070 <system@plt>
lea    0xda1(%rip),%rdx
lea    0xc40(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x200,%esi
mov    %rbx,%rcx
call   1080 <snprintf@plt>
lea    0xd92(%rip),%rsi
lea    0xa40(%rsp),%rdi
call   10e0 <gzopen@plt>
mov    %rax,%r14
lea    0xd7e(%rip),%rsi
mov    %rbp,%rdi
call   10e0 <gzopen@plt>
mov    %rax,%rbx
lea    0xd6e(%rip),%rsi
lea    0x40(%rsp),%r12
mov    %r12,%rdi
call   10e0 <gzopen@plt>
mov    %rax,%rbp
lea    0xd59(%rip),%rsi
mov    %rax,%rdi
xor    %eax,%eax
call   1060 <gzprintf@plt>
mov    %rbp,%rdi
call   1030 <gzclose@plt>
lea    0xd75(%rip),%rsi
mov    %r12,%rdi
call   10e0 <gzopen@plt>
test   %rbx,%rbx
je     13b5 <hash_index_file+0x1e5>
test   %rax,%rax
je     13d6 <hash_index_file+0x206>
test   %r14,%r14
je     13f7 <hash_index_file+0x227>
mov    %rax,0x8(%rsp)
mov    %r14,0x18(%rsp)
lea    0x1240(%rsp),%rsi
mov    %rbx,%rdi
mov    $0x2710,%edx
call   1050 <gzgets@plt>
mov    0x2c93(%rip),%rcx
cmp    (%rcx),%rax
jne    1437 <hash_index_file+0x267>
xor    %eax,%eax
mov    %rax,(%rsp)
lea    0xd15(%rip),%rsi
lea    0x240(%rsp),%rdi
call   10a0 <strcmp@plt>
test   %rax,%rax
mov    0x18(%rsp),%r14
je     1397 <hash_index_file+0x1c7>
lea    0xd82(%rip),%rsi
lea    0x240(%rsp),%rdx
lea    0x640(%rsp),%rcx
mov    %r14,%rdi
mov    (%rsp),%r8
xor    %eax,%eax
call   1060 <gzprintf@plt>
mov    %r14,%rdi
call   1030 <gzclose@plt>
mov    0x8(%rsp),%rdi
call   1030 <gzclose@plt>
mov    %rbx,%rdi
call   1030 <gzclose@plt>
xor    %eax,%eax
jmp    1425 <hash_index_file+0x255>
mov    0x2c24(%rip),%rax
mov    (%rax),%ebx
lea    0x1240(%rsp),%rsi
xor    %edi,%edi
call   10c0 <gzerror@plt>
lea    0xca0(%rip),%rsi
jmp    1416 <hash_index_file+0x246>
mov    0x2c03(%rip),%rax
mov    (%rax),%ebx
lea    0x1240(%rsp),%rsi
xor    %edi,%edi
call   10c0 <gzerror@plt>
lea    0xca6(%rip),%rsi
jmp    1416 <hash_index_file+0x246>
mov    0x2be2(%rip),%rax
mov    (%rax),%ebx
lea    0x1240(%rsp),%rsi
xor    %edi,%edi
call   10c0 <gzerror@plt>
lea    0xca5(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   10b0 <fprintf@plt>
mov    $0xfffffffe,%eax
add    $0x3958,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r15d,0x14(%rsp)
movslq %r15d,%rax
mov    %rax,0x28(%rsp)
lea    0x1240(%rsp),%rbp
lea    0xe40(%rsp),%r14
xor    %r12d,%r12d
xor    %eax,%eax
mov    %rax,(%rsp)
mov    %rbx,0x20(%rsp)
jmp    14a3 <hash_index_file+0x2d3>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbp,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
add    $0x1,%r12
lea    0x1240(%rsp),%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0x2710,%edx
call   1050 <gzgets@plt>
mov    %r15,%rcx
cmp    (%r15),%rax
je     1354 <hash_index_file+0x184>
mov    %rcx,%r15
mov    %rbp,%rdi
lea    0xc2a(%rip),%rsi
mov    %r14,%rdx
lea    0x30(%rsp),%rcx
lea    0x38(%rsp),%r8
call   10d0 <sscanf@plt>
mov    %r14,%rdi
lea    0xc1b(%rip),%rsi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     1487 <hash_index_file+0x2b7>
mov    %r12,%rax
mov    0x28(%rsp),%rcx
or     %rcx,%rax
shr    $0x20,%rax
je     1500 <hash_index_file+0x330>
mov    %r12,%rax
cqto
idiv   %rcx
jmp    1509 <hash_index_file+0x339>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r12d,%eax
xor    %edx,%edx
divl   0x14(%rsp)
lea    0xb60(%rip),%r13
lea    0x240(%rsp),%rbp
test   %rdx,%rdx
je     1530 <hash_index_file+0x360>
mov    0x8(%rsp),%rdi
jmp    15ba <hash_index_file+0x3ea>
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    %r13,%rsi
call   10a0 <strcmp@plt>
test   %rax,%rax
lea    0x640(%rsp),%rbx
je     1565 <hash_index_file+0x395>
mov    0x18(%rsp),%rdi
lea    0xba7(%rip),%rsi
mov    %rbp,%rdx
mov    %rbx,%rcx
mov    (%rsp),%r8
xor    %eax,%eax
call   1060 <gzprintf@plt>
mov    %rbp,%rdi
lea    0xb01(%rip),%r13
mov    %r13,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1040 <strcpy@plt>
mov    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   10f0 <gztell@plt>
mov    %rbx,%rdi
call   1030 <gzclose@plt>
lea    0x40(%rsp),%rbx
mov    %rbx,%rdi
call   1090 <last_chunk_file@plt>
mov    %rax,(%rsp)
mov    %rbx,%rdi
lea    0xabf(%rip),%rsi
call   10e0 <gzopen@plt>
mov    %rax,%rdi
mov    %rdi,0x8(%rsp)
lea    0x1240(%rsp),%rsi
xor    %eax,%eax
call   1060 <gzprintf@plt>
mov    %rbp,%rdi
mov    %r13,%rsi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     15ee <hash_index_file+0x41e>
mov    %r14,%rdi
mov    %rbp,%rsi
call   10a0 <strcmp@plt>
test   %rax,%rax
jns    15f9 <hash_index_file+0x429>
mov    %rbp,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
lea    0x640(%rsp),%rbp
mov    %rbp,%rdi
lea    0xa65(%rip),%rsi
call   10a0 <strcmp@plt>
test   %rax,%rax
mov    0x20(%rsp),%rbx
je     1470 <hash_index_file+0x2a0>
mov    %r14,%rdi
mov    %rbp,%rsi
call   10a0 <strcmp@plt>
test   %rax,%rax
jg     1470 <hash_index_file+0x2a0>
jmp    147b <hash_index_file+0x2ab>

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [9 x i8] c"%s.index\00"
@.str.2 = [14 x i8] c"%s.index.hash\00"
@.str.3 = [14 x i8] c"sort_index %s\00"
@.str.4 = [16 x i8] c"%s.index.sorted\00"
@.str.5 = [3 x i8] c"wb\00"
@.str.6 = [2 x i8] c"r\00"
@.str.7 = [2 x i8] c"w\00"
@.str.8 = [53 x i8] c"UMACOMPRESSEDFORMAT 1 0 0 999999999999 999999999999\0A\00"
@.str.9 = [3 x i8] c"ab\00"
@stderr = global i32 0
@.str.10 = [39 x i8] c"error opening gzsorted_file_index :%s\0A\00"
@.str.11 = [32 x i8] c"error opening gzfile_index :%s\0A\00"
@.str.12 = [31 x i8] c"error opening gzhash_file :%s\0A\00"
@Z_NULL = global i64 0
@.str.13 = [13 x i8] c"%s %lld %lld\00"
@.str.14 = [20 x i8] c"UMACOMPRESSEDFORMAT\00"
@.str.15 = [12 x i8] c"%s %s %lld\0A\00"
define i32 @hash_index_file(i8* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca [512 x i8]
%9 = alloca [512 x i8]
%10 = alloca [512 x i8]
%11 = alloca [1024 x i8]
%12 = alloca i64
%13 = alloca i64
%14 = alloca [10000 x i8]
%15 = alloca i32
%16 = alloca i32
%17 = alloca [1024 x i8]
%18 = alloca [1024 x i8]
%19 = alloca i64
%20 = alloca i64
%21 = alloca [10000 x i8]
%22 = alloca i32*
%23 = alloca i32*
%24 = alloca i32*
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i64 0, i64* %13
store i32 0, i32* %15
store i64 0, i64* %19
store i64 0, i64* %20
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %17, i64 0, i64 0
%26 = call i32 @strcpy(i8* %25, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %18, i64 0, i64 0
%28 = call i32 @strcpy(i8* %27, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%29 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%30 = load i8*, i8** %5
%31 = call i32 @snprintf(i8* %29, i32 512, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %30)
%32 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%33 = load i8*, i8** %5
%34 = call i32 @snprintf(i8* %32, i32 512, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %33)
%35 = load i32, i32* %7
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %43
37: ; preds = %3
%38 = getelementptr inbounds [10000 x i8], [10000 x i8]* %21, i64 0, i64 0
%39 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%40 = call i32 @snprintf(i8* %38, i32 10000, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %39)
%41 = getelementptr inbounds [10000 x i8], [10000 x i8]* %21, i64 0, i64 0
%42 = call i32 @system(i8* %41)
br label %43
43: ; preds = %37, %3
%44 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%45 = load i8*, i8** %5
%46 = call i32 @snprintf(i8* %44, i32 512, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8* %45)
%47 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%48 = call i32* @gzopen(i8* %47, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
store i32* %48, i32** %22
%49 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%50 = call i32* @gzopen(i8* %49, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
store i32* %50, i32** %23
%51 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%52 = call i32* @gzopen(i8* %51, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32* %52, i32** %24
%53 = load i32*, i32** %24
%54 = call i32 (i32*, i8*, ...) @gzprintf(i32* %53, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.8, i64 0, i64 0))
%55 = load i32*, i32** %24
%56 = call i32 @gzclose(i32* %55)
%57 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%58 = call i32* @gzopen(i8* %57, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
store i32* %58, i32** %24
%59 = load i32*, i32** %23
%60 = icmp eq i32* %59, null
br i1 %60, label %61, label %66
61: ; preds = %43
%62 = load i32, i32* @stderr
%63 = load i32*, i32** %23
%64 = call i8* @gzerror(i32* %63, i32* %16)
%65 = call i32 @fprintf(i32 %62, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.10, i64 0, i64 0), i8* %64)
store i32 -2, i32* %4
br label %175
66: ; preds = %43
%67 = load i32*, i32** %24
%68 = icmp eq i32* %67, null
br i1 %68, label %69, label %74
69: ; preds = %66
%70 = load i32, i32* @stderr
%71 = load i32*, i32** %24
%72 = call i8* @gzerror(i32* %71, i32* %16)
%73 = call i32 @fprintf(i32 %70, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.11, i64 0, i64 0), i8* %72)
store i32 -2, i32* %4
br label %175
74: ; preds = %66
%75 = load i32*, i32** %22
%76 = icmp eq i32* %75, null
br i1 %76, label %77, label %82
77: ; preds = %74
%78 = load i32, i32* @stderr
%79 = load i32*, i32** %22
%80 = call i8* @gzerror(i32* %79, i32* %16)
%81 = call i32 @fprintf(i32 %78, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.12, i64 0, i64 0), i8* %80)
store i32 -2, i32* %4
br label %175
82: ; preds = %74
br label %83
83: ; preds = %157, %82
%84 = load i32*, i32** %23
%85 = getelementptr inbounds [10000 x i8], [10000 x i8]* %14, i64 0, i64 0
%86 = call i64 @gzgets(i32* %84, i8* %85, i32 10000)
%87 = load i64, i64* @Z_NULL
%88 = icmp ne i64 %86, %87
br i1 %88, label %89, label %158
89: ; preds = %83
%90 = getelementptr inbounds [10000 x i8], [10000 x i8]* %14, i64 0, i64 0
%91 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%92 = call i32 @sscanf(i8* %90, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.13, i64 0, i64 0), i8* %91, i64* %13, i64* %12)
%93 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%94 = call i64 @strcmp(i8* %93, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.14, i64 0, i64 0))
%95 = icmp ne i64 %94, 0
br i1 %95, label %96, label %157
96: ; preds = %89
%97 = load i64, i64* %20
%98 = load i32, i32* %6
%99 = sext i32 %98 to i64
%100 = srem i64 %97, %99
%101 = icmp eq i64 %100, 0
br i1 %101, label %102, label %125
102: ; preds = %96
%103 = getelementptr inbounds [1024 x i8], [1024 x i8]* %17, i64 0, i64 0
%104 = call i64 @strcmp(i8* %103, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%105 = icmp ne i64 %104, 0
br i1 %105, label %106, label %112
106: ; preds = %102
%107 = load i32*, i32** %22
%108 = getelementptr inbounds [1024 x i8], [1024 x i8]* %17, i64 0, i64 0
%109 = getelementptr inbounds [1024 x i8], [1024 x i8]* %18, i64 0, i64 0
%110 = load i64, i64* %19
%111 = call i32 (i32*, i8*, ...) @gzprintf(i32* %107, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.15, i64 0, i64 0), i8* %108, i8* %109, i64 %110)
store i32 %111, i32* %15
br label %112
112: ; preds = %106, %102
%113 = getelementptr inbounds [1024 x i8], [1024 x i8]* %17, i64 0, i64 0
%114 = call i32 @strcpy(i8* %113, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%115 = getelementptr inbounds [1024 x i8], [1024 x i8]* %18, i64 0, i64 0
%116 = call i32 @strcpy(i8* %115, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%117 = load i32*, i32** %24
%118 = call i64 @gztell(i32* %117)
store i64 %118, i64* %19
%119 = load i32*, i32** %24
%120 = call i32 @gzclose(i32* %119)
%121 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%122 = call i64 @last_chunk_file(i8* %121)
store i64 %122, i64* %19
%123 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%124 = call i32* @gzopen(i8* %123, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
store i32* %124, i32** %24
br label %125
125: ; preds = %112, %96
%126 = load i32*, i32** %24
%127 = getelementptr inbounds [10000 x i8], [10000 x i8]* %14, i64 0, i64 0
%128 = call i32 (i32*, i8*, ...) @gzprintf(i32* %126, i8* %127)
%129 = getelementptr inbounds [1024 x i8], [1024 x i8]* %17, i64 0, i64 0
%130 = call i64 @strcmp(i8* %129, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%131 = icmp eq i64 %130, 0
br i1 %131, label %137, label %132
132: ; preds = %125
%133 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%134 = getelementptr inbounds [1024 x i8], [1024 x i8]* %17, i64 0, i64 0
%135 = call i64 @strcmp(i8* %133, i8* %134)
%136 = icmp slt i64 %135, 0
br i1 %136, label %137, label %141
137: ; preds = %132, %125
%138 = getelementptr inbounds [1024 x i8], [1024 x i8]* %17, i64 0, i64 0
%139 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%140 = call i32 @strcpy(i8* %138, i8* %139)
br label %141
141: ; preds = %137, %132
%142 = getelementptr inbounds [1024 x i8], [1024 x i8]* %18, i64 0, i64 0
%143 = call i64 @strcmp(i8* %142, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%144 = icmp eq i64 %143, 0
br i1 %144, label %150, label %145
145: ; preds = %141
%146 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%147 = getelementptr inbounds [1024 x i8], [1024 x i8]* %18, i64 0, i64 0
%148 = call i64 @strcmp(i8* %146, i8* %147)
%149 = icmp sgt i64 %148, 0
br i1 %149, label %150, label %154
150: ; preds = %145, %141
%151 = getelementptr inbounds [1024 x i8], [1024 x i8]* %18, i64 0, i64 0
%152 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%153 = call i32 @strcpy(i8* %151, i8* %152)
br label %154
154: ; preds = %150, %145
%155 = load i64, i64* %20
%156 = add nsw i64 %155, 1
store i64 %156, i64* %20
br label %157
157: ; preds = %154, %89
br label %83
158: ; preds = %83
%159 = getelementptr inbounds [1024 x i8], [1024 x i8]* %17, i64 0, i64 0
%160 = call i64 @strcmp(i8* %159, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%161 = icmp ne i64 %160, 0
br i1 %161, label %162, label %168
162: ; preds = %158
%163 = load i32*, i32** %22
%164 = getelementptr inbounds [1024 x i8], [1024 x i8]* %17, i64 0, i64 0
%165 = getelementptr inbounds [1024 x i8], [1024 x i8]* %18, i64 0, i64 0
%166 = load i64, i64* %19
%167 = call i32 (i32*, i8*, ...) @gzprintf(i32* %163, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.15, i64 0, i64 0), i8* %164, i8* %165, i64 %166)
store i32 %167, i32* %15
br label %168
168: ; preds = %162, %158
%169 = load i32*, i32** %22
%170 = call i32 @gzclose(i32* %169)
%171 = load i32*, i32** %24
%172 = call i32 @gzclose(i32* %171)
%173 = load i32*, i32** %23
%174 = call i32 @gzclose(i32* %173)
store i32 0, i32* %4
br label %175
175: ; preds = %168, %77, %69, %61
%176 = load i32, i32* %4
ret i32 %176
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [9 x i8] c"%s.index\00"
@.str.2 = [14 x i8] c"%s.index.hash\00"
@.str.3 = [14 x i8] c"sort_index %s\00"
@.str.4 = [16 x i8] c"%s.index.sorted\00"
@.str.5 = [3 x i8] c"wb\00"
@.str.6 = [2 x i8] c"r\00"
@.str.7 = [2 x i8] c"w\00"
@.str.8 = [53 x i8] c"UMACOMPRESSEDFORMAT 1 0 0 999999999999 999999999999\0A\00"
@.str.9 = [3 x i8] c"ab\00"
@stderr = global i32 0
@.str.10 = [39 x i8] c"error opening gzsorted_file_index :%s\0A\00"
@.str.11 = [32 x i8] c"error opening gzfile_index :%s\0A\00"
@.str.12 = [31 x i8] c"error opening gzhash_file :%s\0A\00"
@Z_NULL = global i64 0
@.str.13 = [13 x i8] c"%s %lld %lld\00"
@.str.14 = [20 x i8] c"UMACOMPRESSEDFORMAT\00"
@.str.15 = [12 x i8] c"%s %s %lld\0A\00"
define i32 @hash_index_file(i8* %0, i32 %1, i32 %2) {
%4 = alloca [512 x i8]
%5 = alloca [512 x i8]
%6 = alloca [512 x i8]
%7 = alloca [1024 x i8]
%8 = alloca i64
%9 = alloca i64
%10 = alloca [10000 x i8]
%11 = alloca i32
%12 = alloca [1024 x i8]
%13 = alloca [1024 x i8]
%14 = alloca [10000 x i8]
%15 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%16 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%17 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%19 = bitcast i64* %8 to i8*
%20 = bitcast i64* %9 to i8*
store i64 0, i64* %9
%21 = getelementptr inbounds [10000 x i8], [10000 x i8]* %10, i64 0, i64 0
%22 = bitcast i32* %11 to i8*
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%25 = call i32 @strcpy(i8* %23, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%26 = call i32 @strcpy(i8* %24, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%27 = call i32 @snprintf(i8* %16, i32 512, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%28 = call i32 @snprintf(i8* %15, i32 512, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%29 = icmp eq i32 %2, 0
br i1 %29, label %30, label %34
30: ; preds = %3
%31 = getelementptr inbounds [10000 x i8], [10000 x i8]* %14, i64 0, i64 0
%32 = call i32 @snprintf(i8* %31, i32 10000, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %16)
%33 = call i32 @system(i8* %31)
br label %34
34: ; preds = %30, %3
%35 = call i32 @snprintf(i8* %17, i32 512, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8* %0)
%36 = call i32* @gzopen(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%37 = call i32* @gzopen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%38 = call i32* @gzopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%39 = call i32 (i32*, i8*, ...) @gzprintf(i32* %38, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.8, i64 0, i64 0))
%40 = call i32 @gzclose(i32* %38)
%41 = call i32* @gzopen(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
%42 = icmp eq i32* %37, null
br i1 %42, label %43, label %47
43: ; preds = %34
%44 = load i32, i32* @stderr
%45 = call i8* @gzerror(i32* null, i32* %11)
%46 = call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.10, i64 0, i64 0), i8* %45)
br label %126
47: ; preds = %34
%48 = icmp eq i32* %41, null
br i1 %48, label %49, label %53
49: ; preds = %47
%50 = load i32, i32* @stderr
%51 = call i8* @gzerror(i32* null, i32* %11)
%52 = call i32 @fprintf(i32 %50, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.11, i64 0, i64 0), i8* %51)
br label %126
53: ; preds = %47
%54 = icmp eq i32* %36, null
br i1 %54, label %61, label %55
55: ; preds = %53
%56 = call i64 @gzgets(i32* %37, i8* %21, i32 10000)
%57 = load i64, i64* @Z_NULL
%58 = icmp eq i64 %56, %57
br i1 %58, label %115, label %59
59: ; preds = %55
%60 = sext i32 %1 to i64
br label %65
61: ; preds = %53
%62 = load i32, i32* @stderr
%63 = call i8* @gzerror(i32* null, i32* %11)
%64 = call i32 @fprintf(i32 %62, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.12, i64 0, i64 0), i8* %63)
br label %126
65: ; preds = %59, %108
%66 = phi i32* [ %41, %59 ], [ %111, %108 ]
%67 = phi i64 [ 0, %59 ], [ %110, %108 ]
%68 = phi i64 [ 0, %59 ], [ %109, %108 ]
%69 = call i32 @sscanf(i8* %21, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.13, i64 0, i64 0), i8* %18, i64* %9, i64* %8)
%70 = call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.14, i64 0, i64 0))
%71 = icmp eq i64 %70, 0
br i1 %71, label %108, label %72
72: ; preds = %65
%73 = srem i64 %67, %60
%74 = icmp eq i64 %73, 0
br i1 %74, label %75, label %87
75: ; preds = %72
%76 = call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%77 = icmp eq i64 %76, 0
br i1 %77, label %80, label %78
78: ; preds = %75
%79 = call i32 (i32*, i8*, ...) @gzprintf(i32* %36, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.15, i64 0, i64 0), i8* %23, i8* %24, i64 %68)
br label %80
80: ; preds = %78, %75
%81 = call i32 @strcpy(i8* %23, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%82 = call i32 @strcpy(i8* %24, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%83 = call i64 @gztell(i32* %66)
%84 = call i32 @gzclose(i32* %66)
%85 = call i64 @last_chunk_file(i8* %16)
%86 = call i32* @gzopen(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
br label %87
87: ; preds = %80, %72
%88 = phi i64 [ %85, %80 ], [ %68, %72 ]
%89 = phi i32* [ %86, %80 ], [ %66, %72 ]
%90 = call i32 (i32*, i8*, ...) @gzprintf(i32* %89, i8* %21)
%91 = call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%92 = icmp eq i64 %91, 0
br i1 %92, label %96, label %93
93: ; preds = %87
%94 = call i64 @strcmp(i8* %18, i8* %23)
%95 = icmp slt i64 %94, 0
br i1 %95, label %96, label %98
96: ; preds = %93, %87
%97 = call i32 @strcpy(i8* %23, i8* %18)
br label %98
98: ; preds = %96, %93
%99 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%100 = icmp eq i64 %99, 0
br i1 %100, label %104, label %101
101: ; preds = %98
%102 = call i64 @strcmp(i8* %18, i8* %24)
%103 = icmp sgt i64 %102, 0
br i1 %103, label %104, label %106
104: ; preds = %101, %98
%105 = call i32 @strcpy(i8* %24, i8* %18)
br label %106
106: ; preds = %104, %101
%107 = add nsw i64 %67, 1
br label %108
108: ; preds = %106, %65
%109 = phi i64 [ %88, %106 ], [ %68, %65 ]
%110 = phi i64 [ %107, %106 ], [ %67, %65 ]
%111 = phi i32* [ %89, %106 ], [ %66, %65 ]
%112 = call i64 @gzgets(i32* %37, i8* %21, i32 10000)
%113 = load i64, i64* @Z_NULL
%114 = icmp eq i64 %112, %113
br i1 %114, label %115, label %65
115: ; preds = %108, %55
%116 = phi i64 [ 0, %55 ], [ %109, %108 ]
%117 = phi i32* [ %41, %55 ], [ %111, %108 ]
%118 = call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%119 = icmp eq i64 %118, 0
br i1 %119, label %122, label %120
120: ; preds = %115
%121 = call i32 (i32*, i8*, ...) @gzprintf(i32* %36, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.15, i64 0, i64 0), i8* %23, i8* %24, i64 %116)
br label %122
122: ; preds = %120, %115
%123 = call i32 @gzclose(i32* %36)
%124 = call i32 @gzclose(i32* %117)
%125 = call i32 @gzclose(i32* %37)
br label %126
126: ; preds = %122, %61, %49, %43
%127 = phi i32 [ -2, %43 ], [ -2, %49 ], [ -2, %61 ], [ 0, %122 ]
ret i32 %127
}