#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;
};

/* Variables and functions */
int MAP_ANONYMOUS;
int MAP_PRIVATE;
int MAP_SHARED;
int MCL_CURRENT;
int MS_SYNC;
int O_CREAT;
int /*<<< orphan*/ O_RDONLY;
int O_TRUNC;
int O_WRONLY;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ close(int);
int fstat(int, struct stat *);
int /*<<< orphan*/ lseek(int, int, int /*<<< orphan*/);
int /*<<< orphan*/ mlock(void *, int);
int /*<<< orphan*/ mlockall(int);
void *mmap(void *, int, int, int, int, int);
int /*<<< orphan*/ mprotect(void *, int, int);
void *mremap(void *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ msync(void *, int, int);
int /*<<< orphan*/ munlock(void *, int);
int /*<<< orphan*/ munlockall();
int /*<<< orphan*/ munmap(void *, int);
int open(char *, int, ...);
int /*<<< orphan*/ write(int, char *, int);
int main() {
  int fd, ret;
  struct stat fs;
  void *r;
  fd = open("foobar", O_WRONLY | O_CREAT | O_TRUNC, 0600);
  lseek(fd, 65536, SEEK_SET);
  write(fd, "abcdef", 6);
  close(fd);
  fd = open("foobar", O_RDONLY);
  ret = fstat(fd, &fs);
  r = mmap(NULL, 4096, PROT_READ, MAP_SHARED, fd, 0);
  mlock(r, 4096);
  mlock((void *)-1, 4096);
  mlock(0, -1);
  msync(r, 4096, MS_SYNC);
  msync((void *)-1, 4096, MS_SYNC);
  msync(r, -1, MS_SYNC);
  msync(r, 4096, -1);
  munlock(r, 4096);
  mlockall(MCL_CURRENT);
  mlockall(-1);
  munlockall();
  munmap(r, 4096);
  r = mmap(NULL, 6, PROT_READ, MAP_PRIVATE, fd, 65536);
  munmap(r, 6);
  close(fd);
  r = mmap(NULL, 12288, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1,
           0);
  mprotect(r, 4096, PROT_READ);
  munmap(r, 12288);
  r = mmap(NULL, 8192, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1,
           0);
  r = mremap(r, 8192, 4096, 0);
  munmap(r, 4096);
  r = mmap((void *)-1, 8192, PROT_READ | PROT_WRITE,
           MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
  munmap(r, 8192);
  r = mmap(NULL, -1, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1,
           0);
  r = mmap(NULL, 8192, -1, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
  munmap(r, 8192);
  r = mmap(NULL, 8192, PROT_READ | PROT_WRITE, -1, -1, 0);
  munmap((void *)-1, 8192);
  munmap(r, -1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2d8a(%rip),%rax
mov    (%rax),%esi
mov    0x2df9(%rip),%rax
or     (%rax),%esi
mov    0x2de8(%rip),%rax
or     (%rax),%esi
lea    0xdef(%rip),%rdi
mov    $0x180,%edx
mov    $0x0,%al
call   10e0 <open@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2d86(%rip),%rax
mov    (%rax),%edx
mov    $0x10000,%esi
call   1080 <lseek@plt>
mov    -0x8(%rbp),%edi
lea    0xdc7(%rip),%rsi
mov    $0x6,%edx
call   1050 <write@plt>
mov    -0x8(%rbp),%edi
call   1090 <close@plt>
mov    0x2d6f(%rip),%rax
mov    (%rax),%esi
lea    0xd9e(%rip),%rdi
mov    $0x0,%al
call   10e0 <open@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x10(%rbp),%rsi
call   1100 <fstat@plt>
mov    %eax,-0xc(%rbp)
mov    0x2d66(%rip),%rax
mov    (%rax),%edx
mov    0x2d4d(%rip),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
mov    $0x1000,%esi
xor    %r9d,%r9d
call   1070 <mmap@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x1000,%esi
call   1040 <mlock@plt>
mov    $0xffffffffffffffff,%rdi
mov    $0x1000,%esi
call   1040 <mlock@plt>
xor    %eax,%eax
mov    %eax,%edi
mov    $0xffffffff,%esi
call   1040 <mlock@plt>
mov    -0x18(%rbp),%rdi
mov    0x2cca(%rip),%rax
mov    (%rax),%edx
mov    $0x1000,%esi
call   1060 <msync@plt>
mov    0x2cb7(%rip),%rax
mov    (%rax),%edx
mov    $0xffffffffffffffff,%rdi
mov    $0x1000,%esi
call   1060 <msync@plt>
mov    -0x18(%rbp),%rdi
mov    0x2c99(%rip),%rax
mov    (%rax),%edx
mov    $0xffffffff,%esi
call   1060 <msync@plt>
mov    -0x18(%rbp),%rdi
mov    $0x1000,%esi
mov    $0xffffffff,%edx
call   1060 <msync@plt>
mov    -0x18(%rbp),%rdi
mov    $0x1000,%esi
call   1030 <munlock@plt>
mov    0x2c5d(%rip),%rax
mov    (%rax),%edi
call   10c0 <mlockall@plt>
mov    $0xffffffff,%edi
call   10c0 <mlockall@plt>
mov    $0x0,%al
call   10f0 <munlockall@plt>
mov    -0x18(%rbp),%rdi
mov    $0x1000,%esi
call   10b0 <munmap@plt>
mov    0x2c78(%rip),%rax
mov    (%rax),%edx
mov    0x2c17(%rip),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
mov    $0x6,%esi
mov    $0x10000,%r9d
call   1070 <mmap@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x6,%esi
call   10b0 <munmap@plt>
mov    -0x8(%rbp),%edi
call   1090 <close@plt>
mov    0x2c34(%rip),%rax
mov    (%rax),%edx
mov    0x2bdb(%rip),%rax
or     (%rax),%edx
mov    0x2bca(%rip),%rax
mov    (%rax),%ecx
mov    0x2bf1(%rip),%rax
or     (%rax),%ecx
xor    %eax,%eax
mov    %eax,%edi
mov    $0x3000,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1070 <mmap@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2bf1(%rip),%rax
mov    (%rax),%edx
mov    $0x1000,%esi
call   10d0 <mprotect@plt>
mov    -0x18(%rbp),%rdi
mov    $0x3000,%esi
call   10b0 <munmap@plt>
mov    0x2bd0(%rip),%rax
mov    (%rax),%edx
mov    0x2b77(%rip),%rax
or     (%rax),%edx
mov    0x2b66(%rip),%rax
mov    (%rax),%ecx
mov    0x2b8d(%rip),%rax
or     (%rax),%ecx
xor    %eax,%eax
mov    %eax,%edi
mov    $0x2000,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1070 <mmap@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x2000,%esi
mov    $0x1000,%edx
xor    %ecx,%ecx
call   10a0 <mremap@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x1000,%esi
call   10b0 <munmap@plt>
mov    0x2b6a(%rip),%rax
mov    (%rax),%edx
mov    0x2b11(%rip),%rax
or     (%rax),%edx
mov    0x2b00(%rip),%rax
mov    (%rax),%ecx
mov    0x2b27(%rip),%rax
or     (%rax),%ecx
mov    $0xffffffffffffffff,%rdi
mov    $0x2000,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1070 <mmap@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x2000,%esi
call   10b0 <munmap@plt>
mov    0x2b1a(%rip),%rax
mov    (%rax),%edx
mov    0x2ac1(%rip),%rax
or     (%rax),%edx
mov    0x2ab0(%rip),%rax
mov    (%rax),%ecx
mov    0x2ad7(%rip),%rax
or     (%rax),%ecx
xor    %eax,%eax
mov    %eax,%edi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
mov    %r8d,%esi
call   1070 <mmap@plt>
mov    %rax,-0x18(%rbp)
mov    0x2a85(%rip),%rax
mov    (%rax),%ecx
mov    0x2aac(%rip),%rax
or     (%rax),%ecx
xor    %eax,%eax
mov    %eax,%edi
mov    $0x2000,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
mov    %r8d,%edx
call   1070 <mmap@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x2000,%esi
call   10b0 <munmap@plt>
mov    0x2a9f(%rip),%rax
mov    (%rax),%edx
mov    0x2a46(%rip),%rax
or     (%rax),%edx
xor    %eax,%eax
mov    %eax,%edi
mov    $0x2000,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
mov    %r8d,%ecx
call   1070 <mmap@plt>
mov    %rax,-0x18(%rbp)
mov    $0xffffffffffffffff,%rdi
mov    $0x2000,%esi
call   10b0 <munmap@plt>
mov    -0x18(%rbp),%rdi
mov    $0xffffffff,%esi
call   10b0 <munmap@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    0x2d8d(%rip),%rax
mov    0x2dfe(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2deb(%rip),%rax
or     (%rax),%esi
lea    0xdf2(%rip),%rbx
mov    %rbx,%rdi
mov    $0x180,%edx
xor    %eax,%eax
call   10e0 <open@plt>
mov    %eax,%ebp
mov    0x2d8a(%rip),%rax
mov    (%rax),%edx
mov    %ebp,%edi
mov    $0x10000,%esi
call   1080 <lseek@plt>
lea    0xdcc(%rip),%rsi
mov    %ebp,%edi
mov    $0x6,%edx
call   1050 <write@plt>
mov    %ebp,%edi
call   1090 <close@plt>
mov    0x2d73(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   10e0 <open@plt>
mov    %eax,%r12d
lea    0x8(%rsp),%rsi
mov    %eax,%edi
call   1100 <fstat@plt>
mov    0x2d71(%rip),%r14
mov    (%r14),%edx
mov    0x2d57(%rip),%rax
mov    (%rax),%ecx
xor    %edi,%edi
mov    $0x1000,%esi
mov    %r12d,%r8d
xor    %r9d,%r9d
call   1070 <mmap@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x1000,%esi
call   1040 <mlock@plt>
mov    $0xffffffffffffffff,%rdi
mov    $0x1000,%esi
call   1040 <mlock@plt>
xor    %edi,%edi
mov    $0xffffffff,%esi
call   1040 <mlock@plt>
mov    0x2cdf(%rip),%rbp
mov    0x0(%rbp),%edx
mov    %rbx,%rdi
mov    $0x1000,%esi
call   1060 <msync@plt>
mov    0x0(%rbp),%edx
mov    $0xffffffffffffffff,%rdi
mov    $0x1000,%esi
call   1060 <msync@plt>
mov    0x0(%rbp),%edx
mov    %rbx,%rdi
mov    $0xffffffff,%esi
call   1060 <msync@plt>
mov    %rbx,%rdi
mov    $0x1000,%esi
mov    $0xffffffff,%edx
call   1060 <msync@plt>
mov    %rbx,%rdi
mov    $0x1000,%esi
call   1030 <munlock@plt>
mov    0x2c7d(%rip),%rax
mov    (%rax),%edi
call   10c0 <mlockall@plt>
mov    $0xffffffff,%edi
call   10c0 <mlockall@plt>
xor    %eax,%eax
call   10f0 <munlockall@plt>
mov    %rbx,%rdi
mov    $0x1000,%esi
call   10b0 <munmap@plt>
mov    (%r14),%edx
mov    0x2c3e(%rip),%r15
mov    (%r15),%ecx
xor    %edi,%edi
mov    $0x6,%esi
mov    %r12d,%r8d
mov    $0x10000,%r9d
call   1070 <mmap@plt>
mov    %rax,%rdi
mov    $0x6,%esi
call   10b0 <munmap@plt>
mov    %r12d,%edi
call   1090 <close@plt>
mov    0x2c12(%rip),%r12
mov    (%r12),%edx
or     (%r14),%edx
mov    0x2c2c(%rip),%rbp
mov    0x0(%rbp),%ecx
or     (%r15),%ecx
xor    %edi,%edi
mov    $0x3000,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1070 <mmap@plt>
mov    %rax,%rbx
mov    (%r14),%edx
mov    %rax,%rdi
mov    $0x1000,%esi
call   10d0 <mprotect@plt>
mov    %rbx,%rdi
mov    $0x3000,%esi
call   10b0 <munmap@plt>
mov    (%r12),%edx
or     (%r14),%edx
mov    0x0(%rbp),%ecx
or     (%r15),%ecx
xor    %edi,%edi
mov    $0x2000,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1070 <mmap@plt>
mov    %rax,%rdi
mov    $0x2000,%esi
mov    $0x1000,%edx
xor    %ecx,%ecx
call   10a0 <mremap@plt>
mov    %rax,%rdi
mov    $0x1000,%esi
call   10b0 <munmap@plt>
mov    (%r12),%edx
or     (%r14),%edx
mov    0x0(%rbp),%ecx
or     (%r15),%ecx
mov    $0xffffffffffffffff,%rdi
mov    $0x2000,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1070 <mmap@plt>
mov    %rax,%rdi
mov    $0x2000,%esi
call   10b0 <munmap@plt>
mov    (%r12),%edx
or     (%r14),%edx
mov    0x0(%rbp),%ecx
or     (%r15),%ecx
xor    %edi,%edi
mov    $0xffffffff,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1070 <mmap@plt>
mov    0x0(%rbp),%ecx
or     (%r15),%ecx
xor    %edi,%edi
mov    $0x2000,%esi
mov    $0xffffffff,%edx
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1070 <mmap@plt>
mov    %rax,%rdi
mov    $0x2000,%esi
call   10b0 <munmap@plt>
mov    (%r12),%edx
or     (%r14),%edx
xor    %edi,%edi
mov    $0x2000,%esi
mov    $0xffffffff,%ecx
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1070 <mmap@plt>
mov    %rax,%rbx
mov    $0xffffffffffffffff,%rdi
mov    $0x2000,%esi
call   10b0 <munmap@plt>
mov    %rbx,%rdi
mov    $0xffffffff,%esi
call   10b0 <munmap@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [7 x i8] c"foobar\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@SEEK_SET = global i32 0
@.str.1 = [7 x i8] c"abcdef\00"
@O_RDONLY = global i32 0
@PROT_READ = global i32 0
@MAP_SHARED = global i32 0
@MS_SYNC = global i32 0
@MCL_CURRENT = global i32 0
@MAP_PRIVATE = global i32 0
@PROT_WRITE = global i32 0
@MAP_ANONYMOUS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.stat
%5 = alloca i8*
store i32 0, i32* %1
%6 = load i32, i32* @O_WRONLY
%7 = load i32, i32* @O_CREAT
%8 = or i32 %6, %7
%9 = load i32, i32* @O_TRUNC
%10 = or i32 %8, %9
%11 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %10, i32 384)
store i32 %11, i32* %2
%12 = load i32, i32* %2
%13 = load i32, i32* @SEEK_SET
%14 = call i32 @lseek(i32 %12, i32 65536, i32 %13)
%15 = load i32, i32* %2
%16 = call i32 @write(i32 %15, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 6)
%17 = load i32, i32* %2
%18 = call i32 @close(i32 %17)
%19 = load i32, i32* @O_RDONLY
%20 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %19)
store i32 %20, i32* %2
%21 = load i32, i32* %2
%22 = call i32 @fstat(i32 %21, %struct.stat* %4)
store i32 %22, i32* %3
%23 = load i32, i32* @PROT_READ
%24 = load i32, i32* @MAP_SHARED
%25 = load i32, i32* %2
%26 = call i8* @mmap(i8* null, i32 4096, i32 %23, i32 %24, i32 %25, i32 0)
store i8* %26, i8** %5
%27 = load i8*, i8** %5
%28 = call i32 @mlock(i8* %27, i32 4096)
%29 = call i32 @mlock(i8* inttoptr (i64 -1 to i8*), i32 4096)
%30 = call i32 @mlock(i8* null, i32 -1)
%31 = load i8*, i8** %5
%32 = load i32, i32* @MS_SYNC
%33 = call i32 @msync(i8* %31, i32 4096, i32 %32)
%34 = load i32, i32* @MS_SYNC
%35 = call i32 @msync(i8* inttoptr (i64 -1 to i8*), i32 4096, i32 %34)
%36 = load i8*, i8** %5
%37 = load i32, i32* @MS_SYNC
%38 = call i32 @msync(i8* %36, i32 -1, i32 %37)
%39 = load i8*, i8** %5
%40 = call i32 @msync(i8* %39, i32 4096, i32 -1)
%41 = load i8*, i8** %5
%42 = call i32 @munlock(i8* %41, i32 4096)
%43 = load i32, i32* @MCL_CURRENT
%44 = call i32 @mlockall(i32 %43)
%45 = call i32 @mlockall(i32 -1)
%46 = call i32 (...) @munlockall()
%47 = load i8*, i8** %5
%48 = call i32 @munmap(i8* %47, i32 4096)
%49 = load i32, i32* @PROT_READ
%50 = load i32, i32* @MAP_PRIVATE
%51 = load i32, i32* %2
%52 = call i8* @mmap(i8* null, i32 6, i32 %49, i32 %50, i32 %51, i32 65536)
store i8* %52, i8** %5
%53 = load i8*, i8** %5
%54 = call i32 @munmap(i8* %53, i32 6)
%55 = load i32, i32* %2
%56 = call i32 @close(i32 %55)
%57 = load i32, i32* @PROT_READ
%58 = load i32, i32* @PROT_WRITE
%59 = or i32 %57, %58
%60 = load i32, i32* @MAP_PRIVATE
%61 = load i32, i32* @MAP_ANONYMOUS
%62 = or i32 %60, %61
%63 = call i8* @mmap(i8* null, i32 12288, i32 %59, i32 %62, i32 -1, i32 0)
store i8* %63, i8** %5
%64 = load i8*, i8** %5
%65 = load i32, i32* @PROT_READ
%66 = call i32 @mprotect(i8* %64, i32 4096, i32 %65)
%67 = load i8*, i8** %5
%68 = call i32 @munmap(i8* %67, i32 12288)
%69 = load i32, i32* @PROT_READ
%70 = load i32, i32* @PROT_WRITE
%71 = or i32 %69, %70
%72 = load i32, i32* @MAP_PRIVATE
%73 = load i32, i32* @MAP_ANONYMOUS
%74 = or i32 %72, %73
%75 = call i8* @mmap(i8* null, i32 8192, i32 %71, i32 %74, i32 -1, i32 0)
store i8* %75, i8** %5
%76 = load i8*, i8** %5
%77 = call i8* @mremap(i8* %76, i32 8192, i32 4096, i32 0)
store i8* %77, i8** %5
%78 = load i8*, i8** %5
%79 = call i32 @munmap(i8* %78, i32 4096)
%80 = load i32, i32* @PROT_READ
%81 = load i32, i32* @PROT_WRITE
%82 = or i32 %80, %81
%83 = load i32, i32* @MAP_PRIVATE
%84 = load i32, i32* @MAP_ANONYMOUS
%85 = or i32 %83, %84
%86 = call i8* @mmap(i8* inttoptr (i64 -1 to i8*), i32 8192, i32 %82, i32 %85, i32 -1, i32 0)
store i8* %86, i8** %5
%87 = load i8*, i8** %5
%88 = call i32 @munmap(i8* %87, i32 8192)
%89 = load i32, i32* @PROT_READ
%90 = load i32, i32* @PROT_WRITE
%91 = or i32 %89, %90
%92 = load i32, i32* @MAP_PRIVATE
%93 = load i32, i32* @MAP_ANONYMOUS
%94 = or i32 %92, %93
%95 = call i8* @mmap(i8* null, i32 -1, i32 %91, i32 %94, i32 -1, i32 0)
store i8* %95, i8** %5
%96 = load i32, i32* @MAP_PRIVATE
%97 = load i32, i32* @MAP_ANONYMOUS
%98 = or i32 %96, %97
%99 = call i8* @mmap(i8* null, i32 8192, i32 -1, i32 %98, i32 -1, i32 0)
store i8* %99, i8** %5
%100 = load i8*, i8** %5
%101 = call i32 @munmap(i8* %100, i32 8192)
%102 = load i32, i32* @PROT_READ
%103 = load i32, i32* @PROT_WRITE
%104 = or i32 %102, %103
%105 = call i8* @mmap(i8* null, i32 8192, i32 %104, i32 -1, i32 -1, i32 0)
store i8* %105, i8** %5
%106 = call i32 @munmap(i8* inttoptr (i64 -1 to i8*), i32 8192)
%107 = load i8*, i8** %5
%108 = call i32 @munmap(i8* %107, i32 -1)
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [7 x i8] c"foobar\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@SEEK_SET = global i32 0
@.str.1 = [7 x i8] c"abcdef\00"
@O_RDONLY = global i32 0
@PROT_READ = global i32 0
@MAP_SHARED = global i32 0
@MS_SYNC = global i32 0
@MCL_CURRENT = global i32 0
@MAP_PRIVATE = global i32 0
@PROT_WRITE = global i32 0
@MAP_ANONYMOUS = global i32 0
define i32 @main() {
%1 = alloca %struct.stat
%2 = bitcast %struct.stat* %1 to i8*
%3 = load i32, i32* @O_WRONLY
%4 = load i32, i32* @O_CREAT
%5 = or i32 %4, %3
%6 = load i32, i32* @O_TRUNC
%7 = or i32 %5, %6
%8 = tail call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %7, i32 384)
%9 = load i32, i32* @SEEK_SET
%10 = tail call i32 @lseek(i32 %8, i32 65536, i32 %9)
%11 = tail call i32 @write(i32 %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 6)
%12 = tail call i32 @close(i32 %8)
%13 = load i32, i32* @O_RDONLY
%14 = tail call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = call i32 @fstat(i32 %14, %struct.stat* %1)
%16 = load i32, i32* @PROT_READ
%17 = load i32, i32* @MAP_SHARED
%18 = tail call i8* @mmap(i8* null, i32 4096, i32 %16, i32 %17, i32 %14, i32 0)
%19 = tail call i32 @mlock(i8* %18, i32 4096)
%20 = tail call i32 @mlock(i8* inttoptr (i64 -1 to i8*), i32 4096)
%21 = tail call i32 @mlock(i8* null, i32 -1)
%22 = load i32, i32* @MS_SYNC
%23 = tail call i32 @msync(i8* %18, i32 4096, i32 %22)
%24 = load i32, i32* @MS_SYNC
%25 = tail call i32 @msync(i8* inttoptr (i64 -1 to i8*), i32 4096, i32 %24)
%26 = load i32, i32* @MS_SYNC
%27 = tail call i32 @msync(i8* %18, i32 -1, i32 %26)
%28 = tail call i32 @msync(i8* %18, i32 4096, i32 -1)
%29 = tail call i32 @munlock(i8* %18, i32 4096)
%30 = load i32, i32* @MCL_CURRENT
%31 = tail call i32 @mlockall(i32 %30)
%32 = tail call i32 @mlockall(i32 -1)
%33 = tail call i32 (...) @munlockall()
%34 = tail call i32 @munmap(i8* %18, i32 4096)
%35 = load i32, i32* @PROT_READ
%36 = load i32, i32* @MAP_PRIVATE
%37 = tail call i8* @mmap(i8* null, i32 6, i32 %35, i32 %36, i32 %14, i32 65536)
%38 = tail call i32 @munmap(i8* %37, i32 6)
%39 = tail call i32 @close(i32 %14)
%40 = load i32, i32* @PROT_READ
%41 = load i32, i32* @PROT_WRITE
%42 = or i32 %41, %40
%43 = load i32, i32* @MAP_PRIVATE
%44 = load i32, i32* @MAP_ANONYMOUS
%45 = or i32 %44, %43
%46 = tail call i8* @mmap(i8* null, i32 12288, i32 %42, i32 %45, i32 -1, i32 0)
%47 = load i32, i32* @PROT_READ
%48 = tail call i32 @mprotect(i8* %46, i32 4096, i32 %47)
%49 = tail call i32 @munmap(i8* %46, i32 12288)
%50 = load i32, i32* @PROT_READ
%51 = load i32, i32* @PROT_WRITE
%52 = or i32 %51, %50
%53 = load i32, i32* @MAP_PRIVATE
%54 = load i32, i32* @MAP_ANONYMOUS
%55 = or i32 %54, %53
%56 = tail call i8* @mmap(i8* null, i32 8192, i32 %52, i32 %55, i32 -1, i32 0)
%57 = tail call i8* @mremap(i8* %56, i32 8192, i32 4096, i32 0)
%58 = tail call i32 @munmap(i8* %57, i32 4096)
%59 = load i32, i32* @PROT_READ
%60 = load i32, i32* @PROT_WRITE
%61 = or i32 %60, %59
%62 = load i32, i32* @MAP_PRIVATE
%63 = load i32, i32* @MAP_ANONYMOUS
%64 = or i32 %63, %62
%65 = tail call i8* @mmap(i8* inttoptr (i64 -1 to i8*), i32 8192, i32 %61, i32 %64, i32 -1, i32 0)
%66 = tail call i32 @munmap(i8* %65, i32 8192)
%67 = load i32, i32* @PROT_READ
%68 = load i32, i32* @PROT_WRITE
%69 = or i32 %68, %67
%70 = load i32, i32* @MAP_PRIVATE
%71 = load i32, i32* @MAP_ANONYMOUS
%72 = or i32 %71, %70
%73 = tail call i8* @mmap(i8* null, i32 -1, i32 %69, i32 %72, i32 -1, i32 0)
%74 = load i32, i32* @MAP_PRIVATE
%75 = load i32, i32* @MAP_ANONYMOUS
%76 = or i32 %75, %74
%77 = tail call i8* @mmap(i8* null, i32 8192, i32 -1, i32 %76, i32 -1, i32 0)
%78 = tail call i32 @munmap(i8* %77, i32 8192)
%79 = load i32, i32* @PROT_READ
%80 = load i32, i32* @PROT_WRITE
%81 = or i32 %80, %79
%82 = tail call i8* @mmap(i8* null, i32 8192, i32 %81, i32 -1, i32 -1, i32 0)
%83 = tail call i32 @munmap(i8* inttoptr (i64 -1 to i8*), i32 8192)
%84 = tail call i32 @munmap(i8* %82, i32 -1)
ret i32 0
}