#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_CUR;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fread(unsigned short *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, unsigned short,
                         int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, unsigned short, unsigned char, ...);
int /*<<< orphan*/ process_code_seg(int /*<<< orphan*/ *, unsigned short,
                                    unsigned short, unsigned char *,
                                    unsigned char *, int, int, int);
int /*<<< orphan*/ process_data_seg(int /*<<< orphan*/ *, unsigned short);
void process_func(FILE *f, long func, int i, int *found,
                  unsigned char *opcode_buf, unsigned char *intrinsic_buf,
                  int scan_mode, unsigned long opcode,
                  unsigned long intrinsic) {
  unsigned short s, ds, funcnum;
  long off, bodyoff;
  off = ftell(f);
  fread(&funcnum, sizeof(unsigned short), 1, f);
  fread(&s, sizeof(unsigned short), 1, f);
  bodyoff = ftell(f);
  fread(&ds, sizeof(unsigned short), 1, f);
  if (((func == -1) || scan_mode) && (opcode == -1) && (intrinsic == -1))
    printf("\tFunction #%d (%04XH), offset = %08lx, size = %04x, data = %04x\n",
           i, funcnum, off, s, ds);
  if ((funcnum == func) || scan_mode || (opcode != -1) || (intrinsic != -1)) {
    if (funcnum == func) {
      *found = 1;
      printf("Function at file offset %08lX\n\t.funcnumber\t%04XH\n"
             "\t.msize\t%04XH\n\t.dsize\t%04XH\n",
             off, funcnum, s, ds);
    }
    if (!scan_mode && (opcode == -1) && (intrinsic == -1))
      process_data_seg(f, ds);
    if (opcode != -1)
      memset(opcode_buf, 0, 256);
    if (intrinsic != -1)
      memset(intrinsic_buf, 0, 256);
    process_code_seg(f, ds, s, opcode_buf, intrinsic_buf,
                     scan_mode || (opcode != -1) || (intrinsic != -1),
                     (opcode != -1), (intrinsic != -1));
    if (((opcode != -1) && opcode_buf[opcode] > 0) ||
        ((intrinsic != -1) && intrinsic_buf[intrinsic] > 0)) {
      *found = 1;
      if (intrinsic != -1)
        printf("\tFound function (%04XH) - %d times\n", funcnum,
               intrinsic_buf[intrinsic]);
      else
        printf("\tFound function (%04XH) - %d times\n", funcnum,
               opcode_buf[opcode]);
    }
  }
  fseek(f, bodyoff, SEEK_SET);
  fseek(f, s, SEEK_CUR);
}


x86 assembly (clang, -O0):
<process_func>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <ftell@plt>
mov    %rax,-0x40(%rbp)
mov    -0x8(%rbp),%rcx
lea    -0x36(%rbp),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    -0x8(%rbp),%rcx
lea    -0x32(%rbp),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    -0x8(%rbp),%rdi
call   1070 <ftell@plt>
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%rcx
lea    -0x34(%rbp),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
cmpq   $0xffffffffffffffff,-0x10(%rbp)
je     1211 <process_func+0xa1>
cmpl   $0x0,0x10(%rbp)
je     1253 <process_func+0xe3>
cmpq   $0xffffffffffffffff,0x18(%rbp)
jne    1253 <process_func+0xe3>
cmpq   $0xffffffffffffffff,0x20(%rbp)
jne    1253 <process_func+0xe3>
mov    -0x14(%rbp),%eax
mov    %ax,%dx
mov    -0x36(%rbp),%ax
mov    -0x40(%rbp),%rcx
movzwl -0x32(%rbp),%r8d
movzwl -0x34(%rbp),%r9d
lea    0xdba(%rip),%rdi
movzwl %dx,%esi
movzbl %al,%edx
mov    $0x0,%al
call   1040 <printf@plt>
movzwl -0x36(%rbp),%eax
cmp    -0x10(%rbp),%rax
je     1281 <process_func+0x111>
cmpl   $0x0,0x10(%rbp)
jne    1281 <process_func+0x111>
cmpq   $0xffffffffffffffff,0x18(%rbp)
jne    1281 <process_func+0x111>
cmpq   $0xffffffffffffffff,0x20(%rbp)
je     1467 <process_func+0x2f7>
movzwl -0x36(%rbp),%eax
cmp    -0x10(%rbp),%rax
jne    12c1 <process_func+0x151>
mov    -0x20(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x40(%rbp),%rax
mov    %ax,%dx
mov    -0x36(%rbp),%ax
movzwl -0x32(%rbp),%ecx
movzwl -0x34(%rbp),%r8d
lea    0xd8d(%rip),%rdi
movzwl %dx,%esi
movzbl %al,%edx
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,0x10(%rbp)
jne    12ee <process_func+0x17e>
cmpq   $0xffffffffffffffff,0x18(%rbp)
jne    12ee <process_func+0x17e>
cmpq   $0xffffffffffffffff,0x20(%rbp)
jne    12ee <process_func+0x17e>
mov    -0x8(%rbp),%rdi
movzwl -0x34(%rbp),%esi
call   1050 <process_data_seg@plt>
cmpq   $0xffffffffffffffff,0x18(%rbp)
je     1309 <process_func+0x199>
mov    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1060 <memset@plt>
cmpq   $0xffffffffffffffff,0x20(%rbp)
je     1324 <process_func+0x1b4>
mov    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1060 <memset@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x34(%rbp),%ax
mov    %ax,-0x64(%rbp)
mov    -0x32(%rbp),%ax
mov    %ax,-0x62(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    $0x1,%al
cmpl   $0x0,0x10(%rbp)
mov    %al,-0x49(%rbp)
jne    1376 <process_func+0x206>
mov    $0x1,%al
cmpq   $0xffffffffffffffff,0x18(%rbp)
mov    %al,-0x49(%rbp)
jne    1376 <process_func+0x206>
cmpq   $0xffffffffffffffff,0x20(%rbp)
setne  %al
mov    %al,-0x49(%rbp)
mov    -0x58(%rbp),%r8
mov    -0x60(%rbp),%rcx
mov    -0x62(%rbp),%dx
mov    -0x64(%rbp),%si
mov    -0x70(%rbp),%rdi
mov    -0x49(%rbp),%al
and    $0x1,%al
movzbl %al,%r9d
cmpq   $0xffffffffffffffff,0x18(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%r10d
cmpq   $0xffffffffffffffff,0x20(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%eax
movzwl %si,%esi
movzwl %dx,%edx
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1080 <process_code_seg@plt>
cmpq   $0xffffffffffffffff,0x18(%rbp)
je     13e1 <process_func+0x271>
mov    -0x28(%rbp),%rax
mov    0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jg     1401 <process_func+0x291>
cmpq   $0xffffffffffffffff,0x20(%rbp)
je     1462 <process_func+0x2f2>
mov    -0x30(%rbp),%rax
mov    0x20(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jle    1462 <process_func+0x2f2>
mov    -0x20(%rbp),%rax
movl   $0x1,(%rax)
cmpq   $0xffffffffffffffff,0x20(%rbp)
je     143c <process_func+0x2cc>
mov    -0x36(%rbp),%dx
mov    -0x30(%rbp),%rax
mov    0x20(%rbp),%rcx
lea    0xc66(%rip),%rdi
movzwl %dx,%esi
movzbl (%rax,%rcx,1),%edx
mov    $0x0,%al
call   1040 <printf@plt>
jmp    145d <process_func+0x2ed>
mov    -0x36(%rbp),%dx
mov    -0x28(%rbp),%rax
mov    0x18(%rbp),%rcx
lea    0xc40(%rip),%rdi
movzwl %dx,%esi
movzbl (%rax,%rcx,1),%edx
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1462 <process_func+0x2f2>
jmp    1467 <process_func+0x2f7>
mov    -0x8(%rbp),%rdi
mov    -0x48(%rbp),%rax
mov    0x2b62(%rip),%rcx
mov    (%rcx),%edx
movzwl %ax,%esi
call   1090 <fseek@plt>
mov    -0x8(%rbp),%rdi
mov    -0x32(%rbp),%ax
mov    0x2b59(%rip),%rcx
mov    (%rcx),%edx
movzwl %ax,%esi
call   1090 <fseek@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_func>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %r9,0x20(%rsp)
mov    %r8,0x40(%rsp)
mov    %rcx,0x28(%rsp)
mov    %edx,%r13d
mov    %rsi,%r14
mov    %rdi,%r12
mov    0x90(%rsp),%r15
mov    0x88(%rsp),%rbp
mov    0x80(%rsp),%ebx
call   1070 <ftell@plt>
mov    %rax,0x10(%rsp)
lea    0xe(%rsp),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1030 <fread@plt>
lea    0xc(%rsp),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1030 <fread@plt>
mov    %r12,%rdi
call   1070 <ftell@plt>
mov    %rax,0x18(%rsp)
lea    0xa(%rsp),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1030 <fread@plt>
cmp    $0xffffffffffffffff,%r14
setne  %al
test   %ebx,%ebx
sete   %cl
mov    %r15,0x30(%rsp)
mov    %rbp,%rdx
mov    %rbp,0x38(%rsp)
and    %rbp,%r15
test   %cl,%al
jne    1260 <process_func+0xf0>
cmp    $0xffffffffffffffff,%r15
jne    1260 <process_func+0xf0>
mov    %r13d,%eax
movzwl 0xe(%rsp),%r13d
movzwl 0xc(%rsp),%r8d
movzwl 0xa(%rsp),%r9d
movzwl %ax,%esi
movzbl %r13b,%edx
lea    0xdae(%rip),%rdi
mov    0x10(%rsp),%rcx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1266 <process_func+0xf6>
movzwl 0xe(%rsp),%r13d
movzwl %r13w,%ebp
cmp    $0xffffffffffffffff,%r15
jne    1289 <process_func+0x119>
test   %ebx,%ebx
jne    1289 <process_func+0x119>
cmp    %r14,%rbp
je     1289 <process_func+0x119>
movzwl 0xc(%rsp),%r15d
mov    0x18(%rsp),%rbp
jmp    13ed <process_func+0x27d>
cmp    %r14,%rbp
jne    12bb <process_func+0x14b>
mov    0x28(%rsp),%rax
movl   $0x1,(%rax)
movzwl 0xc(%rsp),%ecx
movzwl 0xa(%rsp),%r8d
movzwl 0x10(%rsp),%esi
movzbl %bpl,%edx
lea    0xd8d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,0x10(%rsp)
test   %ebx,%ebx
mov    0x30(%rsp),%rbp
mov    0x38(%rsp),%r14
jne    12e1 <process_func+0x171>
cmp    $0xffffffffffffffff,%r15
jne    12e1 <process_func+0x171>
movzwl 0xa(%rsp),%esi
mov    %r12,%rdi
call   1050 <process_data_seg@plt>
mov    %ebx,%r15d
cmp    $0xffffffffffffffff,%r14
je     12fb <process_func+0x18b>
mov    0x40(%rsp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1060 <memset@plt>
cmp    $0xffffffffffffffff,%rbp
mov    0x20(%rsp),%rbx
je     131a <process_func+0x1aa>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1060 <memset@plt>
mov    0x20(%rsp),%rbx
xor    %eax,%eax
cmp    $0xffffffffffffffff,%rbp
setne  %al
xor    %ebp,%ebp
cmp    $0xffffffffffffffff,%r14
setne  %bpl
mov    $0x1,%ecx
mov    %eax,%r9d
cmovne %ecx,%r9d
test   %r15d,%r15d
movzwl 0xa(%rsp),%esi
movzwl 0xc(%rsp),%r15d
cmovne %ecx,%r9d
movzwl %r15w,%edx
mov    %r12,%rdi
mov    0x40(%rsp),%r13
mov    %r13,%rcx
mov    %rbx,%r8
push   %rax
push   %rbp
call   1080 <process_code_seg@plt>
add    $0x10,%rsp
cmp    $0xffffffffffffffff,%r14
je     139c <process_func+0x22c>
cmpb   $0x0,0x0(%r13,%r14,1)
je     139c <process_func+0x22c>
mov    0x28(%rsp),%rax
movl   $0x1,(%rax)
mov    0x30(%rsp),%rdx
cmp    $0xffffffffffffffff,%rdx
mov    0x18(%rsp),%rbp
mov    0x20(%rsp),%rcx
je     13cf <process_func+0x25f>
movzbl (%rcx,%rdx,1),%edx
jmp    13da <process_func+0x26a>
mov    0x30(%rsp),%rdx
cmp    $0xffffffffffffffff,%rdx
je     13c8 <process_func+0x258>
mov    0x20(%rsp),%rcx
cmpb   $0x0,(%rcx,%rdx,1)
je     13c8 <process_func+0x258>
mov    0x28(%rsp),%rax
movl   $0x1,(%rax)
mov    0x18(%rsp),%rbp
movzbl (%rcx,%rdx,1),%edx
jmp    13da <process_func+0x26a>
mov    0x18(%rsp),%rbp
jmp    13ed <process_func+0x27d>
mov    0x38(%rsp),%rax
movzbl 0x0(%r13,%rax,1),%edx
lea    0xcae(%rip),%rdi
mov    0x10(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2be4(%rip),%rax
mov    (%rax),%edx
movzwl %bp,%esi
mov    %r12,%rdi
call   1090 <fseek@plt>
mov    0x2be0(%rip),%rax
mov    (%rax),%edx
movzwl %r15w,%esi
mov    %r12,%rdi
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1090 <fseek@plt>

LLVM IR (-O0):
@.str = [65 x i8] c"\09Function #%d (%04XH), offset = %08lx, size = %04x, data = %04x\0A\00"
@.str.1 = [78 x i8] c"Function at file offset %08lX\0A\09.funcnumber\09%04XH\0A\09.msize\09%04XH\0A\09.dsize\09%04XH\0A\00"
@.str.2 = [36 x i8] c"\09Found function (%04XH) - %d times\0A\00"
@SEEK_SET = global i32 0
@SEEK_CUR = global i32 0
define void @process_func(i32* %0, i64 %1, i32 %2, i32* %3, i8* %4, i8* %5, i32 %6, i64 %7, i64 %8) {
%10 = alloca i32*
%11 = alloca i64
%12 = alloca i32
%13 = alloca i32*
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i32
%17 = alloca i64
%18 = alloca i64
%19 = alloca i16
%20 = alloca i16
%21 = alloca i16
%22 = alloca i64
%23 = alloca i64
store i32* %0, i32** %10
store i64 %1, i64* %11
store i32 %2, i32* %12
store i32* %3, i32** %13
store i8* %4, i8** %14
store i8* %5, i8** %15
store i32 %6, i32* %16
store i64 %7, i64* %17
store i64 %8, i64* %18
%24 = load i32*, i32** %10
%25 = call i64 @ftell(i32* %24)
store i64 %25, i64* %22
%26 = load i32*, i32** %10
%27 = call i32 @fread(i16* %21, i32 2, i32 1, i32* %26)
%28 = load i32*, i32** %10
%29 = call i32 @fread(i16* %19, i32 2, i32 1, i32* %28)
%30 = load i32*, i32** %10
%31 = call i64 @ftell(i32* %30)
store i64 %31, i64* %23
%32 = load i32*, i32** %10
%33 = call i32 @fread(i16* %20, i32 2, i32 1, i32* %32)
%34 = load i64, i64* %11
%35 = icmp eq i64 %34, -1
br i1 %35, label %39, label %36
36: ; preds = %9
%37 = load i32, i32* %16
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %56
39: ; preds = %36, %9
%40 = load i64, i64* %17
%41 = icmp eq i64 %40, -1
br i1 %41, label %42, label %56
42: ; preds = %39
%43 = load i64, i64* %18
%44 = icmp eq i64 %43, -1
br i1 %44, label %45, label %56
45: ; preds = %42
%46 = load i32, i32* %12
%47 = trunc i32 %46 to i16
%48 = load i16, i16* %21
%49 = trunc i16 %48 to i8
%50 = load i64, i64* %22
%51 = load i16, i16* %19
%52 = zext i16 %51 to i32
%53 = load i16, i16* %20
%54 = zext i16 %53 to i32
%55 = call i32 (i8*, i16, i8, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i16 zeroext %47, i8 zeroext %49, i64 %50, i32 %52, i32 %54)
br label %56
56: ; preds = %45, %42, %39, %36
%57 = load i16, i16* %21
%58 = zext i16 %57 to i64
%59 = load i64, i64* %11
%60 = icmp eq i64 %58, %59
br i1 %60, label %70, label %61
61: ; preds = %56
%62 = load i32, i32* %16
%63 = icmp ne i32 %62, 0
br i1 %63, label %70, label %64
64: ; preds = %61
%65 = load i64, i64* %17
%66 = icmp ne i64 %65, -1
br i1 %66, label %70, label %67
67: ; preds = %64
%68 = load i64, i64* %18
%69 = icmp ne i64 %68, -1
br i1 %69, label %70, label %174
70: ; preds = %67, %64, %61, %56
%71 = load i16, i16* %21
%72 = zext i16 %71 to i64
%73 = load i64, i64* %11
%74 = icmp eq i64 %72, %73
br i1 %74, label %75, label %86
75: ; preds = %70
%76 = load i32*, i32** %13
store i32 1, i32* %76
%77 = load i64, i64* %22
%78 = trunc i64 %77 to i16
%79 = load i16, i16* %21
%80 = trunc i16 %79 to i8
%81 = load i16, i16* %19
%82 = zext i16 %81 to i32
%83 = load i16, i16* %20
%84 = zext i16 %83 to i32
%85 = call i32 (i8*, i16, i8, ...) @printf(i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.1, i64 0, i64 0), i16 zeroext %78, i8 zeroext %80, i32 %82, i32 %84)
br label %86
86: ; preds = %75, %70
%87 = load i32, i32* %16
%88 = icmp ne i32 %87, 0
br i1 %88, label %99, label %89
89: ; preds = %86
%90 = load i64, i64* %17
%91 = icmp eq i64 %90, -1
br i1 %91, label %92, label %99
92: ; preds = %89
%93 = load i64, i64* %18
%94 = icmp eq i64 %93, -1
br i1 %94, label %95, label %99
95: ; preds = %92
%96 = load i32*, i32** %10
%97 = load i16, i16* %20
%98 = call i32 @process_data_seg(i32* %96, i16 zeroext %97)
br label %99
99: ; preds = %95, %92, %89, %86
%100 = load i64, i64* %17
%101 = icmp ne i64 %100, -1
br i1 %101, label %102, label %105
102: ; preds = %99
%103 = load i8*, i8** %14
%104 = call i32 @memset(i8* %103, i32 0, i32 256)
br label %105
105: ; preds = %102, %99
%106 = load i64, i64* %18
%107 = icmp ne i64 %106, -1
br i1 %107, label %108, label %111
108: ; preds = %105
%109 = load i8*, i8** %15
%110 = call i32 @memset(i8* %109, i32 0, i32 256)
br label %111
111: ; preds = %108, %105
%112 = load i32*, i32** %10
%113 = load i16, i16* %20
%114 = load i16, i16* %19
%115 = load i8*, i8** %14
%116 = load i8*, i8** %15
%117 = load i32, i32* %16
%118 = icmp ne i32 %117, 0
br i1 %118, label %125, label %119
119: ; preds = %111
%120 = load i64, i64* %17
%121 = icmp ne i64 %120, -1
br i1 %121, label %125, label %122
122: ; preds = %119
%123 = load i64, i64* %18
%124 = icmp ne i64 %123, -1
br label %125
125: ; preds = %122, %119, %111
%126 = phi i1 [ true, %119 ], [ true, %111 ], [ %124, %122 ]
%127 = zext i1 %126 to i32
%128 = load i64, i64* %17
%129 = icmp ne i64 %128, -1
%130 = zext i1 %129 to i32
%131 = load i64, i64* %18
%132 = icmp ne i64 %131, -1
%133 = zext i1 %132 to i32
%134 = call i32 @process_code_seg(i32* %112, i16 zeroext %113, i16 zeroext %114, i8* %115, i8* %116, i32 %127, i32 %130, i32 %133)
%135 = load i64, i64* %17
%136 = icmp ne i64 %135, -1
br i1 %136, label %137, label %144
137: ; preds = %125
%138 = load i8*, i8** %14
%139 = load i64, i64* %17
%140 = getelementptr inbounds i8, i8* %138, i64 %139
%141 = load i8, i8* %140
%142 = zext i8 %141 to i32
%143 = icmp sgt i32 %142, 0
br i1 %143, label %154, label %144
144: ; preds = %137, %125
%145 = load i64, i64* %18
%146 = icmp ne i64 %145, -1
br i1 %146, label %147, label %173
147: ; preds = %144
%148 = load i8*, i8** %15
%149 = load i64, i64* %18
%150 = getelementptr inbounds i8, i8* %148, i64 %149
%151 = load i8, i8* %150
%152 = zext i8 %151 to i32
%153 = icmp sgt i32 %152, 0
br i1 %153, label %154, label %173
154: ; preds = %147, %137
%155 = load i32*, i32** %13
store i32 1, i32* %155
%156 = load i64, i64* %18
%157 = icmp ne i64 %156, -1
br i1 %157, label %158, label %165
158: ; preds = %154
%159 = load i16, i16* %21
%160 = load i8*, i8** %15
%161 = load i64, i64* %18
%162 = getelementptr inbounds i8, i8* %160, i64 %161
%163 = load i8, i8* %162
%164 = call i32 (i8*, i16, i8, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i16 zeroext %159, i8 zeroext %163)
br label %172
165: ; preds = %154
%166 = load i16, i16* %21
%167 = load i8*, i8** %14
%168 = load i64, i64* %17
%169 = getelementptr inbounds i8, i8* %167, i64 %168
%170 = load i8, i8* %169
%171 = call i32 (i8*, i16, i8, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i16 zeroext %166, i8 zeroext %170)
br label %172
172: ; preds = %165, %158
br label %173
173: ; preds = %172, %147, %144
br label %174
174: ; preds = %173, %67
%175 = load i32*, i32** %10
%176 = load i64, i64* %23
%177 = trunc i64 %176 to i16
%178 = load i32, i32* @SEEK_SET
%179 = call i32 @fseek(i32* %175, i16 zeroext %177, i32 %178)
%180 = load i32*, i32** %10
%181 = load i16, i16* %19
%182 = load i32, i32* @SEEK_CUR
%183 = call i32 @fseek(i32* %180, i16 zeroext %181, i32 %182)
ret void
}

LLVM IR (-O2):
@.str = [65 x i8] c"\09Function #%d (%04XH), offset = %08lx, size = %04x, data = %04x\0A\00"
@.str.1 = [78 x i8] c"Function at file offset %08lX\0A\09.funcnumber\09%04XH\0A\09.msize\09%04XH\0A\09.dsize\09%04XH\0A\00"
@.str.2 = [36 x i8] c"\09Found function (%04XH) - %d times\0A\00"
@SEEK_SET = global i32 0
@SEEK_CUR = global i32 0
define void @process_func(i32* %0, i64 %1, i32 %2, i32* nocapture writeonly %3, i8* %4, i8* %5, i32 %6, i64 %7, i64 %8) {
%10 = alloca i16
%11 = alloca i16
%12 = alloca i16
%13 = bitcast i16* %10 to i8*
%14 = bitcast i16* %11 to i8*
%15 = bitcast i16* %12 to i8*
%16 = tail call i64 @ftell(i32* %0)
%17 = call i32 @fread(i16* %12, i32 2, i32 1, i32* %0)
%18 = call i32 @fread(i16* %10, i32 2, i32 1, i32* %0)
%19 = tail call i64 @ftell(i32* %0)
%20 = call i32 @fread(i16* %11, i32 2, i32 1, i32* %0)
%21 = icmp eq i64 %1, -1
%22 = icmp ne i32 %6, 0
%23 = or i1 %21, %22
%24 = and i64 %8, %7
%25 = icmp eq i64 %24, -1
%26 = and i1 %23, %25
br i1 %26, label %29, label %27
27: ; preds = %9
%28 = load i16, i16* %12
br label %38
29: ; preds = %9
%30 = trunc i32 %2 to i16
%31 = load i16, i16* %12
%32 = trunc i16 %31 to i8
%33 = load i16, i16* %10
%34 = zext i16 %33 to i32
%35 = load i16, i16* %11
%36 = zext i16 %35 to i32
%37 = tail call i32 (i8*, i16, i8, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i16 zeroext %30, i8 zeroext %32, i64 %16, i32 %34, i32 %36)
br label %38
38: ; preds = %27, %29
%39 = phi i16 [ %28, %27 ], [ %31, %29 ]
%40 = zext i16 %39 to i64
%41 = icmp eq i64 %40, %1
%42 = or i1 %22, %41
%43 = icmp ne i64 %7, -1
%44 = icmp ne i64 %8, -1
%45 = icmp ne i64 %24, -1
%46 = or i1 %45, %42
br i1 %46, label %49, label %47
47: ; preds = %38
%48 = load i16, i16* %10
br label %96
49: ; preds = %38
br i1 %41, label %50, label %58
50: ; preds = %49
store i32 1, i32* %3
%51 = trunc i64 %16 to i16
%52 = trunc i16 %39 to i8
%53 = load i16, i16* %10
%54 = zext i16 %53 to i32
%55 = load i16, i16* %11
%56 = zext i16 %55 to i32
%57 = tail call i32 (i8*, i16, i8, ...) @printf(i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.1, i64 0, i64 0), i16 zeroext %51, i8 zeroext %52, i32 %54, i32 %56)
br label %58
58: ; preds = %50, %49
%59 = icmp eq i32 %6, 0
%60 = and i1 %59, %25
br i1 %60, label %61, label %64
61: ; preds = %58
%62 = load i16, i16* %11
%63 = tail call i32 @process_data_seg(i32* %0, i16 zeroext %62)
br label %64
64: ; preds = %61, %58
br i1 %43, label %65, label %67
65: ; preds = %64
%66 = tail call i32 @memset(i8* %4, i32 0, i32 256)
br label %67
67: ; preds = %65, %64
br i1 %44, label %68, label %70
68: ; preds = %67
%69 = tail call i32 @memset(i8* %5, i32 0, i32 256)
br label %70
70: ; preds = %68, %67
%71 = load i16, i16* %11
%72 = load i16, i16* %10
%73 = or i1 %22, %43
%74 = zext i1 %44 to i32
%75 = select i1 %73, i32 1, i32 %74
%76 = zext i1 %43 to i32
%77 = tail call i32 @process_code_seg(i32* %0, i16 zeroext %71, i16 zeroext %72, i8* %4, i8* %5, i32 %75, i32 %76, i32 %74)
br i1 %43, label %78, label %82
78: ; preds = %70
%79 = getelementptr inbounds i8, i8* %4, i64 %7
%80 = load i8, i8* %79
%81 = icmp eq i8 %80, 0
br i1 %81, label %82, label %88
82: ; preds = %78, %70
br i1 %44, label %83, label %96
83: ; preds = %82
%84 = getelementptr inbounds i8, i8* %5, i64 %8
%85 = load i8, i8* %84
%86 = icmp eq i8 %85, 0
br i1 %86, label %96, label %87
87: ; preds = %83
store i32 1, i32* %3
br label %89
88: ; preds = %78
store i32 1, i32* %3
br i1 %44, label %89, label %93
89: ; preds = %87, %88
%90 = getelementptr inbounds i8, i8* %5, i64 %8
%91 = load i8, i8* %90
%92 = tail call i32 (i8*, i16, i8, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i16 zeroext %39, i8 zeroext %91)
br label %96
93: ; preds = %88
%94 = load i8, i8* %79
%95 = tail call i32 (i8*, i16, i8, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i16 zeroext %39, i8 zeroext %94)
br label %96
96: ; preds = %47, %82, %83, %93, %89
%97 = phi i16 [ %48, %47 ], [ %72, %82 ], [ %72, %83 ], [ %72, %93 ], [ %72, %89 ]
%98 = trunc i64 %19 to i16
%99 = load i32, i32* @SEEK_SET
%100 = tail call i32 @fseek(i32* %0, i16 zeroext %98, i32 %99)
%101 = load i32, i32* @SEEK_CUR
%102 = tail call i32 @fseek(i32* %0, i16 zeroext %97, i32 %101)
ret void
}