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

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int get_format_ver(char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
scalar_t__ nsrl_extract_md5(char *, char **, char **, int);
scalar_t__ nsrl_extract_sha1(char *, char **, char **, int);
int /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcasecmp(char *, char *);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
void nsrl_print(char *db_file, char *hash, off_t offset, int flags) {
  FILE *hFile;
  char buf[512], *name, *cur_hash, pname[512];
  int found = 0;
  int hash_len, ver;
  hash_len = strlen(hash);
  if ((hash_len != 40) && (hash_len != 32)) {
    fprintf(stderr, "nsrl_print: Invalid hash value: %s\n", hash);
    exit(1);
  }
  if (NULL == (hFile = fopen(db_file, "r"))) {
    fprintf(stderr, "nsrl_print: Error opening NSRL DB file: %s\n", db_file);
    return;
  }
  if (NULL == fgets(buf, 512, hFile)) {
    fprintf(stderr, "nsrl_init: Error reading NSRLFile.txt\n");
    exit(1);
  }
  ver = get_format_ver(buf);
  memset(pname, '0', 512);
  while (1) {
    int len;
    if (0 != fseek(hFile, offset, SEEK_SET)) {
      fprintf(stderr, "nsrl_print: Error seeking to get file name: %lu\n",
              (unsigned long)offset);
      exit(1);
    }
    if (NULL == fgets(buf, 512, hFile)) {
      if (feof(hFile))
        break;
      fprintf(stderr, "nsrl_print: Error reading database\n");
      exit(1);
    }
    len = strlen(buf);
    if (len < 40 + 5) {
      fprintf(stderr, "nsrl_print: Invalid entry in database (too short)\n");
      exit(1);
    }
    if (hash_len == 40) {
      if (nsrl_extract_sha1(buf, &cur_hash, &name, ver)) {
        fprintf(stderr, "nsrl_print: Invalid entry in database\n");
        exit(1);
      }
    } else if (hash_len == 32) {
      if (nsrl_extract_md5(buf, &cur_hash, &name, ver)) {
        fprintf(stderr, "nsrl_print: Invalid entry in database\n");
        exit(1);
      }
    }
    if (0 != strcasecmp(cur_hash, hash)) {
      break;
    }
    if (strcmp(name, pname) != 0) {
      printf("%s\t%s\n", hash, name);
      found = 1;
      strncpy(pname, name, 512);
    }
    offset += len;
  }
  if (found == 0) {
    fprintf(stderr, "Hash not found in file at offset: %lu\n",
            (unsigned long)offset);
    exit(1);
  }
  fclose(hFile);
  return;
}


x86 assembly (clang, -O0):
<nsrl_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movl   $0x0,-0x434(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x438(%rbp)
cmpl   $0x28,-0x438(%rbp)
je     1271 <nsrl_print+0x71>
cmpl   $0x20,-0x438(%rbp)
je     1271 <nsrl_print+0x71>
mov    0x2d8d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xda0(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    -0x8(%rbp),%rdi
lea    0xda8(%rip),%rsi
call   1100 <fopen@plt>
mov    %rax,%rcx
mov    %rcx,-0x20(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
jne    12b3 <nsrl_print+0xb3>
mov    0x2d46(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xd7f(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
jmp    1587 <nsrl_print+0x387>
lea    -0x220(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x200,%esi
call   10a0 <fgets@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    12f7 <nsrl_print+0xf7>
mov    0x2d03(%rip),%rax
mov    (%rax),%edi
lea    0xd6c(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
lea    -0x220(%rbp),%rdi
call   10c0 <get_format_ver@plt>
mov    %eax,-0x43c(%rbp)
lea    -0x430(%rbp),%rdi
mov    $0x30,%esi
mov    $0x200,%edx
call   1080 <memset@plt>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    0x2cab(%rip),%rax
mov    (%rax),%edx
call   10f0 <fseek@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     1367 <nsrl_print+0x167>
mov    0x2c97(%rip),%rax
mov    (%rax),%edi
movslq -0x14(%rbp),%rdx
lea    0xd23(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
lea    -0x220(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x200,%esi
call   10a0 <fgets@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    13c3 <nsrl_print+0x1c3>
mov    -0x20(%rbp),%rdi
call   10e0 <feof@plt>
cmp    $0x0,%rax
je     13a2 <nsrl_print+0x1a2>
jmp    154c <nsrl_print+0x34c>
mov    0x2c37(%rip),%rax
mov    (%rax),%edi
lea    0xcf8(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
lea    -0x220(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x440(%rbp)
cmpl   $0x2d,-0x440(%rbp)
jge    1403 <nsrl_print+0x203>
mov    0x2bf7(%rip),%rax
mov    (%rax),%edi
lea    0xcdc(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
cmpl   $0x28,-0x438(%rbp)
jne    1460 <nsrl_print+0x260>
lea    -0x220(%rbp),%rdi
mov    -0x43c(%rbp),%ecx
lea    -0x230(%rbp),%rsi
lea    -0x228(%rbp),%rdx
call   1110 <nsrl_extract_sha1@plt>
cmp    $0x0,%rax
je     145b <nsrl_print+0x25b>
mov    0x2b9f(%rip),%rax
mov    (%rax),%edi
lea    0xcb7(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
jmp    14c2 <nsrl_print+0x2c2>
cmpl   $0x20,-0x438(%rbp)
jne    14bd <nsrl_print+0x2bd>
lea    -0x220(%rbp),%rdi
mov    -0x43c(%rbp),%ecx
lea    -0x230(%rbp),%rsi
lea    -0x228(%rbp),%rdx
call   1090 <nsrl_extract_md5@plt>
cmp    $0x0,%rax
je     14b8 <nsrl_print+0x2b8>
mov    0x2b42(%rip),%rax
mov    (%rax),%edi
lea    0xc5a(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
jmp    14bd <nsrl_print+0x2bd>
jmp    14c2 <nsrl_print+0x2c2>
mov    -0x230(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcasecmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     14e5 <nsrl_print+0x2e5>
jmp    154c <nsrl_print+0x34c>
mov    -0x228(%rbp),%rdi
lea    -0x430(%rbp),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
je     153b <nsrl_print+0x33b>
mov    -0x10(%rbp),%rsi
mov    -0x228(%rbp),%rdx
lea    0xc14(%rip),%rdi
call   1070 <printf@plt>
movl   $0x1,-0x434(%rbp)
lea    -0x430(%rbp),%rdi
mov    -0x228(%rbp),%rsi
mov    $0x200,%edx
call   1040 <strncpy@plt>
mov    -0x440(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    131f <nsrl_print+0x11f>
cmpl   $0x0,-0x434(%rbp)
jne    157e <nsrl_print+0x37e>
mov    0x2a80(%rip),%rax
mov    (%rax),%edi
movslq -0x14(%rbp),%rdx
lea    0xbc2(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nsrl_print>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x428,%rsp
mov    %edx,%r12d
mov    %rdi,%rbp
mov    %rsi,0x10(%rsp)
mov    %rsi,%rdi
call   1060 <strlen@plt>
mov    %eax,%r15d
and    $0xfffffff7,%eax
cmp    $0x20,%eax
jne    145d <nsrl_print+0x25d>
lea    0xdea(%rip),%rsi
mov    %rbp,%rdi
call   1100 <fopen@plt>
test   %rax,%rax
je     13c9 <nsrl_print+0x1c9>
mov    %rax,%rbx
lea    0x20(%rsp),%rdi
mov    $0x200,%esi
mov    %rax,%rdx
call   10a0 <fgets@plt>
test   %rax,%rax
je     1474 <nsrl_print+0x274>
lea    0x20(%rsp),%rdi
call   10c0 <get_format_ver@plt>
mov    %eax,(%rsp)
lea    0x220(%rsp),%rdi
mov    $0x30,%esi
mov    $0x200,%edx
call   1080 <memset@plt>
mov    0x2d44(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    %r12d,%esi
call   10f0 <fseek@plt>
test   %rax,%rax
jne    1486 <nsrl_print+0x286>
movl   $0x0,0x4(%rsp)
lea    0x20(%rsp),%r13
jmp    12e2 <nsrl_print+0xe2>
nopl   0x0(%rax)
add    %r12d,%ebp
mov    0x2d0e(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    %ebp,%esi
call   10f0 <fseek@plt>
mov    %ebp,%r12d
test   %rax,%rax
jne    1489 <nsrl_print+0x289>
mov    %r13,%rdi
mov    $0x200,%esi
mov    %rbx,%rdx
call   10a0 <fgets@plt>
test   %rax,%rax
je     13f4 <nsrl_print+0x1f4>
mov    %r13,%rdi
call   1060 <strlen@plt>
cmp    $0x2c,%eax
jle    142a <nsrl_print+0x22a>
mov    %eax,%ebp
cmp    $0x20,%r15d
je     1340 <nsrl_print+0x140>
cmp    $0x28,%r15d
jne    135e <nsrl_print+0x15e>
mov    %r13,%rdi
lea    0x18(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    (%rsp),%ecx
call   1110 <nsrl_extract_sha1@plt>
jmp    1355 <nsrl_print+0x155>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
lea    0x18(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    (%rsp),%ecx
call   1090 <nsrl_extract_md5@plt>
test   %rax,%rax
jne    143c <nsrl_print+0x23c>
mov    0x18(%rsp),%rdi
mov    0x10(%rsp),%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
jne    1405 <nsrl_print+0x205>
mov    0x8(%rsp),%rdi
lea    0x220(%rsp),%r14
mov    %r14,%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
je     12c0 <nsrl_print+0xc0>
mov    0x8(%rsp),%rdx
lea    0xd88(%rip),%rdi
mov    0x10(%rsp),%rsi
call   1070 <printf@plt>
mov    0x8(%rsp),%rsi
mov    %r14,%rdi
mov    $0x200,%edx
call   1040 <strncpy@plt>
movl   $0x1,0x4(%rsp)
jmp    12c0 <nsrl_print+0xc0>
mov    0x2c10(%rip),%rax
mov    (%rax),%edi
lea    0xc4d(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
add    $0x428,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    10d0 <fprintf@plt>
mov    %rbx,%rdi
call   10e0 <feof@plt>
test   %rax,%rax
je     14c2 <nsrl_print+0x2c2>
cmpl   $0x0,0x4(%rsp)
je     14ad <nsrl_print+0x2ad>
mov    %rbx,%rdi
call   1050 <fclose@plt>
add    $0x428,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2baf(%rip),%rax
mov    (%rax),%edi
lea    0xc94(%rip),%rsi
jmp    144c <nsrl_print+0x24c>
mov    0x2b9d(%rip),%rax
mov    (%rax),%edi
lea    0xcb5(%rip),%rsi
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    0x2b7c(%rip),%rax
mov    (%rax),%edi
lea    0xb93(%rip),%rsi
mov    0x10(%rsp),%rdx
jmp    149c <nsrl_print+0x29c>
mov    0x2b65(%rip),%rax
mov    (%rax),%edi
lea    0xbce(%rip),%rsi
jmp    144c <nsrl_print+0x24c>
mov    %r12d,%ebp
mov    0x2b50(%rip),%rax
mov    (%rax),%edi
movslq %ebp,%rdx
lea    0xbdd(%rip),%rsi
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    0x2b2c(%rip),%rax
mov    (%rax),%edi
movslq %r12d,%rdx
lea    0xc6f(%rip),%rsi
jmp    149c <nsrl_print+0x29c>
mov    0x2b17(%rip),%rax
mov    (%rax),%edi
lea    0xbd8(%rip),%rsi
jmp    144c <nsrl_print+0x24c>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [36 x i8] c"nsrl_print: Invalid hash value: %s\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [44 x i8] c"nsrl_print: Error opening NSRL DB file: %s\0A\00"
@.str.3 = [39 x i8] c"nsrl_init: Error reading NSRLFile.txt\0A\00"
@SEEK_SET = global i32 0
@.str.4 = [49 x i8] c"nsrl_print: Error seeking to get file name: %lu\0A\00"
@.str.5 = [36 x i8] c"nsrl_print: Error reading database\0A\00"
@.str.6 = [51 x i8] c"nsrl_print: Invalid entry in database (too short)\0A\00"
@.str.7 = [39 x i8] c"nsrl_print: Invalid entry in database\0A\00"
@.str.8 = [7 x i8] c"%s\09%s\0A\00"
@.str.9 = [39 x i8] c"Hash not found in file at offset: %lu\0A\00"
define void @nsrl_print(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca [512 x i8]
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca [512 x i8]
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i32 0, i32* %14
%18 = load i8*, i8** %6
%19 = call i32 @strlen(i8* %18)
store i32 %19, i32* %15
%20 = load i32, i32* %15
%21 = icmp ne i32 %20, 40
br i1 %21, label %22, label %30
22: ; preds = %4
%23 = load i32, i32* %15
%24 = icmp ne i32 %23, 32
br i1 %24, label %25, label %30
25: ; preds = %22
%26 = load i32, i32* @stderr
%27 = load i8*, i8** %6
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %27)
%29 = call i32 @exit(i32 1)
unreachable
30: ; preds = %22, %4
%31 = load i8*, i8** %5
%32 = call i32* @fopen(i8* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %32, i32** %9
%33 = icmp eq i32* null, %32
br i1 %33, label %34, label %38
34: ; preds = %30
%35 = load i32, i32* @stderr
%36 = load i8*, i8** %5
%37 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* %36)
br label %148
38: ; preds = %30
%39 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%40 = load i32*, i32** %9
%41 = call i32* @fgets(i8* %39, i32 512, i32* %40)
%42 = icmp eq i32* null, %41
br i1 %42, label %43, label %47
43: ; preds = %38
%44 = load i32, i32* @stderr
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0))
%46 = call i32 @exit(i32 1)
unreachable
47: ; preds = %38
%48 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%49 = call i32 @get_format_ver(i8* %48)
store i32 %49, i32* %16
%50 = getelementptr inbounds [512 x i8], [512 x i8]* %13, i64 0, i64 0
%51 = call i32 @memset(i8* %50, i32 48, i32 512)
br label %52
52: ; preds = %47, %132
%53 = load i32*, i32** %9
%54 = load i32, i32* %7
%55 = load i32, i32* @SEEK_SET
%56 = call i64 @fseek(i32* %53, i32 %54, i32 %55)
%57 = icmp ne i64 0, %56
br i1 %57, label %58, label %64
58: ; preds = %52
%59 = load i32, i32* @stderr
%60 = load i32, i32* %7
%61 = sext i32 %60 to i64
%62 = call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0), i64 %61)
%63 = call i32 @exit(i32 1)
unreachable
64: ; preds = %52
%65 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%66 = load i32*, i32** %9
%67 = call i32* @fgets(i8* %65, i32 512, i32* %66)
%68 = icmp eq i32* null, %67
br i1 %68, label %69, label %78
69: ; preds = %64
%70 = load i32*, i32** %9
%71 = call i64 @feof(i32* %70)
%72 = icmp ne i64 %71, 0
br i1 %72, label %73, label %74
73: ; preds = %69
br label %136
74: ; preds = %69
%75 = load i32, i32* @stderr
%76 = call i32 (i32, i8*, ...) @fprintf(i32 %75, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0))
%77 = call i32 @exit(i32 1)
unreachable
78: ; preds = %64
%79 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%80 = call i32 @strlen(i8* %79)
store i32 %80, i32* %17
%81 = load i32, i32* %17
%82 = icmp slt i32 %81, 45
br i1 %82, label %83, label %87
83: ; preds = %78
%84 = load i32, i32* @stderr
%85 = call i32 (i32, i8*, ...) @fprintf(i32 %84, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.6, i64 0, i64 0))
%86 = call i32 @exit(i32 1)
unreachable
87: ; preds = %78
%88 = load i32, i32* %15
%89 = icmp eq i32 %88, 40
br i1 %89, label %90, label %100
90: ; preds = %87
%91 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%92 = load i32, i32* %16
%93 = call i64 @nsrl_extract_sha1(i8* %91, i8** %12, i8** %11, i32 %92)
%94 = icmp ne i64 %93, 0
br i1 %94, label %95, label %99
95: ; preds = %90
%96 = load i32, i32* @stderr
%97 = call i32 (i32, i8*, ...) @fprintf(i32 %96, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i64 0, i64 0))
%98 = call i32 @exit(i32 1)
unreachable
99: ; preds = %90
br label %114
100: ; preds = %87
%101 = load i32, i32* %15
%102 = icmp eq i32 %101, 32
br i1 %102, label %103, label %113
103: ; preds = %100
%104 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%105 = load i32, i32* %16
%106 = call i64 @nsrl_extract_md5(i8* %104, i8** %12, i8** %11, i32 %105)
%107 = icmp ne i64 %106, 0
br i1 %107, label %108, label %112
108: ; preds = %103
%109 = load i32, i32* @stderr
%110 = call i32 (i32, i8*, ...) @fprintf(i32 %109, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i64 0, i64 0))
%111 = call i32 @exit(i32 1)
unreachable
112: ; preds = %103
br label %113
113: ; preds = %112, %100
br label %114
114: ; preds = %113, %99
%115 = load i8*, i8** %12
%116 = load i8*, i8** %6
%117 = call i64 @strcasecmp(i8* %115, i8* %116)
%118 = icmp ne i64 0, %117
br i1 %118, label %119, label %120
119: ; preds = %114
br label %136
120: ; preds = %114
%121 = load i8*, i8** %11
%122 = getelementptr inbounds [512 x i8], [512 x i8]* %13, i64 0, i64 0
%123 = call i64 @strcmp(i8* %121, i8* %122)
%124 = icmp ne i64 %123, 0
br i1 %124, label %125, label %132
125: ; preds = %120
%126 = load i8*, i8** %6
%127 = load i8*, i8** %11
%128 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i8* %126, i8* %127)
store i32 1, i32* %14
%129 = getelementptr inbounds [512 x i8], [512 x i8]* %13, i64 0, i64 0
%130 = load i8*, i8** %11
%131 = call i32 @strncpy(i8* %129, i8* %130, i32 512)
br label %132
132: ; preds = %125, %120
%133 = load i32, i32* %17
%134 = load i32, i32* %7
%135 = add nsw i32 %134, %133
store i32 %135, i32* %7
br label %52
136: ; preds = %119, %73
%137 = load i32, i32* %14
%138 = icmp eq i32 %137, 0
br i1 %138, label %139, label %145
139: ; preds = %136
%140 = load i32, i32* @stderr
%141 = load i32, i32* %7
%142 = sext i32 %141 to i64
%143 = call i32 (i32, i8*, ...) @fprintf(i32 %140, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.9, i64 0, i64 0), i64 %142)
%144 = call i32 @exit(i32 1)
unreachable
145: ; preds = %136
%146 = load i32*, i32** %9
%147 = call i32 @fclose(i32* %146)
br label %148
148: ; preds = %145, %34
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [36 x i8] c"nsrl_print: Invalid hash value: %s\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [44 x i8] c"nsrl_print: Error opening NSRL DB file: %s\0A\00"
@.str.3 = [39 x i8] c"nsrl_init: Error reading NSRLFile.txt\0A\00"
@SEEK_SET = global i32 0
@.str.4 = [49 x i8] c"nsrl_print: Error seeking to get file name: %lu\0A\00"
@.str.5 = [36 x i8] c"nsrl_print: Error reading database\0A\00"
@.str.6 = [51 x i8] c"nsrl_print: Invalid entry in database (too short)\0A\00"
@.str.7 = [39 x i8] c"nsrl_print: Invalid entry in database\0A\00"
@.str.8 = [7 x i8] c"%s\09%s\0A\00"
@.str.9 = [39 x i8] c"Hash not found in file at offset: %lu\0A\00"
define void @nsrl_print(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca [512 x i8]
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca [512 x i8]
%9 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%10 = bitcast i8** %6 to i8*
%11 = bitcast i8** %7 to i8*
%12 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%13 = tail call i32 @strlen(i8* %1)
%14 = and i32 %13, -9
%15 = icmp eq i32 %14, 32
br i1 %15, label %20, label %16
16: ; preds = %4
%17 = load i32, i32* @stderr
%18 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %1)
%19 = tail call i32 @exit(i32 1)
unreachable
20: ; preds = %4
%21 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load i32, i32* @stderr
%25 = tail call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %107
26: ; preds = %20
%27 = call i32* @fgets(i8* %9, i32 512, i32* %21)
%28 = icmp eq i32* %27, null
br i1 %28, label %29, label %33
29: ; preds = %26
%30 = load i32, i32* @stderr
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0))
%32 = call i32 @exit(i32 1)
unreachable
33: ; preds = %26
%34 = call i32 @get_format_ver(i8* %9)
%35 = call i32 @memset(i8* %12, i32 48, i32 512)
%36 = load i32, i32* @SEEK_SET
%37 = call i64 @fseek(i32* %21, i32 %2, i32 %36)
%38 = icmp eq i64 %37, 0
br i1 %38, label %45, label %39
39: ; preds = %92, %33
%40 = phi i32 [ %2, %33 ], [ %94, %92 ]
%41 = load i32, i32* @stderr
%42 = sext i32 %40 to i64
%43 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0), i64 %42)
%44 = call i32 @exit(i32 1)
unreachable
45: ; preds = %33, %92
%46 = phi i32 [ %94, %92 ], [ %2, %33 ]
%47 = phi i32 [ %93, %92 ], [ 0, %33 ]
%48 = call i32* @fgets(i8* %9, i32 512, i32* %21)
%49 = icmp eq i32* %48, null
br i1 %49, label %50, label %57
50: ; preds = %45
%51 = call i64 @feof(i32* %21)
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %98
53: ; preds = %50
%54 = load i32, i32* @stderr
%55 = call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0))
%56 = call i32 @exit(i32 1)
unreachable
57: ; preds = %45
%58 = call i32 @strlen(i8* %9)
%59 = icmp slt i32 %58, 45
br i1 %59, label %60, label %64
60: ; preds = %57
%61 = load i32, i32* @stderr
%62 = call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.6, i64 0, i64 0))
%63 = call i32 @exit(i32 1)
unreachable
64: ; preds = %57
switch i32 %13, label %79 [
i32 40, label %65
i32 32, label %72
]
65: ; preds = %64
%66 = call i64 @nsrl_extract_sha1(i8* %9, i8** %7, i8** %6, i32 %34)
%67 = icmp eq i64 %66, 0
br i1 %67, label %79, label %68
68: ; preds = %65
%69 = load i32, i32* @stderr
%70 = call i32 (i32, i8*, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i64 0, i64 0))
%71 = call i32 @exit(i32 1)
unreachable
72: ; preds = %64
%73 = call i64 @nsrl_extract_md5(i8* %9, i8** %7, i8** %6, i32 %34)
%74 = icmp eq i64 %73, 0
br i1 %74, label %79, label %75
75: ; preds = %72
%76 = load i32, i32* @stderr
%77 = call i32 (i32, i8*, ...) @fprintf(i32 %76, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i64 0, i64 0))
%78 = call i32 @exit(i32 1)
unreachable
79: ; preds = %64, %72, %65
%80 = load i8*, i8** %7
%81 = call i64 @strcasecmp(i8* %80, i8* %1)
%82 = icmp eq i64 %81, 0
br i1 %82, label %83, label %98
83: ; preds = %79
%84 = load i8*, i8** %6
%85 = call i64 @strcmp(i8* %84, i8* %12)
%86 = icmp eq i64 %85, 0
br i1 %86, label %92, label %87
87: ; preds = %83
%88 = load i8*, i8** %6
%89 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i8* %1, i8* %88)
%90 = load i8*, i8** %6
%91 = call i32 @strncpy(i8* %12, i8* %90, i32 512)
br label %92
92: ; preds = %83, %87
%93 = phi i32 [ 1, %87 ], [ %47, %83 ]
%94 = add nsw i32 %58, %46
%95 = load i32, i32* @SEEK_SET
%96 = call i64 @fseek(i32* %21, i32 %94, i32 %95)
%97 = icmp eq i64 %96, 0
br i1 %97, label %45, label %39
98: ; preds = %79, %50
%99 = icmp eq i32 %47, 0
br i1 %99, label %100, label %105
100: ; preds = %98
%101 = load i32, i32* @stderr
%102 = sext i32 %46 to i64
%103 = call i32 (i32, i8*, ...) @fprintf(i32 %101, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.9, i64 0, i64 0), i64 %102)
%104 = call i32 @exit(i32 1)
unreachable
105: ; preds = %98
%106 = call i32 @fclose(i32* %21)
br label %107
107: ; preds = %105, %23
ret void
}