#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 {
  int st_size;
};
typedef size_t ssize_t;
typedef int off_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
char *MAP_FAILED;
int /*<<< orphan*/ MAP_SHARED;
int /*<<< orphan*/ O_RDWR;
int PROT_EXEC;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ STDOUT_FILENO;
int /*<<< orphan*/ _SC_PAGE_SIZE;
void *atoi(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int fstat(int, struct stat *);
int /*<<< orphan*/ getchar();
char *mmap(int /*<<< orphan*/ *, int, int, int /*<<< orphan*/, int,
           int /*<<< orphan*/);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int sysconf(int /*<<< orphan*/);
size_t write(int /*<<< orphan*/, char *, int);
int main(int argc, char *argv[]) {
  char *addr;
  int fd, ret;
  struct stat sb;
  off_t offset, pa_offset;
  size_t length;
  ssize_t s;
  fd = open(argv[1], O_RDWR);
  if (fd == -1)
    do {
      perror("open");
      exit(EXIT_FAILURE);
    } while (0);
  if (fstat(fd, &sb) == -1)
    do {
      perror("fstat");
      exit(EXIT_FAILURE);
    } while (0);
  printf("PAGE_SIZE:%lx\n", sysconf(_SC_PAGE_SIZE));
  offset = atoi(argv[3]);
  pa_offset = offset & ~(sysconf(_SC_PAGE_SIZE) - 1);
  printf("pa_offset:%lx\n", pa_offset);
  printf("pa_offset:%lx file size:%lx\n", pa_offset, sb.st_size);
  if (offset >= sb.st_size) {
    fprintf(stderr, "offset is past end of file\n");
    exit(EXIT_FAILURE);
  }
  if (argc == 4) {
    length = atoi(argv[2]);
    if (offset + length > sb.st_size)
      length = sb.st_size - offset;
  } else {
    length = sb.st_size - offset;
  }
  printf("length:%d\n", length);
  getchar();
  addr = mmap(NULL, sb.st_size, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_SHARED,
              fd, 0);
  if (addr == MAP_FAILED)
    do {
      perror("mmap");
      exit(EXIT_FAILURE);
    } while (0);
  printf("addr:%p %x\n", addr, *addr);
  s = write(STDOUT_FILENO, addr, sb.st_size);
  if (s != length) {
    if (s == -1)
      do {
        perror("write");
        exit(EXIT_FAILURE);
      } while (0);
    fprintf(stderr, "partial write");
    exit(EXIT_FAILURE);
  }
  getchar();
  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    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2dfb(%rip),%rax
mov    (%rax),%esi
call   1080 <open@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    1208 <main+0x58>
jmp    11ee <main+0x3e>
lea    0xe0b(%rip),%rdi
call   1090 <perror@plt>
mov    0x2daf(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    -0x1c(%rbp),%edi
lea    -0x28(%rbp),%rsi
call   10d0 <fstat@plt>
cmp    $0xffffffff,%eax
jne    123c <main+0x8c>
jmp    1222 <main+0x72>
lea    0xddc(%rip),%rdi
call   1090 <perror@plt>
mov    0x2d7b(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    0x2d5d(%rip),%rax
mov    (%rax),%edi
call   10a0 <sysconf@plt>
mov    %eax,%esi
lea    0xdb8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    0x2d29(%rip),%rax
mov    (%rax),%edi
call   10a0 <sysconf@plt>
mov    %eax,%ecx
mov    -0x44(%rbp),%eax
sub    $0x1,%ecx
xor    $0xffffffff,%ecx
and    %ecx,%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%esi
lea    0xd82(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x30(%rbp),%esi
mov    -0x28(%rbp),%edx
lea    0xd7d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x2c(%rbp),%eax
cmp    -0x28(%rbp),%eax
jl     12e2 <main+0x132>
mov    0x2cf2(%rip),%rax
mov    (%rax),%edi
lea    0xd77(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2cd5(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
cmpl   $0x4,-0x8(%rbp)
jne    1323 <main+0x173>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10b0 <atoi@plt>
mov    %rax,-0x38(%rbp)
movslq -0x2c(%rbp),%rax
add    -0x38(%rbp),%rax
movslq -0x28(%rbp),%rcx
cmp    %rcx,%rax
jbe    131e <main+0x16e>
mov    -0x28(%rbp),%eax
sub    -0x2c(%rbp),%eax
cltq
mov    %rax,-0x38(%rbp)
jmp    132f <main+0x17f>
mov    -0x28(%rbp),%eax
sub    -0x2c(%rbp),%eax
cltq
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rsi
lea    0xd28(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    -0x28(%rbp),%esi
mov    0x2c76(%rip),%rax
mov    (%rax),%edx
mov    0x2c9d(%rip),%rax
or     (%rax),%edx
mov    0x2c44(%rip),%rax
or     (%rax),%edx
mov    0x2c73(%rip),%rax
mov    (%rax),%ecx
mov    -0x1c(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
xor    %r9d,%r9d
call   1040 <mmap@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    0x2c02(%rip),%rcx
cmp    (%rcx),%rax
jne    13b6 <main+0x206>
jmp    139c <main+0x1ec>
lea    0xcca(%rip),%rdi
call   1090 <perror@plt>
mov    0x2c01(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    -0x18(%rbp),%rsi
mov    -0x18(%rbp),%rax
movsbl (%rax),%edx
lea    0xcaa(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2c12(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%edx
call   1030 <write@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
cmp    -0x38(%rbp),%rax
je     1443 <main+0x293>
cmpq   $0xffffffffffffffff,-0x40(%rbp)
jne    1420 <main+0x270>
jmp    1406 <main+0x256>
lea    0xc79(%rip),%rdi
call   1090 <perror@plt>
mov    0x2b97(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    0x2b91(%rip),%rax
mov    (%rax),%edi
lea    0xc4e(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2b74(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    0x2b47(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbp
mov    %edi,%r15d
mov    0x8(%rsi),%rdi
mov    0x2e04(%rip),%rax
mov    (%rax),%esi
call   1080 <open@plt>
cmp    $0xffffffff,%eax
jne    11e1 <main+0x31>
lea    0xe21(%rip),%rdi
jmp    11fa <main+0x4a>
mov    %eax,%r13d
mov    %rsp,%rsi
mov    %eax,%edi
call   10d0 <fstat@plt>
cmp    $0xffffffff,%eax
jne    120d <main+0x5d>
lea    0xe0b(%rip),%rdi
call   1090 <perror@plt>
mov    0x2daa(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    0x2d8c(%rip),%rbx
mov    (%rbx),%edi
call   10a0 <sysconf@plt>
lea    0xde9(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x18(%rbp),%rdi
call   10b0 <atoi@plt>
mov    %rax,%r12
mov    (%rbx),%edi
call   10a0 <sysconf@plt>
mov    %eax,%ebx
neg    %ebx
and    %r12d,%ebx
lea    0xdce(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rsp),%r14d
lea    0xdc9(%rip),%rdi
mov    %ebx,%esi
mov    %r14d,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14d,%ebx
sub    %r12d,%ebx
jle    1302 <main+0x152>
cmp    $0x4,%r15d
jne    1298 <main+0xe8>
movslq %r14d,%r15
mov    0x10(%rbp),%rdi
call   10b0 <atoi@plt>
mov    %rax,%rbp
movslq %r12d,%rax
add    %rbp,%rax
cmp    %r15,%rax
jbe    129b <main+0xeb>
movslq %ebx,%rbp
lea    0xdc0(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    0x2d0e(%rip),%rax
mov    0x2d37(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2cdc(%rip),%rax
or     (%rax),%edx
mov    0x2d0b(%rip),%rax
mov    (%rax),%ecx
xor    %edi,%edi
mov    %r14d,%esi
mov    %r13d,%r8d
xor    %r9d,%r9d
call   1040 <mmap@plt>
mov    %rax,%rbx
mov    0x2c9f(%rip),%rax
cmp    (%rax),%rbx
jne    131c <main+0x16c>
lea    0xd70(%rip),%rdi
jmp    11fa <main+0x4a>
mov    0x2caf(%rip),%rax
mov    (%rax),%edi
lea    0xd34(%rip),%rsi
call   1070 <fprintf@plt>
jmp    11ff <main+0x4f>
movsbl (%rbx),%edx
lea    0xd4c(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2cb1(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1030 <write@plt>
cmp    %rbp,%rax
jne    135e <main+0x1ae>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    0x2c41(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
cmp    $0xffffffffffffffff,%rax
jne    1370 <main+0x1c0>
lea    0xd1b(%rip),%rdi
jmp    11fa <main+0x4a>
mov    0x2c41(%rip),%rax
mov    (%rax),%edi
lea    0xcfe(%rip),%rsi
call   1070 <fprintf@plt>
jmp    11ff <main+0x4f>

LLVM IR (-O0):
%struct.stat = type { i32 }
@O_RDWR = global i32 0
@.str = [5 x i8] c"open\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [6 x i8] c"fstat\00"
@.str.2 = [15 x i8] c"PAGE_SIZE:%lx\0A\00"
@_SC_PAGE_SIZE = global i32 0
@.str.3 = [15 x i8] c"pa_offset:%lx\0A\00"
@.str.4 = [29 x i8] c"pa_offset:%lx file size:%lx\0A\00"
@stderr = global i32 0
@.str.5 = [28 x i8] c"offset is past end of file\0A\00"
@.str.6 = [11 x i8] c"length:%d\0A\00"
@PROT_EXEC = global i32 0
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i8* null
@.str.7 = [5 x i8] c"mmap\00"
@.str.8 = [12 x i8] c"addr:%p %x\0A\00"
@STDOUT_FILENO = global i32 0
@.str.9 = [6 x i8] c"write\00"
@.str.10 = [14 x i8] c"partial write\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.stat
%10 = alloca i32
%11 = alloca i32
%12 = alloca i64
%13 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = load i32, i32* @O_RDWR
%18 = call i32 @open(i8* %16, i32 %17)
store i32 %18, i32* %7
%19 = load i32, i32* %7
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %27
21: ; preds = %2
br label %22
22: ; preds = %21
%23 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%24 = load i32, i32* @EXIT_FAILURE
%25 = call i32 @exit(i32 %24)
unreachable
26: ; No predecessors!
br label %27
27: ; preds = %26, %2
%28 = load i32, i32* %7
%29 = call i32 @fstat(i32 %28, %struct.stat* %9)
%30 = icmp eq i32 %29, -1
br i1 %30, label %31, label %37
31: ; preds = %27
br label %32
32: ; preds = %31
%33 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%34 = load i32, i32* @EXIT_FAILURE
%35 = call i32 @exit(i32 %34)
unreachable
36: ; No predecessors!
br label %37
37: ; preds = %36, %27
%38 = load i32, i32* @_SC_PAGE_SIZE
%39 = call i32 @sysconf(i32 %38)
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %39)
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 3
%43 = load i8*, i8** %42
%44 = call i8* @atoi(i8* %43)
%45 = ptrtoint i8* %44 to i32
store i32 %45, i32* %10
%46 = load i32, i32* %10
%47 = load i32, i32* @_SC_PAGE_SIZE
%48 = call i32 @sysconf(i32 %47)
%49 = sub nsw i32 %48, 1
%50 = xor i32 %49, -1
%51 = and i32 %46, %50
store i32 %51, i32* %11
%52 = load i32, i32* %11
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %52)
%54 = load i32, i32* %11
%55 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%56 = load i32, i32* %55
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i32 %54, i32 %56)
%58 = load i32, i32* %10
%59 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%60 = load i32, i32* %59
%61 = icmp sge i32 %58, %60
br i1 %61, label %62, label %67
62: ; preds = %37
%63 = load i32, i32* @stderr
%64 = call i32 @fprintf(i32 %63, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
%65 = load i32, i32* @EXIT_FAILURE
%66 = call i32 @exit(i32 %65)
unreachable
67: ; preds = %37
%68 = load i32, i32* %4
%69 = icmp eq i32 %68, 4
br i1 %69, label %70, label %91
70: ; preds = %67
%71 = load i8**, i8*** %5
%72 = getelementptr inbounds i8*, i8** %71, i64 2
%73 = load i8*, i8** %72
%74 = call i8* @atoi(i8* %73)
%75 = ptrtoint i8* %74 to i64
store i64 %75, i64* %12
%76 = load i32, i32* %10
%77 = sext i32 %76 to i64
%78 = load i64, i64* %12
%79 = add i64 %77, %78
%80 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%81 = load i32, i32* %80
%82 = sext i32 %81 to i64
%83 = icmp ugt i64 %79, %82
br i1 %83, label %84, label %90
84: ; preds = %70
%85 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%86 = load i32, i32* %85
%87 = load i32, i32* %10
%88 = sub nsw i32 %86, %87
%89 = sext i32 %88 to i64
store i64 %89, i64* %12
br label %90
90: ; preds = %84, %70
br label %97
91: ; preds = %67
%92 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%93 = load i32, i32* %92
%94 = load i32, i32* %10
%95 = sub nsw i32 %93, %94
%96 = sext i32 %95 to i64
store i64 %96, i64* %12
br label %97
97: ; preds = %91, %90
%98 = load i64, i64* %12
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i64 %98)
%100 = call i32 (...) @getchar()
%101 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%102 = load i32, i32* %101
%103 = load i32, i32* @PROT_EXEC
%104 = load i32, i32* @PROT_READ
%105 = or i32 %103, %104
%106 = load i32, i32* @PROT_WRITE
%107 = or i32 %105, %106
%108 = load i32, i32* @MAP_SHARED
%109 = load i32, i32* %7
%110 = call i8* @mmap(i32* null, i32 %102, i32 %107, i32 %108, i32 %109, i32 0)
store i8* %110, i8** %6
%111 = load i8*, i8** %6
%112 = load i8*, i8** @MAP_FAILED
%113 = icmp eq i8* %111, %112
br i1 %113, label %114, label %120
114: ; preds = %97
br label %115
115: ; preds = %114
%116 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%117 = load i32, i32* @EXIT_FAILURE
%118 = call i32 @exit(i32 %117)
unreachable
119: ; No predecessors!
br label %120
120: ; preds = %119, %97
%121 = load i8*, i8** %6
%122 = load i8*, i8** %6
%123 = load i8, i8* %122
%124 = sext i8 %123 to i32
%125 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), i8* %121, i32 %124)
%126 = load i32, i32* @STDOUT_FILENO
%127 = load i8*, i8** %6
%128 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%129 = load i32, i32* %128
%130 = call i64 @write(i32 %126, i8* %127, i32 %129)
store i64 %130, i64* %13
%131 = load i64, i64* %13
%132 = load i64, i64* %12
%133 = icmp ne i64 %131, %132
br i1 %133, label %134, label %148
134: ; preds = %120
%135 = load i64, i64* %13
%136 = icmp eq i64 %135, -1
br i1 %136, label %137, label %143
137: ; preds = %134
br label %138
138: ; preds = %137
%139 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%140 = load i32, i32* @EXIT_FAILURE
%141 = call i32 @exit(i32 %140)
unreachable
142: ; No predecessors!
br label %143
143: ; preds = %142, %134
%144 = load i32, i32* @stderr
%145 = call i32 @fprintf(i32 %144, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0))
%146 = load i32, i32* @EXIT_FAILURE
%147 = call i32 @exit(i32 %146)
unreachable
148: ; preds = %120
%149 = call i32 (...) @getchar()
%150 = load i32, i32* @EXIT_SUCCESS
%151 = call i32 @exit(i32 %150)
unreachable
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@O_RDWR = global i32 0
@.str = [5 x i8] c"open\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [6 x i8] c"fstat\00"
@.str.2 = [15 x i8] c"PAGE_SIZE:%lx\0A\00"
@_SC_PAGE_SIZE = global i32 0
@.str.3 = [15 x i8] c"pa_offset:%lx\0A\00"
@.str.4 = [29 x i8] c"pa_offset:%lx file size:%lx\0A\00"
@stderr = global i32 0
@.str.5 = [28 x i8] c"offset is past end of file\0A\00"
@.str.6 = [11 x i8] c"length:%d\0A\00"
@PROT_EXEC = global i32 0
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i8* null
@.str.7 = [5 x i8] c"mmap\00"
@.str.8 = [12 x i8] c"addr:%p %x\0A\00"
@STDOUT_FILENO = global i32 0
@.str.9 = [6 x i8] c"write\00"
@.str.10 = [14 x i8] c"partial write\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = load i32, i32* @O_RDWR
%8 = tail call i32 @open(i8* %6, i32 %7)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
%13 = tail call i32 @exit(i32 %12)
unreachable
14: ; preds = %2
%15 = call i32 @fstat(i32 %8, %struct.stat* %3)
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %21
17: ; preds = %14
%18 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%19 = load i32, i32* @EXIT_FAILURE
%20 = tail call i32 @exit(i32 %19)
unreachable
21: ; preds = %14
%22 = load i32, i32* @_SC_PAGE_SIZE
%23 = tail call i32 @sysconf(i32 %22)
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %23)
%25 = getelementptr inbounds i8*, i8** %1, i64 3
%26 = load i8*, i8** %25
%27 = tail call i8* @atoi(i8* %26)
%28 = ptrtoint i8* %27 to i64
%29 = trunc i64 %28 to i32
%30 = load i32, i32* @_SC_PAGE_SIZE
%31 = tail call i32 @sysconf(i32 %30)
%32 = sub i32 0, %31
%33 = and i32 %29, %32
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %33)
%35 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%36 = load i32, i32* %35
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i32 %33, i32 %36)
%38 = icmp sgt i32 %36, %29
br i1 %38, label %44, label %39
39: ; preds = %21
%40 = load i32, i32* @stderr
%41 = tail call i32 @fprintf(i32 %40, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
%42 = load i32, i32* @EXIT_FAILURE
%43 = tail call i32 @exit(i32 %42)
unreachable
44: ; preds = %21
%45 = icmp eq i32 %0, 4
br i1 %45, label %46, label %59
46: ; preds = %44
%47 = getelementptr inbounds i8*, i8** %1, i64 2
%48 = load i8*, i8** %47
%49 = tail call i8* @atoi(i8* %48)
%50 = ptrtoint i8* %49 to i64
%51 = shl i64 %28, 32
%52 = ashr exact i64 %51, 32
%53 = add i64 %52, %50
%54 = sext i32 %36 to i64
%55 = icmp ugt i64 %53, %54
br i1 %55, label %56, label %62
56: ; preds = %46
%57 = sub nsw i32 %36, %29
%58 = sext i32 %57 to i64
br label %62
59: ; preds = %44
%60 = sub nsw i32 %36, %29
%61 = sext i32 %60 to i64
br label %62
62: ; preds = %46, %56, %59
%63 = phi i64 [ %58, %56 ], [ %50, %46 ], [ %61, %59 ]
%64 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i64 %63)
%65 = tail call i32 (...) @getchar()
%66 = load i32, i32* @PROT_EXEC
%67 = load i32, i32* @PROT_READ
%68 = or i32 %67, %66
%69 = load i32, i32* @PROT_WRITE
%70 = or i32 %68, %69
%71 = load i32, i32* @MAP_SHARED
%72 = tail call i8* @mmap(i32* null, i32 %36, i32 %70, i32 %71, i32 %8, i32 0)
%73 = load i8*, i8** @MAP_FAILED
%74 = icmp eq i8* %72, %73
br i1 %74, label %75, label %79
75: ; preds = %62
%76 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%77 = load i32, i32* @EXIT_FAILURE
%78 = tail call i32 @exit(i32 %77)
unreachable
79: ; preds = %62
%80 = load i8, i8* %72
%81 = sext i8 %80 to i32
%82 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), i8* %72, i32 %81)
%83 = load i32, i32* @STDOUT_FILENO
%84 = tail call i64 @write(i32 %83, i8* %72, i32 %36)
%85 = icmp eq i64 %84, %63
br i1 %85, label %97, label %86
86: ; preds = %79
%87 = icmp eq i64 %84, -1
br i1 %87, label %88, label %92
88: ; preds = %86
%89 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%90 = load i32, i32* @EXIT_FAILURE
%91 = tail call i32 @exit(i32 %90)
unreachable
92: ; preds = %86
%93 = load i32, i32* @stderr
%94 = tail call i32 @fprintf(i32 %93, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0))
%95 = load i32, i32* @EXIT_FAILURE
%96 = tail call i32 @exit(i32 %95)
unreachable
97: ; preds = %79
%98 = tail call i32 (...) @getchar()
%99 = load i32, i32* @EXIT_SUCCESS
%100 = tail call i32 @exit(i32 %99)
unreachable
}