#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 */
void *MAP_FAILED;
int /*<<< orphan*/ MAP_SHARED;
int O_CREAT;
int O_RDWR;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ _SC_PAGESIZE;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int ftruncate(int, long const);
int /*<<< orphan*/ lseek(int, int /*<<< orphan*/, int /*<<< orphan*/);
void *mmap(int /*<<< orphan*/, long const, int, int /*<<< orphan*/, int,
           int /*<<< orphan*/);
int /*<<< orphan*/ munmap(void *, long const);
int open(char *, int, int);
int /*<<< orphan*/ printf(char *, long const);
int /*<<< orphan*/ read(int, unsigned char *, int);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ syncfs(int);
long sysconf(int /*<<< orphan*/);
int /*<<< orphan*/ write(int, char *, int);
int main() {
  const long pagesize = sysconf(_SC_PAGESIZE);
  const long maplength = pagesize;
  printf("Page size on this system is %ld bytes\n", pagesize);
  int fd = open("mmapped-file", O_RDWR | O_CREAT, 0777);
  if (fd == -1) {
    fprintf(stderr, "Can't open or create mmapped-file\n");
    exit(1);
  }
  if (ftruncate(fd, maplength) == -1) {
    fprintf(stderr, "Failed to set file size to correct length: %s\n",
            strerror(errno));
    exit(2);
  }
  void *m = mmap(0, maplength, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
  if (m == MAP_FAILED) {
    fprintf(stderr, "Can't mmap the requested file\n");
    close(fd);
    exit(3);
  }
  unsigned int *i = (unsigned int *)m;
  i[0] = 0xDEADBEEF;
  syncfs(fd);
  munmap(m, maplength);
  syncfs(fd);
  lseek(fd, 0, SEEK_SET);
  unsigned char readbuffer[4];
  read(fd, readbuffer, 1);
  printf("First byte in file: %2.2X\n", (int)readbuffer[0]);
  write(fd, "\x47", 1);
  m = mmap(0, maplength, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
  if (m == MAP_FAILED) {
    fprintf(stderr, "Can't mmap the requested file: %s\n", strerror(errno));
    close(fd);
    exit(4);
  }
  i = (unsigned int *__attribute__((litteendian)))m;
  printf("Value at address 0: %8.8X\n", i[0]);
  int total = 0;
  int c;
  for (c = 0; c < 100000000; c++) {
    total += i[c % (maplength / sizeof(unsigned int))];
  }
  printf("Total: %d\n", total);
  munmap(m, maplength);
  close(fd);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2dd2(%rip),%rax
mov    (%rax),%edi
call   10e0 <sysconf@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xdec(%rip),%rdi
call   1060 <printf@plt>
mov    0x2db0(%rip),%rax
mov    (%rax),%esi
mov    0x2dcf(%rip),%rax
or     (%rax),%esi
lea    0xdf5(%rip),%rdi
mov    $0x1ff,%edx
call   10d0 <open@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    126a <main+0x8a>
mov    0x2d68(%rip),%rax
mov    (%rax),%edi
lea    0xddb(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1070 <ftruncate@plt>
cmp    $0xffffffff,%eax
jne    12b7 <main+0xd7>
mov    0x2d32(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    0x2d1e(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    -0x40(%rbp),%edi
mov    %rax,%rdx
lea    0xdb1(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x2,%edi
call   10f0 <exit@plt>
mov    -0x18(%rbp),%rsi
mov    0x2d2e(%rip),%rax
mov    (%rax),%edx
mov    0x2cd5(%rip),%rax
or     (%rax),%edx
mov    0x2d0c(%rip),%rax
mov    (%rax),%ecx
mov    -0x1c(%rbp),%r8d
xor    %r9d,%r9d
mov    %r9d,%edi
call   1050 <mmap@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    0x2ca4(%rip),%rcx
cmp    (%rcx),%rax
jne    1326 <main+0x146>
mov    0x2cb4(%rip),%rax
mov    (%rax),%edi
lea    0xd79(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    -0x1c(%rbp),%edi
call   1090 <close@plt>
mov    $0x3,%edi
call   10f0 <exit@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movl   $0xdeadbeef,(%rax)
mov    -0x1c(%rbp),%edi
call   1040 <syncfs@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   10c0 <munmap@plt>
mov    -0x1c(%rbp),%edi
call   1040 <syncfs@plt>
mov    -0x1c(%rbp),%edi
mov    0x2c49(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <lseek@plt>
mov    -0x1c(%rbp),%edi
lea    -0x34(%rbp),%rsi
mov    $0x1,%edx
call   10a0 <read@plt>
movzbl -0x34(%rbp),%eax
movslq %eax,%rsi
lea    0xd1e(%rip),%rdi
call   1060 <printf@plt>
mov    -0x1c(%rbp),%edi
lea    0xd2a(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    -0x18(%rbp),%rsi
mov    0x2c45(%rip),%rax
mov    (%rax),%edx
mov    0x2bec(%rip),%rax
or     (%rax),%edx
mov    0x2c23(%rip),%rax
mov    (%rax),%ecx
mov    -0x1c(%rbp),%r8d
xor    %r9d,%r9d
mov    %r9d,%edi
call   1050 <mmap@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    0x2bbb(%rip),%rcx
cmp    (%rcx),%rax
jne    1426 <main+0x246>
mov    0x2bcb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    0x2bb7(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    -0x44(%rbp),%edi
mov    %rax,%rdx
lea    0xcb5(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    -0x1c(%rbp),%edi
call   1090 <close@plt>
mov    $0x4,%edi
call   10f0 <exit@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%eax
mov    %eax,%esi
lea    0xca8(%rip),%rdi
call   1060 <printf@plt>
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
cmpl   $0x5f5e100,-0x3c(%rbp)
jge    1491 <main+0x2b1>
mov    -0x30(%rbp),%rax
mov    %rax,-0x50(%rbp)
movslq -0x3c(%rbp),%rax
mov    -0x18(%rbp),%rcx
shr    $0x2,%rcx
xor    %edx,%edx
div    %rcx
mov    -0x50(%rbp),%rax
mov    (%rax,%rdx,4),%eax
add    -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1450 <main+0x270>
movslq -0x38(%rbp),%rsi
lea    0xc64(%rip),%rdi
call   1060 <printf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   10c0 <munmap@plt>
mov    -0x1c(%rbp),%edi
call   1090 <close@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2dd6(%rip),%rax
mov    (%rax),%edi
call   10e0 <sysconf@plt>
mov    %rax,%r14
lea    0xdfd(%rip),%rdi
mov    %rax,%rsi
call   1060 <printf@plt>
mov    0x2dbe(%rip),%rax
mov    0x2ddf(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0xe03(%rip),%rdi
mov    $0x1ff,%edx
call   10d0 <open@plt>
cmp    $0xffffffff,%eax
je     13ce <main+0x1ee>
mov    %eax,%r15d
mov    %eax,%edi
mov    %r14,%rsi
call   1070 <ftruncate@plt>
cmp    $0xffffffff,%eax
je     13ef <main+0x20f>
mov    0x2d9c(%rip),%rax
mov    0x2d45(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2d7a(%rip),%r12
mov    (%r12),%ecx
xor    %edi,%edi
mov    %r14,%rsi
mov    %r15d,%r8d
xor    %r9d,%r9d
call   1050 <mmap@plt>
mov    0x2d17(%rip),%r13
cmp    0x0(%r13),%rax
je     1423 <main+0x243>
mov    %rax,%rbx
movl   $0xdeadbeef,(%rax)
mov    %r15d,%edi
call   1040 <syncfs@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   10c0 <munmap@plt>
mov    %r15d,%edi
call   1040 <syncfs@plt>
mov    0x2cf2(%rip),%rax
mov    (%rax),%edx
xor    %ebp,%ebp
mov    %r15d,%edi
xor    %esi,%esi
call   1080 <lseek@plt>
lea    0x4(%rsp),%rsi
mov    %r15d,%edi
mov    $0x1,%edx
call   10a0 <read@plt>
movzbl 0x4(%rsp),%esi
lea    0xdc3(%rip),%rdi
call   1060 <printf@plt>
lea    0xdd2(%rip),%rsi
mov    %r15d,%edi
mov    $0x1,%edx
call   1030 <write@plt>
mov    0x2c9e(%rip),%rax
mov    (%rax),%edx
mov    0x2ce5(%rip),%rax
or     (%rax),%edx
mov    (%r12),%ecx
xor    %edi,%edi
mov    %r14,%rsi
mov    %r15d,%r8d
xor    %r9d,%r9d
call   1050 <mmap@plt>
cmp    0x0(%r13),%rax
je     144c <main+0x26c>
mov    %rax,%rbx
mov    (%rax),%esi
lea    0xdae(%rip),%rdi
call   1060 <printf@plt>
mov    %r14,%rsi
shr    $0x2,%rsi
mov    $0x1,%ecx
jmp    1368 <main+0x188>
nopw   0x0(%rax,%rax,1)
mov    %rcx,%rax
xor    %edx,%edx
div    %rsi
add    (%rbx,%rdx,4),%ebp
add    $0x2,%rcx
cmp    $0x5f5e101,%rcx
je     139b <main+0x1bb>
lea    -0x1(%rcx),%rax
mov    %rax,%rdx
or     %rsi,%rdx
shr    $0x20,%rdx
je     1380 <main+0x1a0>
xor    %edx,%edx
div    %rsi
jmp    1384 <main+0x1a4>
nop
xor    %edx,%edx
div    %esi
mov    %rcx,%rax
or     %rsi,%rax
add    (%rbx,%rdx,4),%ebp
shr    $0x20,%rax
jne    1350 <main+0x170>
mov    %ecx,%eax
xor    %edx,%edx
div    %esi
jmp    1358 <main+0x178>
movslq %ebp,%rsi
lea    0xd5b(%rip),%rdi
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   10c0 <munmap@plt>
mov    %r15d,%edi
call   1090 <close@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2be3(%rip),%rax
mov    (%rax),%edi
lea    0xc56(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    0x2bc2(%rip),%rax
mov    (%rax),%ebx
mov    0x2bb1(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
lea    0xc4a(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x2,%edi
call   10f0 <exit@plt>
mov    0x2b8e(%rip),%rax
mov    (%rax),%edi
lea    0xc53(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    %r15d,%edi
call   1090 <close@plt>
mov    $0x3,%edi
call   10f0 <exit@plt>
mov    0x2b65(%rip),%rax
mov    (%rax),%ebx
mov    0x2b54(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
lea    0xc58(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    %r15d,%edi
call   1090 <close@plt>
mov    $0x4,%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
@_SC_PAGESIZE = global i32 0
@.str = [39 x i8] c"Page size on this system is %ld bytes\0A\00"
@.str.1 = [13 x i8] c"mmapped-file\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@stderr = global i32 0
@.str.2 = [35 x i8] c"Can't open or create mmapped-file\0A\00"
@.str.3 = [47 x i8] c"Failed to set file size to correct length: %s\0A\00"
@errno = global i32 0
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i8* null
@.str.4 = [31 x i8] c"Can't mmap the requested file\0A\00"
@SEEK_SET = global i32 0
@.str.5 = [27 x i8] c"First byte in file: %2.2X\0A\00"
@.str.6 = [2 x i8] c"G\00"
@.str.7 = [35 x i8] c"Can't mmap the requested file: %s\0A\00"
@.str.8 = [27 x i8] c"Value at address 0: %8.8X\0A\00"
@.str.9 = [11 x i8] c"Total: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca [4 x i8]
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
%10 = load i32, i32* @_SC_PAGESIZE
%11 = call i64 @sysconf(i32 %10)
store i64 %11, i64* %2
%12 = load i64, i64* %2
store i64 %12, i64* %3
%13 = load i64, i64* %2
%14 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i64 %13)
%15 = load i32, i32* @O_RDWR
%16 = load i32, i32* @O_CREAT
%17 = or i32 %15, %16
%18 = call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %17, i32 511)
store i32 %18, i32* %4
%19 = load i32, i32* %4
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %25
21: ; preds = %0
%22 = load i32, i32* @stderr
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %0
%26 = load i32, i32* %4
%27 = load i64, i64* %3
%28 = call i32 @ftruncate(i32 %26, i64 %27)
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %36
30: ; preds = %25
%31 = load i32, i32* @stderr
%32 = load i32, i32* @errno
%33 = call i8* @strerror(i32 %32)
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0), i8* %33)
%35 = call i32 @exit(i32 2)
unreachable
36: ; preds = %25
%37 = load i64, i64* %3
%38 = load i32, i32* @PROT_READ
%39 = load i32, i32* @PROT_WRITE
%40 = or i32 %38, %39
%41 = load i32, i32* @MAP_SHARED
%42 = load i32, i32* %4
%43 = call i8* @mmap(i32 0, i64 %37, i32 %40, i32 %41, i32 %42, i32 0)
store i8* %43, i8** %5
%44 = load i8*, i8** %5
%45 = load i8*, i8** @MAP_FAILED
%46 = icmp eq i8* %44, %45
br i1 %46, label %47, label %53
47: ; preds = %36
%48 = load i32, i32* @stderr
%49 = call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
%50 = load i32, i32* %4
%51 = call i32 @close(i32 %50)
%52 = call i32 @exit(i32 3)
unreachable
53: ; preds = %36
%54 = load i8*, i8** %5
%55 = bitcast i8* %54 to i32*
store i32* %55, i32** %6
%56 = load i32*, i32** %6
%57 = getelementptr inbounds i32, i32* %56, i64 0
store i32 -559038737, i32* %57
%58 = load i32, i32* %4
%59 = call i32 @syncfs(i32 %58)
%60 = load i8*, i8** %5
%61 = load i64, i64* %3
%62 = call i32 @munmap(i8* %60, i64 %61)
%63 = load i32, i32* %4
%64 = call i32 @syncfs(i32 %63)
%65 = load i32, i32* %4
%66 = load i32, i32* @SEEK_SET
%67 = call i32 @lseek(i32 %65, i32 0, i32 %66)
%68 = load i32, i32* %4
%69 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%70 = call i32 @read(i32 %68, i8* %69, i32 1)
%71 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%72 = load i8, i8* %71
%73 = zext i8 %72 to i32
%74 = sext i32 %73 to i64
%75 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i64 %74)
%76 = load i32, i32* %4
%77 = call i32 @write(i32 %76, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i32 1)
%78 = load i64, i64* %3
%79 = load i32, i32* @PROT_READ
%80 = load i32, i32* @PROT_WRITE
%81 = or i32 %79, %80
%82 = load i32, i32* @MAP_SHARED
%83 = load i32, i32* %4
%84 = call i8* @mmap(i32 0, i64 %78, i32 %81, i32 %82, i32 %83, i32 0)
store i8* %84, i8** %5
%85 = load i8*, i8** %5
%86 = load i8*, i8** @MAP_FAILED
%87 = icmp eq i8* %85, %86
br i1 %87, label %88, label %96
88: ; preds = %53
%89 = load i32, i32* @stderr
%90 = load i32, i32* @errno
%91 = call i8* @strerror(i32 %90)
%92 = call i32 (i32, i8*, ...) @fprintf(i32 %89, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0), i8* %91)
%93 = load i32, i32* %4
%94 = call i32 @close(i32 %93)
%95 = call i32 @exit(i32 4)
unreachable
96: ; preds = %53
%97 = load i8*, i8** %5
%98 = bitcast i8* %97 to i32*
store i32* %98, i32** %6
%99 = load i32*, i32** %6
%100 = getelementptr inbounds i32, i32* %99, i64 0
%101 = load i32, i32* %100
%102 = zext i32 %101 to i64
%103 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0), i64 %102)
store i32 0, i32* %8
store i32 0, i32* %9
br label %104
104: ; preds = %118, %96
%105 = load i32, i32* %9
%106 = icmp slt i32 %105, 100000000
br i1 %106, label %107, label %121
107: ; preds = %104
%108 = load i32*, i32** %6
%109 = load i32, i32* %9
%110 = sext i32 %109 to i64
%111 = load i64, i64* %3
%112 = udiv i64 %111, 4
%113 = urem i64 %110, %112
%114 = getelementptr inbounds i32, i32* %108, i64 %113
%115 = load i32, i32* %114
%116 = load i32, i32* %8
%117 = add i32 %116, %115
store i32 %117, i32* %8
br label %118
118: ; preds = %107
%119 = load i32, i32* %9
%120 = add nsw i32 %119, 1
store i32 %120, i32* %9
br label %104
121: ; preds = %104
%122 = load i32, i32* %8
%123 = sext i32 %122 to i64
%124 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i64 %123)
%125 = load i8*, i8** %5
%126 = load i64, i64* %3
%127 = call i32 @munmap(i8* %125, i64 %126)
%128 = load i32, i32* %4
%129 = call i32 @close(i32 %128)
%130 = load i32, i32* %1
ret i32 %130
}

LLVM IR (-O2):
@_SC_PAGESIZE = global i32 0
@.str = [39 x i8] c"Page size on this system is %ld bytes\0A\00"
@.str.1 = [13 x i8] c"mmapped-file\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@stderr = global i32 0
@.str.2 = [35 x i8] c"Can't open or create mmapped-file\0A\00"
@.str.3 = [47 x i8] c"Failed to set file size to correct length: %s\0A\00"
@errno = global i32 0
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i8* null
@.str.4 = [31 x i8] c"Can't mmap the requested file\0A\00"
@SEEK_SET = global i32 0
@.str.5 = [27 x i8] c"First byte in file: %2.2X\0A\00"
@.str.6 = [2 x i8] c"G\00"
@.str.7 = [35 x i8] c"Can't mmap the requested file: %s\0A\00"
@.str.8 = [27 x i8] c"Value at address 0: %8.8X\0A\00"
@.str.9 = [11 x i8] c"Total: %d\0A\00"
define i32 @main() {
%1 = alloca [4 x i8]
%2 = load i32, i32* @_SC_PAGESIZE
%3 = tail call i64 @sysconf(i32 %2)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i64 %3)
%5 = load i32, i32* @O_RDWR
%6 = load i32, i32* @O_CREAT
%7 = or i32 %6, %5
%8 = tail call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %7, i32 511)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %14
10: ; preds = %0
%11 = load i32, i32* @stderr
%12 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %0
%15 = tail call i32 @ftruncate(i32 %8, i64 %3)
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %23
17: ; preds = %14
%18 = load i32, i32* @stderr
%19 = load i32, i32* @errno
%20 = tail call i8* @strerror(i32 %19)
%21 = tail call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0), i8* %20)
%22 = tail call i32 @exit(i32 2)
unreachable
23: ; preds = %14
%24 = load i32, i32* @PROT_READ
%25 = load i32, i32* @PROT_WRITE
%26 = or i32 %25, %24
%27 = load i32, i32* @MAP_SHARED
%28 = tail call i8* @mmap(i32 0, i64 %3, i32 %26, i32 %27, i32 %8, i32 0)
%29 = load i8*, i8** @MAP_FAILED
%30 = icmp eq i8* %28, %29
br i1 %30, label %31, label %36
31: ; preds = %23
%32 = load i32, i32* @stderr
%33 = tail call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
%34 = tail call i32 @close(i32 %8)
%35 = tail call i32 @exit(i32 3)
unreachable
36: ; preds = %23
%37 = bitcast i8* %28 to i32*
store i32 -559038737, i32* %37
%38 = tail call i32 @syncfs(i32 %8)
%39 = tail call i32 @munmap(i8* %28, i64 %3)
%40 = tail call i32 @syncfs(i32 %8)
%41 = load i32, i32* @SEEK_SET
%42 = tail call i32 @lseek(i32 %8, i32 0, i32 %41)
%43 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 0
%44 = call i32 @read(i32 %8, i8* %43, i32 1)
%45 = load i8, i8* %43
%46 = zext i8 %45 to i64
%47 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i64 %46)
%48 = tail call i32 @write(i32 %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i32 1)
%49 = load i32, i32* @PROT_READ
%50 = load i32, i32* @PROT_WRITE
%51 = or i32 %50, %49
%52 = load i32, i32* @MAP_SHARED
%53 = tail call i8* @mmap(i32 0, i64 %3, i32 %51, i32 %52, i32 %8, i32 0)
%54 = load i8*, i8** @MAP_FAILED
%55 = icmp eq i8* %53, %54
br i1 %55, label %56, label %63
56: ; preds = %36
%57 = load i32, i32* @stderr
%58 = load i32, i32* @errno
%59 = tail call i8* @strerror(i32 %58)
%60 = tail call i32 (i32, i8*, ...) @fprintf(i32 %57, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0), i8* %59)
%61 = tail call i32 @close(i32 %8)
%62 = tail call i32 @exit(i32 4)
unreachable
63: ; preds = %36
%64 = bitcast i8* %53 to i32*
%65 = load i32, i32* %64
%66 = zext i32 %65 to i64
%67 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0), i64 %66)
%68 = lshr i64 %3, 2
br label %69
69: ; preds = %69, %63
%70 = phi i64 [ 0, %63 ], [ %81, %69 ]
%71 = phi i32 [ 0, %63 ], [ %80, %69 ]
%72 = urem i64 %70, %68
%73 = getelementptr inbounds i32, i32* %64, i64 %72
%74 = load i32, i32* %73
%75 = add i32 %74, %71
%76 = or i64 %70, 1
%77 = urem i64 %76, %68
%78 = getelementptr inbounds i32, i32* %64, i64 %77
%79 = load i32, i32* %78
%80 = add i32 %79, %75
%81 = add nuw nsw i64 %70, 2
%82 = icmp eq i64 %81, 100000000
br i1 %82, label %83, label %69
83: ; preds = %69
%84 = sext i32 %80 to i64
%85 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i64 %84)
%86 = tail call i32 @munmap(i8* %53, i64 %3)
%87 = tail call i32 @close(i32 %8)
ret i32 0
}