#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]);
    }
    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);
    map =
        mmap(0, ((4) * sizeof(int)), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
    map = mmap(0, ((4) * sizeof(int)), PROT_READ, MAP_SHARED, fd, 0);
    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    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x54(%rbp)
cmpl   $0x64,-0x54(%rbp)
jge    1581 <main+0x3a1>
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,-0x84(%rbp)
fildl  -0x84(%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>
xor    %eax,%eax
mov    %eax,-0x94(%rbp)
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   0xb7c(%rip)
fdivrp %st,%st(1)
faddp  %st,%st(1)
fstpt  -0x70(%rbp)
fldt   -0x70(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
lea    0xc3e(%rip),%rdi
call   1060 <printf@plt>
mov    -0x94(%rbp),%r9d
mov    0x2b3b(%rip),%rax
mov    %rax,-0xa0(%rbp)
mov    (%rax),%edx
mov    0x2aeb(%rip),%rax
mov    (%rax),%eax
or     %eax,%edx
mov    0x2b10(%rip),%rax
mov    %rax,-0x90(%rbp)
mov    (%rax),%ecx
mov    -0x18(%rbp),%r8d
mov    $0x10,%esi
mov    %esi,-0x98(%rbp)
mov    %r9d,%edi
call   1050 <mmap@plt>
mov    -0xa0(%rbp),%rcx
mov    -0x98(%rbp),%esi
mov    -0x94(%rbp),%r9d
mov    %rax,%rdx
mov    -0x90(%rbp),%rax
mov    %rdx,-0x28(%rbp)
mov    (%rcx),%edx
mov    (%rax),%ecx
mov    -0x18(%rbp),%r8d
mov    %r9d,%edi
call   1050 <mmap@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%edi
call   1090 <close@plt>
mov    -0x50(%rbp),%rdi
fldt   -0x70(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
lea    0xb9f(%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    156a <main+0x38a>
lea    0xb78(%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    $0xb0,%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),%r14
jmp    121c <main+0x3c>
nopl   0x0(%rax)
mov    %r12,%rdi
call   1040 <fclose@plt>
mov    0x1c(%rsp),%ebx
add    $0xffffffff,%ebx
mov    0x2dd2(%rip),%r14
je     142c <main+0x24c>
lea    0xdf1(%rip),%rdi
lea    0xe0c(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,%r12
mov    0x2dbf(%rip),%rax
mov    (%rax),%esi
mov    0x2d86(%rip),%rax
or     (%rax),%esi
mov    0x2da5(%rip),%rax
or     (%rax),%esi
lea    0xde4(%rip),%rdi
mov    $0x180,%edx
call   10d0 <open@plt>
cmp    $0xffffffff,%eax
je     144e <main+0x26e>
mov    %eax,%r13d
mov    0x2d47(%rip),%rax
mov    (%rax),%edx
mov    %r13d,%edi
mov    $0xf,%esi
call   1070 <lseek@plt>
cmp    $0xffffffff,%eax
je     1457 <main+0x277>
mov    %ebx,0x1c(%rsp)
mov    %r13d,%edi
lea    0xe55(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
cmp    $0x1,%eax
jne    1468 <main+0x288>
mov    0x2cf7(%rip),%rax
mov    (%rax),%edx
or     (%r14),%edx
mov    0x2d1b(%rip),%r15
mov    (%r15),%ecx
xor    %edi,%edi
mov    $0x10,%esi
mov    %r13d,%r8d
xor    %r9d,%r9d
call   1050 <mmap@plt>
mov    0x2cc7(%rip),%rbp
cmp    0x0(%rbp),%rax
je     143d <main+0x25d>
mov    %rax,%rbx
lea    0x58(%rsp),%rdi
xor    %esi,%esi
call   1080 <gettimeofday@plt>
movaps 0xd07(%rip),%xmm0
movups %xmm0,0x4(%rbx)
mov    (%r14),%edx
mov    (%r15),%ecx
xor    %edi,%edi
mov    $0x10,%esi
mov    %r13d,%r8d
xor    %r9d,%r9d
call   1050 <mmap@plt>
cmp    0x0(%rbp),%rax
je     143d <main+0x25d>
mov    %rax,%rbx
mov    0x4(%rax),%eax
mov    %eax,0x20(%rsp)
fildl  0x20(%rsp)
fstpt  (%rsp)
lea    0xdad(%rip),%rbp
mov    %rbp,%rdi
call   1060 <printf@plt>
mov    0xc(%rbx),%eax
mov    %eax,0x24(%rsp)
fildl  0x24(%rsp)
fstpt  (%rsp)
mov    %rbp,%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  0xc83(%rip)
faddp  %st,%st(1)
fld    %st(0)
fstpt  0x3c(%rsp)
fstpt  (%rsp)
lea    0xd49(%rip),%rbp
mov    %rbp,%rdi
call   1060 <printf@plt>
mov    0x2bfa(%rip),%rax
mov    (%rax),%edx
or     (%r14),%edx
mov    (%r15),%ecx
xor    %edi,%edi
mov    $0x10,%esi
mov    %r13d,%r8d
xor    %r9d,%r9d
call   1050 <mmap@plt>
mov    (%r14),%edx
mov    (%r15),%ecx
xor    %edi,%edi
mov    $0x10,%esi
mov    %r13d,%r8d
xor    %r9d,%r9d
call   1050 <mmap@plt>
mov    %rax,%rbx
mov    %r13d,%edi
call   1090 <close@plt>
fldt   0x3c(%rsp)
fstpt  (%rsp)
mov    %r12,%rdi
mov    %rbp,%rsi
call   10a0 <fprintf@plt>
mov    %r12,%rdi
call   10b0 <fflush@plt>
mov    %rbx,%rdi
mov    $0x10,%esi
call   10c0 <munmap@plt>
cmp    $0xffffffff,%eax
jne    1200 <main+0x20>
lea    0xccb(%rip),%rdi
call   10f0 <perror@plt>
jmp    1200 <main+0x20>
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    0xc80(%rip),%rdi
jmp    1477 <main+0x297>
lea    0xc08(%rip),%rdi
jmp    1477 <main+0x297>
mov    %r13d,%edi
call   1090 <close@plt>
lea    0xc16(%rip),%rdi
jmp    1477 <main+0x297>
mov    %r13d,%edi
call   1090 <close@plt>
lea    0xc31(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2b2d(%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 = %157, %2
%17 = load i32, i32* %13
%18 = icmp slt i32 %17, 100
br i1 %18, label %19, label %160
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 = call i32 @gettimeofday(%struct.timeval* %11, i32* null)
%116 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i32 0, i32 1
%117 = load i64, i64* %116
%118 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i32 0, i32 1
%119 = load i64, i64* %118
%120 = sub nsw i64 %117, %119
%121 = sitofp i64 %120 to x86_fp80
%122 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i32 0, i32 0
%123 = load i64, i64* %122
%124 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i32 0, i32 0
%125 = load i64, i64* %124
%126 = sub nsw i64 %123, %125
%127 = sitofp i64 %126 to x86_fp80
%128 = fdiv x86_fp80 %127, 0xK4012F424000000000000
%129 = fadd x86_fp80 %121, %128
store x86_fp80 %129, x86_fp80* %14
%130 = load x86_fp80, x86_fp80* %14
%131 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), x86_fp80 %130)
%132 = load i32, i32* @PROT_READ
%133 = load i32, i32* @PROT_WRITE
%134 = or i32 %132, %133
%135 = load i32, i32* @MAP_SHARED
%136 = load i32, i32* %7
%137 = call i32* @mmap(i32 0, i32 16, i32 %134, i32 %135, i32 %136, i32 0)
store i32* %137, i32** %9
%138 = load i32, i32* @PROT_READ
%139 = load i32, i32* @MAP_SHARED
%140 = load i32, i32* %7
%141 = call i32* @mmap(i32 0, i32 16, i32 %138, i32 %139, i32 %140, i32 0)
store i32* %141, i32** %9
%142 = load i32, i32* %7
%143 = call i32 @close(i32 %142)
%144 = load i32*, i32** %12
%145 = load x86_fp80, x86_fp80* %14
%146 = call i32 @fprintf(i32* %144, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), x86_fp80 %145)
%147 = load i32*, i32** %12
%148 = call i32 @fflush(i32* %147)
%149 = load i32*, i32** %9
%150 = call i32 @munmap(i32* %149, i32 16)
%151 = icmp eq i32 %150, -1
br i1 %151, label %152, label %154
152: ; preds = %114
%153 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0))
br label %154
154: ; preds = %152, %114
%155 = load i32*, i32** %12
%156 = call i32 @fclose(i32* %155)
br label %157
157: ; preds = %154
%158 = load i32, i32* %13
%159 = add nsw i32 %158, 1
store i32 %159, i32* %13
br label %16
160: ; 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, %105
%12 = phi i32 [ 0, %2 ], [ %107, %105 ]
%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 %98, 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 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%74 = load i64, i64* %7
%75 = load i64, i64* %8
%76 = sub nsw i64 %74, %75
%77 = sitofp i64 %76 to x86_fp80
%78 = load i64, i64* %9
%79 = load i64, i64* %10
%80 = sub nsw i64 %78, %79
%81 = sitofp i64 %80 to x86_fp80
%82 = fdiv x86_fp80 %81, 0xK4012F424000000000000
%83 = fadd x86_fp80 %82, %77
%84 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), x86_fp80 %83)
%85 = load i32, i32* @PROT_READ
%86 = load i32, i32* @PROT_WRITE
%87 = or i32 %86, %85
%88 = load i32, i32* @MAP_SHARED
%89 = tail call i32* @mmap(i32 0, i32 16, i32 %87, i32 %88, i32 %19, i32 0)
%90 = load i32, i32* @PROT_READ
%91 = load i32, i32* @MAP_SHARED
%92 = tail call i32* @mmap(i32 0, i32 16, i32 %90, i32 %91, i32 %19, i32 0)
%93 = tail call i32 @close(i32 %19)
%94 = tail call i32 @fprintf(i32* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), x86_fp80 %83)
%95 = tail call i32 @fflush(i32* %13)
%96 = tail call i32 @munmap(i32* %92, i32 16)
%97 = icmp eq i32 %96, -1
br i1 %97, label %103, label %105
98: ; preds = %55
%99 = tail call i32 @close(i32 %19)
%100 = tail call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
%101 = load i32, i32* @EXIT_FAILURE
%102 = tail call i32 @exit(i32 %101)
unreachable
103: ; preds = %64
%104 = tail call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0))
br label %105
105: ; preds = %103, %64
%106 = tail call i32 @fclose(i32* %13)
%107 = add nuw nsw i32 %12, 1
%108 = icmp eq i32 %107, 100
br i1 %108, label %109, label %11
109: ; preds = %105
ret i32 0
}