#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 */
int /*<<< orphan*/ EXIT_FAILURE;
int MAP_ANONYMOUS;
unsigned char *MAP_FAILED;
int MAP_PRIVATE;
int MAP_SHARED;
int O_RDWR;
int O_SYNC;
int /*<<< orphan*/ PROT_READ;
int /*<<< orphan*/ assert(int);
int atoi(char const *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int getpagesize();
unsigned char *mmap(int /*<<< orphan*/ *, int, int /*<<< orphan*/, int, int,
                    int /*<<< orphan*/);
int /*<<< orphan*/ munmap(unsigned char *, int);
int open(char *, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
unsigned long show_mem_usage();
int /*<<< orphan*/ sleep(int);
scalar_t__ system(char *);
scalar_t__ test_read_write(int, unsigned char *);
int main(int argc, const char **argv) {
  int fd, test;
  unsigned char *addr;
  int len = 16 * getpagesize();
  int i;
  unsigned long usage_before_mmap, usage_after_mmap;
  if (argc > 1)
    test = atoi(argv[1]);
  assert(system("mknod "
                "/dev/mymmap"
                " c 42 0") == 0);
  fd = open("/dev/mymmap", O_RDWR | O_SYNC);
  if (fd < 0) {
    perror("open");
    assert(system("rm "
                  "/dev/mymmap") == 0);
    exit(EXIT_FAILURE);
  }
  addr = mmap(NULL, len, PROT_READ, MAP_SHARED, fd, 0);
  if (addr == MAP_FAILED) {
    perror("mmap");
    assert(system("rm "
                  "/dev/mymmap") == 0);
    exit(EXIT_FAILURE);
  }
  for (i = 0; i < 16 * getpagesize(); i += getpagesize()) {
    if (addr[i] != 0xaa || addr[i + 1] != 0xbb || addr[i + 2] != 0xcc ||
        addr[i + 3] != 0xdd)
      printf("0x%x 0x%x 0x%x 0x%x\n", addr[i], addr[i + 1], addr[i + 2],
             addr[i + 3]);
    else
      printf("matched\n");
  }
  if (test >= 2 && test_read_write(fd, addr)) {
    perror("read/write test");
    assert(system("rm "
                  "/dev/mymmap") == 0);
    exit(EXIT_FAILURE);
  }
  if (test >= 3) {
    usage_before_mmap = show_mem_usage();
    if (usage_before_mmap < 0)
      printf("failed to show memory usage\n");
    addr = mmap(NULL, (10 * 1024 * 1024), PROT_READ,
                MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
    if (addr == MAP_FAILED)
      perror("mmap_");
    usage_after_mmap = show_mem_usage();
    if (usage_after_mmap < 0)
      printf("failed to show memory usage\n");
    printf("mmaped :%lu MB\n", (usage_after_mmap - usage_before_mmap) >> 20);
    sleep(30);
    munmap(addr, (10 * 1024 * 1024));
  }
  close(fd);
  assert(system("rm "
                "/dev/mymmap") == 0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   10e0 <getpagesize@plt>
shl    $0x4,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    121d <main+0x3d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10d0 <atoi@plt>
mov    %eax,-0x18(%rbp)
lea    0xddc(%rip),%rdi
call   1040 <system@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    0x2d97(%rip),%rax
mov    (%rax),%esi
mov    0x2d86(%rip),%rax
or     (%rax),%esi
lea    0xdce(%rip),%rdi
call   10b0 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    129c <main+0xbc>
lea    0xdad(%rip),%rdi
call   10c0 <perror@plt>
lea    0xda6(%rip),%rdi
call   1040 <system@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    0x2d23(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
mov    -0x24(%rbp),%esi
mov    0x2d52(%rip),%rax
mov    (%rax),%edx
mov    0x2d39(%rip),%rax
mov    (%rax),%ecx
mov    -0x14(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    0x2cd8(%rip),%rcx
cmp    (%rcx),%rax
jne    1310 <main+0x130>
lea    0xd48(%rip),%rdi
call   10c0 <perror@plt>
lea    0xd32(%rip),%rdi
call   1040 <system@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    0x2caf(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    $0x0,%al
call   10e0 <getpagesize@plt>
mov    %eax,%ecx
mov    -0x3c(%rbp),%eax
shl    $0x4,%ecx
cmp    %ecx,%eax
jge    1417 <main+0x237>
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0xaa,%eax
jne    139f <main+0x1bf>
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0xbb,%eax
jne    139f <main+0x1bf>
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0xcc,%eax
jne    139f <main+0x1bf>
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0xdd,%eax
je     13f2 <main+0x212>
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%edx
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%ecx
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%edi
add    $0x3,%edi
movslq %edi,%rdi
movzbl (%rax,%rdi,1),%r8d
lea    0xc47(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1400 <main+0x220>
lea    0xc49(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1405 <main+0x225>
mov    $0x0,%al
call   10e0 <getpagesize@plt>
add    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    1317 <main+0x137>
cmpl   $0x2,-0x18(%rbp)
jl     146e <main+0x28e>
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1090 <test_read_write@plt>
cmp    $0x0,%rax
je     146e <main+0x28e>
lea    0xc0d(%rip),%rdi
call   10c0 <perror@plt>
lea    0xbd4(%rip),%rdi
call   1040 <system@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    0x2b51(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
cmpl   $0x3,-0x18(%rbp)
jl     1548 <main+0x368>
mov    $0x0,%al
call   1070 <show_mem_usage@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jae    149c <main+0x2bc>
lea    0xbc6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2b55(%rip),%rax
mov    (%rax),%edx
mov    0x2b04(%rip),%rax
mov    (%rax),%ecx
mov    0x2b13(%rip),%rax
or     (%rax),%ecx
xor    %eax,%eax
mov    %eax,%edi
mov    $0xa00000,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    0x2acb(%rip),%rcx
cmp    (%rcx),%rax
jne    14f2 <main+0x312>
lea    0xb8b(%rip),%rdi
call   10c0 <perror@plt>
mov    $0x0,%al
call   1070 <show_mem_usage@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jae    1516 <main+0x336>
lea    0xb4c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x38(%rbp),%rsi
sub    -0x30(%rbp),%rsi
shr    $0x14,%rsi
lea    0xb55(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1e,%edi
call   1100 <sleep@plt>
mov    -0x20(%rbp),%rdi
mov    $0xa00000,%esi
call   10a0 <munmap@plt>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
lea    0xac7(%rip),%rdi
call   1040 <system@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %edi,%ebp
xor    %eax,%eax
call   10f0 <getpagesize@plt>
mov    %eax,%ebx
cmp    $0x2,%ebp
jl     121a <main+0x2a>
mov    0x8(%r15),%rdi
call   10e0 <atoi@plt>
mov    %eax,%r14d
lea    0xddf(%rip),%rdi
call   1050 <system@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1090 <assert@plt>
mov    0x2d9d(%rip),%rax
mov    0x2d8e(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0xdd4(%rip),%rdi
call   10c0 <open@plt>
test   %eax,%eax
js     13f7 <main+0x207>
mov    %eax,%r12d
shl    $0x4,%ebx
mov    0x2d91(%rip),%rax
mov    (%rax),%edx
mov    0x2d78(%rip),%rax
mov    (%rax),%ecx
xor    %edi,%edi
mov    %ebx,%esi
mov    %r12d,%r8d
xor    %r9d,%r9d
call   1040 <mmap@plt>
mov    %rax,%rbp
mov    0x2d1d(%rip),%rax
cmp    (%rax),%rbp
je     1400 <main+0x210>
xor    %eax,%eax
call   10f0 <getpagesize@plt>
test   %eax,%eax
jle    1313 <main+0x123>
lea    0xdc2(%rip),%r15
lea    0xd80(%rip),%rbx
xor    %r13d,%r13d
movslq %r13d,%rax
movzbl 0x0(%rbp,%rax,1),%esi
cmp    $0xaa,%esi
jne    12e0 <main+0xf0>
cmpb   $0xbb,0x1(%rbp,%rax,1)
jne    12e0 <main+0xf0>
cmpb   $0xcc,0x2(%rax,%rbp,1)
jne    12e0 <main+0xf0>
cmpb   $0xdd,0x3(%rax,%rbp,1)
jne    12e0 <main+0xf0>
mov    %r15,%rdi
call   1030 <puts@plt>
jmp    12fa <main+0x10a>
nop
movzbl 0x1(%rbp,%rax,1),%edx
movzbl 0x2(%rbp,%rax,1),%ecx
movzbl 0x3(%rbp,%rax,1),%r8d
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   10f0 <getpagesize@plt>
add    %eax,%r13d
xor    %eax,%eax
call   10f0 <getpagesize@plt>
shl    $0x4,%eax
cmp    %eax,%r13d
jl     12b0 <main+0xc0>
cmp    $0x2,%r14d
jl     13b6 <main+0x1c6>
mov    %r12d,%edi
mov    %rbp,%rsi
call   10a0 <test_read_write@plt>
test   %rax,%rax
jne    1409 <main+0x219>
cmp    $0x3,%r14d
jb     13b6 <main+0x1c6>
xor    %eax,%eax
call   1080 <show_mem_usage@plt>
mov    %rax,%rbx
mov    0x2cb0(%rip),%rax
mov    (%rax),%edx
mov    0x2c5f(%rip),%rax
mov    0x2c70(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
xor    %edi,%edi
mov    $0xa00000,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1040 <mmap@plt>
mov    %rax,%rbp
mov    0x2c2d(%rip),%rax
cmp    (%rax),%rbp
je     13e9 <main+0x1f9>
xor    %eax,%eax
call   1080 <show_mem_usage@plt>
sub    %rbx,%rax
shr    $0x14,%rax
lea    0xcc3(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1e,%edi
call   1110 <sleep@plt>
mov    %rbp,%rdi
mov    $0xa00000,%esi
call   10b0 <munmap@plt>
mov    %r12d,%edi
call   1070 <close@plt>
lea    0xc59(%rip),%rdi
call   1050 <system@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1090 <assert@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc62(%rip),%rdi
call   10d0 <perror@plt>
jmp    1380 <main+0x190>
lea    0xc1b(%rip),%rdi
jmp    1410 <main+0x220>
lea    0xc21(%rip),%rdi
jmp    1410 <main+0x220>
lea    0xc32(%rip),%rdi
call   10d0 <perror@plt>
lea    0xc02(%rip),%rdi
call   1050 <system@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1090 <assert@plt>
mov    0x2b82(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>

LLVM IR (-O0):
@.str = [25 x i8] c"mknod /dev/mymmap c 42 0\00"
@.str.1 = [12 x i8] c"/dev/mymmap\00"
@O_RDWR = global i32 0
@O_SYNC = global i32 0
@.str.2 = [5 x i8] c"open\00"
@.str.3 = [15 x i8] c"rm /dev/mymmap\00"
@EXIT_FAILURE = global i32 0
@PROT_READ = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i8* null
@.str.4 = [5 x i8] c"mmap\00"
@.str.5 = [21 x i8] c"0x%x 0x%x 0x%x 0x%x\0A\00"
@.str.6 = [9 x i8] c"matched\0A\00"
@.str.7 = [16 x i8] c"read/write test\00"
@.str.8 = [29 x i8] c"failed to show memory usage\0A\00"
@MAP_PRIVATE = global i32 0
@MAP_ANONYMOUS = global i32 0
@.str.9 = [6 x i8] c"mmap_\00"
@.str.10 = [16 x i8] c"mmaped :%lu MB\0A\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 i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i64
%12 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = call i32 (...) @getpagesize()
%14 = mul nsw i32 16, %13
store i32 %14, i32* %9
%15 = load i32, i32* %4
%16 = icmp sgt i32 %15, 1
br i1 %16, label %17, label %22
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @atoi(i8* %20)
store i32 %21, i32* %7
br label %22
22: ; preds = %17, %2
%23 = call i64 @system(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
%25 = zext i1 %24 to i32
%26 = call i32 @assert(i32 %25)
%27 = load i32, i32* @O_RDWR
%28 = load i32, i32* @O_SYNC
%29 = or i32 %27, %28
%30 = call i32 @open(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %29)
store i32 %30, i32* %6
%31 = load i32, i32* %6
%32 = icmp slt i32 %31, 0
br i1 %32, label %33, label %41
33: ; preds = %22
%34 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%35 = call i64 @system(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
%37 = zext i1 %36 to i32
%38 = call i32 @assert(i32 %37)
%39 = load i32, i32* @EXIT_FAILURE
%40 = call i32 @exit(i32 %39)
unreachable
41: ; preds = %22
%42 = load i32, i32* %9
%43 = load i32, i32* @PROT_READ
%44 = load i32, i32* @MAP_SHARED
%45 = load i32, i32* %6
%46 = call i8* @mmap(i32* null, i32 %42, i32 %43, i32 %44, i32 %45, i32 0)
store i8* %46, i8** %8
%47 = load i8*, i8** %8
%48 = load i8*, i8** @MAP_FAILED
%49 = icmp eq i8* %47, %48
br i1 %49, label %50, label %58
50: ; preds = %41
%51 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%52 = call i64 @system(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%53 = icmp eq i64 %52, 0
%54 = zext i1 %53 to i32
%55 = call i32 @assert(i32 %54)
%56 = load i32, i32* @EXIT_FAILURE
%57 = call i32 @exit(i32 %56)
unreachable
58: ; preds = %41
store i32 0, i32* %10
br label %59
59: ; preds = %131, %58
%60 = load i32, i32* %10
%61 = call i32 (...) @getpagesize()
%62 = mul nsw i32 16, %61
%63 = icmp slt i32 %60, %62
br i1 %63, label %64, label %135
64: ; preds = %59
%65 = load i8*, i8** %8
%66 = load i32, i32* %10
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i8, i8* %65, i64 %67
%69 = load i8, i8* %68
%70 = zext i8 %69 to i32
%71 = icmp ne i32 %70, 170
br i1 %71, label %99, label %72
72: ; preds = %64
%73 = load i8*, i8** %8
%74 = load i32, i32* %10
%75 = add nsw i32 %74, 1
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds i8, i8* %73, i64 %76
%78 = load i8, i8* %77
%79 = zext i8 %78 to i32
%80 = icmp ne i32 %79, 187
br i1 %80, label %99, label %81
81: ; preds = %72
%82 = load i8*, i8** %8
%83 = load i32, i32* %10
%84 = add nsw i32 %83, 2
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds i8, i8* %82, i64 %85
%87 = load i8, i8* %86
%88 = zext i8 %87 to i32
%89 = icmp ne i32 %88, 204
br i1 %89, label %99, label %90
90: ; preds = %81
%91 = load i8*, i8** %8
%92 = load i32, i32* %10
%93 = add nsw i32 %92, 3
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds i8, i8* %91, i64 %94
%96 = load i8, i8* %95
%97 = zext i8 %96 to i32
%98 = icmp ne i32 %97, 221
br i1 %98, label %99, label %128
99: ; preds = %90, %81, %72, %64
%100 = load i8*, i8** %8
%101 = load i32, i32* %10
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds i8, i8* %100, i64 %102
%104 = load i8, i8* %103
%105 = zext i8 %104 to i32
%106 = load i8*, i8** %8
%107 = load i32, i32* %10
%108 = add nsw i32 %107, 1
%109 = sext i32 %108 to i64
%110 = getelementptr inbounds i8, i8* %106, i64 %109
%111 = load i8, i8* %110
%112 = zext i8 %111 to i32
%113 = load i8*, i8** %8
%114 = load i32, i32* %10
%115 = add nsw i32 %114, 2
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds i8, i8* %113, i64 %116
%118 = load i8, i8* %117
%119 = zext i8 %118 to i32
%120 = load i8*, i8** %8
%121 = load i32, i32* %10
%122 = add nsw i32 %121, 3
%123 = sext i32 %122 to i64
%124 = getelementptr inbounds i8, i8* %120, i64 %123
%125 = load i8, i8* %124
%126 = zext i8 %125 to i32
%127 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i32 %105, i32 %112, i32 %119, i32 %126)
br label %130
128: ; preds = %90
%129 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
br label %130
130: ; preds = %128, %99
br label %131
131: ; preds = %130
%132 = call i32 (...) @getpagesize()
%133 = load i32, i32* %10
%134 = add nsw i32 %133, %132
store i32 %134, i32* %10
br label %59
135: ; preds = %59
%136 = load i32, i32* %7
%137 = icmp sge i32 %136, 2
br i1 %137, label %138, label %151
138: ; preds = %135
%139 = load i32, i32* %6
%140 = load i8*, i8** %8
%141 = call i64 @test_read_write(i32 %139, i8* %140)
%142 = icmp ne i64 %141, 0
br i1 %142, label %143, label %151
143: ; preds = %138
%144 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0))
%145 = call i64 @system(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%146 = icmp eq i64 %145, 0
%147 = zext i1 %146 to i32
%148 = call i32 @assert(i32 %147)
%149 = load i32, i32* @EXIT_FAILURE
%150 = call i32 @exit(i32 %149)
unreachable
151: ; preds = %138, %135
%152 = load i32, i32* %7
%153 = icmp sge i32 %152, 3
br i1 %153, label %154, label %186
154: ; preds = %151
%155 = call i64 (...) @show_mem_usage()
store i64 %155, i64* %11
%156 = load i64, i64* %11
%157 = icmp ult i64 %156, 0
br i1 %157, label %158, label %160
158: ; preds = %154
%159 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0))
br label %160
160: ; preds = %158, %154
%161 = load i32, i32* @PROT_READ
%162 = load i32, i32* @MAP_PRIVATE
%163 = load i32, i32* @MAP_ANONYMOUS
%164 = or i32 %162, %163
%165 = call i8* @mmap(i32* null, i32 10485760, i32 %161, i32 %164, i32 -1, i32 0)
store i8* %165, i8** %8
%166 = load i8*, i8** %8
%167 = load i8*, i8** @MAP_FAILED
%168 = icmp eq i8* %166, %167
br i1 %168, label %169, label %171
169: ; preds = %160
%170 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
br label %171
171: ; preds = %169, %160
%172 = call i64 (...) @show_mem_usage()
store i64 %172, i64* %12
%173 = load i64, i64* %12
%174 = icmp ult i64 %173, 0
br i1 %174, label %175, label %177
175: ; preds = %171
%176 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0))
br label %177
177: ; preds = %175, %171
%178 = load i64, i64* %12
%179 = load i64, i64* %11
%180 = sub i64 %178, %179
%181 = lshr i64 %180, 20
%182 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i64 %181)
%183 = call i32 @sleep(i32 30)
%184 = load i8*, i8** %8
%185 = call i32 @munmap(i8* %184, i32 10485760)
br label %186
186: ; preds = %177, %151
%187 = load i32, i32* %6
%188 = call i32 @close(i32 %187)
%189 = call i64 @system(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%190 = icmp eq i64 %189, 0
%191 = zext i1 %190 to i32
%192 = call i32 @assert(i32 %191)
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c"mknod /dev/mymmap c 42 0\00"
@.str.1 = [12 x i8] c"/dev/mymmap\00"
@O_RDWR = global i32 0
@O_SYNC = global i32 0
@.str.2 = [5 x i8] c"open\00"
@.str.3 = [15 x i8] c"rm /dev/mymmap\00"
@EXIT_FAILURE = global i32 0
@PROT_READ = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i8* null
@.str.4 = [5 x i8] c"mmap\00"
@.str.5 = [21 x i8] c"0x%x 0x%x 0x%x 0x%x\0A\00"
@.str.7 = [16 x i8] c"read/write test\00"
@MAP_PRIVATE = global i32 0
@MAP_ANONYMOUS = global i32 0
@.str.9 = [6 x i8] c"mmap_\00"
@.str.10 = [16 x i8] c"mmaped :%lu MB\0A\00"
@str = [8 x i8] c"matched\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 (...) @getpagesize()
%4 = shl nsw i32 %3, 4
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @atoi(i8* %8)
br label %10
10: ; preds = %6, %2
%11 = phi i32 [ %9, %6 ], [ undef, %2 ]
%12 = tail call i64 @system(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
%14 = zext i1 %13 to i32
%15 = tail call i32 @assert(i32 %14)
%16 = load i32, i32* @O_RDWR
%17 = load i32, i32* @O_SYNC
%18 = or i32 %17, %16
%19 = tail call i32 @open(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %29
21: ; preds = %10
%22 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%23 = tail call i64 @system(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
%25 = zext i1 %24 to i32
%26 = tail call i32 @assert(i32 %25)
%27 = load i32, i32* @EXIT_FAILURE
%28 = tail call i32 @exit(i32 %27)
unreachable
29: ; preds = %10
%30 = load i32, i32* @PROT_READ
%31 = load i32, i32* @MAP_SHARED
%32 = tail call i8* @mmap(i32* null, i32 %4, i32 %30, i32 %31, i32 %19, i32 0)
%33 = load i8*, i8** @MAP_FAILED
%34 = icmp eq i8* %32, %33
br i1 %34, label %38, label %35
35: ; preds = %29
%36 = tail call i32 (...) @getpagesize()
%37 = icmp sgt i32 %36, 0
br i1 %37, label %46, label %94
38: ; preds = %29
%39 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%40 = tail call i64 @system(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%41 = icmp eq i64 %40, 0
%42 = zext i1 %41 to i32
%43 = tail call i32 @assert(i32 %42)
%44 = load i32, i32* @EXIT_FAILURE
%45 = tail call i32 @exit(i32 %44)
unreachable
46: ; preds = %35, %88
%47 = phi i32 [ %90, %88 ], [ 0, %35 ]
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %32, i64 %48
%50 = load i8, i8* %49
%51 = icmp eq i8 %50, -86
%52 = add nsw i32 %47, 1
%53 = sext i32 %52 to i64
br i1 %51, label %54, label %70
54: ; preds = %46
%55 = getelementptr inbounds i8, i8* %32, i64 %53
%56 = load i8, i8* %55
%57 = icmp eq i8 %56, -69
br i1 %57, label %58, label %70
58: ; preds = %54
%59 = add nsw i32 %47, 2
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8, i8* %32, i64 %60
%62 = load i8, i8* %61
%63 = icmp eq i8 %62, -52
br i1 %63, label %64, label %70
64: ; preds = %58
%65 = add nsw i32 %47, 3
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i8, i8* %32, i64 %66
%68 = load i8, i8* %67
%69 = icmp eq i8 %68, -35
br i1 %69, label %86, label %70
70: ; preds = %46, %64, %58, %54
%71 = zext i8 %50 to i32
%72 = getelementptr inbounds i8, i8* %32, i64 %53
%73 = load i8, i8* %72
%74 = zext i8 %73 to i32
%75 = add nsw i32 %47, 2
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds i8, i8* %32, i64 %76
%78 = load i8, i8* %77
%79 = zext i8 %78 to i32
%80 = add nsw i32 %47, 3
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds i8, i8* %32, i64 %81
%83 = load i8, i8* %82
%84 = zext i8 %83 to i32
%85 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i32 %71, i32 %74, i32 %79, i32 %84)
br label %88
86: ; preds = %64
%87 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
br label %88
88: ; preds = %70, %86
%89 = tail call i32 (...) @getpagesize()
%90 = add nsw i32 %89, %47
%91 = tail call i32 (...) @getpagesize()
%92 = shl nsw i32 %91, 4
%93 = icmp slt i32 %90, %92
br i1 %93, label %46, label %94
94: ; preds = %88, %35
%95 = icmp sgt i32 %11, 1
br i1 %95, label %96, label %127
96: ; preds = %94
%97 = tail call i64 @test_read_write(i32 %19, i8* %32)
%98 = icmp eq i64 %97, 0
br i1 %98, label %107, label %99
99: ; preds = %96
%100 = tail call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0))
%101 = tail call i64 @system(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%102 = icmp eq i64 %101, 0
%103 = zext i1 %102 to i32
%104 = tail call i32 @assert(i32 %103)
%105 = load i32, i32* @EXIT_FAILURE
%106 = tail call i32 @exit(i32 %105)
unreachable
107: ; preds = %96
%108 = icmp ugt i32 %11, 2
br i1 %108, label %109, label %127
109: ; preds = %107
%110 = tail call i64 (...) @show_mem_usage()
%111 = load i32, i32* @PROT_READ
%112 = load i32, i32* @MAP_PRIVATE
%113 = load i32, i32* @MAP_ANONYMOUS
%114 = or i32 %113, %112
%115 = tail call i8* @mmap(i32* null, i32 10485760, i32 %111, i32 %114, i32 -1, i32 0)
%116 = load i8*, i8** @MAP_FAILED
%117 = icmp eq i8* %115, %116
br i1 %117, label %118, label %120
118: ; preds = %109
%119 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
br label %120
120: ; preds = %118, %109
%121 = tail call i64 (...) @show_mem_usage()
%122 = sub i64 %121, %110
%123 = lshr i64 %122, 20
%124 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i64 %123)
%125 = tail call i32 @sleep(i32 30)
%126 = tail call i32 @munmap(i8* %115, i32 10485760)
br label %127
127: ; preds = %94, %120, %107
%128 = tail call i32 @close(i32 %19)
%129 = tail call i64 @system(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%130 = icmp eq i64 %129, 0
%131 = zext i1 %130 to i32
%132 = tail call i32 @assert(i32 %131)
ret i32 0
}