#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 dummy;
};
typedef int ssize_t;
typedef int /*<<< orphan*/ off_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
char *MAP_FAILED;
int /*<<< orphan*/ MAP_SHARED;
int /*<<< orphan*/ MS_SYNC;
int /*<<< orphan*/ O_RDWR;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ STDOUT_FILENO;
int /*<<< orphan*/ _SC_PAGESIZE;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int fstat(int, struct stat *);
int /*<<< orphan*/ memcpy(char *, char *, int);
char *mmap(int /*<<< orphan*/ *, int, int, int /*<<< orphan*/, int, int);
int /*<<< orphan*/ msync(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ munmap(char *, int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
int strlen(char *);
int sysconf(int /*<<< orphan*/);
int write(int /*<<< orphan*/, char *, int);
int main(int argc, char *argv[]) {
  char *addr1;
  char *addr2;
  int fd;
  struct stat sb;
  off_t offset1, pa_offset1;
  off_t offset2, pa_offset2;
  ssize_t s;
  ssize_t _page_size = sysconf(_SC_PAGESIZE);
  char *buf = "hello world";
  char msg[1024];
  int buflen;
  buflen = strlen(buf);
  fd = open("m.dat", 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);
  addr1 = mmap(NULL, 1024 * 8, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
  if (addr1 == MAP_FAILED)
    do {
      perror("mmap1");
      exit(EXIT_FAILURE);
    } while (0);
  addr2 = mmap(NULL, 1024 * 4, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 4096);
  if (addr2 == MAP_FAILED)
    do {
      perror("mmap2");
      exit(EXIT_FAILURE);
    } while (0);
  memcpy(addr2, "000000000000000", 10);
  msync(addr2, 4096, MS_SYNC);
  memcpy(addr1 + 4096, "111111111111111111", 10);
  msync(addr1, 4096 * 2, MS_SYNC);
  s = write(STDOUT_FILENO, addr1 + 4096, 10);
  if (s != 10) {
    if (s == -1)
      do {
        perror("write2");
        exit(EXIT_FAILURE);
      } while (0);
    fprintf(stderr, "partial write");
    exit(EXIT_FAILURE);
  }
  s = write(STDOUT_FILENO, addr2, 10);
  if (s != 10) {
    if (s == -1)
      do {
        perror("write1");
        exit(EXIT_FAILURE);
      } while (0);
    fprintf(stderr, "partial write %d\n", s);
    exit(EXIT_FAILURE);
  }
  munmap(addr1, 4096 * 2);
  munmap(addr2, 4096);
  close(fd);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x460,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2dd8(%rip),%rax
mov    (%rax),%edi
call   10d0 <sysconf@plt>
mov    %eax,-0x40(%rbp)
lea    0xdff(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x454(%rbp)
mov    0x2db5(%rip),%rax
mov    (%rax),%esi
lea    0xde8(%rip),%rdi
call   10b0 <open@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    1255 <main+0x85>
jmp    123b <main+0x6b>
lea    0xdd0(%rip),%rdi
call   10c0 <perror@plt>
mov    0x2d5a(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    -0x24(%rbp),%edi
lea    -0x28(%rbp),%rsi
call   10f0 <fstat@plt>
cmp    $0xffffffff,%eax
jne    1289 <main+0xb9>
jmp    126f <main+0x9f>
lea    0xda1(%rip),%rdi
call   10c0 <perror@plt>
mov    0x2d26(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    0x2d68(%rip),%rax
mov    (%rax),%edx
mov    0x2d07(%rip),%rax
or     (%rax),%edx
mov    0x2d3e(%rip),%rax
mov    (%rax),%ecx
mov    -0x24(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
mov    $0x2000,%esi
xor    %r9d,%r9d
call   1060 <mmap@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    0x2cc8(%rip),%rcx
cmp    (%rcx),%rax
jne    12f0 <main+0x120>
jmp    12d6 <main+0x106>
lea    0xd40(%rip),%rdi
call   10c0 <perror@plt>
mov    0x2cbf(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    0x2d01(%rip),%rax
mov    (%rax),%edx
mov    0x2ca0(%rip),%rax
or     (%rax),%edx
mov    0x2cd7(%rip),%rax
mov    (%rax),%ecx
mov    -0x24(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
mov    $0x1000,%r9d
mov    %r9d,%esi
call   1060 <mmap@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    0x2c60(%rip),%rcx
cmp    (%rcx),%rax
jne    1358 <main+0x188>
jmp    133e <main+0x16e>
lea    0xcde(%rip),%rdi
call   10c0 <perror@plt>
mov    0x2c57(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    -0x20(%rbp),%rdi
lea    0xcc6(%rip),%rsi
mov    $0xa,%edx
call   1090 <memcpy@plt>
mov    -0x20(%rbp),%rdi
mov    0x2c38(%rip),%rax
mov    (%rax),%edx
mov    $0x1000,%esi
call   1040 <msync@plt>
mov    -0x18(%rbp),%rdi
add    $0x1000,%rdi
lea    0xca3(%rip),%rsi
mov    $0xa,%edx
call   1090 <memcpy@plt>
mov    -0x18(%rbp),%rdi
mov    0x2c05(%rip),%rax
mov    (%rax),%edx
mov    $0x2000,%esi
call   1040 <msync@plt>
mov    0x2c2a(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
add    $0x1000,%rsi
mov    $0xa,%edx
call   1030 <write@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0xa,-0x3c(%rbp)
je     1430 <main+0x260>
cmpl   $0xffffffff,-0x3c(%rbp)
jne    140b <main+0x23b>
jmp    13f1 <main+0x221>
lea    0xc54(%rip),%rdi
call   10c0 <perror@plt>
mov    0x2ba4(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    0x2ba6(%rip),%rax
mov    (%rax),%edi
lea    0xc38(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2b7f(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    0x2bb1(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rsi
mov    $0xa,%edx
call   1030 <write@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0xa,-0x3c(%rbp)
je     14a5 <main+0x2d5>
cmpl   $0xffffffff,-0x3c(%rbp)
jne    147d <main+0x2ad>
jmp    1463 <main+0x293>
lea    0xbf7(%rip),%rdi
call   10c0 <perror@plt>
mov    0x2b32(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    0x2b34(%rip),%rax
mov    (%rax),%edi
mov    -0x3c(%rbp),%edx
lea    0xbd8(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2b0a(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    -0x18(%rbp),%rdi
mov    $0x2000,%esi
call   10a0 <munmap@plt>
mov    -0x20(%rbp),%rdi
mov    $0x1000,%esi
call   10a0 <munmap@plt>
mov    -0x24(%rbp),%edi
call   1070 <close@plt>
mov    0x2ac8(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2de6(%rip),%rax
mov    (%rax),%edi
call   10d0 <sysconf@plt>
lea    0xe10(%rip),%rdi
call   1050 <strlen@plt>
mov    0x2dd4(%rip),%rax
mov    (%rax),%esi
lea    0xe07(%rip),%rdi
call   10b0 <open@plt>
cmp    $0xffffffff,%eax
jne    121b <main+0x4b>
lea    0xdfc(%rip),%rdi
jmp    135f <main+0x18f>
mov    %eax,%ebx
mov    %rsp,%rsi
mov    %eax,%edi
call   10f0 <fstat@plt>
cmp    $0xffffffff,%eax
jne    1238 <main+0x68>
lea    0xde4(%rip),%rdi
jmp    135f <main+0x18f>
mov    0x2db9(%rip),%r15
mov    0x2d5a(%rip),%r12
mov    (%r12),%edx
or     (%r15),%edx
mov    0x2d8c(%rip),%r13
mov    0x0(%r13),%ecx
xor    %edi,%edi
mov    $0x2000,%esi
mov    %ebx,%r8d
xor    %r9d,%r9d
call   1060 <mmap@plt>
mov    0x2d1f(%rip),%rbp
cmp    0x0(%rbp),%rax
jne    1283 <main+0xb3>
lea    0xd9f(%rip),%rdi
jmp    135f <main+0x18f>
mov    %rax,%r14
mov    (%r12),%edx
or     (%r15),%edx
mov    0x0(%r13),%ecx
xor    %edi,%edi
mov    $0x1000,%esi
mov    %ebx,%r8d
mov    $0x1000,%r9d
call   1060 <mmap@plt>
cmp    0x0(%rbp),%rax
jne    12b8 <main+0xe8>
lea    0xd70(%rip),%rdi
jmp    135f <main+0x18f>
mov    %rax,%r15
lea    0xd67(%rip),%rsi
mov    %rax,%rdi
mov    $0xa,%edx
call   1090 <memcpy@plt>
mov    0x2cda(%rip),%rbp
mov    0x0(%rbp),%edx
mov    %r15,%rdi
mov    $0x1000,%esi
call   1040 <msync@plt>
mov    %r14,%r12
add    $0x1000,%r12
lea    0xd42(%rip),%rsi
mov    %r12,%rdi
mov    $0xa,%edx
call   1090 <memcpy@plt>
mov    0x0(%rbp),%edx
mov    %r14,%rdi
mov    $0x2000,%esi
call   1040 <msync@plt>
mov    0x2ccd(%rip),%rbp
mov    0x0(%rbp),%edi
mov    %r12,%rsi
mov    $0xa,%edx
call   1030 <write@plt>
cmp    $0xa,%eax
je     133e <main+0x16e>
cmp    $0xffffffff,%eax
jne    1372 <main+0x1a2>
lea    0xd10(%rip),%rdi
jmp    135f <main+0x18f>
mov    0x0(%rbp),%edi
mov    %r15,%rsi
mov    $0xa,%edx
call   1030 <write@plt>
cmp    $0xa,%eax
je     138b <main+0x1bb>
cmp    $0xffffffff,%eax
jne    13ba <main+0x1ea>
lea    0xd02(%rip),%rdi
call   10c0 <perror@plt>
mov    0x2c3d(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    0x2c3f(%rip),%rax
mov    (%rax),%edi
lea    0xcd1(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    1364 <main+0x194>
mov    %r14,%rdi
mov    $0x2000,%esi
call   10a0 <munmap@plt>
mov    %r15,%rdi
mov    $0x1000,%esi
call   10a0 <munmap@plt>
mov    %ebx,%edi
call   1070 <close@plt>
mov    0x2be5(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    0x2bf7(%rip),%rcx
mov    (%rcx),%edi
lea    0xc9e(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    1364 <main+0x194>

LLVM IR (-O0):
%struct.stat = type { i32 }
@_SC_PAGESIZE = global i32 0
@.str = [12 x i8] c"hello world\00"
@.str.1 = [6 x i8] c"m.dat\00"
@O_RDWR = global i32 0
@.str.2 = [5 x i8] c"open\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [6 x i8] c"fstat\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i8* null
@.str.4 = [6 x i8] c"mmap1\00"
@.str.5 = [6 x i8] c"mmap2\00"
@.str.6 = [16 x i8] c"000000000000000\00"
@MS_SYNC = global i32 0
@.str.7 = [19 x i8] c"111111111111111111\00"
@STDOUT_FILENO = global i32 0
@.str.8 = [7 x i8] c"write2\00"
@stderr = global i32 0
@.str.9 = [14 x i8] c"partial write\00"
@.str.10 = [7 x i8] c"write1\00"
@.str.11 = [18 x i8] c"partial write %d\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 i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca %struct.stat
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i8*
%17 = alloca [1024 x i8]
%18 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%19 = load i32, i32* @_SC_PAGESIZE
%20 = call i32 @sysconf(i32 %19)
store i32 %20, i32* %15
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %16
%21 = load i8*, i8** %16
%22 = call i32 @strlen(i8* %21)
store i32 %22, i32* %18
%23 = load i32, i32* @O_RDWR
%24 = call i32 @open(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %23)
store i32 %24, i32* %8
%25 = load i32, i32* %8
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %33
27: ; preds = %2
br label %28
28: ; preds = %27
%29 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%30 = load i32, i32* @EXIT_FAILURE
%31 = call i32 @exit(i32 %30)
unreachable
32: ; No predecessors!
br label %33
33: ; preds = %32, %2
%34 = load i32, i32* %8
%35 = call i32 @fstat(i32 %34, %struct.stat* %9)
%36 = icmp eq i32 %35, -1
br i1 %36, label %37, label %43
37: ; preds = %33
br label %38
38: ; preds = %37
%39 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%40 = load i32, i32* @EXIT_FAILURE
%41 = call i32 @exit(i32 %40)
unreachable
42: ; No predecessors!
br label %43
43: ; preds = %42, %33
%44 = load i32, i32* @PROT_READ
%45 = load i32, i32* @PROT_WRITE
%46 = or i32 %44, %45
%47 = load i32, i32* @MAP_SHARED
%48 = load i32, i32* %8
%49 = call i8* @mmap(i32* null, i32 8192, i32 %46, i32 %47, i32 %48, i32 0)
store i8* %49, i8** %6
%50 = load i8*, i8** %6
%51 = load i8*, i8** @MAP_FAILED
%52 = icmp eq i8* %50, %51
br i1 %52, label %53, label %59
53: ; preds = %43
br label %54
54: ; preds = %53
%55 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%56 = load i32, i32* @EXIT_FAILURE
%57 = call i32 @exit(i32 %56)
unreachable
58: ; No predecessors!
br label %59
59: ; preds = %58, %43
%60 = load i32, i32* @PROT_READ
%61 = load i32, i32* @PROT_WRITE
%62 = or i32 %60, %61
%63 = load i32, i32* @MAP_SHARED
%64 = load i32, i32* %8
%65 = call i8* @mmap(i32* null, i32 4096, i32 %62, i32 %63, i32 %64, i32 4096)
store i8* %65, i8** %7
%66 = load i8*, i8** %7
%67 = load i8*, i8** @MAP_FAILED
%68 = icmp eq i8* %66, %67
br i1 %68, label %69, label %75
69: ; preds = %59
br label %70
70: ; preds = %69
%71 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%72 = load i32, i32* @EXIT_FAILURE
%73 = call i32 @exit(i32 %72)
unreachable
74: ; No predecessors!
br label %75
75: ; preds = %74, %59
%76 = load i8*, i8** %7
%77 = call i32 @memcpy(i8* %76, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 10)
%78 = load i8*, i8** %7
%79 = load i32, i32* @MS_SYNC
%80 = call i32 @msync(i8* %78, i32 4096, i32 %79)
%81 = load i8*, i8** %6
%82 = getelementptr inbounds i8, i8* %81, i64 4096
%83 = call i32 @memcpy(i8* %82, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i32 10)
%84 = load i8*, i8** %6
%85 = load i32, i32* @MS_SYNC
%86 = call i32 @msync(i8* %84, i32 8192, i32 %85)
%87 = load i32, i32* @STDOUT_FILENO
%88 = load i8*, i8** %6
%89 = getelementptr inbounds i8, i8* %88, i64 4096
%90 = call i32 @write(i32 %87, i8* %89, i32 10)
store i32 %90, i32* %14
%91 = load i32, i32* %14
%92 = icmp ne i32 %91, 10
br i1 %92, label %93, label %107
93: ; preds = %75
%94 = load i32, i32* %14
%95 = icmp eq i32 %94, -1
br i1 %95, label %96, label %102
96: ; preds = %93
br label %97
97: ; preds = %96
%98 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
%99 = load i32, i32* @EXIT_FAILURE
%100 = call i32 @exit(i32 %99)
unreachable
101: ; No predecessors!
br label %102
102: ; preds = %101, %93
%103 = load i32, i32* @stderr
%104 = call i32 (i32, i8*, ...) @fprintf(i32 %103, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0))
%105 = load i32, i32* @EXIT_FAILURE
%106 = call i32 @exit(i32 %105)
unreachable
107: ; preds = %75
%108 = load i32, i32* @STDOUT_FILENO
%109 = load i8*, i8** %7
%110 = call i32 @write(i32 %108, i8* %109, i32 10)
store i32 %110, i32* %14
%111 = load i32, i32* %14
%112 = icmp ne i32 %111, 10
br i1 %112, label %113, label %128
113: ; preds = %107
%114 = load i32, i32* %14
%115 = icmp eq i32 %114, -1
br i1 %115, label %116, label %122
116: ; preds = %113
br label %117
117: ; preds = %116
%118 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
%119 = load i32, i32* @EXIT_FAILURE
%120 = call i32 @exit(i32 %119)
unreachable
121: ; No predecessors!
br label %122
122: ; preds = %121, %113
%123 = load i32, i32* @stderr
%124 = load i32, i32* %14
%125 = call i32 (i32, i8*, ...) @fprintf(i32 %123, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0), i32 %124)
%126 = load i32, i32* @EXIT_FAILURE
%127 = call i32 @exit(i32 %126)
unreachable
128: ; preds = %107
%129 = load i8*, i8** %6
%130 = call i32 @munmap(i8* %129, i32 8192)
%131 = load i8*, i8** %7
%132 = call i32 @munmap(i8* %131, i32 4096)
%133 = load i32, i32* %8
%134 = call i32 @close(i32 %133)
%135 = load i32, i32* @EXIT_SUCCESS
%136 = call i32 @exit(i32 %135)
unreachable
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@_SC_PAGESIZE = global i32 0
@.str = [12 x i8] c"hello world\00"
@.str.1 = [6 x i8] c"m.dat\00"
@O_RDWR = global i32 0
@.str.2 = [5 x i8] c"open\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [6 x i8] c"fstat\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i8* null
@.str.4 = [6 x i8] c"mmap1\00"
@.str.5 = [6 x i8] c"mmap2\00"
@.str.6 = [16 x i8] c"000000000000000\00"
@MS_SYNC = global i32 0
@.str.7 = [19 x i8] c"111111111111111111\00"
@STDOUT_FILENO = global i32 0
@.str.8 = [7 x i8] c"write2\00"
@stderr = global i32 0
@.str.9 = [14 x i8] c"partial write\00"
@.str.10 = [7 x i8] c"write1\00"
@.str.11 = [18 x i8] c"partial write %d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = load i32, i32* @_SC_PAGESIZE
%6 = tail call i32 @sysconf(i32 %5)
%7 = tail call i32 @strlen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @O_RDWR
%9 = tail call i32 @open(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%13 = load i32, i32* @EXIT_FAILURE
%14 = tail call i32 @exit(i32 %13)
unreachable
15: ; preds = %2
%16 = call i32 @fstat(i32 %9, %struct.stat* %3)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%20 = load i32, i32* @EXIT_FAILURE
%21 = tail call i32 @exit(i32 %20)
unreachable
22: ; preds = %15
%23 = load i32, i32* @PROT_READ
%24 = load i32, i32* @PROT_WRITE
%25 = or i32 %24, %23
%26 = load i32, i32* @MAP_SHARED
%27 = tail call i8* @mmap(i32* null, i32 8192, i32 %25, i32 %26, i32 %9, i32 0)
%28 = load i8*, i8** @MAP_FAILED
%29 = icmp eq i8* %27, %28
br i1 %29, label %30, label %34
30: ; preds = %22
%31 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%32 = load i32, i32* @EXIT_FAILURE
%33 = tail call i32 @exit(i32 %32)
unreachable
34: ; preds = %22
%35 = load i32, i32* @PROT_READ
%36 = load i32, i32* @PROT_WRITE
%37 = or i32 %36, %35
%38 = load i32, i32* @MAP_SHARED
%39 = tail call i8* @mmap(i32* null, i32 4096, i32 %37, i32 %38, i32 %9, i32 4096)
%40 = load i8*, i8** @MAP_FAILED
%41 = icmp eq i8* %39, %40
br i1 %41, label %42, label %46
42: ; preds = %34
%43 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%44 = load i32, i32* @EXIT_FAILURE
%45 = tail call i32 @exit(i32 %44)
unreachable
46: ; preds = %34
%47 = tail call i32 @memcpy(i8* %39, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 10)
%48 = load i32, i32* @MS_SYNC
%49 = tail call i32 @msync(i8* %39, i32 4096, i32 %48)
%50 = getelementptr inbounds i8, i8* %27, i64 4096
%51 = tail call i32 @memcpy(i8* %50, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i32 10)
%52 = load i32, i32* @MS_SYNC
%53 = tail call i32 @msync(i8* %27, i32 8192, i32 %52)
%54 = load i32, i32* @STDOUT_FILENO
%55 = tail call i32 @write(i32 %54, i8* %50, i32 10)
switch i32 %55, label %60 [
i32 10, label %65
i32 -1, label %56
]
56: ; preds = %46
%57 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
%58 = load i32, i32* @EXIT_FAILURE
%59 = tail call i32 @exit(i32 %58)
unreachable
60: ; preds = %46
%61 = load i32, i32* @stderr
%62 = tail call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0))
%63 = load i32, i32* @EXIT_FAILURE
%64 = tail call i32 @exit(i32 %63)
unreachable
65: ; preds = %46
%66 = load i32, i32* @STDOUT_FILENO
%67 = tail call i32 @write(i32 %66, i8* %39, i32 10)
switch i32 %67, label %72 [
i32 10, label %77
i32 -1, label %68
]
68: ; preds = %65
%69 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
%70 = load i32, i32* @EXIT_FAILURE
%71 = tail call i32 @exit(i32 %70)
unreachable
72: ; preds = %65
%73 = load i32, i32* @stderr
%74 = tail call i32 (i32, i8*, ...) @fprintf(i32 %73, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0), i32 %67)
%75 = load i32, i32* @EXIT_FAILURE
%76 = tail call i32 @exit(i32 %75)
unreachable
77: ; preds = %65
%78 = tail call i32 @munmap(i8* %27, i32 8192)
%79 = tail call i32 @munmap(i8* %39, i32 4096)
%80 = tail call i32 @close(i32 %9)
%81 = load i32, i32* @EXIT_SUCCESS
%82 = tail call i32 @exit(i32 %81)
unreachable
}