#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 */
struct stat {
  int dummy;
};
typedef scalar_t__ off_t;
typedef scalar_t__ htype;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
int get_format_ver(char *);
char *malloc(int);
scalar_t__ memcmp(char *, char *, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
scalar_t__ nsrl_extract_md5(char *, char **, int /*<<< orphan*/ *, int);
scalar_t__ nsrl_extract_sha1(char *, char **, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ snprintf(char *, int, char *, ...);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
scalar_t__ system(char *);
scalar_t__ unlink(char *);
int nsrl_init(char *db_file, unsigned char htype) {
  FILE *hIn, *hOut;
  int i, len;
  char buf[512], unsorted[512], sorted[512];
  char *hash = NULL, *phash;
  char *hash_str;
  off_t offset = 0;
  char offstr[16 + 1], temp[16 + 1];
  int hash_len, ver = 0;
  int db_cnt = 0, idx_cnt = 0, ig_cnt = 0;
  if (htype & 0x01) {
    hash_str = "md5";
  } else if (htype & 0x02) {
    hash_str = "sha1";
  } else {
    fprintf(stderr,
            "nsrl_init: At least one hashing algorithm must be given\n");
    exit(1);
  }
  hash_len = (((htype)&0x01) ? (32) : ((((htype)&0x02) ? 40 : 0)));
  if (NULL == (hIn = fopen(db_file, "r"))) {
    fprintf(stderr, "Error opening NSRL file: %s\n", db_file);
    exit(1);
  }
  snprintf(unsorted, 512, "%s-%s-ns.idx", db_file, hash_str);
  snprintf(sorted, 512, "%s-%s.idx", db_file, hash_str);
  if (NULL == (hOut = fopen(unsorted, "w"))) {
    fprintf(stderr, "Error creating NSRL index file: %s\n", unsorted);
    exit(1);
  }
  fprintf(hOut, "%s|%s\n", "00000000000000000000000000000000000000000", "nsrl");
  printf("Extracting Data from Database (%s)\n", db_file);
  phash = malloc(hash_len + 1);
  if (phash == NULL) {
    fprintf(stderr, "nsrl_init: Error allocating memory\n");
    exit(1);
  }
  memset(phash, '0', hash_len + 1);
  strcpy(offstr, "0000000000000000");
  for (i = 0; NULL != fgets(buf, 512, hIn); offset += len, i++) {
    char *ptr;
    len = strlen(buf);
    if (i == 0) {
      ver = get_format_ver(buf);
      ig_cnt++;
      continue;
    }
    if (htype & 0x02) {
      if (nsrl_extract_sha1(buf, &hash, NULL, ver)) {
        ig_cnt++;
        continue;
      }
    } else if (htype & 0x01) {
      if (nsrl_extract_md5(buf, &hash, NULL, ver)) {
        ig_cnt++;
        continue;
      }
    }
    db_cnt++;
    if (memcmp(hash, phash, hash_len) == 0) {
      continue;
    }
    snprintf(temp, 16 + 1, "%i", (int)offset);
    ptr = offstr + 16 - strlen(temp);
    strcpy(ptr, temp);
    fprintf(hOut, "%s|%s\n", hash, offstr);
    idx_cnt++;
    strncpy(phash, hash, hash_len + 1);
  }
  free(phash);
  fclose(hIn);
  fclose(hOut);
  if (idx_cnt > 0) {
    char *root = "/bin/sort";
    char *usr = "/usr/bin/sort";
    char *local = "/usr/local/bin/sort";
    struct stat stats;
    printf("  Valid Database Entries: %d\n", db_cnt);
    printf("  Invalid Database Entries (headers or errors): %d\n", ig_cnt);
    printf("  Index File Entries %s: %d\n",
           (idx_cnt == db_cnt) ? "" : "(optimized)", idx_cnt);
    printf("Sorting Index (%s)\n", sorted);
    if (0 == stat(local, &stats)) {
      snprintf(buf, 512, "%s -o \"%s\" \"%s\"", local, sorted, unsorted);
    } else if (0 == stat(usr, &stats)) {
      snprintf(buf, 512, "%s -o \"%s\" \"%s\"", usr, sorted, unsorted);
    } else if (0 == stat(root, &stats)) {
      snprintf(buf, 512, "%s -o \"%s\" \"%s\"", root, sorted, unsorted);
    } else {
      fprintf(stderr, "Error finding 'sort' binary\n");
      exit(1);
    }
    if (0 != system(buf)) {
      fprintf(stderr, "Error sorting index file using %s\n", buf);
      exit(1);
    }
  } else {
    fprintf(stderr, "Error parsing NSRL DB File: %s\n", db_file);
  }
  if (0 != unlink(unsorted)) {
    fprintf(stderr, "Error removing temporary index file\n");
    exit(1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<nsrl_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x6e0,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
movq   $0x0,-0x638(%rbp)
movq   $0x0,-0x650(%rbp)
movl   $0x0,-0x698(%rbp)
movl   $0x0,-0x69c(%rbp)
movl   $0x0,-0x6a0(%rbp)
movl   $0x0,-0x6a4(%rbp)
movzbl -0x9(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     12b6 <nsrl_init+0x76>
lea    0xd56(%rip),%rax
mov    %rax,-0x648(%rbp)
jmp    12ff <nsrl_init+0xbf>
movzbl -0x9(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     12d9 <nsrl_init+0x99>
lea    0xd37(%rip),%rax
mov    %rax,-0x648(%rbp)
jmp    12fa <nsrl_init+0xba>
mov    0x2d00(%rip),%rax
mov    (%rax),%edi
lea    0xd20(%rip),%rsi
mov    $0x0,%al
call   1110 <fprintf@plt>
mov    $0x1,%edi
call   1160 <exit@plt>
jmp    12ff <nsrl_init+0xbf>
movzbl -0x9(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     131f <nsrl_init+0xdf>
mov    $0x20,%eax
mov    %eax,-0x6d4(%rbp)
jmp    1339 <nsrl_init+0xf9>
movzbl -0x9(%rbp),%edx
and    $0x2,%edx
xor    %eax,%eax
mov    $0x28,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x6d4(%rbp)
mov    -0x6d4(%rbp),%eax
mov    %eax,-0x694(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xcf2(%rip),%rsi
call   1140 <fopen@plt>
mov    %rax,%rcx
mov    %rcx,-0x18(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
jne    138c <nsrl_init+0x14c>
mov    0x2c72(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xcc9(%rip),%rsi
mov    $0x0,%al
call   1110 <fprintf@plt>
mov    $0x1,%edi
call   1160 <exit@plt>
lea    -0x430(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    -0x648(%rbp),%r8
mov    $0x200,%esi
lea    0xcb7(%rip),%rdx
mov    $0x0,%al
call   10b0 <snprintf@plt>
lea    -0x630(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    -0x648(%rbp),%r8
mov    $0x200,%esi
lea    0xc9f(%rip),%rdx
mov    $0x0,%al
call   10b0 <snprintf@plt>
lea    -0x430(%rbp),%rdi
lea    0xc94(%rip),%rsi
call   1140 <fopen@plt>
mov    %rax,%rcx
mov    %rcx,-0x20(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
jne    1423 <nsrl_init+0x1e3>
mov    0x2bde(%rip),%rax
mov    (%rax),%edi
lea    -0x430(%rbp),%rdx
lea    0xc68(%rip),%rsi
mov    $0x0,%al
call   1110 <fprintf@plt>
mov    $0x1,%edi
call   1160 <exit@plt>
mov    -0x20(%rbp),%rax
mov    %eax,%edi
lea    0xc6e(%rip),%rsi
lea    0xc6e(%rip),%rdx
lea    0xc91(%rip),%rcx
mov    $0x0,%al
call   1110 <fprintf@plt>
mov    -0x8(%rbp),%rsi
lea    0xc84(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    -0x694(%rbp),%edi
add    $0x1,%edi
call   1130 <malloc@plt>
mov    %rax,-0x640(%rbp)
cmpq   $0x0,-0x640(%rbp)
jne    149b <nsrl_init+0x25b>
mov    0x2b5f(%rip),%rax
mov    (%rax),%edi
lea    0xc6e(%rip),%rsi
mov    $0x0,%al
call   1110 <fprintf@plt>
mov    $0x1,%edi
call   1160 <exit@plt>
mov    -0x640(%rbp),%rdi
mov    -0x694(%rbp),%edx
add    $0x1,%edx
mov    $0x30,%esi
call   10c0 <memset@plt>
lea    -0x670(%rbp),%rdi
lea    0xbfb(%rip),%rsi
call   1060 <strcpy@plt>
movl   $0x0,-0x24(%rbp)
lea    -0x230(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x200,%esi
call   10f0 <fgets@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     16e9 <nsrl_init+0x4a9>
lea    -0x230(%rbp),%rdi
call   1080 <strlen@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    1531 <nsrl_init+0x2f1>
lea    -0x230(%rbp),%rdi
call   1100 <get_format_ver@plt>
mov    %eax,-0x698(%rbp)
mov    -0x6a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6a4(%rbp)
jmp    16c9 <nsrl_init+0x489>
movzbl -0x9(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     1581 <nsrl_init+0x341>
lea    -0x230(%rbp),%rdi
mov    -0x698(%rbp),%ecx
lea    -0x638(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1150 <nsrl_extract_sha1@plt>
cmp    $0x0,%rax
je     157c <nsrl_init+0x33c>
mov    -0x6a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6a4(%rbp)
jmp    16c9 <nsrl_init+0x489>
jmp    15d6 <nsrl_init+0x396>
movzbl -0x9(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     15d1 <nsrl_init+0x391>
lea    -0x230(%rbp),%rdi
mov    -0x698(%rbp),%ecx
lea    -0x638(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   10d0 <nsrl_extract_md5@plt>
cmp    $0x0,%rax
je     15cc <nsrl_init+0x38c>
mov    -0x6a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6a4(%rbp)
jmp    16c9 <nsrl_init+0x489>
jmp    15d1 <nsrl_init+0x391>
jmp    15d6 <nsrl_init+0x396>
mov    -0x69c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x69c(%rbp)
mov    -0x638(%rbp),%rdi
mov    -0x640(%rbp),%rsi
mov    -0x694(%rbp),%edx
call   10e0 <memcmp@plt>
cmp    $0x0,%rax
jne    160d <nsrl_init+0x3cd>
jmp    16c9 <nsrl_init+0x489>
lea    -0x690(%rbp),%rdi
mov    -0x650(%rbp),%rax
mov    %eax,%ecx
mov    $0x11,%esi
lea    0xaf3(%rip),%rdx
mov    $0x0,%al
call   10b0 <snprintf@plt>
lea    -0x670(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x6e0(%rbp)
lea    -0x690(%rbp),%rdi
call   1080 <strlen@plt>
mov    %eax,%ecx
mov    -0x6e0(%rbp),%rax
movslq %ecx,%rdx
xor    %ecx,%ecx
sub    %rdx,%rcx
add    %rcx,%rax
mov    %rax,-0x6b0(%rbp)
mov    -0x6b0(%rbp),%rdi
lea    -0x690(%rbp),%rsi
call   1060 <strcpy@plt>
mov    -0x20(%rbp),%rax
mov    %eax,%edi
mov    -0x638(%rbp),%rdx
lea    -0x670(%rbp),%rcx
lea    0xa07(%rip),%rsi
mov    $0x0,%al
call   1110 <fprintf@plt>
mov    -0x6a0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6a0(%rbp)
mov    -0x640(%rbp),%rdi
mov    -0x638(%rbp),%rsi
mov    -0x694(%rbp),%edx
add    $0x1,%edx
call   1050 <strncpy@plt>
movslq -0x28(%rbp),%rax
add    -0x650(%rbp),%rax
mov    %rax,-0x650(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    14cf <nsrl_init+0x28f>
mov    -0x640(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1070 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1070 <fclose@plt>
cmpl   $0x0,-0x6a0(%rbp)
jle    1920 <nsrl_init+0x6e0>
lea    0xa1c(%rip),%rax
mov    %rax,-0x6b8(%rbp)
lea    0x9f6(%rip),%rax
mov    %rax,-0x6c0(%rbp)
lea    0x9f6(%rip),%rax
mov    %rax,-0x6c8(%rbp)
mov    -0x69c(%rbp),%esi
lea    0x9f6(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    -0x6a4(%rbp),%esi
lea    0xa00(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    -0x6a0(%rbp),%ecx
mov    -0x69c(%rbp),%edx
lea    0xa37(%rip),%rsi
lea    0x977(%rip),%rax
cmp    %edx,%ecx
cmove  %rax,%rsi
mov    -0x6a0(%rbp),%edx
lea    0xa00(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
lea    -0x630(%rbp),%rsi
lea    0xa14(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    -0x6c8(%rbp),%rdi
lea    -0x6d0(%rbp),%rsi
call   1120 <stat@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1804 <nsrl_init+0x5c4>
lea    -0x230(%rbp),%rdi
mov    -0x6c8(%rbp),%rcx
lea    -0x630(%rbp),%r8
lea    -0x430(%rbp),%r9
mov    $0x200,%esi
lea    0x9d8(%rip),%rdx
mov    $0x0,%al
call   10b0 <snprintf@plt>
jmp    18d9 <nsrl_init+0x699>
mov    -0x6c0(%rbp),%rdi
lea    -0x6d0(%rbp),%rsi
call   1120 <stat@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1859 <nsrl_init+0x619>
lea    -0x230(%rbp),%rdi
mov    -0x6c0(%rbp),%rcx
lea    -0x630(%rbp),%r8
lea    -0x430(%rbp),%r9
mov    $0x200,%esi
lea    0x983(%rip),%rdx
mov    $0x0,%al
call   10b0 <snprintf@plt>
jmp    18d4 <nsrl_init+0x694>
mov    -0x6b8(%rbp),%rdi
lea    -0x6d0(%rbp),%rsi
call   1120 <stat@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    18ae <nsrl_init+0x66e>
lea    -0x230(%rbp),%rdi
mov    -0x6b8(%rbp),%rcx
lea    -0x630(%rbp),%r8
lea    -0x430(%rbp),%r9
mov    $0x200,%esi
lea    0x92e(%rip),%rdx
mov    $0x0,%al
call   10b0 <snprintf@plt>
jmp    18cf <nsrl_init+0x68f>
mov    0x272b(%rip),%rax
mov    (%rax),%edi
lea    0x922(%rip),%rsi
mov    $0x0,%al
call   1110 <fprintf@plt>
mov    $0x1,%edi
call   1160 <exit@plt>
jmp    18d4 <nsrl_init+0x694>
jmp    18d9 <nsrl_init+0x699>
lea    -0x230(%rbp),%rdi
call   1090 <system@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     191b <nsrl_init+0x6db>
mov    0x26e6(%rip),%rax
mov    (%rax),%edi
lea    -0x230(%rbp),%rdx
lea    0x8f3(%rip),%rsi
mov    $0x0,%al
call   1110 <fprintf@plt>
mov    $0x1,%edi
call   1160 <exit@plt>
jmp    193b <nsrl_init+0x6fb>
mov    0x26b9(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0x8ec(%rip),%rsi
mov    $0x0,%al
call   1110 <fprintf@plt>
lea    -0x430(%rbp),%rdi
call   1040 <unlink@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     1976 <nsrl_init+0x736>
mov    0x2684(%rip),%rax
mov    (%rax),%edi
lea    0x8db(%rip),%rsi
mov    $0x0,%al
call   1110 <fprintf@plt>
mov    $0x1,%edi
call   1160 <exit@plt>
xor    %eax,%eax
add    $0x6e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nsrl_init>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x698,%rsp
mov    %esi,%r14d
mov    %rdi,%r13
movq   $0x0,0x18(%rsp)
test   $0x1,%r14b
jne    1279 <nsrl_init+0x39>
test   $0x2,%r14b
je     1717 <nsrl_init+0x4d7>
lea    0xd8d(%rip),%rbx
jmp    1280 <nsrl_init+0x40>
lea    0xd80(%rip),%rbx
mov    %r14d,%eax
shl    $0x1e,%eax
sar    $0x1f,%eax
and    $0x28,%eax
test   $0x1,%r14b
mov    $0x20,%ecx
cmove  %eax,%ecx
mov    %ecx,0x20(%rsp)
lea    0xd9f(%rip),%rsi
mov    %r13,%rdi
call   1140 <fopen@plt>
test   %rax,%rax
je     16b5 <nsrl_init+0x475>
mov    %rax,%r12
lea    0xda3(%rip),%rdx
lea    0x290(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x200,%esi
mov    %r13,%rcx
mov    %rbx,%r8
xor    %eax,%eax
call   10b0 <snprintf@plt>
lea    0xd8c(%rip),%rdx
lea    0x490(%rsp),%rdi
mov    $0x200,%esi
mov    %r13,%rcx
mov    %rbx,%r8
xor    %eax,%eax
call   10b0 <snprintf@plt>
lea    0xd75(%rip),%rsi
mov    %rbp,%rdi
call   1140 <fopen@plt>
test   %rax,%rax
je     16ca <nsrl_init+0x48a>
mov    %rax,%rbp
lea    0xd80(%rip),%rsi
lea    0xd80(%rip),%rdx
lea    0xda3(%rip),%rcx
mov    %ebp,%edi
xor    %eax,%eax
call   1110 <fprintf@plt>
lea    0xd98(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   10a0 <printf@plt>
mov    0x20(%rsp),%ebx
or     $0x1,%ebx
mov    %ebx,%edi
call   1130 <malloc@plt>
test   %rax,%rax
je     16f3 <nsrl_init+0x4b3>
mov    %rax,0x38(%rsp)
mov    %rax,%rdi
mov    $0x30,%esi
mov    %ebx,%edx
call   10c0 <memset@plt>
lea    0xd46(%rip),%rsi
lea    0x50(%rsp),%rdi
call   1060 <strcpy@plt>
lea    0x90(%rsp),%rdi
mov    $0x200,%esi
mov    %r12,%rdx
call   10f0 <fgets@plt>
test   %rax,%rax
mov    %r13,0x48(%rsp)
mov    %rbp,0x30(%rsp)
mov    %r12,0x40(%rsp)
je     1518 <nsrl_init+0x2d8>
mov    %ebx,0x2c(%rsp)
lea    0x90(%rsp),%rbx
mov    %rbx,%rdi
call   1080 <strlen@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
call   1100 <get_format_ver@plt>
mov    %eax,0x24(%rsp)
mov    %rbx,%rdi
mov    $0x200,%esi
mov    %r12,%rdx
call   10f0 <fgets@plt>
test   %rax,%rax
je     152c <nsrl_init+0x2ec>
mov    %r15d,%r13d
mov    $0x1,%ebp
lea    0x90(%rsp),%rbx
movl   $0x0,0x8(%rsp)
movl   $0x0,0xc(%rsp)
jmp    144c <nsrl_init+0x20c>
nopl   (%rax)
mov    %rbx,%rdi
lea    0x18(%rsp),%rsi
xor    %edx,%edx
mov    0x24(%rsp),%ecx
call   1150 <nsrl_extract_sha1@plt>
test   %rax,%rax
je     1480 <nsrl_init+0x240>
add    $0x1,%ebp
mov    %r12d,%eax
add    %rax,%r13
mov    %rbx,%rdi
mov    $0x200,%esi
mov    0x40(%rsp),%rdx
call   10f0 <fgets@plt>
test   %rax,%rax
je     1541 <nsrl_init+0x301>
mov    %rbx,%rdi
call   1080 <strlen@plt>
mov    %eax,%r12d
test   $0x2,%r14b
jne    1410 <nsrl_init+0x1d0>
test   $0x1,%r14b
je     1480 <nsrl_init+0x240>
mov    %rbx,%rdi
lea    0x18(%rsp),%rsi
xor    %edx,%edx
mov    0x24(%rsp),%ecx
call   10d0 <nsrl_extract_md5@plt>
test   %rax,%rax
jne    1428 <nsrl_init+0x1e8>
nopl   0x0(%rax,%rax,1)
mov    %ebp,0x28(%rsp)
addl   $0x1,0xc(%rsp)
mov    0x18(%rsp),%rdi
mov    0x38(%rsp),%rbp
mov    %rbp,%rsi
mov    0x20(%rsp),%edx
call   10e0 <memcmp@plt>
test   %rax,%rax
je     150f <nsrl_init+0x2cf>
lea    0x70(%rsp),%r15
mov    %r15,%rdi
mov    $0x11,%esi
lea    0xc64(%rip),%rdx
mov    %r13d,%ecx
xor    %eax,%eax
call   10b0 <snprintf@plt>
mov    %r15,%rdi
call   1080 <strlen@plt>
cltq
lea    0x60(%rsp),%rdi
sub    %rax,%rdi
mov    %r15,%rsi
call   1060 <strcpy@plt>
mov    0x18(%rsp),%rdx
mov    0x30(%rsp),%rdi
lea    0xbb1(%rip),%rsi
lea    0x50(%rsp),%rcx
xor    %eax,%eax
call   1110 <fprintf@plt>
addl   $0x1,0x8(%rsp)
mov    0x18(%rsp),%rsi
mov    %rbp,%rdi
mov    0x2c(%rsp),%edx
call   1050 <strncpy@plt>
mov    0x28(%rsp),%ebp
jmp    142b <nsrl_init+0x1eb>
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
xor    %ebp,%ebp
jmp    1541 <nsrl_init+0x301>
movl   $0x0,0xc(%rsp)
mov    $0x1,%ebp
movl   $0x0,0x8(%rsp)
mov    0x38(%rsp),%rdi
call   1030 <free@plt>
mov    0x40(%rsp),%rdi
call   1070 <fclose@plt>
mov    0x30(%rsp),%rdi
call   1070 <fclose@plt>
mov    0x8(%rsp),%ebx
test   %ebx,%ebx
jle    1673 <nsrl_init+0x433>
lea    0xbcf(%rip),%rdi
mov    0xc(%rsp),%r15d
mov    %r15d,%esi
xor    %eax,%eax
call   10a0 <printf@plt>
lea    0xbd7(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   10a0 <printf@plt>
cmp    %r15d,%ebx
lea    0xb5c(%rip),%rax
lea    0xc0e(%rip),%rsi
cmove  %rax,%rsi
lea    0xbe6(%rip),%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   10a0 <printf@plt>
lea    0xbff(%rip),%rdi
lea    0x490(%rsp),%rsi
xor    %eax,%eax
call   10a0 <printf@plt>
lea    0xb5a(%rip),%rbx
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1120 <stat@plt>
test   %rax,%rax
je     161b <nsrl_init+0x3db>
lea    0xb33(%rip),%rbx
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1120 <stat@plt>
test   %rax,%rax
je     161b <nsrl_init+0x3db>
lea    0xb32(%rip),%rbx
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1120 <stat@plt>
test   %rax,%rax
jne    1729 <nsrl_init+0x4e9>
lea    0xbae(%rip),%rdx
lea    0x90(%rsp),%rbp
lea    0x490(%rsp),%r8
lea    0x290(%rsp),%r9
mov    %rbp,%rdi
mov    $0x200,%esi
mov    %rbx,%rcx
xor    %eax,%eax
call   10b0 <snprintf@plt>
mov    %rbp,%rdi
call   1090 <system@plt>
test   %rax,%rax
je     168f <nsrl_init+0x44f>
mov    0x2980(%rip),%rax
mov    (%rax),%edi
lea    0xb94(%rip),%rsi
lea    0x90(%rsp),%rdx
jmp    16e2 <nsrl_init+0x4a2>
mov    0x2966(%rip),%rax
mov    (%rax),%edi
lea    0xb9d(%rip),%rsi
mov    0x48(%rsp),%rdx
xor    %eax,%eax
call   1110 <fprintf@plt>
lea    0x290(%rsp),%rdi
call   1040 <unlink@plt>
test   %rax,%rax
jne    1705 <nsrl_init+0x4c5>
xor    %eax,%eax
add    $0x698,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2924(%rip),%rax
mov    (%rax),%edi
lea    0x97f(%rip),%rsi
mov    %r13,%rdx
jmp    16e2 <nsrl_init+0x4a2>
mov    0x290f(%rip),%rax
mov    (%rax),%edi
lea    0x9a0(%rip),%rsi
lea    0x290(%rsp),%rdx
xor    %eax,%eax
call   1110 <fprintf@plt>
mov    $0x1,%edi
call   1160 <exit@plt>
mov    0x28e6(%rip),%rax
mov    (%rax),%edi
lea    0x9f5(%rip),%rsi
jmp    1739 <nsrl_init+0x4f9>
mov    0x28d4(%rip),%rax
mov    (%rax),%edi
lea    0xb2b(%rip),%rsi
jmp    1739 <nsrl_init+0x4f9>
mov    0x28c2(%rip),%rax
mov    (%rax),%edi
lea    0x8e2(%rip),%rsi
jmp    1739 <nsrl_init+0x4f9>
mov    0x28b0(%rip),%rax
mov    (%rax),%edi
lea    0xaa7(%rip),%rsi
xor    %eax,%eax
call   1110 <fprintf@plt>
mov    $0x1,%edi
call   1160 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [4 x i8] c"md5\00"
@.str.1 = [5 x i8] c"sha1\00"
@stderr = global i32 0
@.str.2 = [57 x i8] c"nsrl_init: At least one hashing algorithm must be given\0A\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [29 x i8] c"Error opening NSRL file: %s\0A\00"
@.str.5 = [13 x i8] c"%s-%s-ns.idx\00"
@.str.6 = [10 x i8] c"%s-%s.idx\00"
@.str.7 = [2 x i8] c"w\00"
@.str.8 = [36 x i8] c"Error creating NSRL index file: %s\0A\00"
@.str.9 = [7 x i8] c"%s|%s\0A\00"
@.str.10 = [42 x i8] c"00000000000000000000000000000000000000000\00"
@.str.11 = [5 x i8] c"nsrl\00"
@.str.12 = [36 x i8] c"Extracting Data from Database (%s)\0A\00"
@.str.13 = [36 x i8] c"nsrl_init: Error allocating memory\0A\00"
@.str.14 = [17 x i8] c"0000000000000000\00"
@.str.15 = [3 x i8] c"%i\00"
@.str.16 = [10 x i8] c"/bin/sort\00"
@.str.17 = [14 x i8] c"/usr/bin/sort\00"
@.str.18 = [20 x i8] c"/usr/local/bin/sort\00"
@.str.19 = [30 x i8] c" Valid Database Entries: %d\0A\00"
@.str.20 = [52 x i8] c" Invalid Database Entries (headers or errors): %d\0A\00"
@.str.21 = [29 x i8] c" Index File Entries %s: %d\0A\00"
@.str.22 = [1 x i8] zeroinitializer
@.str.23 = [12 x i8] c"(optimized)\00"
@.str.24 = [20 x i8] c"Sorting Index (%s)\0A\00"
@.str.25 = [16 x i8] c"%s -o \22%s\22 \22%s\22\00"
@.str.26 = [29 x i8] c"Error finding 'sort' binary\0A\00"
@.str.27 = [35 x i8] c"Error sorting index file using %s\0A\00"
@.str.28 = [32 x i8] c"Error parsing NSRL DB File: %s\0A\00"
@.str.29 = [37 x i8] c"Error removing temporary index file\0A\00"
define i32 @nsrl_init(i8* %0, i8 zeroext %1) {
%3 = alloca i8*
%4 = alloca i8
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca [512 x i8]
%10 = alloca [512 x i8]
%11 = alloca [512 x i8]
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i64
%16 = alloca [17 x i8]
%17 = alloca [17 x i8]
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i8*
%24 = alloca i8*
%25 = alloca i8*
%26 = alloca i8*
%27 = alloca %struct.stat
store i8* %0, i8** %3
store i8 %1, i8* %4
store i8* null, i8** %12
store i64 0, i64* %15
store i32 0, i32* %19
store i32 0, i32* %20
store i32 0, i32* %21
store i32 0, i32* %22
%28 = load i8, i8* %4
%29 = zext i8 %28 to i32
%30 = and i32 %29, 1
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %2
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %14
br label %44
33: ; preds = %2
%34 = load i8, i8* %4
%35 = zext i8 %34 to i32
%36 = and i32 %35, 2
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %33
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %14
br label %43
39: ; preds = %33
%40 = load i32, i32* @stderr
%41 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.2, i64 0, i64 0))
%42 = call i32 @exit(i32 1)
unreachable
43: ; preds = %38
br label %44
44: ; preds = %43, %32
%45 = load i8, i8* %4
%46 = zext i8 %45 to i32
%47 = and i32 %46, 1
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %50
49: ; preds = %44
br label %57
50: ; preds = %44
%51 = load i8, i8* %4
%52 = zext i8 %51 to i32
%53 = and i32 %52, 2
%54 = icmp ne i32 %53, 0
%55 = zext i1 %54 to i64
%56 = select i1 %54, i32 40, i32 0
br label %57
57: ; preds = %50, %49
%58 = phi i32 [ 32, %49 ], [ %56, %50 ]
store i32 %58, i32* %18
%59 = load i8*, i8** %3
%60 = call i32* @fopen(i8* %59, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %60, i32** %5
%61 = icmp eq i32* null, %60
br i1 %61, label %62, label %67
62: ; preds = %57
%63 = load i32, i32* @stderr
%64 = load i8*, i8** %3
%65 = call i32 (i32, i8*, ...) @fprintf(i32 %63, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i8* %64)
%66 = call i32 @exit(i32 1)
unreachable
67: ; preds = %57
%68 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%69 = load i8*, i8** %3
%70 = load i8*, i8** %14
%71 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %68, i32 512, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* %69, i8* %70)
%72 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%73 = load i8*, i8** %3
%74 = load i8*, i8** %14
%75 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %72, i32 512, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* %73, i8* %74)
%76 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%77 = call i32* @fopen(i8* %76, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32* %77, i32** %6
%78 = icmp eq i32* null, %77
br i1 %78, label %79, label %84
79: ; preds = %67
%80 = load i32, i32* @stderr
%81 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%82 = call i32 (i32, i8*, ...) @fprintf(i32 %80, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0), i8* %81)
%83 = call i32 @exit(i32 1)
unreachable
84: ; preds = %67
%85 = load i32*, i32** %6
%86 = ptrtoint i32* %85 to i32
%87 = call i32 (i32, i8*, ...) @fprintf(i32 %86, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
%88 = load i8*, i8** %3
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.12, i64 0, i64 0), i8* %88)
%90 = load i32, i32* %18
%91 = add nsw i32 %90, 1
%92 = call i8* @malloc(i32 %91)
store i8* %92, i8** %13
%93 = load i8*, i8** %13
%94 = icmp eq i8* %93, null
br i1 %94, label %95, label %99
95: ; preds = %84
%96 = load i32, i32* @stderr
%97 = call i32 (i32, i8*, ...) @fprintf(i32 %96, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.13, i64 0, i64 0))
%98 = call i32 @exit(i32 1)
unreachable
99: ; preds = %84
%100 = load i8*, i8** %13
%101 = load i32, i32* %18
%102 = add nsw i32 %101, 1
%103 = call i32 @memset(i8* %100, i32 48, i32 %102)
%104 = getelementptr inbounds [17 x i8], [17 x i8]* %16, i64 0, i64 0
%105 = call i32 @strcpy(i8* %104, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.14, i64 0, i64 0))
store i32 0, i32* %7
br label %106
106: ; preds = %186, %99
%107 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%108 = load i32*, i32** %5
%109 = call i32* @fgets(i8* %107, i32 512, i32* %108)
%110 = icmp ne i32* null, %109
br i1 %110, label %111, label %193
111: ; preds = %106
%112 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%113 = call i32 @strlen(i8* %112)
store i32 %113, i32* %8
%114 = load i32, i32* %7
%115 = icmp eq i32 %114, 0
br i1 %115, label %116, label %121
116: ; preds = %111
%117 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%118 = call i32 @get_format_ver(i8* %117)
store i32 %118, i32* %19
%119 = load i32, i32* %22
%120 = add nsw i32 %119, 1
store i32 %120, i32* %22
br label %186
121: ; preds = %111
%122 = load i8, i8* %4
%123 = zext i8 %122 to i32
%124 = and i32 %123, 2
%125 = icmp ne i32 %124, 0
br i1 %125, label %126, label %135
126: ; preds = %121
%127 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%128 = load i32, i32* %19
%129 = call i64 @nsrl_extract_sha1(i8* %127, i8** %12, i32* null, i32 %128)
%130 = icmp ne i64 %129, 0
br i1 %130, label %131, label %134
131: ; preds = %126
%132 = load i32, i32* %22
%133 = add nsw i32 %132, 1
store i32 %133, i32* %22
br label %186
134: ; preds = %126
br label %150
135: ; preds = %121
%136 = load i8, i8* %4
%137 = zext i8 %136 to i32
%138 = and i32 %137, 1
%139 = icmp ne i32 %138, 0
br i1 %139, label %140, label %149
140: ; preds = %135
%141 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%142 = load i32, i32* %19
%143 = call i64 @nsrl_extract_md5(i8* %141, i8** %12, i32* null, i32 %142)
%144 = icmp ne i64 %143, 0
br i1 %144, label %145, label %148
145: ; preds = %140
%146 = load i32, i32* %22
%147 = add nsw i32 %146, 1
store i32 %147, i32* %22
br label %186
148: ; preds = %140
br label %149
149: ; preds = %148, %135
br label %150
150: ; preds = %149, %134
%151 = load i32, i32* %20
%152 = add nsw i32 %151, 1
store i32 %152, i32* %20
%153 = load i8*, i8** %12
%154 = load i8*, i8** %13
%155 = load i32, i32* %18
%156 = call i64 @memcmp(i8* %153, i8* %154, i32 %155)
%157 = icmp eq i64 %156, 0
br i1 %157, label %158, label %159
158: ; preds = %150
br label %186
159: ; preds = %150
%160 = getelementptr inbounds [17 x i8], [17 x i8]* %17, i64 0, i64 0
%161 = load i64, i64* %15
%162 = trunc i64 %161 to i32
%163 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %160, i32 17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i64 0, i64 0), i32 %162)
%164 = getelementptr inbounds [17 x i8], [17 x i8]* %16, i64 0, i64 0
%165 = getelementptr inbounds i8, i8* %164, i64 16
%166 = getelementptr inbounds [17 x i8], [17 x i8]* %17, i64 0, i64 0
%167 = call i32 @strlen(i8* %166)
%168 = sext i32 %167 to i64
%169 = sub i64 0, %168
%170 = getelementptr inbounds i8, i8* %165, i64 %169
store i8* %170, i8** %23
%171 = load i8*, i8** %23
%172 = getelementptr inbounds [17 x i8], [17 x i8]* %17, i64 0, i64 0
%173 = call i32 @strcpy(i8* %171, i8* %172)
%174 = load i32*, i32** %6
%175 = ptrtoint i32* %174 to i32
%176 = load i8*, i8** %12
%177 = getelementptr inbounds [17 x i8], [17 x i8]* %16, i64 0, i64 0
%178 = call i32 (i32, i8*, ...) @fprintf(i32 %175, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i8* %176, i8* %177)
%179 = load i32, i32* %21
%180 = add nsw i32 %179, 1
store i32 %180, i32* %21
%181 = load i8*, i8** %13
%182 = load i8*, i8** %12
%183 = load i32, i32* %18
%184 = add nsw i32 %183, 1
%185 = call i32 @strncpy(i8* %181, i8* %182, i32 %184)
br label %186
186: ; preds = %159, %158, %145, %131, %116
%187 = load i32, i32* %8
%188 = sext i32 %187 to i64
%189 = load i64, i64* %15
%190 = add nsw i64 %189, %188
store i64 %190, i64* %15
%191 = load i32, i32* %7
%192 = add nsw i32 %191, 1
store i32 %192, i32* %7
br label %106
193: ; preds = %106
%194 = load i8*, i8** %13
%195 = call i32 @free(i8* %194)
%196 = load i32*, i32** %5
%197 = call i32 @fclose(i32* %196)
%198 = load i32*, i32** %6
%199 = call i32 @fclose(i32* %198)
%200 = load i32, i32* %21
%201 = icmp sgt i32 %200, 0
br i1 %201, label %202, label %261
202: ; preds = %193
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.16, i64 0, i64 0), i8** %24
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.17, i64 0, i64 0), i8** %25
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.18, i64 0, i64 0), i8** %26
%203 = load i32, i32* %20
%204 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.19, i64 0, i64 0), i32 %203)
%205 = load i32, i32* %22
%206 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.20, i64 0, i64 0), i32 %205)
%207 = load i32, i32* %21
%208 = load i32, i32* %20
%209 = icmp eq i32 %207, %208
%210 = zext i1 %209 to i64
%211 = select i1 %209, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.22, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.23, i64 0, i64 0)
%212 = load i32, i32* %21
%213 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.21, i64 0, i64 0), i8* %211, i32 %212)
%214 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%215 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.24, i64 0, i64 0), i8* %214)
%216 = load i8*, i8** %26
%217 = call i64 @stat(i8* %216, %struct.stat* %27)
%218 = icmp eq i64 0, %217
br i1 %218, label %219, label %225
219: ; preds = %202
%220 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%221 = load i8*, i8** %26
%222 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%223 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%224 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %220, i32 512, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.25, i64 0, i64 0), i8* %221, i8* %222, i8* %223)
br label %251
225: ; preds = %202
%226 = load i8*, i8** %25
%227 = call i64 @stat(i8* %226, %struct.stat* %27)
%228 = icmp eq i64 0, %227
br i1 %228, label %229, label %235
229: ; preds = %225
%230 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%231 = load i8*, i8** %25
%232 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%233 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%234 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %230, i32 512, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.25, i64 0, i64 0), i8* %231, i8* %232, i8* %233)
br label %250
235: ; preds = %225
%236 = load i8*, i8** %24
%237 = call i64 @stat(i8* %236, %struct.stat* %27)
%238 = icmp eq i64 0, %237
br i1 %238, label %239, label %245
239: ; preds = %235
%240 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%241 = load i8*, i8** %24
%242 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%243 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%244 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %240, i32 512, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.25, i64 0, i64 0), i8* %241, i8* %242, i8* %243)
br label %249
245: ; preds = %235
%246 = load i32, i32* @stderr
%247 = call i32 (i32, i8*, ...) @fprintf(i32 %246, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.26, i64 0, i64 0))
%248 = call i32 @exit(i32 1)
unreachable
249: ; preds = %239
br label %250
250: ; preds = %249, %229
br label %251
251: ; preds = %250, %219
%252 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%253 = call i64 @system(i8* %252)
%254 = icmp ne i64 0, %253
br i1 %254, label %255, label %260
255: ; preds = %251
%256 = load i32, i32* @stderr
%257 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%258 = call i32 (i32, i8*, ...) @fprintf(i32 %256, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.27, i64 0, i64 0), i8* %257)
%259 = call i32 @exit(i32 1)
unreachable
260: ; preds = %251
br label %265
261: ; preds = %193
%262 = load i32, i32* @stderr
%263 = load i8*, i8** %3
%264 = call i32 (i32, i8*, ...) @fprintf(i32 %262, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.28, i64 0, i64 0), i8* %263)
br label %265
265: ; preds = %261, %260
%266 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%267 = call i64 @unlink(i8* %266)
%268 = icmp ne i64 0, %267
br i1 %268, label %269, label %273
269: ; preds = %265
%270 = load i32, i32* @stderr
%271 = call i32 (i32, i8*, ...) @fprintf(i32 %270, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.29, i64 0, i64 0))
%272 = call i32 @exit(i32 1)
unreachable
273: ; preds = %265
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [4 x i8] c"md5\00"
@.str.1 = [5 x i8] c"sha1\00"
@stderr = global i32 0
@.str.2 = [57 x i8] c"nsrl_init: At least one hashing algorithm must be given\0A\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [29 x i8] c"Error opening NSRL file: %s\0A\00"
@.str.5 = [13 x i8] c"%s-%s-ns.idx\00"
@.str.6 = [10 x i8] c"%s-%s.idx\00"
@.str.7 = [2 x i8] c"w\00"
@.str.8 = [36 x i8] c"Error creating NSRL index file: %s\0A\00"
@.str.9 = [7 x i8] c"%s|%s\0A\00"
@.str.10 = [42 x i8] c"00000000000000000000000000000000000000000\00"
@.str.11 = [5 x i8] c"nsrl\00"
@.str.12 = [36 x i8] c"Extracting Data from Database (%s)\0A\00"
@.str.13 = [36 x i8] c"nsrl_init: Error allocating memory\0A\00"
@.str.14 = [17 x i8] c"0000000000000000\00"
@.str.15 = [3 x i8] c"%i\00"
@.str.16 = [10 x i8] c"/bin/sort\00"
@.str.17 = [14 x i8] c"/usr/bin/sort\00"
@.str.18 = [20 x i8] c"/usr/local/bin/sort\00"
@.str.19 = [30 x i8] c" Valid Database Entries: %d\0A\00"
@.str.20 = [52 x i8] c" Invalid Database Entries (headers or errors): %d\0A\00"
@.str.21 = [29 x i8] c" Index File Entries %s: %d\0A\00"
@.str.22 = [1 x i8] zeroinitializer
@.str.23 = [12 x i8] c"(optimized)\00"
@.str.24 = [20 x i8] c"Sorting Index (%s)\0A\00"
@.str.25 = [16 x i8] c"%s -o \22%s\22 \22%s\22\00"
@.str.26 = [29 x i8] c"Error finding 'sort' binary\0A\00"
@.str.27 = [35 x i8] c"Error sorting index file using %s\0A\00"
@.str.28 = [32 x i8] c"Error parsing NSRL DB File: %s\0A\00"
@.str.29 = [37 x i8] c"Error removing temporary index file\0A\00"
define i32 @nsrl_init(i8* %0, i8 zeroext %1) {
%3 = alloca [512 x i8]
%4 = alloca [512 x i8]
%5 = alloca [512 x i8]
%6 = alloca i8*
%7 = alloca [17 x i8]
%8 = alloca [17 x i8]
%9 = alloca %struct.stat
%10 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%11 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%12 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%13 = bitcast i8** %6 to i8*
store i8* null, i8** %6
%14 = getelementptr inbounds [17 x i8], [17 x i8]* %7, i64 0, i64 0
%15 = getelementptr inbounds [17 x i8], [17 x i8]* %8, i64 0, i64 0
%16 = zext i8 %1 to i32
%17 = and i32 %16, 1
%18 = icmp eq i32 %17, 0
%19 = and i32 %16, 2
br i1 %18, label %20, label %26
20: ; preds = %2
%21 = icmp eq i32 %19, 0
br i1 %21, label %22, label %26
22: ; preds = %20
%23 = load i32, i32* @stderr
%24 = tail call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.2, i64 0, i64 0))
%25 = tail call i32 @exit(i32 1)
unreachable
26: ; preds = %2, %20
%27 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %20 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), %2 ]
%28 = icmp eq i32 %19, 0
%29 = select i1 %28, i32 0, i32 40
%30 = select i1 %18, i32 %29, i32 32
%31 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%32 = icmp eq i32* %31, null
br i1 %32, label %33, label %37
33: ; preds = %26
%34 = load i32, i32* @stderr
%35 = tail call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i8* %0)
%36 = tail call i32 @exit(i32 1)
unreachable
37: ; preds = %26
%38 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %11, i32 512, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* %0, i8* %27)
%39 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %12, i32 512, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* %0, i8* %27)
%40 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%41 = icmp eq i32* %40, null
br i1 %41, label %42, label %46
42: ; preds = %37
%43 = load i32, i32* @stderr
%44 = call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0), i8* %11)
%45 = call i32 @exit(i32 1)
unreachable
46: ; preds = %37
%47 = ptrtoint i32* %40 to i64
%48 = trunc i64 %47 to i32
%49 = call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.12, i64 0, i64 0), i8* %0)
%51 = or i32 %30, 1
%52 = call i8* @malloc(i32 %51)
%53 = icmp eq i8* %52, null
br i1 %53, label %54, label %58
54: ; preds = %46
%55 = load i32, i32* @stderr
%56 = call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.13, i64 0, i64 0))
%57 = call i32 @exit(i32 1)
unreachable
58: ; preds = %46
%59 = call i32 @memset(i8* %52, i32 48, i32 %51)
%60 = call i32 @strcpy(i8* %14, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.14, i64 0, i64 0))
%61 = call i32* @fgets(i8* %10, i32 512, i32* %31)
%62 = icmp eq i32* %61, null
br i1 %62, label %114, label %63
63: ; preds = %58
%64 = getelementptr inbounds [17 x i8], [17 x i8]* %7, i64 0, i64 16
%65 = call i32 @strlen(i8* %10)
%66 = call i32 @get_format_ver(i8* %10)
%67 = call i32* @fgets(i8* %10, i32 512, i32* %31)
%68 = icmp eq i32* %67, null
br i1 %68, label %114, label %69
69: ; preds = %63
%70 = zext i32 %65 to i64
br label %71
71: ; preds = %106, %69
%72 = phi i64 [ %70, %69 ], [ %111, %106 ]
%73 = phi i32 [ 1, %69 ], [ %109, %106 ]
%74 = phi i32 [ 0, %69 ], [ %108, %106 ]
%75 = phi i32 [ 0, %69 ], [ %107, %106 ]
%76 = call i32 @strlen(i8* %10)
br i1 %28, label %82, label %77
77: ; preds = %71
%78 = call i64 @nsrl_extract_sha1(i8* %10, i8** %6, i32* null, i32 %66)
%79 = icmp eq i64 %78, 0
br i1 %79, label %88, label %80
80: ; preds = %77
%81 = add nsw i32 %73, 1
br label %106
82: ; preds = %71
br i1 %18, label %88, label %83
83: ; preds = %82
%84 = call i64 @nsrl_extract_md5(i8* %10, i8** %6, i32* null, i32 %66)
%85 = icmp eq i64 %84, 0
br i1 %85, label %88, label %86
86: ; preds = %83
%87 = add nsw i32 %73, 1
br label %106
88: ; preds = %82, %83, %77
%89 = add nsw i32 %75, 1
%90 = load i8*, i8** %6
%91 = call i64 @memcmp(i8* %90, i8* %52, i32 %30)
%92 = icmp eq i64 %91, 0
br i1 %92, label %106, label %93
93: ; preds = %88
%94 = trunc i64 %72 to i32
%95 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %15, i32 17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i64 0, i64 0), i32 %94)
%96 = call i32 @strlen(i8* %15)
%97 = sext i32 %96 to i64
%98 = sub nsw i64 0, %97
%99 = getelementptr inbounds i8, i8* %64, i64 %98
%100 = call i32 @strcpy(i8* %99, i8* %15)
%101 = load i8*, i8** %6
%102 = call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i8* %101, i8* %14)
%103 = add nsw i32 %74, 1
%104 = load i8*, i8** %6
%105 = call i32 @strncpy(i8* %52, i8* %104, i32 %51)
br label %106
106: ; preds = %88, %93, %86, %80
%107 = phi i32 [ %75, %80 ], [ %89, %93 ], [ %75, %86 ], [ %89, %88 ]
%108 = phi i32 [ %74, %80 ], [ %103, %93 ], [ %74, %86 ], [ %74, %88 ]
%109 = phi i32 [ %81, %80 ], [ %73, %93 ], [ %87, %86 ], [ %73, %88 ]
%110 = zext i32 %76 to i64
%111 = add i64 %72, %110
%112 = call i32* @fgets(i8* %10, i32 512, i32* %31)
%113 = icmp eq i32* %112, null
br i1 %113, label %114, label %71
114: ; preds = %106, %63, %58
%115 = phi i32 [ 0, %58 ], [ 0, %63 ], [ %107, %106 ]
%116 = phi i32 [ 0, %58 ], [ 0, %63 ], [ %108, %106 ]
%117 = phi i32 [ 0, %58 ], [ 1, %63 ], [ %109, %106 ]
%118 = call i32 @free(i8* %52)
%119 = call i32 @fclose(i32* %31)
%120 = call i32 @fclose(i32* %40)
%121 = icmp sgt i32 %116, 0
br i1 %121, label %122, label %152
122: ; preds = %114
%123 = bitcast %struct.stat* %9 to i8*
%124 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.19, i64 0, i64 0), i32 %115)
%125 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.20, i64 0, i64 0), i32 %117)
%126 = icmp eq i32 %116, %115
%127 = select i1 %126, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.22, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.23, i64 0, i64 0)
%128 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.21, i64 0, i64 0), i8* %127, i32 %116)
%129 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.24, i64 0, i64 0), i8* %12)
%130 = call i64 @stat(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.18, i64 0, i64 0), %struct.stat* %9)
%131 = icmp eq i64 %130, 0
br i1 %131, label %142, label %132
132: ; preds = %122
%133 = call i64 @stat(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.17, i64 0, i64 0), %struct.stat* %9)
%134 = icmp eq i64 %133, 0
br i1 %134, label %142, label %135
135: ; preds = %132
%136 = call i64 @stat(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.16, i64 0, i64 0), %struct.stat* %9)
%137 = icmp eq i64 %136, 0
br i1 %137, label %142, label %138
138: ; preds = %135
%139 = load i32, i32* @stderr
%140 = call i32 (i32, i8*, ...) @fprintf(i32 %139, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.26, i64 0, i64 0))
%141 = call i32 @exit(i32 1)
unreachable
142: ; preds = %135, %132, %122
%143 = phi i8* [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.18, i64 0, i64 0), %122 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.17, i64 0, i64 0), %132 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.16, i64 0, i64 0), %135 ]
%144 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %10, i32 512, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.25, i64 0, i64 0), i8* %143, i8* %12, i8* %11)
%145 = call i64 @system(i8* %10)
%146 = icmp eq i64 %145, 0
br i1 %146, label %151, label %147
147: ; preds = %142
%148 = load i32, i32* @stderr
%149 = call i32 (i32, i8*, ...) @fprintf(i32 %148, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.27, i64 0, i64 0), i8* %10)
%150 = call i32 @exit(i32 1)
unreachable
151: ; preds = %142
br label %155
152: ; preds = %114
%153 = load i32, i32* @stderr
%154 = call i32 (i32, i8*, ...) @fprintf(i32 %153, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.28, i64 0, i64 0), i8* %0)
br label %155
155: ; preds = %152, %151
%156 = call i64 @unlink(i8* %11)
%157 = icmp eq i64 %156, 0
br i1 %157, label %162, label %158
158: ; preds = %155
%159 = load i32, i32* @stderr
%160 = call i32 (i32, i8*, ...) @fprintf(i32 %159, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.29, i64 0, i64 0))
%161 = call i32 @exit(i32 1)
unreachable
162: ; preds = %155
ret i32 0
}