#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 MAP_ANONYMOUS;
void *MAP_FAILED;
int MAP_PRIVATE;
int PROT_READ;
int PROT_WRITE;
int atoi(char *);
long atol(char *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int ftruncate(int, long);
void *malloc(long);
int /*<<< orphan*/ memset(void *, int, long);
int mkstemp(char *);
void *mmap(int /*<<< orphan*/ *, long, int, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ print_memstat();
int /*<<< orphan*/ printf(char *, ...);
void *sbrk(long);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ unlink(char *);
int main(int argc, char *argv[]) {
  int sleeptot = 0;
  if (argc < 3) {
    printf("Usage: %s MODE SIZE_IN_MiB\nwhere\n    MODE=0: Anonymous mmap\n    "
           "MODE=1: mmap of a temporary file\n    MODE=2: malloc\n    MODE=3: "
           "brk\n",
           argv[0]);
    return 0;
  }
  int mode = atoi(argv[1]);
  long n = atol(argv[2]);
  n *= 1024 * 1024;
  void *p;
  int fd;
  char template[] = "/tmp/mmaptestXXXXXX";
  switch (mode) {
  case 0:
    p = mmap(NULL, n, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1,
             0);
    if (p == MAP_FAILED) {
      perror("anonymous mmap failed");
      return 1;
    }
    break;
  case 1:
    fd = mkstemp(template);
    if (fd == -1) {
      perror("mkstemp failed");
      return 1;
    }
    unlink(template);
    if (ftruncate(fd, n) == -1) {
      perror("ftruncate failed");
      return 1;
    }
    p = mmap(NULL, n, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
    if (p == MAP_FAILED) {
      perror("mmap failed");
      return 1;
    }
    break;
  case 2:
    p = malloc(n);
    if (!p) {
      perror("malloc failed");
      return 1;
    }
    break;
  case 3:
    p = sbrk(n);
    if (p == (void *)-1) {
      perror("sbrk failed");
      return 1;
    }
    break;
  default:
    printf("MODE must be 0, 1, 2 or 3\n");
    return 0;
  }
  sleep(2);
  memset(p, 42, n);
  print_memstat();
  while (1) {
    sleep(5);
    sleeptot += 5;
    printf("Slept for a total of %d s.\n", sleeptot);
    fflush(stdout);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    1228 <main+0x48>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xdfb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    14aa <main+0x2ca>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10f0 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10d0 <atol@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
shl    $0x14,%rax
mov    %rax,-0x20(%rbp)
movaps 0xec4(%rip),%xmm0
movaps %xmm0,-0x40(%rbp)
movl   $0x585858,-0x30(%rbp)
mov    -0x18(%rbp),%eax
mov    %rax,-0x48(%rbp)
sub    $0x3,%rax
ja     1433 <main+0x253>
mov    -0x48(%rbp),%rax
lea    0xd7d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x20(%rbp),%rsi
mov    0x2d61(%rip),%rax
mov    (%rax),%edx
mov    0x2d30(%rip),%rax
or     (%rax),%edx
mov    0x2d17(%rip),%rax
mov    (%rax),%ecx
mov    0x2d2e(%rip),%rax
or     (%rax),%ecx
xor    %eax,%eax
mov    %eax,%edi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1050 <mmap@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    0x2ce3(%rip),%rcx
cmp    (%rcx),%rax
jne    12f6 <main+0x116>
lea    0xdb0(%rip),%rdi
call   10e0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    14aa <main+0x2ca>
jmp    144d <main+0x26d>
lea    -0x40(%rbp),%rdi
call   10c0 <mkstemp@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0xffffffff,-0x2c(%rbp)
jne    1329 <main+0x149>
lea    0xd93(%rip),%rdi
call   10e0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    14aa <main+0x2ca>
lea    -0x40(%rbp),%rdi
call   1030 <unlink@plt>
mov    -0x2c(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1070 <ftruncate@plt>
cmp    $0xffffffff,%eax
jne    135f <main+0x17f>
lea    0xd6c(%rip),%rdi
call   10e0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    14aa <main+0x2ca>
mov    -0x20(%rbp),%rsi
mov    0x2c8e(%rip),%rax
mov    (%rax),%edx
mov    0x2c5d(%rip),%rax
or     (%rax),%edx
mov    0x2c44(%rip),%rax
mov    (%rax),%ecx
mov    -0x2c(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
xor    %r9d,%r9d
call   1050 <mmap@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    0x2c1b(%rip),%rcx
cmp    (%rcx),%rax
jne    13be <main+0x1de>
lea    0xcf2(%rip),%rdi
call   10e0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    14aa <main+0x2ca>
jmp    144d <main+0x26d>
mov    -0x20(%rbp),%rdi
call   10a0 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    13f3 <main+0x213>
lea    0xce9(%rip),%rdi
call   10e0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    14aa <main+0x2ca>
jmp    144d <main+0x26d>
mov    -0x20(%rbp),%rdi
call   1090 <sbrk@plt>
mov    %rax,-0x28(%rbp)
mov    $0xffffffffffffffff,%rax
cmp    %rax,-0x28(%rbp)
jne    142e <main+0x24e>
lea    0xcbc(%rip),%rdi
call   10e0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    14aa <main+0x2ca>
jmp    144d <main+0x26d>
lea    0xcab(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    14aa <main+0x2ca>
mov    $0x2,%edi
call   1100 <sleep@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x2a,%esi
call   1080 <memset@plt>
mov    $0x0,%al
call   1040 <print_memstat@plt>
mov    $0x5,%edi
call   1100 <sleep@plt>
mov    -0x14(%rbp),%eax
add    $0x5,%eax
mov    %eax,-0x4c(%rbp)
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xc70(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2b2a(%rip),%rax
mov    (%rax),%edi
call   10b0 <fflush@plt>
jmp    1470 <main+0x290>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jg     121e <main+0x2e>
mov    (%rbx),%rsi
lea    0xe06(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1070 <printf@plt>
mov    %ebx,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x8(%rbx),%rdi
call   1100 <atoi@plt>
mov    %eax,%ebp
mov    0x10(%rbx),%rdi
call   10e0 <atol@plt>
movaps 0xee7(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0x585858,0x10(%rsp)
cmp    $0x3,%ebp
ja     12b9 <main+0xc9>
mov    %rax,%rbx
shl    $0x14,%rbx
mov    %ebp,%eax
lea    0xda6(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2d8e(%rip),%rax
mov    0x2d5f(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2d44(%rip),%rax
mov    0x2d5d(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
xor    %edi,%edi
mov    %rbx,%rsi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1060 <mmap@plt>
mov    %rax,%rbp
mov    0x2d14(%rip),%rax
cmp    (%rax),%rbp
jne    136d <main+0x17d>
lea    0xde1(%rip),%rdi
jmp    13ec <main+0x1fc>
lea    0xe41(%rip),%rdi
call   1040 <puts@plt>
xor    %ebx,%ebx
jmp    1213 <main+0x23>
mov    %rsp,%rdi
call   10d0 <mkstemp@plt>
cmp    $0xffffffff,%eax
je     13d3 <main+0x1e3>
mov    %eax,%ebp
mov    %rsp,%rdi
call   1030 <unlink@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1080 <ftruncate@plt>
cmp    $0xffffffff,%eax
je     13e5 <main+0x1f5>
mov    0x2cf7(%rip),%rax
mov    0x2cc8(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2cad(%rip),%rax
mov    (%rax),%ecx
xor    %edi,%edi
mov    %rbx,%rsi
mov    %ebp,%r8d
xor    %r9d,%r9d
call   1060 <mmap@plt>
mov    %rax,%rbp
mov    0x2c89(%rip),%rax
cmp    (%rax),%rbp
jne    136d <main+0x17d>
lea    0xd64(%rip),%rdi
jmp    13ec <main+0x1fc>
mov    %rbx,%rdi
call   10b0 <malloc@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    136d <main+0x17d>
lea    0xd74(%rip),%rdi
jmp    13ec <main+0x1fc>
mov    %rbx,%rdi
call   10a0 <sbrk@plt>
mov    %rax,%rbp
cmp    $0xffffffffffffffff,%rax
je     13dc <main+0x1ec>
mov    $0x2,%edi
call   1110 <sleep@plt>
mov    %rbp,%rdi
mov    $0x2a,%esi
mov    %rbx,%rdx
call   1090 <memset@plt>
xor    %eax,%eax
call   1050 <print_memstat@plt>
mov    $0x5,%ebx
lea    0xd4b(%rip),%r14
mov    0x2c27(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x5,%edi
call   1110 <sleep@plt>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x0(%rbp),%edi
call   10c0 <fflush@plt>
add    $0x5,%ebx
jmp    13b0 <main+0x1c0>
lea    0xcd1(%rip),%rdi
jmp    13ec <main+0x1fc>
lea    0xcf6(%rip),%rdi
jmp    13ec <main+0x1fc>
lea    0xcce(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%ebx
jmp    1213 <main+0x23>

LLVM IR (-O0):
@.str = [133 x i8] c"Usage: %s MODE SIZE_IN_MiB\0Awhere\0A MODE=0: Anonymous mmap\0A MODE=1: mmap of a temporary file\0A MODE=2: malloc\0A MODE=3: brk\0A\00"
@__const.main.template = [20 x i8] c"/tmp/mmaptestXXXXXX\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_PRIVATE = global i32 0
@MAP_ANONYMOUS = global i32 0
@MAP_FAILED = global i8* null
@.str.1 = [22 x i8] c"anonymous mmap failed\00"
@.str.2 = [15 x i8] c"mkstemp failed\00"
@.str.3 = [17 x i8] c"ftruncate failed\00"
@.str.4 = [12 x i8] c"mmap failed\00"
@.str.5 = [14 x i8] c"malloc failed\00"
@.str.6 = [12 x i8] c"sbrk failed\00"
@.str.7 = [27 x i8] c"MODE must be 0, 1, 2 or 3\0A\00"
@.str.8 = [28 x i8] c"Slept for a total of %d s.\0A\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i32
%11 = alloca [20 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 3
br i1 %13, label %14, label %19
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([133 x i8], [133 x i8]* @.str, i64 0, i64 0), i8* %17)
store i32 0, i32* %3
br label %109
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @atoi(i8* %22)
store i32 %23, i32* %7
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
%27 = call i64 @atol(i8* %26)
store i64 %27, i64* %8
%28 = load i64, i64* %8
%29 = mul nsw i64 %28, 1048576
store i64 %29, i64* %8
%30 = bitcast [20 x i8]* %11 to i8*
%31 = load i32, i32* %7
switch i32 %31, label %93 [
i32 0, label %32
i32 1, label %47
i32 2, label %77
i32 3, label %85
]
32: ; preds = %19
%33 = load i64, i64* %8
%34 = load i32, i32* @PROT_READ
%35 = load i32, i32* @PROT_WRITE
%36 = or i32 %34, %35
%37 = load i32, i32* @MAP_PRIVATE
%38 = load i32, i32* @MAP_ANONYMOUS
%39 = or i32 %37, %38
%40 = call i8* @mmap(i32* null, i64 %33, i32 %36, i32 %39, i32 -1, i32 0)
store i8* %40, i8** %9
%41 = load i8*, i8** %9
%42 = load i8*, i8** @MAP_FAILED
%43 = icmp eq i8* %41, %42
br i1 %43, label %44, label %46
44: ; preds = %32
%45 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %109
46: ; preds = %32
br label %95
47: ; preds = %19
%48 = getelementptr inbounds [20 x i8], [20 x i8]* %11, i64 0, i64 0
%49 = call i32 @mkstemp(i8* %48)
store i32 %49, i32* %10
%50 = load i32, i32* %10
%51 = icmp eq i32 %50, -1
br i1 %51, label %52, label %54
52: ; preds = %47
%53 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %109
54: ; preds = %47
%55 = getelementptr inbounds [20 x i8], [20 x i8]* %11, i64 0, i64 0
%56 = call i32 @unlink(i8* %55)
%57 = load i32, i32* %10
%58 = load i64, i64* %8
%59 = call i32 @ftruncate(i32 %57, i64 %58)
%60 = icmp eq i32 %59, -1
br i1 %60, label %61, label %63
61: ; preds = %54
%62 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %109
63: ; preds = %54
%64 = load i64, i64* %8
%65 = load i32, i32* @PROT_READ
%66 = load i32, i32* @PROT_WRITE
%67 = or i32 %65, %66
%68 = load i32, i32* @MAP_PRIVATE
%69 = load i32, i32* %10
%70 = call i8* @mmap(i32* null, i64 %64, i32 %67, i32 %68, i32 %69, i32 0)
store i8* %70, i8** %9
%71 = load i8*, i8** %9
%72 = load i8*, i8** @MAP_FAILED
%73 = icmp eq i8* %71, %72
br i1 %73, label %74, label %76
74: ; preds = %63
%75 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %3
br label %109
76: ; preds = %63
br label %95
77: ; preds = %19
%78 = load i64, i64* %8
%79 = call i8* @malloc(i64 %78)
store i8* %79, i8** %9
%80 = load i8*, i8** %9
%81 = icmp ne i8* %80, null
br i1 %81, label %84, label %82
82: ; preds = %77
%83 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %109
84: ; preds = %77
br label %95
85: ; preds = %19
%86 = load i64, i64* %8
%87 = call i8* @sbrk(i64 %86)
store i8* %87, i8** %9
%88 = load i8*, i8** %9
%89 = icmp eq i8* %88, inttoptr (i64 -1 to i8*)
br i1 %89, label %90, label %92
90: ; preds = %85
%91 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %3
br label %109
92: ; preds = %85
br label %95
93: ; preds = %19
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %3
br label %109
95: ; preds = %92, %84, %76, %46
%96 = call i32 @sleep(i32 2)
%97 = load i8*, i8** %9
%98 = load i64, i64* %8
%99 = call i32 @memset(i8* %97, i32 42, i64 %98)
%100 = call i32 (...) @print_memstat()
br label %101
101: ; preds = %95, %101
%102 = call i32 @sleep(i32 5)
%103 = load i32, i32* %6
%104 = add nsw i32 %103, 5
store i32 %104, i32* %6
%105 = load i32, i32* %6
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0), i32 %105)
%107 = load i32, i32* @stdout
%108 = call i32 @fflush(i32 %107)
br label %101
109: ; preds = %93, %90, %82, %74, %61, %52, %44, %14
%110 = load i32, i32* %3
ret i32 %110
}

LLVM IR (-O2):
@.str = [133 x i8] c"Usage: %s MODE SIZE_IN_MiB\0Awhere\0A MODE=0: Anonymous mmap\0A MODE=1: mmap of a temporary file\0A MODE=2: malloc\0A MODE=3: brk\0A\00"
@__const.main.template = [20 x i8] c"/tmp/mmaptestXXXXXX\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_PRIVATE = global i32 0
@MAP_ANONYMOUS = global i32 0
@MAP_FAILED = global i8* null
@.str.1 = [22 x i8] c"anonymous mmap failed\00"
@.str.2 = [15 x i8] c"mkstemp failed\00"
@.str.3 = [17 x i8] c"ftruncate failed\00"
@.str.4 = [12 x i8] c"mmap failed\00"
@.str.5 = [14 x i8] c"malloc failed\00"
@.str.6 = [12 x i8] c"sbrk failed\00"
@.str.8 = [28 x i8] c"Slept for a total of %d s.\0A\00"
@stdout = global i32 0
@str = [26 x i8] c"MODE must be 0, 1, 2 or 3\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [20 x i8]
%4 = icmp slt i32 %0, 3
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = load i8*, i8** %1
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([133 x i8], [133 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %76
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @atoi(i8* %10)
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = tail call i64 @atol(i8* %13)
%15 = shl nsw i64 %14, 20
%16 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
switch i32 %11, label %60 [
i32 0, label %17
i32 1, label %29
i32 2, label %50
i32 3, label %55
]
17: ; preds = %8
%18 = load i32, i32* @PROT_READ
%19 = load i32, i32* @PROT_WRITE
%20 = or i32 %19, %18
%21 = load i32, i32* @MAP_PRIVATE
%22 = load i32, i32* @MAP_ANONYMOUS
%23 = or i32 %22, %21
%24 = tail call i8* @mmap(i32* null, i64 %15, i32 %20, i32 %23, i32 -1, i32 0)
%25 = load i8*, i8** @MAP_FAILED
%26 = icmp eq i8* %24, %25
br i1 %26, label %27, label %62
27: ; preds = %17
%28 = tail call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %74
29: ; preds = %8
%30 = call i32 @mkstemp(i8* %16)
%31 = icmp eq i32 %30, -1
br i1 %31, label %32, label %34
32: ; preds = %29
%33 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %74
34: ; preds = %29
%35 = call i32 @unlink(i8* %16)
%36 = call i32 @ftruncate(i32 %30, i64 %15)
%37 = icmp eq i32 %36, -1
br i1 %37, label %38, label %40
38: ; preds = %34
%39 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %74
40: ; preds = %34
%41 = load i32, i32* @PROT_READ
%42 = load i32, i32* @PROT_WRITE
%43 = or i32 %42, %41
%44 = load i32, i32* @MAP_PRIVATE
%45 = call i8* @mmap(i32* null, i64 %15, i32 %43, i32 %44, i32 %30, i32 0)
%46 = load i8*, i8** @MAP_FAILED
%47 = icmp eq i8* %45, %46
br i1 %47, label %48, label %62
48: ; preds = %40
%49 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
br label %74
50: ; preds = %8
%51 = tail call i8* @malloc(i64 %15)
%52 = icmp eq i8* %51, null
br i1 %52, label %53, label %62
53: ; preds = %50
%54 = tail call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
br label %74
55: ; preds = %8
%56 = tail call i8* @sbrk(i64 %15)
%57 = icmp eq i8* %56, inttoptr (i64 -1 to i8*)
br i1 %57, label %58, label %62
58: ; preds = %55
%59 = tail call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
br label %74
60: ; preds = %8
%61 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
br label %74
62: ; preds = %55, %50, %40, %17
%63 = phi i8* [ %56, %55 ], [ %51, %50 ], [ %45, %40 ], [ %24, %17 ]
%64 = call i32 @sleep(i32 2)
%65 = call i32 @memset(i8* %63, i32 42, i64 %15)
%66 = call i32 (...) @print_memstat()
br label %67
67: ; preds = %67, %62
%68 = phi i32 [ 0, %62 ], [ %70, %67 ]
%69 = call i32 @sleep(i32 5)
%70 = add nuw nsw i32 %68, 5
%71 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0), i32 %70)
%72 = load i32, i32* @stdout
%73 = call i32 @fflush(i32 %72)
br label %67
74: ; preds = %60, %58, %53, %48, %38, %32, %27
%75 = phi i32 [ 0, %60 ], [ 1, %58 ], [ 1, %53 ], [ 1, %32 ], [ 1, %38 ], [ 1, %48 ], [ 1, %27 ]
br label %76
76: ; preds = %74, %5
%77 = phi i32 [ 0, %5 ], [ %75, %74 ]
ret i32 %77
}