#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 {
  long st_size;
};

/* Variables and functions */
void *MAP_FAILED;
int /*<<< orphan*/ MAP_SHARED;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ PROT_READ;
int /*<<< orphan*/ _SC_PAGESIZE;
int close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ error(int, int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(unsigned char *);
int fstat(int, struct stat *);
unsigned char *malloc(size_t);
int mincore(void *, long, unsigned char *);
void *mmap(int /*<<< orphan*/ *, long, int /*<<< orphan*/, int /*<<< orphan*/,
           int, int /*<<< orphan*/);
int munmap(void *, long);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ print_slice(int, long, long, long, unsigned long *);
int /*<<< orphan*/ printf(char *, ...);
long sysconf(int /*<<< orphan*/);
int /*<<< orphan*/ warning(int /*<<< orphan*/, char *, char *);
int main(int argc, char *argv[]) {
  struct stat st;
  void *filemap = NULL;
  unsigned char *pages = NULL;
  size_t lip;
  unsigned long pim, k;
  unsigned long spim;
  long int pagesize, slice_start, slice_end;
  int i, fd, in_a_slice, sindex;
  pagesize = sysconf(_SC_PAGESIZE);
  if (pagesize == -1)
    error(1, errno, "Unable to get pagesize");
  else
    printf("Pagesize is: %ld bytes.\n", pagesize);
  for (i = 1; i < argc; i++) {
    fd = open(argv[i], O_RDONLY);
    if (fd != -1) {
      if (fstat(fd, &st) == -1) {
        warning(errno, "Unable to stat '%s'", argv[i]);
        continue;
      }
      filemap = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
      if (filemap == MAP_FAILED) {
        warning(errno, "Unable to map '%s'", argv[i]);
        continue;
      }
      lip = (st.st_size + pagesize - 1) / pagesize;
      pages = malloc(lip);
      if (pages == NULL)
        error(2, errno, "Unable to allocate pages[%lu]", (unsigned long)lip);
      if (mincore(filemap, st.st_size, pages) == -1) {
        warning(errno, "Unable to get core info for '%s'", argv[i]);
        continue;
      }
      pim = spim = 0;
      sindex = slice_start = slice_end = in_a_slice = 0;
      printf("'%s':\n", argv[i]);
      for (k = 0; k < lip; k++) {
        if (pages[k] & 1) {
          if (!in_a_slice) {
            in_a_slice = 1;
            slice_start = pagesize * k;
            slice_end = slice_start + pagesize - 1;
          } else
            slice_end += pagesize;
          pim++;
        } else if (in_a_slice) {
          in_a_slice = 0;
          print_slice(sindex, pagesize, slice_start, slice_end, &spim);
          sindex++;
        }
      }
      if (in_a_slice) {
        print_slice(sindex, pagesize, slice_start, slice_end, &spim);
      }
      if (spim)
        printf("\t%lu pages in slices appear to be in "
               "pagecache\n",
               spim);
      printf("\t%lu pages out of %lu appear to be in "
             "pagecache\n",
             pim, (unsigned long)lip);
      free(pages);
      pages = NULL;
      if (munmap(filemap, st.st_size) == -1) {
        warning(errno, "Unable to unmap '%s'", argv[i]);
        continue;
      }
      if (close(fd) == -1)
        warning(errno, "Problem closing '%s'", argv[i]);
    } else
      warning(errno, "Unable to open '%s'", argv[i]);
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    0x2dd3(%rip),%rax
mov    (%rax),%edi
call   10e0 <sysconf@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0xffffffffffffffff,-0x50(%rbp)
jne    1234 <main+0x64>
mov    0x2da6(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
lea    0xdd8(%rip),%rdx
mov    $0x0,%al
call   10c0 <error@plt>
jmp    1246 <main+0x76>
mov    -0x50(%rbp),%rsi
lea    0xdd8(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    15cd <main+0x3fd>
mov    -0x10(%rbp),%rax
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2d6c(%rip),%rax
mov    (%rax),%esi
call   10d0 <open@plt>
mov    %eax,-0x68(%rbp)
cmpl   $0xffffffff,-0x68(%rbp)
je     1599 <main+0x3c9>
mov    -0x68(%rbp),%edi
lea    -0x18(%rbp),%rsi
call   10f0 <fstat@plt>
cmp    $0xffffffff,%eax
jne    12bb <main+0xeb>
mov    0x2d24(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xd7f(%rip),%rsi
call   1040 <warning@plt>
jmp    15bf <main+0x3ef>
mov    -0x18(%rbp),%rsi
mov    0x2d32(%rip),%rax
mov    (%rax),%edx
mov    0x2d19(%rip),%rax
mov    (%rax),%ecx
mov    -0x68(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
xor    %r9d,%r9d
call   1050 <mmap@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    0x2cc8(%rip),%rcx
cmp    (%rcx),%rax
jne    131f <main+0x14f>
mov    0x2cc0(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xd2f(%rip),%rsi
call   1040 <warning@plt>
jmp    15bf <main+0x3ef>
mov    -0x18(%rbp),%rax
add    -0x50(%rbp),%rax
sub    $0x1,%rax
cqto
idivq  -0x50(%rbp)
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1090 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    136d <main+0x19d>
mov    0x2c6c(%rip),%rax
mov    (%rax),%esi
mov    -0x30(%rbp),%rcx
mov    $0x2,%edi
lea    0xcf1(%rip),%rdx
mov    $0x0,%al
call   10c0 <error@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1080 <mincore@plt>
cmp    $0xffffffff,%eax
jne    13ad <main+0x1dd>
mov    0x2c32(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xcd2(%rip),%rsi
call   1040 <warning@plt>
jmp    15bf <main+0x3ef>
movq   $0x0,-0x48(%rbp)
movq   $0x0,-0x38(%rbp)
movl   $0x0,-0x6c(%rbp)
movq   $0x0,-0x60(%rbp)
movq   $0x0,-0x58(%rbp)
movl   $0x0,-0x70(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xca8(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movq   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%rax
cmp    -0x30(%rbp),%rax
jae    14c0 <main+0x2f0>
mov    -0x28(%rbp),%rax
mov    -0x40(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1473 <main+0x2a3>
cmpl   $0x0,-0x6c(%rbp)
jne    1456 <main+0x286>
movl   $0x1,-0x6c(%rbp)
mov    -0x50(%rbp),%rax
imul   -0x40(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rax
add    -0x50(%rbp),%rax
sub    $0x1,%rax
mov    %rax,-0x60(%rbp)
jmp    1462 <main+0x292>
mov    -0x50(%rbp),%rax
add    -0x60(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    14aa <main+0x2da>
cmpl   $0x0,-0x6c(%rbp)
je     14a5 <main+0x2d5>
movl   $0x0,-0x6c(%rbp)
mov    -0x70(%rbp),%edi
mov    -0x50(%rbp),%rsi
mov    -0x58(%rbp),%rdx
mov    -0x60(%rbp),%rcx
lea    -0x48(%rbp),%r8
call   10b0 <print_slice@plt>
mov    -0x70(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x70(%rbp)
jmp    14aa <main+0x2da>
jmp    14af <main+0x2df>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    13fd <main+0x22d>
cmpl   $0x0,-0x6c(%rbp)
je     14e2 <main+0x312>
mov    -0x70(%rbp),%edi
mov    -0x50(%rbp),%rsi
mov    -0x58(%rbp),%rdx
mov    -0x60(%rbp),%rcx
lea    -0x48(%rbp),%r8
call   10b0 <print_slice@plt>
cmpq   $0x0,-0x48(%rbp)
je     14ff <main+0x32f>
mov    -0x48(%rbp),%rsi
lea    0xba5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x38(%rbp),%rsi
mov    -0x30(%rbp),%rdx
lea    0xbbf(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   10a0 <munmap@plt>
cmp    $0xffffffff,%eax
jne    1562 <main+0x392>
mov    0x2a7d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xba6(%rip),%rsi
call   1040 <warning@plt>
jmp    15bf <main+0x3ef>
mov    -0x68(%rbp),%edi
call   1070 <close@plt>
cmp    $0xffffffff,%eax
jne    1594 <main+0x3c4>
mov    0x2a46(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xb84(%rip),%rsi
call   1040 <warning@plt>
jmp    15ba <main+0x3ea>
mov    0x2a20(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xb73(%rip),%rsi
call   1040 <warning@plt>
jmp    15bf <main+0x3ef>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    124d <main+0x7d>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %rsi,%r13
mov    %edi,%r14d
mov    0x2de5(%rip),%rax
mov    (%rax),%edi
call   10e0 <sysconf@plt>
cmp    $0xffffffffffffffff,%rax
mov    %rax,0x10(%rsp)
je     1219 <main+0x49>
lea    0xe13(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
cmp    $0x2,%r14d
jge    123f <main+0x6f>
jmp    1520 <main+0x350>
mov    0x2da0(%rip),%rax
mov    (%rax),%esi
lea    0xdd7(%rip),%rdx
mov    $0x1,%edi
xor    %eax,%eax
call   10c0 <error@plt>
cmp    $0x2,%r14d
jl     1520 <main+0x350>
mov    0x10(%rsp),%rax
lea    -0x1(%rax),%r15
mov    %r14d,%r14d
mov    $0x1,%ebp
mov    0x2d81(%rip),%r12
mov    %r13,0x40(%rsp)
mov    %r15,0x38(%rsp)
mov    %r14,0x30(%rsp)
cs nopw 0x0(%rax,%rax,1)
mov    0x0(%r13,%rbp,8),%rdi
mov    (%r12),%esi
call   10d0 <open@plt>
lea    0xea3(%rip),%rsi
cmp    $0xffffffff,%eax
je     1500 <main+0x330>
mov    %eax,%edi
lea    0x70(%rsp),%rsi
mov    %eax,0x1c(%rsp)
call   10f0 <fstat@plt>
lea    0xd8b(%rip),%rsi
cmp    $0xffffffff,%eax
je     1500 <main+0x330>
mov    0x70(%rsp),%rbx
mov    0x2d3e(%rip),%rax
mov    (%rax),%edx
mov    0x2d25(%rip),%rax
mov    (%rax),%ecx
xor    %edi,%edi
mov    %rbx,%rsi
mov    0x1c(%rsp),%r8d
xor    %r9d,%r9d
call   1050 <mmap@plt>
mov    %rax,%rcx
lea    0xd63(%rip),%rsi
mov    0x2cd0(%rip),%rax
mov    %rcx,0x58(%rsp)
cmp    (%rax),%rcx
je     1500 <main+0x330>
lea    (%r15,%rbx,1),%rax
mov    %rax,%rcx
mov    0x10(%rsp),%rsi
or     %rsi,%rcx
shr    $0x20,%rcx
mov    %rbx,0x50(%rsp)
je     1317 <main+0x147>
cqto
idiv   %rsi
jmp    131b <main+0x14b>
xor    %edx,%edx
div    %esi
mov    %rax,0x8(%rsp)
mov    %rax,%rdi
call   1090 <malloc@plt>
test   %rax,%rax
mov    %rax,0x20(%rsp)
jne    1358 <main+0x188>
mov    0x2c87(%rip),%rax
mov    (%rax),%esi
mov    $0x2,%edi
lea    0xd10(%rip),%rdx
mov    0x8(%rsp),%rcx
xor    %eax,%eax
call   10c0 <error@plt>
mov    0x20(%rsp),%rax
mov    0x58(%rsp),%rdi
mov    0x50(%rsp),%rsi
mov    %rax,%rdx
call   1080 <mincore@plt>
lea    0xd04(%rip),%rsi
cmp    $0xffffffff,%eax
je     1500 <main+0x330>
movq   $0x0,0x28(%rsp)
mov    0x0(%r13,%rbp,8),%rsi
lea    0xd07(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x8(%rsp),%rdx
test   %rdx,%rdx
je     148d <main+0x2bd>
mov    %rbp,0x48(%rsp)
xor    %r12d,%r12d
mov    %r15,%rbp
xor    %r15d,%r15d
xor    %eax,%eax
xor    %r14d,%r14d
xor    %r9d,%r9d
xor    %ebx,%ebx
xor    %r8d,%r8d
mov    0x10(%rsp),%rsi
mov    0x20(%rsp),%r10
jmp    13fb <main+0x22b>
nopl   0x0(%rax,%rax,1)
add    %rsi,%r14
test   %eax,%eax
cmove  %r12,%r9
cmove  %rbp,%r14
add    $0x1,%r8
mov    $0x1,%r13d
xor    %ecx,%ecx
add    $0x1,%rbx
add    %rsi,%rbp
add    %rsi,%r12
mov    %r13d,%eax
cmp    %rbx,%rdx
je     144e <main+0x27e>
testb  $0x1,(%r10,%rbx,1)
jne    13d0 <main+0x200>
xor    %r13d,%r13d
mov    $0x1,%cl
test   %eax,%eax
je     13e9 <main+0x219>
mov    %r15d,%edi
mov    0x10(%rsp),%rsi
mov    %r9,%rdx
mov    %r14,%rcx
mov    %r8,0x68(%rsp)
lea    0x28(%rsp),%r8
mov    %r9,0x60(%rsp)
call   10b0 <print_slice@plt>
mov    $0x1,%cl
mov    0x60(%rsp),%r9
mov    0x68(%rsp),%r8
mov    0x20(%rsp),%r10
mov    0x8(%rsp),%rdx
mov    0x10(%rsp),%rsi
add    $0x1,%r15d
jmp    13e9 <main+0x219>
test   %cl,%cl
jne    1470 <main+0x2a0>
mov    %r15d,%edi
mov    %r9,%rdx
mov    %r14,%rcx
mov    %r8,%rbx
lea    0x28(%rsp),%r8
call   10b0 <print_slice@plt>
mov    %rbx,%r8
mov    0x8(%rsp),%rdx
mov    0x40(%rsp),%r13
mov    0x38(%rsp),%r15
mov    0x30(%rsp),%r14
mov    0x48(%rsp),%rbp
mov    0x2b4d(%rip),%r12
jmp    1490 <main+0x2c0>
xor    %r8d,%r8d
mov    0x28(%rsp),%rsi
test   %rsi,%rsi
je     14b3 <main+0x2e3>
lea    0xbfc(%rip),%rdi
xor    %eax,%eax
mov    %r8,%rbx
call   1060 <printf@plt>
mov    %rbx,%r8
mov    0x8(%rsp),%rdx
lea    0xc13(%rip),%rdi
mov    %r8,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x20(%rsp),%rdi
call   1030 <free@plt>
mov    0x58(%rsp),%rdi
mov    0x50(%rsp),%rsi
call   10a0 <munmap@plt>
lea    0xc1a(%rip),%rsi
cmp    $0xffffffff,%eax
mov    0x1c(%rsp),%edi
je     1500 <main+0x330>
call   1070 <close@plt>
lea    0xc1a(%rip),%rsi
cmp    $0xffffffff,%eax
jne    1513 <main+0x343>
xchg   %ax,%ax
mov    0x2ab9(%rip),%rax
mov    (%rax),%edi
mov    0x0(%r13,%rbp,8),%rdx
call   1040 <warning@plt>
add    $0x1,%rbp
cmp    %r14,%rbp
jne    1270 <main+0xa0>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i64 }
@_SC_PAGESIZE = global i32 0
@errno = global i32 0
@.str = [23 x i8] c"Unable to get pagesize\00"
@.str.1 = [25 x i8] c"Pagesize is: %ld bytes.\0A\00"
@O_RDONLY = global i32 0
@.str.2 = [20 x i8] c"Unable to stat '%s'\00"
@PROT_READ = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i8* null
@.str.3 = [19 x i8] c"Unable to map '%s'\00"
@.str.4 = [30 x i8] c"Unable to allocate pages[%lu]\00"
@.str.5 = [33 x i8] c"Unable to get core info for '%s'\00"
@.str.6 = [7 x i8] c"'%s':\0A\00"
@.str.7 = [48 x i8] c"\09%lu pages in slices appear to be in pagecache\0A\00"
@.str.8 = [49 x i8] c"\09%lu pages out of %lu appear to be in pagecache\0A\00"
@.str.9 = [21 x i8] c"Unable to unmap '%s'\00"
@.str.10 = [21 x i8] c"Problem closing '%s'\00"
@.str.11 = [20 x i8] c"Unable to open '%s'\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.stat
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64
%13 = alloca i64
%14 = alloca i64
%15 = alloca i64
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %7
store i8* null, i8** %8
%20 = load i32, i32* @_SC_PAGESIZE
%21 = call i64 @sysconf(i32 %20)
store i64 %21, i64* %13
%22 = load i64, i64* %13
%23 = icmp eq i64 %22, -1
br i1 %23, label %24, label %27
24: ; preds = %2
%25 = load i32, i32* @errno
%26 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 %25, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %30
27: ; preds = %2
%28 = load i64, i64* %13
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i64 %28)
br label %30
30: ; preds = %27, %24
store i32 1, i32* %16
br label %31
31: ; preds = %215, %30
%32 = load i32, i32* %16
%33 = load i32, i32* %4
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %218
35: ; preds = %31
%36 = load i8**, i8*** %5
%37 = load i32, i32* %16
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8*, i8** %36, i64 %38
%40 = load i8*, i8** %39
%41 = load i32, i32* @O_RDONLY
%42 = call i32 @open(i8* %40, i32 %41)
store i32 %42, i32* %17
%43 = load i32, i32* %17
%44 = icmp ne i32 %43, -1
br i1 %44, label %45, label %206
45: ; preds = %35
%46 = load i32, i32* %17
%47 = call i32 @fstat(i32 %46, %struct.stat* %6)
%48 = icmp eq i32 %47, -1
br i1 %48, label %49, label %57
49: ; preds = %45
%50 = load i32, i32* @errno
%51 = load i8**, i8*** %5
%52 = load i32, i32* %16
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8*, i8** %51, i64 %53
%55 = load i8*, i8** %54
%56 = call i32 @warning(i32 %50, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %55)
br label %215
57: ; preds = %45
%58 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%59 = load i64, i64* %58
%60 = load i32, i32* @PROT_READ
%61 = load i32, i32* @MAP_SHARED
%62 = load i32, i32* %17
%63 = call i8* @mmap(i32* null, i64 %59, i32 %60, i32 %61, i32 %62, i32 0)
store i8* %63, i8** %7
%64 = load i8*, i8** %7
%65 = load i8*, i8** @MAP_FAILED
%66 = icmp eq i8* %64, %65
br i1 %66, label %67, label %75
67: ; preds = %57
%68 = load i32, i32* @errno
%69 = load i8**, i8*** %5
%70 = load i32, i32* %16
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds i8*, i8** %69, i64 %71
%73 = load i8*, i8** %72
%74 = call i32 @warning(i32 %68, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %73)
br label %215
75: ; preds = %57
%76 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%77 = load i64, i64* %76
%78 = load i64, i64* %13
%79 = add nsw i64 %77, %78
%80 = sub nsw i64 %79, 1
%81 = load i64, i64* %13
%82 = sdiv i64 %80, %81
store i64 %82, i64* %9
%83 = load i64, i64* %9
%84 = call i8* @malloc(i64 %83)
store i8* %84, i8** %8
%85 = load i8*, i8** %8
%86 = icmp eq i8* %85, null
br i1 %86, label %87, label %91
87: ; preds = %75
%88 = load i32, i32* @errno
%89 = load i64, i64* %9
%90 = call i32 (i32, i32, i8*, ...) @error(i32 2, i32 %88, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i64 %89)
br label %91
91: ; preds = %87, %75
%92 = load i8*, i8** %7
%93 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%94 = load i64, i64* %93
%95 = load i8*, i8** %8
%96 = call i32 @mincore(i8* %92, i64 %94, i8* %95)
%97 = icmp eq i32 %96, -1
br i1 %97, label %98, label %106
98: ; preds = %91
%99 = load i32, i32* @errno
%100 = load i8**, i8*** %5
%101 = load i32, i32* %16
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds i8*, i8** %100, i64 %102
%104 = load i8*, i8** %103
%105 = call i32 @warning(i32 %99, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i8* %104)
br label %215
106: ; preds = %91
store i64 0, i64* %12
store i64 0, i64* %10
store i32 0, i32* %18
store i64 0, i64* %15
store i64 0, i64* %14
store i32 0, i32* %19
%107 = load i8**, i8*** %5
%108 = load i32, i32* %16
%109 = sext i32 %108 to i64
%110 = getelementptr inbounds i8*, i8** %107, i64 %109
%111 = load i8*, i8** %110
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %111)
store i64 0, i64* %11
br label %113
113: ; preds = %156, %106
%114 = load i64, i64* %11
%115 = load i64, i64* %9
%116 = icmp ult i64 %114, %115
br i1 %116, label %117, label %159
117: ; preds = %113
%118 = load i8*, i8** %8
%119 = load i64, i64* %11
%120 = getelementptr inbounds i8, i8* %118, i64 %119
%121 = load i8, i8* %120
%122 = zext i8 %121 to i32
%123 = and i32 %122, 1
%124 = icmp ne i32 %123, 0
br i1 %124, label %125, label %143
125: ; preds = %117
%126 = load i32, i32* %18
%127 = icmp ne i32 %126, 0
br i1 %127, label %136, label %128
128: ; preds = %125
store i32 1, i32* %18
%129 = load i64, i64* %13
%130 = load i64, i64* %11
%131 = mul i64 %129, %130
store i64 %131, i64* %14
%132 = load i64, i64* %14
%133 = load i64, i64* %13
%134 = add nsw i64 %132, %133
%135 = sub nsw i64 %134, 1
store i64 %135, i64* %15
br label %140
136: ; preds = %125
%137 = load i64, i64* %13
%138 = load i64, i64* %15
%139 = add nsw i64 %138, %137
store i64 %139, i64* %15
br label %140
140: ; preds = %136, %128
%141 = load i64, i64* %10
%142 = add i64 %141, 1
store i64 %142, i64* %10
br label %155
143: ; preds = %117
%144 = load i32, i32* %18
%145 = icmp ne i32 %144, 0
br i1 %145, label %146, label %154
146: ; preds = %143
store i32 0, i32* %18
%147 = load i32, i32* %19
%148 = load i64, i64* %13
%149 = load i64, i64* %14
%150 = load i64, i64* %15
%151 = call i32 @print_slice(i32 %147, i64 %148, i64 %149, i64 %150, i64* %12)
%152 = load i32, i32* %19
%153 = add nsw i32 %152, 1
store i32 %153, i32* %19
br label %154
154: ; preds = %146, %143
br label %155
155: ; preds = %154, %140
br label %156
156: ; preds = %155
%157 = load i64, i64* %11
%158 = add i64 %157, 1
store i64 %158, i64* %11
br label %113
159: ; preds = %113
%160 = load i32, i32* %18
%161 = icmp ne i32 %160, 0
br i1 %161, label %162, label %168
162: ; preds = %159
%163 = load i32, i32* %19
%164 = load i64, i64* %13
%165 = load i64, i64* %14
%166 = load i64, i64* %15
%167 = call i32 @print_slice(i32 %163, i64 %164, i64 %165, i64 %166, i64* %12)
br label %168
168: ; preds = %162, %159
%169 = load i64, i64* %12
%170 = icmp ne i64 %169, 0
br i1 %170, label %171, label %174
171: ; preds = %168
%172 = load i64, i64* %12
%173 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.7, i64 0, i64 0), i64 %172)
br label %174
174: ; preds = %171, %168
%175 = load i64, i64* %10
%176 = load i64, i64* %9
%177 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.8, i64 0, i64 0), i64 %175, i64 %176)
%178 = load i8*, i8** %8
%179 = call i32 @free(i8* %178)
store i8* null, i8** %8
%180 = load i8*, i8** %7
%181 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%182 = load i64, i64* %181
%183 = call i32 @munmap(i8* %180, i64 %182)
%184 = icmp eq i32 %183, -1
br i1 %184, label %185, label %193
185: ; preds = %174
%186 = load i32, i32* @errno
%187 = load i8**, i8*** %5
%188 = load i32, i32* %16
%189 = sext i32 %188 to i64
%190 = getelementptr inbounds i8*, i8** %187, i64 %189
%191 = load i8*, i8** %190
%192 = call i32 @warning(i32 %186, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0), i8* %191)
br label %215
193: ; preds = %174
%194 = load i32, i32* %17
%195 = call i32 @close(i32 %194)
%196 = icmp eq i32 %195, -1
br i1 %196, label %197, label %205
197: ; preds = %193
%198 = load i32, i32* @errno
%199 = load i8**, i8*** %5
%200 = load i32, i32* %16
%201 = sext i32 %200 to i64
%202 = getelementptr inbounds i8*, i8** %199, i64 %201
%203 = load i8*, i8** %202
%204 = call i32 @warning(i32 %198, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0), i8* %203)
br label %205
205: ; preds = %197, %193
br label %214
206: ; preds = %35
%207 = load i32, i32* @errno
%208 = load i8**, i8*** %5
%209 = load i32, i32* %16
%210 = sext i32 %209 to i64
%211 = getelementptr inbounds i8*, i8** %208, i64 %210
%212 = load i8*, i8** %211
%213 = call i32 @warning(i32 %207, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.11, i64 0, i64 0), i8* %212)
br label %214
214: ; preds = %206, %205
br label %215
215: ; preds = %214, %185, %98, %67, %49
%216 = load i32, i32* %16
%217 = add nsw i32 %216, 1
store i32 %217, i32* %16
br label %31
218: ; preds = %31
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i64 }
@_SC_PAGESIZE = global i32 0
@errno = global i32 0
@.str = [23 x i8] c"Unable to get pagesize\00"
@.str.1 = [25 x i8] c"Pagesize is: %ld bytes.\0A\00"
@O_RDONLY = global i32 0
@.str.2 = [20 x i8] c"Unable to stat '%s'\00"
@PROT_READ = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i8* null
@.str.3 = [19 x i8] c"Unable to map '%s'\00"
@.str.4 = [30 x i8] c"Unable to allocate pages[%lu]\00"
@.str.5 = [33 x i8] c"Unable to get core info for '%s'\00"
@.str.6 = [7 x i8] c"'%s':\0A\00"
@.str.7 = [48 x i8] c"\09%lu pages in slices appear to be in pagecache\0A\00"
@.str.8 = [49 x i8] c"\09%lu pages out of %lu appear to be in pagecache\0A\00"
@.str.9 = [21 x i8] c"Unable to unmap '%s'\00"
@.str.10 = [21 x i8] c"Problem closing '%s'\00"
@.str.11 = [20 x i8] c"Unable to open '%s'\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = alloca i64
%5 = bitcast %struct.stat* %3 to i8*
%6 = bitcast i64* %4 to i8*
%7 = load i32, i32* @_SC_PAGESIZE
%8 = tail call i64 @sysconf(i32 %7)
%9 = icmp eq i64 %8, -1
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i32, i32* @errno
%12 = tail call i32 (i32, i32, i8*, ...) @error(i32 1, i32 %11, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %15
13: ; preds = %2
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i64 %8)
br label %15
15: ; preds = %13, %10
%16 = icmp sgt i32 %0, 1
br i1 %16, label %17, label %110
17: ; preds = %15
%18 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%19 = add i64 %8, -1
%20 = zext i32 %0 to i64
br label %21
21: ; preds = %17, %107
%22 = phi i64 [ 1, %17 ], [ %108, %107 ]
%23 = getelementptr inbounds i8*, i8** %1, i64 %22
%24 = load i8*, i8** %23
%25 = load i32, i32* @O_RDONLY
%26 = call i32 @open(i8* %24, i32 %25)
%27 = icmp eq i32 %26, -1
br i1 %27, label %102, label %28
28: ; preds = %21
%29 = call i32 @fstat(i32 %26, %struct.stat* %3)
%30 = icmp eq i32 %29, -1
br i1 %30, label %102, label %31
31: ; preds = %28
%32 = load i64, i64* %18
%33 = load i32, i32* @PROT_READ
%34 = load i32, i32* @MAP_SHARED
%35 = call i8* @mmap(i32* null, i64 %32, i32 %33, i32 %34, i32 %26, i32 0)
%36 = load i8*, i8** @MAP_FAILED
%37 = icmp eq i8* %35, %36
br i1 %37, label %102, label %38
38: ; preds = %31
%39 = add i64 %19, %32
%40 = sdiv i64 %39, %8
%41 = call i8* @malloc(i64 %40)
%42 = icmp eq i8* %41, null
br i1 %42, label %43, label %46
43: ; preds = %38
%44 = load i32, i32* @errno
%45 = call i32 (i32, i32, i8*, ...) @error(i32 2, i32 %44, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i64 %40)
br label %46
46: ; preds = %43, %38
%47 = call i32 @mincore(i8* %35, i64 %32, i8* %41)
%48 = icmp eq i32 %47, -1
br i1 %48, label %102, label %49
49: ; preds = %46
store i64 0, i64* %4
%50 = load i8*, i8** %23
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %50)
%52 = icmp eq i64 %40, 0
br i1 %52, label %88, label %53
53: ; preds = %49, %76
%54 = phi i32 [ %82, %76 ], [ 0, %49 ]
%55 = phi i32 [ %81, %76 ], [ 0, %49 ]
%56 = phi i64 [ %79, %76 ], [ 0, %49 ]
%57 = phi i64 [ %78, %76 ], [ 0, %49 ]
%58 = phi i64 [ %83, %76 ], [ 0, %49 ]
%59 = phi i64 [ %77, %76 ], [ 0, %49 ]
%60 = getelementptr inbounds i8, i8* %41, i64 %58
%61 = load i8, i8* %60
%62 = and i8 %61, 1
%63 = icmp eq i8 %62, 0
%64 = icmp eq i32 %55, 0
br i1 %63, label %72, label %65
65: ; preds = %53
%66 = add nsw i64 %56, %8
%67 = mul i64 %58, %8
%68 = add i64 %19, %67
%69 = select i1 %64, i64 %67, i64 %57
%70 = select i1 %64, i64 %68, i64 %66
%71 = add i64 %59, 1
br label %76
72: ; preds = %53
br i1 %64, label %76, label %73
73: ; preds = %72
%74 = call i32 @print_slice(i32 %54, i64 %8, i64 %57, i64 %56, i64* %4)
%75 = add nsw i32 %54, 1
br label %76
76: ; preds = %65, %73, %72
%77 = phi i64 [ %71, %65 ], [ %59, %73 ], [ %59, %72 ]
%78 = phi i64 [ %69, %65 ], [ %57, %73 ], [ %57, %72 ]
%79 = phi i64 [ %70, %65 ], [ %56, %73 ], [ %56, %72 ]
%80 = phi i1 [ false, %65 ], [ true, %73 ], [ true, %72 ]
%81 = phi i32 [ 1, %65 ], [ 0, %73 ], [ 0, %72 ]
%82 = phi i32 [ %54, %65 ], [ %75, %73 ], [ %54, %72 ]
%83 = add nuw i64 %58, 1
%84 = icmp eq i64 %83, %40
br i1 %84, label %85, label %53
85: ; preds = %76
br i1 %80, label %88, label %86
86: ; preds = %85
%87 = call i32 @print_slice(i32 %82, i64 %8, i64 %78, i64 %79, i64* %4)
br label %88
88: ; preds = %49, %86, %85
%89 = phi i64 [ %77, %86 ], [ %77, %85 ], [ 0, %49 ]
%90 = load i64, i64* %4
%91 = icmp eq i64 %90, 0
br i1 %91, label %94, label %92
92: ; preds = %88
%93 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.7, i64 0, i64 0), i64 %90)
br label %94
94: ; preds = %92, %88
%95 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.8, i64 0, i64 0), i64 %89, i64 %40)
%96 = call i32 @free(i8* %41)
%97 = call i32 @munmap(i8* %35, i64 %32)
%98 = icmp eq i32 %97, -1
br i1 %98, label %102, label %99
99: ; preds = %94
%100 = call i32 @close(i32 %26)
%101 = icmp eq i32 %100, -1
br i1 %101, label %102, label %107
102: ; preds = %21, %99, %94, %46, %31, %28
%103 = phi i8* [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), %28 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), %31 ], [ getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), %46 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0), %94 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0), %99 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.11, i64 0, i64 0), %21 ]
%104 = load i32, i32* @errno
%105 = load i8*, i8** %23
%106 = call i32 @warning(i32 %104, i8* %103, i8* %105)
br label %107
107: ; preds = %102, %99
%108 = add nuw nsw i64 %22, 1
%109 = icmp eq i64 %108, %20
br i1 %109, label %110, label %21
110: ; preds = %107, %15
ret i32 0
}