#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*/);
scalar_t__ hk_extract_md5(char *, char **, char *, int, char *, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, 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 hk_print(char *db_file, char *hash, off_t offset, int flags) {
  FILE *hFile;
  char buf[512], name[512], *ptr = NULL, pname[512], other[512];
  int found = 0;
  if (strlen(hash) != 32) {
    fprintf(stderr, "hk_print: Invalid hash value: %s\n", hash);
    exit(1);
  }
  if (NULL == (hFile = fopen(db_file, "r"))) {
    fprintf(stderr, "hk_print: Error opening hash keeper DB file: %s\n",
            db_file);
    return;
  }
  memset(pname, '0', 512);
  while (1) {
    int len;
    if (0 != fseek(hFile, offset, SEEK_SET)) {
      fprintf(stderr, "hk_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, "hk_print: Error reading database\n");
      exit(1);
    }
    len = strlen(buf);
    if (hk_extract_md5(buf, &ptr, name, 512, ((flags & 0x02) ? other : NULL),
                       ((flags & 0x02) ? 512 : 0))) {
      fprintf(stderr, "hk_print: Invalid entry in database: %s\n", buf);
      exit(1);
    }
    if (0 != strcasecmp(ptr, hash)) {
      break;
    }
    if (strcmp(name, pname) != 0) {
      if (flags & 0x02)
        printf("%s\t%s\t(%s)\n", hash, name, other);
      else
        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):
<hk_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x850,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movq   $0x0,-0x428(%rbp)
movl   $0x0,-0x834(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <strlen@plt>
cmp    $0x20,%eax
je     1245 <hk_print+0x65>
mov    0x2db9(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xdcc(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    -0x8(%rbp),%rdi
lea    0xdd2(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,%rcx
mov    %rcx,-0x20(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
jne    1287 <hk_print+0xa7>
mov    0x2d72(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xda9(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
jmp    1507 <hk_print+0x327>
lea    -0x630(%rbp),%rdi
mov    $0x30,%esi
mov    $0x200,%edx
call   1080 <memset@plt>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    0x2d2d(%rip),%rax
mov    (%rax),%edx
call   10d0 <fseek@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     12e5 <hk_print+0x105>
mov    0x2d19(%rip),%rax
mov    (%rax),%edi
movslq -0x14(%rbp),%rdx
lea    0xd81(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
lea    -0x220(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x200,%esi
call   1090 <fgets@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1341 <hk_print+0x161>
mov    -0x20(%rbp),%rdi
call   10c0 <feof@plt>
cmp    $0x0,%rax
je     1320 <hk_print+0x140>
jmp    14cc <hk_print+0x2ec>
mov    0x2cb9(%rip),%rax
mov    (%rax),%edi
lea    0xd54(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
lea    -0x220(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x838(%rbp)
lea    -0x220(%rbp),%rax
mov    %rax,-0x848(%rbp)
lea    -0x420(%rbp),%rax
mov    %rax,-0x840(%rbp)
mov    -0x18(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     1391 <hk_print+0x1b1>
lea    -0x830(%rbp),%rax
mov    %rax,-0x850(%rbp)
jmp    139f <hk_print+0x1bf>
xor    %eax,%eax
mov    %rax,-0x850(%rbp)
jmp    139f <hk_print+0x1bf>
mov    -0x840(%rbp),%rdx
mov    -0x848(%rbp),%rdi
mov    -0x850(%rbp),%r8
mov    -0x18(%rbp),%ecx
and    $0x2,%ecx
xor    %r9d,%r9d
mov    $0x200,%eax
cmp    $0x0,%ecx
cmovne %eax,%r9d
lea    -0x428(%rbp),%rsi
mov    $0x200,%ecx
call   10e0 <hk_extract_md5@plt>
cmp    $0x0,%rax
je     140c <hk_print+0x22c>
mov    0x2bf5(%rip),%rax
mov    (%rax),%edi
lea    -0x220(%rbp),%rdx
lea    0xcab(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    -0x428(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcasecmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     142f <hk_print+0x24f>
jmp    14cc <hk_print+0x2ec>
lea    -0x420(%rbp),%rdi
lea    -0x630(%rbp),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
je     14bb <hk_print+0x2db>
mov    -0x18(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     1480 <hk_print+0x2a0>
mov    -0x10(%rbp),%rsi
lea    -0x420(%rbp),%rdx
lea    -0x830(%rbp),%rcx
lea    0xc5b(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1499 <hk_print+0x2b9>
mov    -0x10(%rbp),%rsi
lea    -0x420(%rbp),%rdx
lea    0xc49(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x1,-0x834(%rbp)
lea    -0x630(%rbp),%rdi
lea    -0x420(%rbp),%rsi
mov    $0x200,%edx
call   1040 <strncpy@plt>
mov    -0x838(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    129d <hk_print+0xbd>
cmpl   $0x0,-0x834(%rbp)
jne    14fe <hk_print+0x31e>
mov    0x2b00(%rip),%rax
mov    (%rax),%edi
movslq -0x14(%rbp),%rdx
lea    0xbf5(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
add    $0x850,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hk_print>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x828,%rsp
mov    %ecx,%r12d
mov    %edx,%r14d
mov    %rsi,%r15
mov    %rdi,%rbp
movq   $0x0,0x10(%rsp)
mov    %rsi,%rdi
call   1060 <strlen@plt>
cmp    $0x20,%eax
jne    1416 <hk_print+0x236>
lea    0xe04(%rip),%rsi
mov    %rbp,%rdi
call   10f0 <fopen@plt>
test   %rax,%rax
je     139f <hk_print+0x1bf>
mov    %rax,%rbx
lea    0x20(%rsp),%rdi
mov    $0x30,%esi
mov    $0x200,%edx
call   1080 <memset@plt>
mov    0x2d8b(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    %r14d,%esi
call   10d0 <fseek@plt>
test   %rax,%rax
jne    142b <hk_print+0x24b>
xor    %eax,%eax
and    $0x2,%r12d
lea    0x220(%rsp),%rcx
cmove  %rax,%rcx
mov    %rcx,0x18(%rsp)
mov    %r12d,0x8(%rsp)
shl    $0x8,%r12d
mov    %r12d,0xc(%rsp)
lea    0x420(%rsp),%r12
lea    0x620(%rsp),%r13
movl   $0x0,0x4(%rsp)
jmp    1300 <hk_print+0x120>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0xe24(%rip),%rdi
mov    %r15,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1070 <printf@plt>
lea    0x20(%rsp),%rdi
mov    %r13,%rsi
mov    $0x200,%edx
call   1040 <strncpy@plt>
movl   $0x1,0x4(%rsp)
add    %r14d,%ebp
mov    0x2cf0(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    %ebp,%esi
call   10d0 <fseek@plt>
mov    %ebp,%r14d
test   %rax,%rax
jne    142e <hk_print+0x24e>
mov    %r12,%rdi
mov    $0x200,%esi
mov    %rbx,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     13ca <hk_print+0x1ea>
mov    %r12,%rdi
call   1060 <strlen@plt>
mov    %eax,%ebp
mov    %r12,%rdi
lea    0x10(%rsp),%rsi
mov    %r13,%rdx
mov    $0x200,%ecx
mov    0x18(%rsp),%r8
mov    0xc(%rsp),%r9d
call   10e0 <hk_extract_md5@plt>
test   %rax,%rax
jne    13fc <hk_print+0x21c>
mov    0x10(%rsp),%rdi
mov    %r15,%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
jne    13db <hk_print+0x1fb>
mov    %r13,%rdi
lea    0x20(%rsp),%rsi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     12de <hk_print+0xfe>
cmpl   $0x0,0x8(%rsp)
je     12b0 <hk_print+0xd0>
lea    0xd4a(%rip),%rdi
mov    %r15,%rsi
mov    %r13,%rdx
lea    0x220(%rsp),%rcx
xor    %eax,%eax
call   1070 <printf@plt>
jmp    12c4 <hk_print+0xe4>
mov    0x2c3a(%rip),%rax
mov    (%rax),%edi
lea    0xc75(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
add    $0x828,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    10b0 <fprintf@plt>
mov    %rbx,%rdi
call   10c0 <feof@plt>
test   %rax,%rax
je     1467 <hk_print+0x287>
cmpl   $0x0,0x4(%rsp)
je     1452 <hk_print+0x272>
mov    %rbx,%rdi
call   1050 <fclose@plt>
add    $0x828,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2bdd(%rip),%rax
mov    (%rax),%edi
lea    0xc9a(%rip),%rsi
lea    0x420(%rsp),%rdx
jmp    1441 <hk_print+0x261>
mov    0x2bc3(%rip),%rax
mov    (%rax),%edi
lea    0xbda(%rip),%rsi
mov    %r15,%rdx
jmp    1441 <hk_print+0x261>
mov    %r14d,%ebp
mov    0x2bab(%rip),%rax
mov    (%rax),%edi
movslq %ebp,%rdx
lea    0xc14(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    0x2b87(%rip),%rax
mov    (%rax),%edi
movslq %r14d,%rdx
lea    0xc7d(%rip),%rsi
jmp    1441 <hk_print+0x261>
mov    0x2b72(%rip),%rax
mov    (%rax),%edi
lea    0xc0d(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>

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

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