#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 *);
scalar_t__ mmap(int /*<<< orphan*/ *, long, int /*<<< orphan*/,
                int /*<<< orphan*/, int, int /*<<< orphan*/);
int munmap(void *, long);
int open(char *, int /*<<< orphan*/);
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 *vec = NULL;
  size_t vlen;
  unsigned long pim, k;
  long int pagesize;
  int i, fd;
  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 =
          (unsigned char *)mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
      if (filemap == MAP_FAILED) {
        warning(errno, "Unable to map '%s'", argv[i]);
        continue;
      }
      vlen = (st.st_size + pagesize - 1) / pagesize;
      vec = malloc(vlen);
      if (vec == NULL)
        error(2, errno, "Unable to allocate vec[%lu]", (unsigned long)vlen);
      if (mincore(filemap, st.st_size, vec) == -1) {
        warning(errno, "Unable to get core info for '%s'", argv[i]);
        continue;
      }
      pim = 0;
      for (k = 0; k < vlen; k++) {
        if (vec[k] & 1)
          pim++;
      }
      printf("'%s': %lu pages out of %lu appear to be in "
             "pagecache\n",
             argv[i], pim, (unsigned long)vlen);
      free(vec);
      vec = 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    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    0x2de3(%rip),%rax
mov    (%rax),%edi
call   10d0 <sysconf@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0xffffffffffffffff,-0x48(%rbp)
jne    1224 <main+0x64>
mov    0x2db6(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
lea    0xde8(%rip),%rdx
mov    $0x0,%al
call   10b0 <error@plt>
jmp    1236 <main+0x76>
mov    -0x48(%rbp),%rsi
lea    0xde8(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    14cf <main+0x30f>
mov    -0x10(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2d7c(%rip),%rax
mov    (%rax),%esi
call   10c0 <open@plt>
mov    %eax,-0x50(%rbp)
cmpl   $0xffffffff,-0x50(%rbp)
je     149b <main+0x2db>
mov    -0x50(%rbp),%edi
lea    -0x18(%rbp),%rsi
call   10e0 <fstat@plt>
cmp    $0xffffffff,%eax
jne    12ab <main+0xeb>
mov    0x2d34(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xd8f(%rip),%rsi
call   1040 <warning@plt>
jmp    14c1 <main+0x301>
mov    -0x18(%rbp),%rsi
mov    0x2d42(%rip),%rax
mov    (%rax),%edx
mov    0x2d29(%rip),%rax
mov    (%rax),%ecx
mov    -0x50(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
xor    %r9d,%r9d
call   1050 <mmap@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    0x2cd8(%rip),%rcx
cmp    (%rcx),%rax
jne    130f <main+0x14f>
mov    0x2cd0(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xd3f(%rip),%rsi
call   1040 <warning@plt>
jmp    14c1 <main+0x301>
mov    -0x18(%rbp),%rax
add    -0x48(%rbp),%rax
sub    $0x1,%rax
cqto
idivq  -0x48(%rbp)
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1090 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    135d <main+0x19d>
mov    0x2c7c(%rip),%rax
mov    (%rax),%esi
mov    -0x30(%rbp),%rcx
mov    $0x2,%edi
lea    0xd01(%rip),%rdx
mov    $0x0,%al
call   10b0 <error@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1080 <mincore@plt>
cmp    $0xffffffff,%eax
jne    139d <main+0x1dd>
mov    0x2c42(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xce0(%rip),%rsi
call   1040 <warning@plt>
jmp    14c1 <main+0x301>
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%rax
cmp    -0x30(%rbp),%rax
jae    13f5 <main+0x235>
mov    -0x28(%rbp),%rax
mov    -0x40(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     13df <main+0x21f>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    13e4 <main+0x224>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    13ad <main+0x1ed>
mov    -0x10(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x30(%rbp),%rcx
lea    0xc84(%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    1464 <main+0x2a4>
mov    0x2b7b(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xc70(%rip),%rsi
call   1040 <warning@plt>
jmp    14c1 <main+0x301>
mov    -0x50(%rbp),%edi
call   1070 <close@plt>
cmp    $0xffffffff,%eax
jne    1496 <main+0x2d6>
mov    0x2b44(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xc4e(%rip),%rsi
call   1040 <warning@plt>
jmp    14bc <main+0x2fc>
mov    0x2b1e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xc3d(%rip),%rsi
call   1040 <warning@plt>
jmp    14c1 <main+0x301>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    123d <main+0x7d>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x2df6(%rip),%rax
mov    (%rax),%edi
call   10d0 <sysconf@plt>
cmp    $0xffffffffffffffff,%rax
mov    %rax,(%rsp)
je     1206 <main+0x46>
lea    0xe35(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
cmp    $0x2,%ebp
jge    122b <main+0x6b>
jmp    1521 <main+0x361>
mov    0x2db3(%rip),%rax
mov    (%rax),%esi
lea    0xdfa(%rip),%rdx
mov    $0x1,%edi
xor    %eax,%eax
call   10b0 <error@plt>
cmp    $0x2,%ebp
jl     1521 <main+0x361>
mov    (%rsp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,0x10(%rsp)
mov    %ebp,%eax
mov    %rax,0x18(%rsp)
mov    $0x1,%r13d
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%rbx,%r13,8),%rdi
mov    0x2d7d(%rip),%rax
mov    (%rax),%esi
call   10c0 <open@plt>
lea    0xe9b(%rip),%rsi
cmp    $0xffffffff,%eax
je     1500 <main+0x340>
mov    %eax,%ebp
mov    %eax,%edi
lea    0x20(%rsp),%rsi
call   10e0 <fstat@plt>
lea    0xdb9(%rip),%rsi
cmp    $0xffffffff,%eax
je     1500 <main+0x340>
mov    0x20(%rsp),%r12
mov    0x2d5c(%rip),%rax
mov    (%rax),%edx
mov    0x2d43(%rip),%rax
mov    (%rax),%ecx
xor    %edi,%edi
mov    %r12,%rsi
mov    %ebp,%r8d
xor    %r9d,%r9d
call   1050 <mmap@plt>
mov    %rax,%rcx
lea    0xd93(%rip),%rsi
mov    0x2cf0(%rip),%rax
mov    %rcx,0x8(%rsp)
cmp    %rcx,(%rax)
je     1500 <main+0x340>
mov    0x10(%rsp),%rax
add    %r12,%rax
mov    %rax,%rcx
mov    (%rsp),%rsi
or     %rsi,%rcx
shr    $0x20,%rcx
je     12f8 <main+0x138>
cqto
idiv   %rsi
mov    %rax,%r15
jmp    12ff <main+0x13f>
xor    %edx,%edx
div    %esi
mov    %eax,%r15d
mov    %r15,%rdi
call   1090 <malloc@plt>
mov    %rax,%r14
test   %rax,%rax
jne    132e <main+0x16e>
mov    0x2caa(%rip),%rax
mov    (%rax),%esi
mov    $0x2,%edi
lea    0xd43(%rip),%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   10b0 <error@plt>
mov    0x8(%rsp),%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1080 <mincore@plt>
lea    0xd3e(%rip),%rsi
cmp    $0xffffffff,%eax
je     1500 <main+0x340>
test   %r15,%r15
je     1362 <main+0x1a2>
cmp    $0x4,%r15
jae    1369 <main+0x1a9>
xor    %eax,%eax
xor    %edx,%edx
jmp    14a0 <main+0x2e0>
xor    %edx,%edx
jmp    14b4 <main+0x2f4>
mov    %r15,%rax
and    $0xfffffffffffffffc,%rax
lea    -0x4(%rax),%rdx
mov    %rdx,%rcx
shr    $0x2,%rcx
add    $0x1,%rcx
test   %rdx,%rdx
movdqa 0xc76(%rip),%xmm4
pxor   %xmm5,%xmm5
je     1489 <main+0x2c9>
mov    %rcx,%rsi
and    $0xfffffffffffffffe,%rsi
pxor   %xmm0,%xmm0
xor    %edx,%edx
pxor   %xmm1,%xmm1
cs nopw 0x0(%rax,%rax,1)
nop
movzwl (%r14,%rdx,1),%edi
movd   %edi,%xmm3
movzwl 0x2(%r14,%rdx,1),%edi
movd   %edi,%xmm2
pand   %xmm4,%xmm3
pand   %xmm4,%xmm2
punpcklbw %xmm5,%xmm3
punpcklwd %xmm5,%xmm3
punpckldq %xmm5,%xmm3
paddq  %xmm0,%xmm3
punpcklbw %xmm5,%xmm2
punpcklwd %xmm5,%xmm2
punpckldq %xmm5,%xmm2
paddq  %xmm1,%xmm2
movzwl 0x4(%r14,%rdx,1),%edi
movd   %edi,%xmm0
movzwl 0x6(%r14,%rdx,1),%edi
movd   %edi,%xmm1
pand   %xmm4,%xmm0
pand   %xmm4,%xmm1
punpcklbw %xmm5,%xmm0
punpcklwd %xmm5,%xmm0
punpckldq %xmm5,%xmm0
paddq  %xmm3,%xmm0
punpcklbw %xmm5,%xmm1
punpcklwd %xmm5,%xmm1
punpckldq %xmm5,%xmm1
paddq  %xmm2,%xmm1
add    $0x8,%rdx
add    $0xfffffffffffffffe,%rsi
jne    13b0 <main+0x1f0>
test   $0x1,%cl
je     1475 <main+0x2b5>
movzwl (%r14,%rdx,1),%ecx
movd   %ecx,%xmm2
movzwl 0x2(%r14,%rdx,1),%ecx
movd   %ecx,%xmm3
pand   %xmm4,%xmm2
pand   %xmm4,%xmm3
punpcklbw %xmm5,%xmm2
punpcklwd %xmm5,%xmm2
punpckldq %xmm5,%xmm2
paddq  %xmm2,%xmm0
punpcklbw %xmm5,%xmm3
punpcklwd %xmm5,%xmm3
punpckldq %xmm5,%xmm3
paddq  %xmm3,%xmm1
paddq  %xmm1,%xmm0
pshufd $0xee,%xmm0,%xmm1
paddq  %xmm0,%xmm1
movq   %xmm1,%rdx
jmp    14af <main+0x2ef>
pxor   %xmm0,%xmm0
xor    %edx,%edx
pxor   %xmm1,%xmm1
test   $0x1,%cl
jne    143a <main+0x27a>
jmp    1475 <main+0x2b5>
nopw   0x0(%rax,%rax,1)
movzbl (%r14,%rax,1),%ecx
and    $0x1,%ecx
add    %rcx,%rdx
add    $0x1,%rax
cmp    %rax,%r15
jne    14a0 <main+0x2e0>
mov    (%rbx,%r13,8),%rsi
lea    0xbe5(%rip),%rdi
mov    %r15,%rcx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    0x8(%rsp),%rdi
mov    %r12,%rsi
call   10a0 <munmap@plt>
lea    0xbf5(%rip),%rsi
cmp    $0xffffffff,%eax
je     1500 <main+0x340>
mov    %ebp,%edi
call   1070 <close@plt>
lea    0xbf7(%rip),%rsi
cmp    $0xffffffff,%eax
jne    1512 <main+0x352>
nopl   (%rax)
mov    0x2ab9(%rip),%rax
mov    (%rax),%edi
mov    (%rbx,%r13,8),%rdx
call   1040 <warning@plt>
add    $0x1,%r13
cmp    0x18(%rsp),%r13
jne    1250 <main+0x90>
xor    %eax,%eax
add    $0x28,%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 = [28 x i8] c"Unable to allocate vec[%lu]\00"
@.str.5 = [33 x i8] c"Unable to get core info for '%s'\00"
@.str.6 = [54 x i8] c"'%s': %lu pages out of %lu appear to be in pagecache\0A\00"
@.str.7 = [21 x i8] c"Unable to unmap '%s'\00"
@.str.8 = [21 x i8] c"Problem closing '%s'\00"
@.str.9 = [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 i32
%14 = 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
%15 = load i32, i32* @_SC_PAGESIZE
%16 = call i64 @sysconf(i32 %15)
store i64 %16, i64* %12
%17 = load i64, i64* %12
%18 = icmp eq i64 %17, -1
br i1 %18, label %19, label %22
19: ; preds = %2
%20 = load i32, i32* @errno
%21 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 %20, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %25
22: ; preds = %2
%23 = load i64, i64* %12
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i64 %23)
br label %25
25: ; preds = %22, %19
store i32 1, i32* %13
br label %26
26: ; preds = %168, %25
%27 = load i32, i32* %13
%28 = load i32, i32* %4
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %171
30: ; preds = %26
%31 = load i8**, i8*** %5
%32 = load i32, i32* %13
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8*, i8** %31, i64 %33
%35 = load i8*, i8** %34
%36 = load i32, i32* @O_RDONLY
%37 = call i32 @open(i8* %35, i32 %36)
store i32 %37, i32* %14
%38 = load i32, i32* %14
%39 = icmp ne i32 %38, -1
br i1 %39, label %40, label %159
40: ; preds = %30
%41 = load i32, i32* %14
%42 = call i32 @fstat(i32 %41, %struct.stat* %6)
%43 = icmp eq i32 %42, -1
br i1 %43, label %44, label %52
44: ; preds = %40
%45 = load i32, i32* @errno
%46 = load i8**, i8*** %5
%47 = load i32, i32* %13
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8*, i8** %46, i64 %48
%50 = load i8*, i8** %49
%51 = call i32 @warning(i32 %45, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %50)
br label %168
52: ; preds = %40
%53 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%54 = load i64, i64* %53
%55 = load i32, i32* @PROT_READ
%56 = load i32, i32* @MAP_SHARED
%57 = load i32, i32* %14
%58 = call i64 @mmap(i32* null, i64 %54, i32 %55, i32 %56, i32 %57, i32 0)
%59 = inttoptr i64 %58 to i8*
store i8* %59, i8** %7
%60 = load i8*, i8** %7
%61 = load i8*, i8** @MAP_FAILED
%62 = icmp eq i8* %60, %61
br i1 %62, label %63, label %71
63: ; preds = %52
%64 = load i32, i32* @errno
%65 = load i8**, i8*** %5
%66 = load i32, i32* %13
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i8*, i8** %65, i64 %67
%69 = load i8*, i8** %68
%70 = call i32 @warning(i32 %64, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %69)
br label %168
71: ; preds = %52
%72 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%73 = load i64, i64* %72
%74 = load i64, i64* %12
%75 = add nsw i64 %73, %74
%76 = sub nsw i64 %75, 1
%77 = load i64, i64* %12
%78 = sdiv i64 %76, %77
store i64 %78, i64* %9
%79 = load i64, i64* %9
%80 = call i8* @malloc(i64 %79)
store i8* %80, i8** %8
%81 = load i8*, i8** %8
%82 = icmp eq i8* %81, null
br i1 %82, label %83, label %87
83: ; preds = %71
%84 = load i32, i32* @errno
%85 = load i64, i64* %9
%86 = call i32 (i32, i32, i8*, ...) @error(i32 2, i32 %84, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i64 %85)
br label %87
87: ; preds = %83, %71
%88 = load i8*, i8** %7
%89 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%90 = load i64, i64* %89
%91 = load i8*, i8** %8
%92 = call i32 @mincore(i8* %88, i64 %90, i8* %91)
%93 = icmp eq i32 %92, -1
br i1 %93, label %94, label %102
94: ; preds = %87
%95 = load i32, i32* @errno
%96 = load i8**, i8*** %5
%97 = load i32, i32* %13
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds i8*, i8** %96, i64 %98
%100 = load i8*, i8** %99
%101 = call i32 @warning(i32 %95, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i8* %100)
br label %168
102: ; preds = %87
store i64 0, i64* %10
store i64 0, i64* %11
br label %103
103: ; preds = %119, %102
%104 = load i64, i64* %11
%105 = load i64, i64* %9
%106 = icmp ult i64 %104, %105
br i1 %106, label %107, label %122
107: ; preds = %103
%108 = load i8*, i8** %8
%109 = load i64, i64* %11
%110 = getelementptr inbounds i8, i8* %108, i64 %109
%111 = load i8, i8* %110
%112 = zext i8 %111 to i32
%113 = and i32 %112, 1
%114 = icmp ne i32 %113, 0
br i1 %114, label %115, label %118
115: ; preds = %107
%116 = load i64, i64* %10
%117 = add i64 %116, 1
store i64 %117, i64* %10
br label %118
118: ; preds = %115, %107
br label %119
119: ; preds = %118
%120 = load i64, i64* %11
%121 = add i64 %120, 1
store i64 %121, i64* %11
br label %103
122: ; preds = %103
%123 = load i8**, i8*** %5
%124 = load i32, i32* %13
%125 = sext i32 %124 to i64
%126 = getelementptr inbounds i8*, i8** %123, i64 %125
%127 = load i8*, i8** %126
%128 = load i64, i64* %10
%129 = load i64, i64* %9
%130 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.6, i64 0, i64 0), i8* %127, i64 %128, i64 %129)
%131 = load i8*, i8** %8
%132 = call i32 @free(i8* %131)
store i8* null, i8** %8
%133 = load i8*, i8** %7
%134 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%135 = load i64, i64* %134
%136 = call i32 @munmap(i8* %133, i64 %135)
%137 = icmp eq i32 %136, -1
br i1 %137, label %138, label %146
138: ; preds = %122
%139 = load i32, i32* @errno
%140 = load i8**, i8*** %5
%141 = load i32, i32* %13
%142 = sext i32 %141 to i64
%143 = getelementptr inbounds i8*, i8** %140, i64 %142
%144 = load i8*, i8** %143
%145 = call i32 @warning(i32 %139, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i8* %144)
br label %168
146: ; preds = %122
%147 = load i32, i32* %14
%148 = call i32 @close(i32 %147)
%149 = icmp eq i32 %148, -1
br i1 %149, label %150, label %158
150: ; preds = %146
%151 = load i32, i32* @errno
%152 = load i8**, i8*** %5
%153 = load i32, i32* %13
%154 = sext i32 %153 to i64
%155 = getelementptr inbounds i8*, i8** %152, i64 %154
%156 = load i8*, i8** %155
%157 = call i32 @warning(i32 %151, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i8* %156)
br label %158
158: ; preds = %150, %146
br label %167
159: ; preds = %30
%160 = load i32, i32* @errno
%161 = load i8**, i8*** %5
%162 = load i32, i32* %13
%163 = sext i32 %162 to i64
%164 = getelementptr inbounds i8*, i8** %161, i64 %163
%165 = load i8*, i8** %164
%166 = call i32 @warning(i32 %160, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), i8* %165)
br label %167
167: ; preds = %159, %158
br label %168
168: ; preds = %167, %138, %94, %63, %44
%169 = load i32, i32* %13
%170 = add nsw i32 %169, 1
store i32 %170, i32* %13
br label %26
171: ; preds = %26
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 = [28 x i8] c"Unable to allocate vec[%lu]\00"
@.str.5 = [33 x i8] c"Unable to get core info for '%s'\00"
@.str.6 = [54 x i8] c"'%s': %lu pages out of %lu appear to be in pagecache\0A\00"
@.str.7 = [21 x i8] c"Unable to unmap '%s'\00"
@.str.8 = [21 x i8] c"Problem closing '%s'\00"
@.str.9 = [20 x i8] c"Unable to open '%s'\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = load i32, i32* @_SC_PAGESIZE
%6 = tail call i64 @sysconf(i32 %5)
%7 = icmp eq i64 %6, -1
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i32, i32* @errno
%10 = tail call i32 (i32, i32, i8*, ...) @error(i32 1, i32 %9, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %13
11: ; preds = %2
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i64 %6)
br label %13
13: ; preds = %11, %8
%14 = icmp sgt i32 %0, 1
br i1 %14, label %15, label %151
15: ; preds = %13
%16 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%17 = add i64 %6, -1
%18 = zext i32 %0 to i64
br label %19
19: ; preds = %15, %148
%20 = phi i64 [ 1, %15 ], [ %149, %148 ]
%21 = getelementptr inbounds i8*, i8** %1, i64 %20
%22 = load i8*, i8** %21
%23 = load i32, i32* @O_RDONLY
%24 = tail call i32 @open(i8* %22, i32 %23)
%25 = icmp eq i32 %24, -1
br i1 %25, label %143, label %26
26: ; preds = %19
%27 = call i32 @fstat(i32 %24, %struct.stat* %3)
%28 = icmp eq i32 %27, -1
br i1 %28, label %143, label %29
29: ; preds = %26
%30 = load i64, i64* %16
%31 = load i32, i32* @PROT_READ
%32 = load i32, i32* @MAP_SHARED
%33 = tail call i64 @mmap(i32* null, i64 %30, i32 %31, i32 %32, i32 %24, i32 0)
%34 = inttoptr i64 %33 to i8*
%35 = load i8*, i8** @MAP_FAILED
%36 = icmp eq i8* %35, %34
br i1 %36, label %143, label %37
37: ; preds = %29
%38 = add i64 %17, %30
%39 = sdiv i64 %38, %6
%40 = tail call i8* @malloc(i64 %39)
%41 = icmp eq i8* %40, null
br i1 %41, label %42, label %45
42: ; preds = %37
%43 = load i32, i32* @errno
%44 = tail call i32 (i32, i32, i8*, ...) @error(i32 2, i32 %43, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i64 %39)
br label %45
45: ; preds = %42, %37
%46 = tail call i32 @mincore(i8* %34, i64 %30, i8* %40)
%47 = icmp eq i32 %46, -1
br i1 %47, label %143, label %48
48: ; preds = %45
%49 = icmp eq i64 %39, 0
br i1 %49, label %133, label %50
50: ; preds = %48
%51 = icmp ult i64 %39, 4
br i1 %51, label %120, label %52
52: ; preds = %50
%53 = and i64 %39, -4
%54 = add i64 %53, -4
%55 = lshr exact i64 %54, 2
%56 = add nuw nsw i64 %55, 1
%57 = and i64 %56, 1
%58 = icmp eq i64 %54, 0
br i1 %58, label %94, label %59
59: ; preds = %52
%60 = and i64 %56, 9223372036854775806
br label %61
61: ; preds = %61, %59
%62 = phi i64 [ 0, %59 ], [ %91, %61 ]
%63 = phi <2 x i64> [ zeroinitializer, %59 ], [ %89, %61 ]
%64 = phi <2 x i64> [ zeroinitializer, %59 ], [ %90, %61 ]
%65 = phi i64 [ 0, %59 ], [ %92, %61 ]
%66 = getelementptr inbounds i8, i8* %40, i64 %62
%67 = bitcast i8* %66 to <2 x i8>*
%68 = load <2 x i8>, <2 x i8>* %67
%69 = getelementptr inbounds i8, i8* %66, i64 2
%70 = bitcast i8* %69 to <2 x i8>*
%71 = load <2 x i8>, <2 x i8>* %70
%72 = and <2 x i8> %68, <i8 1, i8 1>
%73 = and <2 x i8> %71, <i8 1, i8 1>
%74 = zext <2 x i8> %72 to <2 x i64>
%75 = zext <2 x i8> %73 to <2 x i64>
%76 = add <2 x i64> %63, %74
%77 = add <2 x i64> %64, %75
%78 = or i64 %62, 4
%79 = getelementptr inbounds i8, i8* %40, i64 %78
%80 = bitcast i8* %79 to <2 x i8>*
%81 = load <2 x i8>, <2 x i8>* %80
%82 = getelementptr inbounds i8, i8* %79, i64 2
%83 = bitcast i8* %82 to <2 x i8>*
%84 = load <2 x i8>, <2 x i8>* %83
%85 = and <2 x i8> %81, <i8 1, i8 1>
%86 = and <2 x i8> %84, <i8 1, i8 1>
%87 = zext <2 x i8> %85 to <2 x i64>
%88 = zext <2 x i8> %86 to <2 x i64>
%89 = add <2 x i64> %76, %87
%90 = add <2 x i64> %77, %88
%91 = add nuw i64 %62, 8
%92 = add i64 %65, 2
%93 = icmp eq i64 %92, %60
br i1 %93, label %94, label %61
94: ; preds = %61, %52
%95 = phi <2 x i64> [ undef, %52 ], [ %89, %61 ]
%96 = phi <2 x i64> [ undef, %52 ], [ %90, %61 ]
%97 = phi i64 [ 0, %52 ], [ %91, %61 ]
%98 = phi <2 x i64> [ zeroinitializer, %52 ], [ %89, %61 ]
%99 = phi <2 x i64> [ zeroinitializer, %52 ], [ %90, %61 ]
%100 = icmp eq i64 %57, 0
br i1 %100, label %114, label %101
101: ; preds = %94
%102 = getelementptr inbounds i8, i8* %40, i64 %97
%103 = bitcast i8* %102 to <2 x i8>*
%104 = load <2 x i8>, <2 x i8>* %103
%105 = getelementptr inbounds i8, i8* %102, i64 2
%106 = bitcast i8* %105 to <2 x i8>*
%107 = load <2 x i8>, <2 x i8>* %106
%108 = and <2 x i8> %104, <i8 1, i8 1>
%109 = and <2 x i8> %107, <i8 1, i8 1>
%110 = zext <2 x i8> %108 to <2 x i64>
%111 = zext <2 x i8> %109 to <2 x i64>
%112 = add <2 x i64> %98, %110
%113 = add <2 x i64> %99, %111
br label %114
114: ; preds = %94, %101
%115 = phi <2 x i64> [ %95, %94 ], [ %112, %101 ]
%116 = phi <2 x i64> [ %96, %94 ], [ %113, %101 ]
%117 = add <2 x i64> %116, %115
%118 = call i64 @llvm.vector.reduce.add.v2i64(<2 x i64> %117)
%119 = icmp eq i64 %39, %53
br i1 %119, label %133, label %120
120: ; preds = %50, %114
%121 = phi i64 [ 0, %50 ], [ %53, %114 ]
%122 = phi i64 [ 0, %50 ], [ %118, %114 ]
br label %123
123: ; preds = %120, %123
%124 = phi i64 [ %131, %123 ], [ %121, %120 ]
%125 = phi i64 [ %130, %123 ], [ %122, %120 ]
%126 = getelementptr inbounds i8, i8* %40, i64 %124
%127 = load i8, i8* %126
%128 = and i8 %127, 1
%129 = zext i8 %128 to i64
%130 = add i64 %125, %129
%131 = add nuw i64 %124, 1
%132 = icmp eq i64 %131, %39
br i1 %132, label %133, label %123
133: ; preds = %123, %114, %48
%134 = phi i64 [ 0, %48 ], [ %118, %114 ], [ %130, %123 ]
%135 = load i8*, i8** %21
%136 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.6, i64 0, i64 0), i8* %135, i64 %134, i64 %39)
%137 = tail call i32 @free(i8* %40)
%138 = tail call i32 @munmap(i8* %34, i64 %30)
%139 = icmp eq i32 %138, -1
br i1 %139, label %143, label %140
140: ; preds = %133
%141 = tail call i32 @close(i32 %24)
%142 = icmp eq i32 %141, -1
br i1 %142, label %143, label %148
143: ; preds = %19, %140, %133, %45, %29, %26
%144 = phi i8* [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), %26 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), %29 ], [ getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), %45 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), %133 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), %140 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), %19 ]
%145 = load i32, i32* @errno
%146 = load i8*, i8** %21
%147 = tail call i32 @warning(i32 %145, i8* %144, i8* %146)
br label %148
148: ; preds = %143, %140
%149 = add nuw nsw i64 %20, 1
%150 = icmp eq i64 %149, %18
br i1 %150, label %151, label %19
151: ; preds = %148, %13
ret i32 0
}