#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 timeval {
  scalar_t__ tv_usec;
  scalar_t__ tv_sec;
};
typedef int /*<<< orphan*/ mode_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int *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 /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, long double);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int lseek(int, int, int /*<<< orphan*/);
int *mmap(int /*<<< orphan*/, int, int, int /*<<< orphan*/, int,
          int /*<<< orphan*/);
int munmap(int *, int);
int open(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, long double);
int write(int, char *, int);
int main(int argc, char *argv[]) {
  int i;
  int fd;
  int result;
  int *map;
  struct timeval start, end;
  FILE *fp2;
  int iter = 0;
  for (iter; iter < 100; iter++) {
    fp2 = fopen("/home/george/Documents/C/pipe.txt", "a");
    fd = open("/home/george/Documents/C/mmapped.bin",
              O_RDWR | O_CREAT | O_TRUNC, (mode_t)0600);
    if (fd == -1) {
      perror("Error opening file for writing");
      exit(EXIT_FAILURE);
    }
    result = lseek(fd, ((4) * sizeof(int)) - 1, SEEK_SET);
    if (result == -1) {
      close(fd);
      perror("Error calling lseek() to 'stretch' the file");
      exit(EXIT_FAILURE);
    }
    result = write(fd, "", 1);
    if (result != 1) {
      close(fd);
      perror("Error writing last byte of the file");
      exit(EXIT_FAILURE);
    }
    map =
        mmap(0, ((4) * sizeof(int)), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
    if (map == MAP_FAILED) {
      close(fd);
      perror("Error mmapping the file");
      exit(EXIT_FAILURE);
    }
    gettimeofday(&start, NULL);
    for (i = 1; i <= (4); ++i) {
      map[i] = 1;
    }
    map = mmap(0, ((4) * sizeof(int)), PROT_READ, MAP_SHARED, fd, 0);
    if (map == MAP_FAILED) {
      close(fd);
      perror("Error mmapping the file");
      exit(EXIT_FAILURE);
    }
    for (i = 1; i <= (4) - 1; i = i + (4) / 2) {
      printf("%d ", map[i]);
    }
    map =
        mmap(0, ((4) * sizeof(int)), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
    if (map == MAP_FAILED) {
      close(fd);
      perror("Error mmapping the file");
      exit(EXIT_FAILURE);
    }
    map[0] = 6;
    map = mmap(0, ((4) * sizeof(int)), PROT_READ, MAP_SHARED, fd, 0);
    if (map == MAP_FAILED) {
      close(fd);
      perror("Error mmapping the file");
      exit(EXIT_FAILURE);
    }
    printf("%d ", map[0]);
    gettimeofday(&end, NULL);
    long double time =
        ((long double)(end.tv_sec - start.tv_sec) +
         ((long double)(end.tv_usec - start.tv_usec) / 1000000.0));
    printf("%Lf\n", time);
    close(fd);
    fprintf(fp2, "%Lf\n", time);
    fflush(fp2);
    if (munmap(map, ((4) * sizeof(int))) == -1) {
      perror("Error un-mmapping the file");
    }
    fclose(fp2);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x54(%rbp)
cmpl   $0x64,-0x54(%rbp)
jge    15f2 <main+0x412>
lea    0xdf3(%rip),%rdi
lea    0xe0e(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x50(%rbp)
mov    0x2da0(%rip),%rax
mov    (%rax),%esi
mov    0x2dc7(%rip),%rax
or     (%rax),%esi
mov    0x2db6(%rip),%rax
or     (%rax),%esi
lea    0xde5(%rip),%rdi
mov    $0x180,%edx
call   10d0 <open@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    1274 <main+0x94>
lea    0xdec(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2d43(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
mov    -0x18(%rbp),%edi
mov    0x2d3a(%rip),%rax
mov    (%rax),%edx
mov    $0xf,%esi
call   1070 <lseek@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    12b9 <main+0xd9>
mov    -0x18(%rbp),%edi
call   1090 <close@plt>
lea    0xdc6(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2cfe(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
mov    -0x18(%rbp),%edi
lea    0xe19(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x1,-0x1c(%rbp)
je     12fc <main+0x11c>
mov    -0x18(%rbp),%edi
call   1090 <close@plt>
lea    0xdaf(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2cbb(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
mov    0x2ce5(%rip),%rax
mov    (%rax),%edx
mov    0x2c9c(%rip),%rax
or     (%rax),%edx
mov    0x2cc3(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%r8d
xor    %r9d,%r9d
mov    $0x10,%esi
mov    %r9d,%edi
call   1050 <mmap@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    0x2c66(%rip),%rcx
cmp    (%rcx),%rax
jne    1365 <main+0x185>
mov    -0x18(%rbp),%edi
call   1090 <close@plt>
lea    0xd6a(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2c52(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
lea    -0x38(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1080 <gettimeofday@plt>
movl   $0x1,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jg     13a0 <main+0x1c0>
mov    -0x28(%rbp),%rax
movslq -0x14(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1379 <main+0x199>
mov    0x2c41(%rip),%rax
mov    (%rax),%edx
mov    0x2c28(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%r8d
xor    %r9d,%r9d
mov    $0x10,%esi
mov    %r9d,%edi
call   1050 <mmap@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    0x2bcb(%rip),%rcx
cmp    (%rcx),%rax
jne    1400 <main+0x220>
mov    -0x18(%rbp),%edi
call   1090 <close@plt>
lea    0xccf(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2bb7(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
movl   $0x1,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jg     1447 <main+0x267>
mov    -0x28(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x88(%rbp)
fildl  -0x88(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
lea    0xca0(%rip),%rdi
call   1060 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
jmp    1407 <main+0x227>
mov    0x2b9a(%rip),%rax
mov    (%rax),%edx
mov    0x2b51(%rip),%rax
or     (%rax),%edx
mov    0x2b78(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%r8d
xor    %r9d,%r9d
mov    $0x10,%esi
mov    %r9d,%edi
call   1050 <mmap@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    0x2b1b(%rip),%rcx
cmp    (%rcx),%rax
jne    14b0 <main+0x2d0>
mov    -0x18(%rbp),%edi
call   1090 <close@plt>
lea    0xc1f(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2b07(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
mov    -0x28(%rbp),%rax
movl   $0x6,(%rax)
mov    0x2b27(%rip),%rax
mov    (%rax),%edx
mov    0x2b0e(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%r8d
xor    %r9d,%r9d
mov    $0x10,%esi
mov    %r9d,%edi
call   1050 <mmap@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    0x2ab1(%rip),%rcx
cmp    (%rcx),%rax
jne    151a <main+0x33a>
mov    -0x18(%rbp),%edi
call   1090 <close@plt>
lea    0xbb5(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2a9d(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
mov    -0x28(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x84(%rbp)
fildl  -0x84(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
lea    0xb9c(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
mov    %eax,%esi
lea    -0x48(%rbp),%rdi
call   1080 <gettimeofday@plt>
mov    -0x48(%rbp),%rax
mov    -0x40(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    -0x30(%rbp),%rsi
sub    %rsi,%rdx
mov    %rdx,-0x78(%rbp)
fildll -0x78(%rbp)
sub    %rcx,%rax
mov    %rax,-0x80(%rbp)
fildll -0x80(%rbp)
flds   0xa8c(%rip)
fdivrp %st,%st(1)
faddp  %st,%st(1)
fstpt  -0x70(%rbp)
fldt   -0x70(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
lea    0xb4e(%rip),%rdi
call   1060 <printf@plt>
mov    -0x18(%rbp),%edi
call   1090 <close@plt>
mov    -0x50(%rbp),%rdi
fldt   -0x70(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
lea    0xb2e(%rip),%rsi
call   10a0 <fprintf@plt>
mov    -0x50(%rbp),%rdi
call   10b0 <fflush@plt>
mov    -0x28(%rbp),%rdi
mov    $0x10,%esi
call   10c0 <munmap@plt>
cmp    $0xffffffff,%eax
jne    15db <main+0x3fb>
lea    0xb07(%rip),%rdi
call   10f0 <perror@plt>
mov    -0x50(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1200 <main+0x20>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    $0x64,%ebx
mov    0x2dee(%rip),%r12
mov    0x2dd7(%rip),%r15
jmp    1225 <main+0x45>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbp,%rdi
call   1040 <fclose@plt>
mov    0x10(%rsp),%ebx
add    $0xffffffff,%ebx
je     146f <main+0x28f>
lea    0xde8(%rip),%rdi
lea    0xe03(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,%rbp
mov    0x2db6(%rip),%rax
mov    (%rax),%esi
mov    0x2d7d(%rip),%rax
or     (%rax),%esi
mov    0x2d9c(%rip),%rax
or     (%rax),%esi
lea    0xddb(%rip),%rdi
mov    $0x180,%edx
call   10d0 <open@plt>
cmp    $0xffffffff,%eax
je     1491 <main+0x2b1>
mov    %eax,%r13d
mov    0x2d3e(%rip),%rax
mov    (%rax),%edx
mov    %r13d,%edi
mov    $0xf,%esi
call   1070 <lseek@plt>
cmp    $0xffffffff,%eax
je     149a <main+0x2ba>
mov    %rbp,0x20(%rsp)
mov    %ebx,0x10(%rsp)
mov    %r13d,%edi
lea    0xe47(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
cmp    $0x1,%eax
jne    14ab <main+0x2cb>
mov    0x2ce9(%rip),%rax
mov    (%rax),%edx
or     (%r12),%edx
mov    (%r15),%ecx
xor    %edi,%edi
mov    $0x10,%esi
mov    %r13d,%r8d
xor    %r9d,%r9d
call   1050 <mmap@plt>
mov    0x2cbf(%rip),%r14
cmp    (%r14),%rax
je     1480 <main+0x2a0>
mov    %r12,%rbp
mov    %rax,%rbx
lea    0x58(%rsp),%rdi
xor    %esi,%esi
call   1080 <gettimeofday@plt>
movaps 0xcfd(%rip),%xmm0
movups %xmm0,0x4(%rbx)
mov    (%r12),%edx
mov    (%r15),%ecx
xor    %edi,%edi
mov    $0x10,%esi
mov    %r13d,%r8d
xor    %r9d,%r9d
call   1050 <mmap@plt>
cmp    (%r14),%rax
je     1480 <main+0x2a0>
mov    %rax,%rbx
mov    0x4(%rax),%eax
mov    %eax,0x18(%rsp)
fildl  0x18(%rsp)
fstpt  (%rsp)
lea    0xda3(%rip),%r12
mov    %r12,%rdi
call   1060 <printf@plt>
mov    0xc(%rbx),%eax
mov    %eax,0x1c(%rsp)
fildl  0x1c(%rsp)
fstpt  (%rsp)
mov    %r12,%rdi
call   1060 <printf@plt>
mov    0x2c42(%rip),%rax
mov    (%rax),%edx
or     0x0(%rbp),%edx
mov    (%r15),%ecx
xor    %edi,%edi
mov    $0x10,%esi
mov    %r13d,%r8d
xor    %r9d,%r9d
call   1050 <mmap@plt>
cmp    (%r14),%rax
je     1480 <main+0x2a0>
movl   $0x6,(%rax)
mov    %rbp,%r12
mov    0x0(%rbp),%edx
mov    (%r15),%ecx
xor    %edi,%edi
mov    $0x10,%esi
mov    %r13d,%r8d
xor    %r9d,%r9d
call   1050 <mmap@plt>
cmp    (%r14),%rax
je     1480 <main+0x2a0>
mov    %rax,%rbx
mov    (%rax),%eax
mov    %eax,0x14(%rsp)
fildl  0x14(%rsp)
fstpt  (%rsp)
lea    0xd1a(%rip),%rdi
call   1060 <printf@plt>
lea    0x48(%rsp),%rdi
xor    %esi,%esi
call   1080 <gettimeofday@plt>
mov    0x48(%rsp),%rax
mov    0x50(%rsp),%rcx
sub    0x60(%rsp),%rcx
mov    %rcx,0x28(%rsp)
fildll 0x28(%rsp)
sub    0x58(%rsp),%rax
mov    %rax,0x30(%rsp)
fildll 0x30(%rsp)
fdivs  0xc09(%rip)
faddp  %st,%st(1)
fld    %st(0)
fstpt  0x3c(%rsp)
fstpt  (%rsp)
lea    0xccf(%rip),%r14
mov    %r14,%rdi
call   1060 <printf@plt>
mov    %r13d,%edi
call   1090 <close@plt>
fldt   0x3c(%rsp)
fstpt  (%rsp)
mov    0x20(%rsp),%rbp
mov    %rbp,%rdi
mov    %r14,%rsi
call   10a0 <fprintf@plt>
mov    %rbp,%rdi
call   10b0 <fflush@plt>
mov    %rbx,%rdi
mov    $0x10,%esi
call   10c0 <munmap@plt>
cmp    $0xffffffff,%eax
jne    1210 <main+0x30>
lea    0xc88(%rip),%rdi
call   10f0 <perror@plt>
jmp    1210 <main+0x30>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r13d,%edi
call   1090 <close@plt>
lea    0xc3d(%rip),%rdi
jmp    14ba <main+0x2da>
lea    0xbc5(%rip),%rdi
jmp    14ba <main+0x2da>
mov    %r13d,%edi
call   1090 <close@plt>
lea    0xbd3(%rip),%rdi
jmp    14ba <main+0x2da>
mov    %r13d,%edi
call   1090 <close@plt>
lea    0xbee(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2aea(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>

LLVM IR (-O0):
%struct.timeval = type { i64, i64 }
@.str = [34 x i8] c"/home/george/Documents/C/pipe.txt\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [37 x i8] c"/home/george/Documents/C/mmapped.bin\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@.str.3 = [31 x i8] c"Error opening file for writing\00"
@EXIT_FAILURE = global i32 0
@SEEK_SET = global i32 0
@.str.4 = [44 x i8] c"Error calling lseek() to 'stretch' the file\00"
@.str.5 = [1 x i8] zeroinitializer
@.str.6 = [36 x i8] c"Error writing last byte of the file\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i32* null
@.str.7 = [24 x i8] c"Error mmapping the file\00"
@.str.8 = [4 x i8] c"%d \00"
@.str.9 = [5 x i8] c"%Lf\0A\00"
@.str.10 = [27 x i8] c"Error un-mmapping the file\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca %struct.timeval
%11 = alloca %struct.timeval
%12 = alloca i32*
%13 = alloca i32
%14 = alloca x86_fp80
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %13
%15 = load i32, i32* %13
br label %16
16: ; preds = %184, %2
%17 = load i32, i32* %13
%18 = icmp slt i32 %17, 100
br i1 %18, label %19, label %187
19: ; preds = %16
%20 = call i32* @fopen(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %20, i32** %12
%21 = load i32, i32* @O_RDWR
%22 = load i32, i32* @O_CREAT
%23 = or i32 %21, %22
%24 = load i32, i32* @O_TRUNC
%25 = or i32 %23, %24
%26 = call i32 @open(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %25, i32 384)
store i32 %26, i32* %7
%27 = load i32, i32* %7
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %33
29: ; preds = %19
%30 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%31 = load i32, i32* @EXIT_FAILURE
%32 = call i32 @exit(i32 %31)
unreachable
33: ; preds = %19
%34 = load i32, i32* %7
%35 = load i32, i32* @SEEK_SET
%36 = call i32 @lseek(i32 %34, i32 15, i32 %35)
store i32 %36, i32* %8
%37 = load i32, i32* %8
%38 = icmp eq i32 %37, -1
br i1 %38, label %39, label %45
39: ; preds = %33
%40 = load i32, i32* %7
%41 = call i32 @close(i32 %40)
%42 = call i32 @perror(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0))
%43 = load i32, i32* @EXIT_FAILURE
%44 = call i32 @exit(i32 %43)
unreachable
45: ; preds = %33
%46 = load i32, i32* %7
%47 = call i32 @write(i32 %46, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0), i32 1)
store i32 %47, i32* %8
%48 = load i32, i32* %8
%49 = icmp ne i32 %48, 1
br i1 %49, label %50, label %56
50: ; preds = %45
%51 = load i32, i32* %7
%52 = call i32 @close(i32 %51)
%53 = call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0))
%54 = load i32, i32* @EXIT_FAILURE
%55 = call i32 @exit(i32 %54)
unreachable
56: ; preds = %45
%57 = load i32, i32* @PROT_READ
%58 = load i32, i32* @PROT_WRITE
%59 = or i32 %57, %58
%60 = load i32, i32* @MAP_SHARED
%61 = load i32, i32* %7
%62 = call i32* @mmap(i32 0, i32 16, i32 %59, i32 %60, i32 %61, i32 0)
store i32* %62, i32** %9
%63 = load i32*, i32** %9
%64 = load i32*, i32** @MAP_FAILED
%65 = icmp eq i32* %63, %64
br i1 %65, label %66, label %72
66: ; preds = %56
%67 = load i32, i32* %7
%68 = call i32 @close(i32 %67)
%69 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
%70 = load i32, i32* @EXIT_FAILURE
%71 = call i32 @exit(i32 %70)
unreachable
72: ; preds = %56
%73 = call i32 @gettimeofday(%struct.timeval* %10, i32* null)
store i32 1, i32* %6
br label %74
74: ; preds = %82, %72
%75 = load i32, i32* %6
%76 = icmp sle i32 %75, 4
br i1 %76, label %77, label %85
77: ; preds = %74
%78 = load i32*, i32** %9
%79 = load i32, i32* %6
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds i32, i32* %78, i64 %80
store i32 1, i32* %81
br label %82
82: ; preds = %77
%83 = load i32, i32* %6
%84 = add nsw i32 %83, 1
store i32 %84, i32* %6
br label %74
85: ; preds = %74
%86 = load i32, i32* @PROT_READ
%87 = load i32, i32* @MAP_SHARED
%88 = load i32, i32* %7
%89 = call i32* @mmap(i32 0, i32 16, i32 %86, i32 %87, i32 %88, i32 0)
store i32* %89, i32** %9
%90 = load i32*, i32** %9
%91 = load i32*, i32** @MAP_FAILED
%92 = icmp eq i32* %90, %91
br i1 %92, label %93, label %99
93: ; preds = %85
%94 = load i32, i32* %7
%95 = call i32 @close(i32 %94)
%96 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
%97 = load i32, i32* @EXIT_FAILURE
%98 = call i32 @exit(i32 %97)
unreachable
99: ; preds = %85
store i32 1, i32* %6
br label %100
100: ; preds = %111, %99
%101 = load i32, i32* %6
%102 = icmp sle i32 %101, 3
br i1 %102, label %103, label %114
103: ; preds = %100
%104 = load i32*, i32** %9
%105 = load i32, i32* %6
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds i32, i32* %104, i64 %106
%108 = load i32, i32* %107
%109 = sitofp i32 %108 to x86_fp80
%110 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), x86_fp80 %109)
br label %111
111: ; preds = %103
%112 = load i32, i32* %6
%113 = add nsw i32 %112, 2
store i32 %113, i32* %6
br label %100
114: ; preds = %100
%115 = load i32, i32* @PROT_READ
%116 = load i32, i32* @PROT_WRITE
%117 = or i32 %115, %116
%118 = load i32, i32* @MAP_SHARED
%119 = load i32, i32* %7
%120 = call i32* @mmap(i32 0, i32 16, i32 %117, i32 %118, i32 %119, i32 0)
store i32* %120, i32** %9
%121 = load i32*, i32** %9
%122 = load i32*, i32** @MAP_FAILED
%123 = icmp eq i32* %121, %122
br i1 %123, label %124, label %130
124: ; preds = %114
%125 = load i32, i32* %7
%126 = call i32 @close(i32 %125)
%127 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
%128 = load i32, i32* @EXIT_FAILURE
%129 = call i32 @exit(i32 %128)
unreachable
130: ; preds = %114
%131 = load i32*, i32** %9
%132 = getelementptr inbounds i32, i32* %131, i64 0
store i32 6, i32* %132
%133 = load i32, i32* @PROT_READ
%134 = load i32, i32* @MAP_SHARED
%135 = load i32, i32* %7
%136 = call i32* @mmap(i32 0, i32 16, i32 %133, i32 %134, i32 %135, i32 0)
store i32* %136, i32** %9
%137 = load i32*, i32** %9
%138 = load i32*, i32** @MAP_FAILED
%139 = icmp eq i32* %137, %138
br i1 %139, label %140, label %146
140: ; preds = %130
%141 = load i32, i32* %7
%142 = call i32 @close(i32 %141)
%143 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
%144 = load i32, i32* @EXIT_FAILURE
%145 = call i32 @exit(i32 %144)
unreachable
146: ; preds = %130
%147 = load i32*, i32** %9
%148 = getelementptr inbounds i32, i32* %147, i64 0
%149 = load i32, i32* %148
%150 = sitofp i32 %149 to x86_fp80
%151 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), x86_fp80 %150)
%152 = call i32 @gettimeofday(%struct.timeval* %11, i32* null)
%153 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i32 0, i32 1
%154 = load i64, i64* %153
%155 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i32 0, i32 1
%156 = load i64, i64* %155
%157 = sub nsw i64 %154, %156
%158 = sitofp i64 %157 to x86_fp80
%159 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i32 0, i32 0
%160 = load i64, i64* %159
%161 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i32 0, i32 0
%162 = load i64, i64* %161
%163 = sub nsw i64 %160, %162
%164 = sitofp i64 %163 to x86_fp80
%165 = fdiv x86_fp80 %164, 0xK4012F424000000000000
%166 = fadd x86_fp80 %158, %165
store x86_fp80 %166, x86_fp80* %14
%167 = load x86_fp80, x86_fp80* %14
%168 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), x86_fp80 %167)
%169 = load i32, i32* %7
%170 = call i32 @close(i32 %169)
%171 = load i32*, i32** %12
%172 = load x86_fp80, x86_fp80* %14
%173 = call i32 @fprintf(i32* %171, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), x86_fp80 %172)
%174 = load i32*, i32** %12
%175 = call i32 @fflush(i32* %174)
%176 = load i32*, i32** %9
%177 = call i32 @munmap(i32* %176, i32 16)
%178 = icmp eq i32 %177, -1
br i1 %178, label %179, label %181
179: ; preds = %146
%180 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0))
br label %181
181: ; preds = %179, %146
%182 = load i32*, i32** %12
%183 = call i32 @fclose(i32* %182)
br label %184
184: ; preds = %181
%185 = load i32, i32* %13
%186 = add nsw i32 %185, 1
store i32 %186, i32* %13
br label %16
187: ; preds = %16
ret i32 0
}

LLVM IR (-O2):
%struct.timeval = type { i64, i64 }
@.str = [34 x i8] c"/home/george/Documents/C/pipe.txt\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [37 x i8] c"/home/george/Documents/C/mmapped.bin\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@.str.3 = [31 x i8] c"Error opening file for writing\00"
@EXIT_FAILURE = global i32 0
@SEEK_SET = global i32 0
@.str.4 = [44 x i8] c"Error calling lseek() to 'stretch' the file\00"
@.str.5 = [1 x i8] zeroinitializer
@.str.6 = [36 x i8] c"Error writing last byte of the file\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i32* null
@.str.7 = [24 x i8] c"Error mmapping the file\00"
@.str.8 = [4 x i8] c"%d \00"
@.str.9 = [5 x i8] c"%Lf\0A\00"
@.str.10 = [27 x i8] c"Error un-mmapping the file\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.timeval
%4 = alloca %struct.timeval
%5 = bitcast %struct.timeval* %3 to i8*
%6 = bitcast %struct.timeval* %4 to i8*
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 1
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
br label %11
11: ; preds = %2, %124
%12 = phi i32 [ 0, %2 ], [ %126, %124 ]
%13 = tail call i32* @fopen(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = load i32, i32* @O_RDWR
%15 = load i32, i32* @O_CREAT
%16 = or i32 %15, %14
%17 = load i32, i32* @O_TRUNC
%18 = or i32 %16, %17
%19 = tail call i32 @open(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %18, i32 384)
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %25
21: ; preds = %11
%22 = tail call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%23 = load i32, i32* @EXIT_FAILURE
%24 = tail call i32 @exit(i32 %23)
unreachable
25: ; preds = %11
%26 = load i32, i32* @SEEK_SET
%27 = tail call i32 @lseek(i32 %19, i32 15, i32 %26)
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %34
29: ; preds = %25
%30 = tail call i32 @close(i32 %19)
%31 = tail call i32 @perror(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0))
%32 = load i32, i32* @EXIT_FAILURE
%33 = tail call i32 @exit(i32 %32)
unreachable
34: ; preds = %25
%35 = tail call i32 @write(i32 %19, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0), i32 1)
%36 = icmp eq i32 %35, 1
br i1 %36, label %42, label %37
37: ; preds = %34
%38 = tail call i32 @close(i32 %19)
%39 = tail call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0))
%40 = load i32, i32* @EXIT_FAILURE
%41 = tail call i32 @exit(i32 %40)
unreachable
42: ; preds = %34
%43 = load i32, i32* @PROT_READ
%44 = load i32, i32* @PROT_WRITE
%45 = or i32 %44, %43
%46 = load i32, i32* @MAP_SHARED
%47 = tail call i32* @mmap(i32 0, i32 16, i32 %45, i32 %46, i32 %19, i32 0)
%48 = load i32*, i32** @MAP_FAILED
%49 = icmp eq i32* %47, %48
br i1 %49, label %50, label %55
50: ; preds = %42
%51 = tail call i32 @close(i32 %19)
%52 = tail call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
%53 = load i32, i32* @EXIT_FAILURE
%54 = tail call i32 @exit(i32 %53)
unreachable
55: ; preds = %42
%56 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%57 = getelementptr inbounds i32, i32* %47, i64 1
%58 = bitcast i32* %57 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %58
%59 = load i32, i32* @PROT_READ
%60 = load i32, i32* @MAP_SHARED
%61 = tail call i32* @mmap(i32 0, i32 16, i32 %59, i32 %60, i32 %19, i32 0)
%62 = load i32*, i32** @MAP_FAILED
%63 = icmp eq i32* %61, %62
br i1 %63, label %80, label %64
64: ; preds = %55
%65 = getelementptr inbounds i32, i32* %61, i64 1
%66 = load i32, i32* %65
%67 = sitofp i32 %66 to x86_fp80
%68 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), x86_fp80 %67)
%69 = getelementptr inbounds i32, i32* %61, i64 3
%70 = load i32, i32* %69
%71 = sitofp i32 %70 to x86_fp80
%72 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), x86_fp80 %71)
%73 = load i32, i32* @PROT_READ
%74 = load i32, i32* @PROT_WRITE
%75 = or i32 %74, %73
%76 = load i32, i32* @MAP_SHARED
%77 = tail call i32* @mmap(i32 0, i32 16, i32 %75, i32 %76, i32 %19, i32 0)
%78 = load i32*, i32** @MAP_FAILED
%79 = icmp eq i32* %77, %78
br i1 %79, label %85, label %90
80: ; preds = %55
%81 = tail call i32 @close(i32 %19)
%82 = tail call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
%83 = load i32, i32* @EXIT_FAILURE
%84 = tail call i32 @exit(i32 %83)
unreachable
85: ; preds = %64
%86 = tail call i32 @close(i32 %19)
%87 = tail call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
%88 = load i32, i32* @EXIT_FAILURE
%89 = tail call i32 @exit(i32 %88)
unreachable
90: ; preds = %64
store i32 6, i32* %77
%91 = load i32, i32* @PROT_READ
%92 = load i32, i32* @MAP_SHARED
%93 = tail call i32* @mmap(i32 0, i32 16, i32 %91, i32 %92, i32 %19, i32 0)
%94 = load i32*, i32** @MAP_FAILED
%95 = icmp eq i32* %93, %94
br i1 %95, label %96, label %101
96: ; preds = %90
%97 = tail call i32 @close(i32 %19)
%98 = tail call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
%99 = load i32, i32* @EXIT_FAILURE
%100 = tail call i32 @exit(i32 %99)
unreachable
101: ; preds = %90
%102 = load i32, i32* %93
%103 = sitofp i32 %102 to x86_fp80
%104 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), x86_fp80 %103)
%105 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%106 = load i64, i64* %7
%107 = load i64, i64* %8
%108 = sub nsw i64 %106, %107
%109 = sitofp i64 %108 to x86_fp80
%110 = load i64, i64* %9
%111 = load i64, i64* %10
%112 = sub nsw i64 %110, %111
%113 = sitofp i64 %112 to x86_fp80
%114 = fdiv x86_fp80 %113, 0xK4012F424000000000000
%115 = fadd x86_fp80 %114, %109
%116 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), x86_fp80 %115)
%117 = tail call i32 @close(i32 %19)
%118 = tail call i32 @fprintf(i32* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), x86_fp80 %115)
%119 = tail call i32 @fflush(i32* %13)
%120 = tail call i32 @munmap(i32* %93, i32 16)
%121 = icmp eq i32 %120, -1
br i1 %121, label %122, label %124
122: ; preds = %101
%123 = tail call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0))
br label %124
124: ; preds = %122, %101
%125 = tail call i32 @fclose(i32* %13)
%126 = add nuw nsw i32 %12, 1
%127 = icmp eq i32 %126, 100
br i1 %127, label %128, label %11
128: ; preds = %124
ret i32 0
}