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

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
char *MAP_FAILED;
int /*<<< orphan*/ MAP_SHARED;
int O_CREAT;
int O_RDWR;
int O_TRUNC;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ SEEK_SET;
int S_IRGRP;
int S_IROTH;
int S_IRUSR;
int S_IWUSR;
int /*<<< orphan*/ _SC_PAGESIZE;
size_t atoi(char *);
int close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int lseek(int, size_t, int /*<<< orphan*/);
char *mmap(int /*<<< orphan*/ *, size_t, int, int /*<<< orphan*/, int,
           int /*<<< orphan*/);
int open(char *, int, int);
int /*<<< orphan*/ printf(char *, ...);
char *strerror(int /*<<< orphan*/);
size_t sysconf(int /*<<< orphan*/);
int write(int, char *, int);
int main(int argc, char **argv) {
  int fd, i;
  char *ptr;
  size_t filesize, mmapsize, pagesize;
  if (4 != argc) {
    printf("usage: %s <pathname> <filesize> <mmapsize>\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  filesize = atoi(argv[2]);
  mmapsize = atoi(argv[3]);
  if ((fd = open(argv[1], O_RDWR | O_TRUNC | O_CREAT,
                 (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH))) == -1) {
    printf("open error: %s\n", strerror(errno));
    exit(EXIT_FAILURE);
  }
  if (lseek(fd, filesize - 1, SEEK_SET) == -1) {
    printf("lseek error: %s\n", strerror(errno));
    exit(EXIT_FAILURE);
  }
  if (write(fd, "", 1) == -1) {
    printf("write error: %s\n", strerror(errno));
    exit(EXIT_FAILURE);
  }
  if ((ptr = mmap(NULL, mmapsize, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)) ==
      MAP_FAILED) {
    printf("mmap error: %s\n", strerror(errno));
    exit(EXIT_FAILURE);
  }
  if (close(fd) == -1) {
    printf("close error: %s\n", strerror(errno));
    exit(EXIT_FAILURE);
  }
  if ((pagesize = sysconf(_SC_PAGESIZE)) == -1) {
    printf("sysconf error: %s\n", strerror(errno));
    exit(EXIT_FAILURE);
  }
  printf("page size = %ld, file size = %d, mmap size = %d\n", (long)pagesize,
         filesize, mmapsize);
  for (i = 0; i < ((filesize) > (mmapsize) ? (filesize) : (mmapsize));
       i += pagesize) {
    printf("ptr[%d] = %d\n", i, ptr[i]);
    ptr[i] = 1;
    printf("ptr[%d] = %d\n", i + pagesize - 1, ptr[i + pagesize - 1]);
    ptr[i + pagesize - 1] = 1;
  }
  printf("ptr[%d] = %d\n", i, ptr[i]);
  printf("done\n");
  exit(EXIT_SUCCESS);
}


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)
mov    $0x4,%eax
cmp    -0x8(%rbp),%eax
je     11e7 <main+0x47>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2da8(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10a0 <atoi@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   10a0 <atoi@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2db0(%rip),%rax
mov    (%rax),%esi
mov    0x2dcf(%rip),%rax
or     (%rax),%esi
mov    0x2dce(%rip),%rax
or     (%rax),%esi
mov    0x2d45(%rip),%rax
mov    (%rax),%edx
mov    0x2d7c(%rip),%rax
or     (%rax),%edx
mov    0x2d53(%rip),%rax
or     (%rax),%edx
mov    0x2d42(%rip),%rax
or     (%rax),%edx
call   1080 <open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    128e <main+0xee>
mov    0x2d40(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    %rax,%rsi
lea    0xdb3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2d01(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    -0x14(%rbp),%edi
mov    -0x28(%rbp),%rsi
sub    $0x1,%rsi
mov    0x2d00(%rip),%rax
mov    (%rax),%edx
call   1060 <lseek@plt>
cmp    $0xffffffff,%eax
jne    12dd <main+0x13d>
mov    0x2cf1(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    %rax,%rsi
lea    0xd74(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2cb2(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    -0x14(%rbp),%edi
lea    0xd44(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
cmp    $0xffffffff,%eax
jne    1327 <main+0x187>
mov    0x2ca7(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    %rax,%rsi
lea    0xd3b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2c68(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    -0x30(%rbp),%rsi
mov    0x2cb6(%rip),%rax
mov    (%rax),%edx
mov    0x2c45(%rip),%rax
or     (%rax),%edx
mov    0x2c94(%rip),%rax
mov    (%rax),%ecx
mov    -0x14(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
xor    %r9d,%r9d
call   1040 <mmap@plt>
mov    %rax,-0x20(%rbp)
mov    0x2c07(%rip),%rcx
cmp    (%rcx),%rax
jne    1397 <main+0x1f7>
mov    0x2c37(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    %rax,%rsi
lea    0xcdc(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2bf8(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
cmp    $0xffffffff,%eax
jne    13d5 <main+0x235>
mov    0x2bf9(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    %rax,%rsi
lea    0xcae(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2bba(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    0x2be4(%rip),%rax
mov    (%rax),%edi
call   1090 <sysconf@plt>
mov    %rax,-0x38(%rbp)
cmp    $0xffffffffffffffff,%rax
jne    141e <main+0x27e>
mov    0x2bb0(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    %rax,%rsi
lea    0xc76(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2b71(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    -0x38(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
lea    0xc61(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x18(%rbp)
movslq -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x30(%rbp),%rax
jbe    1462 <main+0x2c2>
mov    -0x28(%rbp),%rax
mov    %rax,-0x48(%rbp)
jmp    146a <main+0x2ca>
mov    -0x30(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x40(%rbp),%rax
mov    -0x48(%rbp),%rcx
cmp    %rcx,%rax
jae    14f9 <main+0x359>
mov    -0x18(%rbp),%esi
mov    -0x20(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%edx
lea    0xc32(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x1,(%rax,%rcx,1)
movslq -0x18(%rbp),%rsi
add    -0x38(%rbp),%rsi
sub    $0x1,%rsi
mov    -0x20(%rbp),%rax
movslq -0x18(%rbp),%rcx
add    -0x38(%rbp),%rcx
sub    $0x1,%rcx
movsbl (%rax,%rcx,1),%edx
lea    0xbf8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rax
movslq -0x18(%rbp),%rcx
add    -0x38(%rbp),%rcx
sub    $0x1,%rcx
movb   $0x1,(%rax,%rcx,1)
mov    -0x38(%rbp),%rcx
movslq -0x18(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x18(%rbp)
jmp    143f <main+0x29f>
mov    -0x18(%rbp),%esi
mov    -0x20(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%edx
lea    0xbb4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xbb4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2a45(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x4,%edi
jne    1242 <main+0x92>
mov    0x10(%rbx),%rdi
call   10b0 <atoi@plt>
mov    %rax,%r14
mov    0x18(%rbx),%rdi
call   10b0 <atoi@plt>
mov    0x2de9(%rip),%rcx
mov    0x2e0a(%rip),%rdx
mov    (%rdx),%esi
or     (%rcx),%esi
mov    0x2e07(%rip),%rcx
or     (%rcx),%esi
mov    0x2d7e(%rip),%rcx
mov    0x2db7(%rip),%rdx
mov    (%rdx),%edx
or     (%rcx),%edx
mov    %rax,%r15
mov    0x2d89(%rip),%rax
or     (%rax),%edx
mov    0x8(%rbx),%rdi
mov    0x2d74(%rip),%rax
or     (%rax),%edx
call   1090 <open@plt>
cmp    $0xffffffff,%eax
jne    1251 <main+0xa1>
mov    0x2d79(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xdef(%rip),%rdi
jmp    1355 <main+0x1a5>
mov    (%rbx),%rsi
lea    0xdb4(%rip),%rdi
jmp    1358 <main+0x1a8>
mov    %eax,%ebp
lea    -0x1(%r14),%rsi
mov    0x2d42(%rip),%rax
mov    (%rax),%edx
mov    %ebp,%edi
call   1070 <lseek@plt>
cmp    $0xffffffff,%eax
jne    1286 <main+0xd6>
mov    0x2d35(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xdbb(%rip),%rdi
jmp    1355 <main+0x1a5>
lea    0xd9e(%rip),%rsi
mov    %ebp,%edi
mov    $0x1,%edx
call   1040 <write@plt>
cmp    $0xffffffff,%eax
jne    12b8 <main+0x108>
mov    0x2d03(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xd9a(%rip),%rdi
jmp    1355 <main+0x1a5>
mov    0x2d29(%rip),%rax
mov    0x2cba(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2d07(%rip),%rax
mov    (%rax),%ecx
xor    %edi,%edi
mov    %r15,%rsi
mov    %ebp,%r8d
xor    %r9d,%r9d
call   1050 <mmap@plt>
mov    %rax,%r13
mov    0x2c7b(%rip),%rax
cmp    (%rax),%r13
jne    1309 <main+0x159>
mov    0x2caf(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xd57(%rip),%rdi
jmp    1355 <main+0x1a5>
mov    %ebp,%edi
call   1080 <close@plt>
cmp    $0xffffffff,%eax
jne    132c <main+0x17c>
mov    0x2c8c(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xd44(%rip),%rdi
jmp    1355 <main+0x1a5>
mov    0x2c8d(%rip),%rax
mov    (%rax),%edi
call   10a0 <sysconf@plt>
cmp    $0xffffffffffffffff,%rax
jne    136d <main+0x1bd>
mov    0x2c61(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xd2a(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2c22(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    %rax,%r12
lea    0xd1b(%rip),%rdi
xor    %ebp,%ebp
mov    %rax,%rsi
mov    %r14,%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1060 <printf@plt>
cmp    %r15,%r14
cmova  %r14,%r15
test   %r15,%r15
jne    1399 <main+0x1e9>
xor    %ebx,%ebx
jmp    13f4 <main+0x244>
lea    0xd23(%rip),%r14
xor    %ebx,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl 0x0(%r13,%rbx,1),%edx
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
movb   $0x1,0x0(%r13,%rbx,1)
lea    (%rbx,%r12,1),%rsi
add    $0xffffffffffffffff,%rsi
mov    %rbx,%rbp
add    %r12,%rbp
movsbl -0x1(%r13,%rbp,1),%edx
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movb   $0x1,-0x1(%r13,%rbp,1)
movslq %ebp,%rbx
cmp    %rbx,%r15
ja     13b0 <main+0x200>
movsbl 0x0(%r13,%rbx,1),%edx
lea    0xcc2(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xcc0(%rip),%rdi
call   1030 <puts@plt>
mov    0x2b53(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [44 x i8] c"usage: %s <pathname> <filesize> <mmapsize>\0A\00"
@EXIT_FAILURE = global i32 0
@O_RDWR = global i32 0
@O_TRUNC = global i32 0
@O_CREAT = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IRGRP = global i32 0
@S_IROTH = global i32 0
@.str.1 = [16 x i8] c"open error: %s\0A\00"
@errno = global i32 0
@SEEK_SET = global i32 0
@.str.2 = [17 x i8] c"lseek error: %s\0A\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [17 x i8] c"write error: %s\0A\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i8* null
@.str.5 = [16 x i8] c"mmap error: %s\0A\00"
@.str.6 = [17 x i8] c"close error: %s\0A\00"
@_SC_PAGESIZE = global i32 0
@.str.7 = [19 x i8] c"sysconf error: %s\0A\00"
@.str.8 = [49 x i8] c"page size = %ld, file size = %d, mmap size = %d\0A\00"
@.str.9 = [14 x i8] c"ptr[%d] = %d\0A\00"
@.str.10 = [6 x i8] c"done\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp ne i32 4, %12
br i1 %13, label %14, label %21
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = load i32, i32* @EXIT_FAILURE
%20 = call i32 @exit(i32 %19)
unreachable
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 2
%24 = load i8*, i8** %23
%25 = call i64 @atoi(i8* %24)
store i64 %25, i64* %9
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 3
%28 = load i8*, i8** %27
%29 = call i64 @atoi(i8* %28)
store i64 %29, i64* %10
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = load i32, i32* @O_RDWR
%34 = load i32, i32* @O_TRUNC
%35 = or i32 %33, %34
%36 = load i32, i32* @O_CREAT
%37 = or i32 %35, %36
%38 = load i32, i32* @S_IRUSR
%39 = load i32, i32* @S_IWUSR
%40 = or i32 %38, %39
%41 = load i32, i32* @S_IRGRP
%42 = or i32 %40, %41
%43 = load i32, i32* @S_IROTH
%44 = or i32 %42, %43
%45 = call i32 @open(i8* %32, i32 %37, i32 %44)
store i32 %45, i32* %6
%46 = icmp eq i32 %45, -1
br i1 %46, label %47, label %53
47: ; preds = %21
%48 = load i32, i32* @errno
%49 = call i8* @strerror(i32 %48)
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %49)
%51 = load i32, i32* @EXIT_FAILURE
%52 = call i32 @exit(i32 %51)
unreachable
53: ; preds = %21
%54 = load i32, i32* %6
%55 = load i64, i64* %9
%56 = sub i64 %55, 1
%57 = load i32, i32* @SEEK_SET
%58 = call i32 @lseek(i32 %54, i64 %56, i32 %57)
%59 = icmp eq i32 %58, -1
br i1 %59, label %60, label %66
60: ; preds = %53
%61 = load i32, i32* @errno
%62 = call i8* @strerror(i32 %61)
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %62)
%64 = load i32, i32* @EXIT_FAILURE
%65 = call i32 @exit(i32 %64)
unreachable
66: ; preds = %53
%67 = load i32, i32* %6
%68 = call i32 @write(i32 %67, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i32 1)
%69 = icmp eq i32 %68, -1
br i1 %69, label %70, label %76
70: ; preds = %66
%71 = load i32, i32* @errno
%72 = call i8* @strerror(i32 %71)
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %72)
%74 = load i32, i32* @EXIT_FAILURE
%75 = call i32 @exit(i32 %74)
unreachable
76: ; preds = %66
%77 = load i64, i64* %10
%78 = load i32, i32* @PROT_READ
%79 = load i32, i32* @PROT_WRITE
%80 = or i32 %78, %79
%81 = load i32, i32* @MAP_SHARED
%82 = load i32, i32* %6
%83 = call i8* @mmap(i32* null, i64 %77, i32 %80, i32 %81, i32 %82, i32 0)
store i8* %83, i8** %8
%84 = load i8*, i8** @MAP_FAILED
%85 = icmp eq i8* %83, %84
br i1 %85, label %86, label %92
86: ; preds = %76
%87 = load i32, i32* @errno
%88 = call i8* @strerror(i32 %87)
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i8* %88)
%90 = load i32, i32* @EXIT_FAILURE
%91 = call i32 @exit(i32 %90)
unreachable
92: ; preds = %76
%93 = load i32, i32* %6
%94 = call i32 @close(i32 %93)
%95 = icmp eq i32 %94, -1
br i1 %95, label %96, label %102
96: ; preds = %92
%97 = load i32, i32* @errno
%98 = call i8* @strerror(i32 %97)
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i8* %98)
%100 = load i32, i32* @EXIT_FAILURE
%101 = call i32 @exit(i32 %100)
unreachable
102: ; preds = %92
%103 = load i32, i32* @_SC_PAGESIZE
%104 = call i64 @sysconf(i32 %103)
store i64 %104, i64* %11
%105 = icmp eq i64 %104, -1
br i1 %105, label %106, label %112
106: ; preds = %102
%107 = load i32, i32* @errno
%108 = call i8* @strerror(i32 %107)
%109 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i8* %108)
%110 = load i32, i32* @EXIT_FAILURE
%111 = call i32 @exit(i32 %110)
unreachable
112: ; preds = %102
%113 = load i64, i64* %11
%114 = load i64, i64* %9
%115 = load i64, i64* %10
%116 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.8, i64 0, i64 0), i64 %113, i64 %114, i64 %115)
store i32 0, i32* %7
br label %117
117: ; preds = %165, %112
%118 = load i32, i32* %7
%119 = sext i32 %118 to i64
%120 = load i64, i64* %9
%121 = load i64, i64* %10
%122 = icmp ugt i64 %120, %121
br i1 %122, label %123, label %125
123: ; preds = %117
%124 = load i64, i64* %9
br label %127
125: ; preds = %117
%126 = load i64, i64* %10
br label %127
127: ; preds = %125, %123
%128 = phi i64 [ %124, %123 ], [ %126, %125 ]
%129 = icmp ult i64 %119, %128
br i1 %129, label %130, label %171
130: ; preds = %127
%131 = load i32, i32* %7
%132 = load i8*, i8** %8
%133 = load i32, i32* %7
%134 = sext i32 %133 to i64
%135 = getelementptr inbounds i8, i8* %132, i64 %134
%136 = load i8, i8* %135
%137 = sext i8 %136 to i32
%138 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i32 %131, i32 %137)
%139 = load i8*, i8** %8
%140 = load i32, i32* %7
%141 = sext i32 %140 to i64
%142 = getelementptr inbounds i8, i8* %139, i64 %141
store i8 1, i8* %142
%143 = load i32, i32* %7
%144 = sext i32 %143 to i64
%145 = load i64, i64* %11
%146 = add i64 %144, %145
%147 = sub i64 %146, 1
%148 = load i8*, i8** %8
%149 = load i32, i32* %7
%150 = sext i32 %149 to i64
%151 = load i64, i64* %11
%152 = add i64 %150, %151
%153 = sub i64 %152, 1
%154 = getelementptr inbounds i8, i8* %148, i64 %153
%155 = load i8, i8* %154
%156 = sext i8 %155 to i32
%157 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i64 %147, i32 %156)
%158 = load i8*, i8** %8
%159 = load i32, i32* %7
%160 = sext i32 %159 to i64
%161 = load i64, i64* %11
%162 = add i64 %160, %161
%163 = sub i64 %162, 1
%164 = getelementptr inbounds i8, i8* %158, i64 %163
store i8 1, i8* %164
br label %165
165: ; preds = %130
%166 = load i64, i64* %11
%167 = load i32, i32* %7
%168 = sext i32 %167 to i64
%169 = add i64 %168, %166
%170 = trunc i64 %169 to i32
store i32 %170, i32* %7
br label %117
171: ; preds = %127
%172 = load i32, i32* %7
%173 = load i8*, i8** %8
%174 = load i32, i32* %7
%175 = sext i32 %174 to i64
%176 = getelementptr inbounds i8, i8* %173, i64 %175
%177 = load i8, i8* %176
%178 = sext i8 %177 to i32
%179 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i32 %172, i32 %178)
%180 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
%181 = load i32, i32* @EXIT_SUCCESS
%182 = call i32 @exit(i32 %181)
unreachable
}

LLVM IR (-O2):
@.str = [44 x i8] c"usage: %s <pathname> <filesize> <mmapsize>\0A\00"
@EXIT_FAILURE = global i32 0
@O_RDWR = global i32 0
@O_TRUNC = global i32 0
@O_CREAT = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IRGRP = global i32 0
@S_IROTH = global i32 0
@.str.1 = [16 x i8] c"open error: %s\0A\00"
@errno = global i32 0
@SEEK_SET = global i32 0
@.str.2 = [17 x i8] c"lseek error: %s\0A\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [17 x i8] c"write error: %s\0A\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i8* null
@.str.5 = [16 x i8] c"mmap error: %s\0A\00"
@.str.6 = [17 x i8] c"close error: %s\0A\00"
@_SC_PAGESIZE = global i32 0
@.str.7 = [19 x i8] c"sysconf error: %s\0A\00"
@.str.8 = [49 x i8] c"page size = %ld, file size = %d, mmap size = %d\0A\00"
@.str.9 = [14 x i8] c"ptr[%d] = %d\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [5 x i8] c"done\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %9, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = load i32, i32* @EXIT_FAILURE
%8 = tail call i32 @exit(i32 %7)
unreachable
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = tail call i64 @atoi(i8* %11)
%13 = getelementptr inbounds i8*, i8** %1, i64 3
%14 = load i8*, i8** %13
%15 = tail call i64 @atoi(i8* %14)
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = load i32, i32* @O_RDWR
%19 = load i32, i32* @O_TRUNC
%20 = or i32 %19, %18
%21 = load i32, i32* @O_CREAT
%22 = or i32 %20, %21
%23 = load i32, i32* @S_IRUSR
%24 = load i32, i32* @S_IWUSR
%25 = or i32 %24, %23
%26 = load i32, i32* @S_IRGRP
%27 = or i32 %25, %26
%28 = load i32, i32* @S_IROTH
%29 = or i32 %27, %28
%30 = tail call i32 @open(i8* %17, i32 %22, i32 %29)
%31 = icmp eq i32 %30, -1
br i1 %31, label %32, label %38
32: ; preds = %9
%33 = load i32, i32* @errno
%34 = tail call i8* @strerror(i32 %33)
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %34)
%36 = load i32, i32* @EXIT_FAILURE
%37 = tail call i32 @exit(i32 %36)
unreachable
38: ; preds = %9
%39 = add i64 %12, -1
%40 = load i32, i32* @SEEK_SET
%41 = tail call i32 @lseek(i32 %30, i64 %39, i32 %40)
%42 = icmp eq i32 %41, -1
br i1 %42, label %43, label %49
43: ; preds = %38
%44 = load i32, i32* @errno
%45 = tail call i8* @strerror(i32 %44)
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %45)
%47 = load i32, i32* @EXIT_FAILURE
%48 = tail call i32 @exit(i32 %47)
unreachable
49: ; preds = %38
%50 = tail call i32 @write(i32 %30, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i32 1)
%51 = icmp eq i32 %50, -1
br i1 %51, label %52, label %58
52: ; preds = %49
%53 = load i32, i32* @errno
%54 = tail call i8* @strerror(i32 %53)
%55 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %54)
%56 = load i32, i32* @EXIT_FAILURE
%57 = tail call i32 @exit(i32 %56)
unreachable
58: ; preds = %49
%59 = load i32, i32* @PROT_READ
%60 = load i32, i32* @PROT_WRITE
%61 = or i32 %60, %59
%62 = load i32, i32* @MAP_SHARED
%63 = tail call i8* @mmap(i32* null, i64 %15, i32 %61, i32 %62, i32 %30, i32 0)
%64 = load i8*, i8** @MAP_FAILED
%65 = icmp eq i8* %63, %64
br i1 %65, label %66, label %72
66: ; preds = %58
%67 = load i32, i32* @errno
%68 = tail call i8* @strerror(i32 %67)
%69 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i8* %68)
%70 = load i32, i32* @EXIT_FAILURE
%71 = tail call i32 @exit(i32 %70)
unreachable
72: ; preds = %58
%73 = tail call i32 @close(i32 %30)
%74 = icmp eq i32 %73, -1
br i1 %74, label %75, label %81
75: ; preds = %72
%76 = load i32, i32* @errno
%77 = tail call i8* @strerror(i32 %76)
%78 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i8* %77)
%79 = load i32, i32* @EXIT_FAILURE
%80 = tail call i32 @exit(i32 %79)
unreachable
81: ; preds = %72
%82 = load i32, i32* @_SC_PAGESIZE
%83 = tail call i64 @sysconf(i32 %82)
%84 = icmp eq i64 %83, -1
br i1 %84, label %85, label %91
85: ; preds = %81
%86 = load i32, i32* @errno
%87 = tail call i8* @strerror(i32 %86)
%88 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i8* %87)
%89 = load i32, i32* @EXIT_FAILURE
%90 = tail call i32 @exit(i32 %89)
unreachable
91: ; preds = %81
%92 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.8, i64 0, i64 0), i64 %83, i64 %12, i64 %15)
%93 = icmp ugt i64 %12, %15
%94 = select i1 %93, i64 %12, i64 %15
%95 = icmp eq i64 %94, 0
br i1 %95, label %115, label %96
96: ; preds = %91, %96
%97 = phi i64 [ %111, %96 ], [ 0, %91 ]
%98 = phi i32 [ %109, %96 ], [ 0, %91 ]
%99 = getelementptr inbounds i8, i8* %63, i64 %97
%100 = load i8, i8* %99
%101 = sext i8 %100 to i32
%102 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i32 %98, i32 %101)
store i8 1, i8* %99
%103 = add i64 %97, %83
%104 = add i64 %103, -1
%105 = getelementptr inbounds i8, i8* %63, i64 %104
%106 = load i8, i8* %105
%107 = sext i8 %106 to i32
%108 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i64 %104, i32 %107)
store i8 1, i8* %105
%109 = trunc i64 %103 to i32
%110 = shl i64 %103, 32
%111 = ashr exact i64 %110, 32
%112 = icmp ugt i64 %94, %111
br i1 %112, label %96, label %113
113: ; preds = %96
%114 = trunc i64 %103 to i32
br label %115
115: ; preds = %113, %91
%116 = phi i32 [ 0, %91 ], [ %114, %113 ]
%117 = phi i64 [ 0, %91 ], [ %111, %113 ]
%118 = getelementptr inbounds i8, i8* %63, i64 %117
%119 = load i8, i8* %118
%120 = sext i8 %119 to i32
%121 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i32 %116, i32 %120)
%122 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
%123 = load i32, i32* @EXIT_SUCCESS
%124 = tail call i32 @exit(i32 %123)
unreachable
}