#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_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ fread(unsigned char *, long, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
scalar_t__ isprint(unsigned char);
unsigned char *malloc(int);
int /*<<< orphan*/ printEntry(unsigned char *, long, long);
int /*<<< orphan*/ printf(char *, long, ...);
int /*<<< orphan*/ stderr;
int processDump(long addr, const char *fname) {
  FILE *fp;
  long flen = 0;
  unsigned char *buf = NULL;
  fp = fopen(fname, "r");
  if (!fp) {
    return -10;
  }
  fseek(fp, 0, SEEK_END);
  flen = ftell(fp);
  fseek(fp, 0, SEEK_SET);
  printf("File contains %ld bytes.\n", flen);
  buf = malloc(sizeof(unsigned char) * flen);
  if (!buf) {
    fprintf(stderr, "ERROR: Couldnt malloc!\n");
    return -20;
  }
  fread(buf, flen, 1, fp);
  printf("File covers %04lx - %04lx\n", addr, addr + flen - 1);
  fclose(fp);
  do {
    long count = 0;
    long p;
    long q;
    for (p = 0; p < flen; p++) {
      if (buf[p] == 0x2f) {
        count++;
        if (buf[p + 2] == 0x2f) {
          count++;
          q = p - 1;
          while (q > 0 && isprint(buf[q])) {
            q--;
          }
          q--;
          printEntry(buf, addr, q);
          p += 2;
        }
      }
    }
    printf("Found %ld candidates.\n", count);
  } while (0);
  return 0;
}


x86 assembly (clang, -O0):
<processDump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe35(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11eb <processDump+0x4b>
movl   $0xfffffff6,-0x4(%rbp)
jmp    13c4 <processDump+0x224>
mov    -0x20(%rbp),%rdi
mov    0x2df2(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
mov    -0x20(%rbp),%rdi
call   1070 <ftell@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2db9(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
mov    -0x28(%rbp),%rsi
lea    0xdd7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x28(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1271 <processDump+0xd1>
mov    0x2d81(%rip),%rax
mov    (%rax),%edi
lea    0xdbc(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0xffffffec,-0x4(%rbp)
jmp    13c4 <processDump+0x224>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rcx
mov    $0x1,%edx
call   1030 <fread@plt>
mov    -0x10(%rbp),%rsi
mov    -0x10(%rbp),%rdx
add    -0x28(%rbp),%rdx
sub    $0x1,%rdx
lea    0xd96(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%rax
cmp    -0x28(%rbp),%rax
jge    13ab <processDump+0x20b>
mov    -0x30(%rbp),%rax
mov    -0x40(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    1395 <processDump+0x1f5>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x40(%rbp),%rcx
movzbl 0x2(%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    1390 <processDump+0x1f0>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x40(%rbp),%rax
sub    $0x1,%rax
mov    %rax,-0x48(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x48(%rbp)
mov    %al,-0x49(%rbp)
jle    1346 <processDump+0x1a6>
mov    -0x30(%rbp),%rax
mov    -0x48(%rbp),%rcx
movzbl (%rax,%rcx,1),%edi
call   10a0 <isprint@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x49(%rbp)
mov    -0x49(%rbp),%al
test   $0x1,%al
jne    1356 <processDump+0x1b6>
jmp    1367 <processDump+0x1c7>
mov    -0x48(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x48(%rbp)
jmp    131b <processDump+0x17b>
mov    -0x48(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x48(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x48(%rbp),%rdx
call   10b0 <printEntry@plt>
mov    -0x40(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x40(%rbp)
jmp    1395 <processDump+0x1f5>
jmp    139a <processDump+0x1fa>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    12be <processDump+0x11e>
mov    -0x38(%rbp),%rsi
lea    0xc99(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<processDump>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rax
mov    %rdi,%r14
lea    0xe48(%rip),%rsi
mov    %rax,%rdi
call   10c0 <fopen@plt>
test   %rax,%rax
je     12d0 <processDump+0x130>
mov    %rax,%r13
mov    0x2e15(%rip),%rax
mov    (%rax),%edx
mov    %r13,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %r13,%rdi
call   1070 <ftell@plt>
mov    %rax,%r12
mov    0x2ddf(%rip),%rax
mov    (%rax),%edx
mov    %r13,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
lea    0xdfe(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12d,%edi
call   1080 <malloc@plt>
test   %rax,%rax
je     12d7 <processDump+0x137>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r12,%rsi
mov    $0x1,%edx
mov    %r13,%rcx
call   1030 <fread@plt>
lea    (%r14,%r12,1),%rdx
add    $0xffffffffffffffff,%rdx
lea    0xdf0(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r13,%rdi
call   1040 <fclose@plt>
test   %r12,%r12
jle    12f3 <processDump+0x153>
xor    %ecx,%ecx
xor    %r13d,%r13d
jmp    1283 <processDump+0xe3>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r13
mov    %rcx,%r15
add    $0x1,%r15
mov    %r15,%rcx
cmp    %r12,%r15
jge    12f6 <processDump+0x156>
cmpb   $0x2f,(%rbx,%rcx,1)
jne    1274 <processDump+0xd4>
cmpb   $0x2f,0x2(%rbx,%rcx,1)
jne    1270 <processDump+0xd0>
lea    0x2(%rcx),%r15
add    $0x2,%r13
nopl   0x0(%rax,%rax,1)
mov    %rcx,%rbp
cmp    $0x2,%rcx
jl     12bc <processDump+0x11c>
movzbl -0x1(%rbx,%rbp,1),%edi
call   10a0 <isprint@plt>
lea    -0x1(%rbp),%rcx
test   %rax,%rax
jne    12a0 <processDump+0x100>
add    $0xfffffffffffffffe,%rbp
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rbp,%rdx
call   10b0 <printEntry@plt>
jmp    1277 <processDump+0xd7>
mov    $0xfffffff6,%eax
jmp    1309 <processDump+0x169>
mov    0x2cfa(%rip),%rax
mov    (%rax),%edi
lea    0xd35(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0xffffffec,%eax
jmp    1309 <processDump+0x169>
xor    %r13d,%r13d
lea    0xd52(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.1 = [26 x i8] c"File contains %ld bytes.\0A\00"
@stderr = global i32 0
@.str.2 = [24 x i8] c"ERROR: Couldnt malloc!\0A\00"
@.str.3 = [27 x i8] c"File covers %04lx - %04lx\0A\00"
@.str.4 = [23 x i8] c"Found %ld candidates.\0A\00"
define i32 @processDump(i64 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
store i64 %0, i64* %4
store i8* %1, i8** %5
store i64 0, i64* %7
store i8* null, i8** %8
%12 = load i8*, i8** %5
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %13, i32** %6
%14 = load i32*, i32** %6
%15 = icmp ne i32* %14, null
br i1 %15, label %17, label %16
16: ; preds = %2
store i32 -10, i32* %3
br label %110
17: ; preds = %2
%18 = load i32*, i32** %6
%19 = load i32, i32* @SEEK_END
%20 = call i32 @fseek(i32* %18, i32 0, i32 %19)
%21 = load i32*, i32** %6
%22 = call i64 @ftell(i32* %21)
store i64 %22, i64* %7
%23 = load i32*, i32** %6
%24 = load i32, i32* @SEEK_SET
%25 = call i32 @fseek(i32* %23, i32 0, i32 %24)
%26 = load i64, i64* %7
%27 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i64 %26)
%28 = load i64, i64* %7
%29 = mul i64 1, %28
%30 = trunc i64 %29 to i32
%31 = call i8* @malloc(i32 %30)
store i8* %31, i8** %8
%32 = load i8*, i8** %8
%33 = icmp ne i8* %32, null
br i1 %33, label %37, label %34
34: ; preds = %17
%35 = load i32, i32* @stderr
%36 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
store i32 -20, i32* %3
br label %110
37: ; preds = %17
%38 = load i8*, i8** %8
%39 = load i64, i64* %7
%40 = load i32*, i32** %6
%41 = call i32 @fread(i8* %38, i64 %39, i32 1, i32* %40)
%42 = load i64, i64* %4
%43 = load i64, i64* %4
%44 = load i64, i64* %7
%45 = add nsw i64 %43, %44
%46 = sub nsw i64 %45, 1
%47 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i64 %42, i64 %46)
%48 = load i32*, i32** %6
%49 = call i32 @fclose(i32* %48)
br label %50
50: ; preds = %37
store i64 0, i64* %9
store i64 0, i64* %10
br label %51
51: ; preds = %103, %50
%52 = load i64, i64* %10
%53 = load i64, i64* %7
%54 = icmp slt i64 %52, %53
br i1 %54, label %55, label %106
55: ; preds = %51
%56 = load i8*, i8** %8
%57 = load i64, i64* %10
%58 = getelementptr inbounds i8, i8* %56, i64 %57
%59 = load i8, i8* %58
%60 = zext i8 %59 to i32
%61 = icmp eq i32 %60, 47
br i1 %61, label %62, label %102
62: ; preds = %55
%63 = load i64, i64* %9
%64 = add nsw i64 %63, 1
store i64 %64, i64* %9
%65 = load i8*, i8** %8
%66 = load i64, i64* %10
%67 = add nsw i64 %66, 2
%68 = getelementptr inbounds i8, i8* %65, i64 %67
%69 = load i8, i8* %68
%70 = zext i8 %69 to i32
%71 = icmp eq i32 %70, 47
br i1 %71, label %72, label %101
72: ; preds = %62
%73 = load i64, i64* %9
%74 = add nsw i64 %73, 1
store i64 %74, i64* %9
%75 = load i64, i64* %10
%76 = sub nsw i64 %75, 1
store i64 %76, i64* %11
br label %77
77: ; preds = %89, %72
%78 = load i64, i64* %11
%79 = icmp sgt i64 %78, 0
br i1 %79, label %80, label %87
80: ; preds = %77
%81 = load i8*, i8** %8
%82 = load i64, i64* %11
%83 = getelementptr inbounds i8, i8* %81, i64 %82
%84 = load i8, i8* %83
%85 = call i64 @isprint(i8 zeroext %84)
%86 = icmp ne i64 %85, 0
br label %87
87: ; preds = %80, %77
%88 = phi i1 [ false, %77 ], [ %86, %80 ]
br i1 %88, label %89, label %92
89: ; preds = %87
%90 = load i64, i64* %11
%91 = add nsw i64 %90, -1
store i64 %91, i64* %11
br label %77
92: ; preds = %87
%93 = load i64, i64* %11
%94 = add nsw i64 %93, -1
store i64 %94, i64* %11
%95 = load i8*, i8** %8
%96 = load i64, i64* %4
%97 = load i64, i64* %11
%98 = call i32 @printEntry(i8* %95, i64 %96, i64 %97)
%99 = load i64, i64* %10
%100 = add nsw i64 %99, 2
store i64 %100, i64* %10
br label %101
101: ; preds = %92, %62
br label %102
102: ; preds = %101, %55
br label %103
103: ; preds = %102
%104 = load i64, i64* %10
%105 = add nsw i64 %104, 1
store i64 %105, i64* %10
br label %51
106: ; preds = %51
%107 = load i64, i64* %9
%108 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i64 %107)
br label %109
109: ; preds = %106
store i32 0, i32* %3
br label %110
110: ; preds = %109, %34, %16
%111 = load i32, i32* %3
ret i32 %111
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.1 = [26 x i8] c"File contains %ld bytes.\0A\00"
@stderr = global i32 0
@.str.2 = [24 x i8] c"ERROR: Couldnt malloc!\0A\00"
@.str.3 = [27 x i8] c"File covers %04lx - %04lx\0A\00"
@.str.4 = [23 x i8] c"Found %ld candidates.\0A\00"
define i32 @processDump(i64 %0, i8* nocapture %1) {
%3 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %59, label %5
5: ; preds = %2
%6 = load i32, i32* @SEEK_END
%7 = tail call i32 @fseek(i32* %3, i32 0, i32 %6)
%8 = tail call i64 @ftell(i32* %3)
%9 = load i32, i32* @SEEK_SET
%10 = tail call i32 @fseek(i32* %3, i32 0, i32 %9)
%11 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i64 %8)
%12 = trunc i64 %8 to i32
%13 = tail call i8* @malloc(i32 %12)
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %18
15: ; preds = %5
%16 = load i32, i32* @stderr
%17 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
br label %59
18: ; preds = %5
%19 = tail call i32 @fread(i8* %13, i64 %8, i32 1, i32* %3)
%20 = add i64 %0, -1
%21 = add i64 %20, %8
%22 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i64 %0, i64 %21)
%23 = tail call i32 @fclose(i32* %3)
%24 = icmp sgt i64 %8, 0
br i1 %24, label %25, label %56
25: ; preds = %18, %51
%26 = phi i64 [ %54, %51 ], [ 0, %18 ]
%27 = phi i64 [ %52, %51 ], [ 0, %18 ]
%28 = getelementptr inbounds i8, i8* %13, i64 %26
%29 = load i8, i8* %28
%30 = icmp eq i8 %29, 47
br i1 %30, label %31, label %51
31: ; preds = %25
%32 = add nsw i64 %27, 1
%33 = add nsw i64 %26, 2
%34 = getelementptr inbounds i8, i8* %13, i64 %33
%35 = load i8, i8* %34
%36 = icmp eq i8 %35, 47
br i1 %36, label %37, label %51
37: ; preds = %31
%38 = add nsw i64 %27, 2
br label %39
39: ; preds = %43, %37
%40 = phi i64 [ %26, %37 ], [ %41, %43 ]
%41 = add nsw i64 %40, -1
%42 = icmp sgt i64 %40, 1
br i1 %42, label %43, label %48
43: ; preds = %39
%44 = getelementptr inbounds i8, i8* %13, i64 %41
%45 = load i8, i8* %44
%46 = tail call i64 @isprint(i8 zeroext %45)
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %39
48: ; preds = %39, %43
%49 = add nsw i64 %40, -2
%50 = tail call i32 @printEntry(i8* %13, i64 %0, i64 %49)
br label %51
51: ; preds = %25, %48, %31
%52 = phi i64 [ %38, %48 ], [ %32, %31 ], [ %27, %25 ]
%53 = phi i64 [ %33, %48 ], [ %26, %31 ], [ %26, %25 ]
%54 = add nsw i64 %53, 1
%55 = icmp slt i64 %54, %8
br i1 %55, label %25, label %56
56: ; preds = %51, %18
%57 = phi i64 [ 0, %18 ], [ %52, %51 ]
%58 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i64 %57)
br label %59
59: ; preds = %2, %56, %15
%60 = phi i32 [ 0, %56 ], [ -20, %15 ], [ -10, %2 ]
ret i32 %60
}