int main() {
  int rounds;
  int counter = 0;
  for (rounds = 0; rounds < 5; rounds++) {
    int i;
    printf("Round %d\n", rounds);
    printf("Allocating 4M chars...\n");
    char **x = (char **)malloc(4 * 1024 * 1024 * sizeof(char *));
    for (i = 0; i < 4 * 1024 * 1024; i++) {
      x[i] = (char *)malloc(1);
      counter++;
      if (!x[i]) {
        printf("Failed after %d iterations\n", counter);
        return -1;
      }
    }
    for (i = 0; i < 4 * 1024 * 1024; i++) {
      free(x[i]);
    }
    free(x);
    printf("Allocating 2M ints...\n");
    int **y = (int **)malloc(2 * 1024 * 1024 * sizeof(char *));
    for (i = 0; i < 2 * 1024 * 1024; i++) {
      y[i] = (int *)malloc(sizeof(int));
      counter++;
      if (!y[i]) {
        printf("Failed after %d iterations\n", counter);
        return -1;
      }
    }
    for (i = 0; i < 2 * 1024 * 1024; i++) {
      free(y[i]);
    }
    free(y);
    printf("Allocating 1M random sizes...\n");
    char **z = (char **)malloc(1024 * 1024 * sizeof(char *));
    for (i = 0; i < 1024 * 1024; i++) {
      z[i] = (char *)malloc(sizeof(char) * (rand() % 5) + 1);
      counter++;
      if (!z[i]) {
        printf("Failed after %d iterations\n", counter);
        return -1;
      }
    }
    for (i = 0; i < 1024 * 1024; i++) {
      free(z[i]);
    }
    free(z);
  }
  printf("Leave 16M residue behind\n");
  char *bla = malloc(16 * 1024 * 1024);
  *bla = 1;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    140e <main+0x2ce>
mov    -0x8(%rbp),%esi
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x2000000,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x400000,-0x10(%rbp)
jge    120d <main+0xcd>
mov    $0x1,%edi
call   1050 <malloc@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x10(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    11fa <main+0xba>
mov    -0xc(%rbp),%esi
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1438 <main+0x2f8>
jmp    11ff <main+0xbf>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    119b <main+0x5b>
movl   $0x0,-0x10(%rbp)
cmpl   $0x400000,-0x10(%rbp)
jge    1240 <main+0x100>
mov    -0x18(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1214 <main+0xd4>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1000000,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x200000,-0x10(%rbp)
jge    12de <main+0x19e>
mov    $0x4,%edi
call   1050 <malloc@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x10(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    12cb <main+0x18b>
mov    -0xc(%rbp),%esi
lea    0xd6a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1438 <main+0x2f8>
jmp    12d0 <main+0x190>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    126c <main+0x12c>
movl   $0x0,-0x10(%rbp)
cmpl   $0x200000,-0x10(%rbp)
jge    1311 <main+0x1d1>
mov    -0x20(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    12e5 <main+0x1a5>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
lea    0xd34(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x800000,%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x100000,-0x10(%rbp)
jge    13c4 <main+0x284>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x5,%ecx
cltd
idiv   %ecx
movslq %edx,%rdi
shl    $0x0,%rdi
add    $0x1,%rdi
call   1050 <malloc@plt>
mov    %rax,%rdx
mov    -0x28(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x10(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    13b1 <main+0x271>
mov    -0xc(%rbp),%esi
lea    0xc84(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1438 <main+0x2f8>
jmp    13b6 <main+0x276>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    133d <main+0x1fd>
movl   $0x0,-0x10(%rbp)
cmpl   $0x100000,-0x10(%rbp)
jge    13f7 <main+0x2b7>
mov    -0x28(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    13cb <main+0x28b>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    115d <main+0x1d>
lea    0xc5f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1000000,%edi
call   1050 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movb   $0x1,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0xff9fffff,%r14d
lea    0x200000(%r14),%r12
lea    0x600000(%r14),%r13
lea    0xe8a(%rip),%rdi
lea    0xec2(%rip),%rbx
xor    %r15d,%r15d
mov    %r15d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    $0x2000000,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x1,%edi
call   1060 <malloc@plt>
mov    %rax,(%rbx,%rbp,8)
test   %rax,%rax
je     1343 <main+0x1f3>
add    $0x1,%rbp
cmp    $0x400000,%rbp
jne    11b0 <main+0x60>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
mov    (%rbx,%rbp,8),%rdi
call   1030 <free@plt>
add    $0x1,%rbp
cmp    $0x400000,%rbp
jne    11e0 <main+0x90>
mov    %rbx,%rdi
call   1030 <free@plt>
lea    0xe51(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1000000,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    $0x4,%edi
call   1060 <malloc@plt>
mov    %rax,(%rbx,%rbp,8)
test   %rax,%rax
je     1348 <main+0x1f8>
add    $0x1,%rbp
cmp    $0x200000,%rbp
jne    1220 <main+0xd0>
mov    %r12,(%rsp)
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    (%rbx,%rbp,8),%rdi
call   1030 <free@plt>
add    $0x1,%rbp
cmp    $0x200000,%rbp
jne    1250 <main+0x100>
mov    %rbx,%rdi
call   1030 <free@plt>
lea    0xdf7(%rip),%rdi
call   1040 <puts@plt>
mov    $0x800000,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
xor    %r12d,%r12d
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%ecx
neg    %ecx
add    %ecx,%eax
add    $0x1,%eax
movslq %eax,%rdi
call   1060 <malloc@plt>
mov    %rax,(%rbx,%r12,8)
test   %rax,%rax
je     136f <main+0x21f>
add    $0x1,%r12
cmp    $0x100000,%r12
jne    1290 <main+0x140>
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    (%rbx,%rbp,8),%rdi
call   1030 <free@plt>
add    $0x1,%rbp
cmp    $0x100000,%rbp
jne    12e0 <main+0x190>
mov    %rbx,%rdi
call   1030 <free@plt>
add    $0x1,%r15d
add    $0xffffffffff900000,%r13
mov    (%rsp),%r12
add    $0xffffffffff900000,%r12
add    $0xffffffffff900000,%r14
cmp    $0x5,%r15d
lea    0xcda(%rip),%rdi
lea    0xd12(%rip),%rbx
jne    1180 <main+0x30>
lea    0xcec(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
jmp    1360 <main+0x210>
sub    %r13d,%ebp
jmp    134b <main+0x1fb>
sub    %r12d,%ebp
lea    0xcb8(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
sub    %r14d,%r12d
lea    0xc91(%rip),%rdi
mov    %r12d,%esi
jmp    1354 <main+0x204>

LLVM IR (-O0):
@.str = [10 x i8] c"Round %d\0A\00"
@.str.1 = [24 x i8] c"Allocating 4M chars...\0A\00"
@.str.2 = [28 x i8] c"Failed after %d iterations\0A\00"
@.str.3 = [23 x i8] c"Allocating 2M ints...\0A\00"
@.str.4 = [31 x i8] c"Allocating 1M random sizes...\0A\00"
@.str.5 = [26 x i8] c"Leave 16M residue behind\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32**
%7 = alloca i8**
%8 = alloca i8*
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %2
br label %9
9: ; preds = %151, %0
%10 = load i32, i32* %2
%11 = icmp slt i32 %10, 5
br i1 %11, label %12, label %154
12: ; preds = %9
%13 = load i32, i32* %2
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%16 = call i8* @malloc(i64 33554432)
%17 = bitcast i8* %16 to i8**
store i8** %17, i8*** %5
store i32 0, i32* %4
br label %18
18: ; preds = %39, %12
%19 = load i32, i32* %4
%20 = icmp slt i32 %19, 4194304
br i1 %20, label %21, label %42
21: ; preds = %18
%22 = call i8* @malloc(i64 1)
%23 = load i8**, i8*** %5
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8*, i8** %23, i64 %25
store i8* %22, i8** %26
%27 = load i32, i32* %3
%28 = add nsw i32 %27, 1
store i32 %28, i32* %3
%29 = load i8**, i8*** %5
%30 = load i32, i32* %4
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %29, i64 %31
%33 = load i8*, i8** %32
%34 = icmp ne i8* %33, null
br i1 %34, label %38, label %35
35: ; preds = %21
%36 = load i32, i32* %3
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %36)
store i32 -1, i32* %1
br label %158
38: ; preds = %21
br label %39
39: ; preds = %38
%40 = load i32, i32* %4
%41 = add nsw i32 %40, 1
store i32 %41, i32* %4
br label %18
42: ; preds = %18
store i32 0, i32* %4
br label %43
43: ; preds = %52, %42
%44 = load i32, i32* %4
%45 = icmp slt i32 %44, 4194304
br i1 %45, label %46, label %55
46: ; preds = %43
%47 = load i8**, i8*** %5
%48 = load i32, i32* %4
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8*, i8** %47, i64 %49
%51 = load i8*, i8** %50
br label %52
52: ; preds = %46
%53 = load i32, i32* %4
%54 = add nsw i32 %53, 1
store i32 %54, i32* %4
br label %43
55: ; preds = %43
%56 = load i8**, i8*** %5
%57 = bitcast i8** %56 to i8*
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%59 = call i8* @malloc(i64 16777216)
%60 = bitcast i8* %59 to i32**
store i32** %60, i32*** %6
store i32 0, i32* %4
br label %61
61: ; preds = %83, %55
%62 = load i32, i32* %4
%63 = icmp slt i32 %62, 2097152
br i1 %63, label %64, label %86
64: ; preds = %61
%65 = call i8* @malloc(i64 4)
%66 = bitcast i8* %65 to i32*
%67 = load i32**, i32*** %6
%68 = load i32, i32* %4
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i32*, i32** %67, i64 %69
store i32* %66, i32** %70
%71 = load i32, i32* %3
%72 = add nsw i32 %71, 1
store i32 %72, i32* %3
%73 = load i32**, i32*** %6
%74 = load i32, i32* %4
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds i32*, i32** %73, i64 %75
%77 = load i32*, i32** %76
%78 = icmp ne i32* %77, null
br i1 %78, label %82, label %79
79: ; preds = %64
%80 = load i32, i32* %3
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %80)
store i32 -1, i32* %1
br label %158
82: ; preds = %64
br label %83
83: ; preds = %82
%84 = load i32, i32* %4
%85 = add nsw i32 %84, 1
store i32 %85, i32* %4
br label %61
86: ; preds = %61
store i32 0, i32* %4
br label %87
87: ; preds = %97, %86
%88 = load i32, i32* %4
%89 = icmp slt i32 %88, 2097152
br i1 %89, label %90, label %100
90: ; preds = %87
%91 = load i32**, i32*** %6
%92 = load i32, i32* %4
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds i32*, i32** %91, i64 %93
%95 = load i32*, i32** %94
%96 = bitcast i32* %95 to i8*
br label %97
97: ; preds = %90
%98 = load i32, i32* %4
%99 = add nsw i32 %98, 1
store i32 %99, i32* %4
br label %87
100: ; preds = %87
%101 = load i32**, i32*** %6
%102 = bitcast i32** %101 to i8*
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
%104 = call i8* @malloc(i64 8388608)
%105 = bitcast i8* %104 to i8**
store i8** %105, i8*** %7
store i32 0, i32* %4
br label %106
106: ; preds = %132, %100
%107 = load i32, i32* %4
%108 = icmp slt i32 %107, 1048576
br i1 %108, label %109, label %135
109: ; preds = %106
%110 = call i32 (...) @rand()
%111 = srem i32 %110, 5
%112 = sext i32 %111 to i64
%113 = mul i64 1, %112
%114 = add i64 %113, 1
%115 = call i8* @malloc(i64 %114)
%116 = load i8**, i8*** %7
%117 = load i32, i32* %4
%118 = sext i32 %117 to i64
%119 = getelementptr inbounds i8*, i8** %116, i64 %118
store i8* %115, i8** %119
%120 = load i32, i32* %3
%121 = add nsw i32 %120, 1
store i32 %121, i32* %3
%122 = load i8**, i8*** %7
%123 = load i32, i32* %4
%124 = sext i32 %123 to i64
%125 = getelementptr inbounds i8*, i8** %122, i64 %124
%126 = load i8*, i8** %125
%127 = icmp ne i8* %126, null
br i1 %127, label %131, label %128
128: ; preds = %109
%129 = load i32, i32* %3
%130 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %129)
store i32 -1, i32* %1
br label %158
131: ; preds = %109
br label %132
132: ; preds = %131
%133 = load i32, i32* %4
%134 = add nsw i32 %133, 1
store i32 %134, i32* %4
br label %106
135: ; preds = %106
store i32 0, i32* %4
br label %136
136: ; preds = %145, %135
%137 = load i32, i32* %4
%138 = icmp slt i32 %137, 1048576
br i1 %138, label %139, label %148
139: ; preds = %136
%140 = load i8**, i8*** %7
%141 = load i32, i32* %4
%142 = sext i32 %141 to i64
%143 = getelementptr inbounds i8*, i8** %140, i64 %142
%144 = load i8*, i8** %143
br label %145
145: ; preds = %139
%146 = load i32, i32* %4
%147 = add nsw i32 %146, 1
store i32 %147, i32* %4
br label %136
148: ; preds = %136
%149 = load i8**, i8*** %7
%150 = bitcast i8** %149 to i8*
br label %151
151: ; preds = %148
%152 = load i32, i32* %2
%153 = add nsw i32 %152, 1
store i32 %153, i32* %2
br label %9
154: ; preds = %9
%155 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
%156 = call i8* @malloc(i64 16777216)
store i8* %156, i8** %8
%157 = load i8*, i8** %8
store i8 1, i8* %157
store i32 0, i32* %1
br label %158
158: ; preds = %154, %128, %79, %35
%159 = load i32, i32* %1
ret i32 %159
}

LLVM IR (-O2):
@.str = [10 x i8] c"Round %d\0A\00"
@.str.2 = [28 x i8] c"Failed after %d iterations\0A\00"
@str = [25 x i8] c"Leave 16M residue behind\00"
@str.6 = [23 x i8] c"Allocating 4M chars...\00"
@str.7 = [22 x i8] c"Allocating 2M ints...\00"
@str.8 = [30 x i8] c"Allocating 1M random sizes...\00"
define i32 @main() {
br label %1
1: ; preds = %0, %79
%2 = phi i32 [ 0, %0 ], [ %80, %79 ]
%3 = phi i32 [ 0, %0 ], [ %56, %79 ]
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %2)
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.6, i64 0, i64 0))
%6 = tail call dereferenceable_or_null(33554432) i8* @malloc(i64 33554432)
%7 = bitcast i8* %6 to i8**
%8 = add nuw nsw i32 %3, 4194304
br label %12
9: ; preds = %12
%10 = add nuw nsw i64 %13, 1
%11 = icmp eq i64 %10, 4194304
br i1 %11, label %21, label %12
12: ; preds = %1, %9
%13 = phi i64 [ 0, %1 ], [ %10, %9 ]
%14 = phi i32 [ %3, %1 ], [ %17, %9 ]
%15 = tail call dereferenceable_or_null(1) i8* @malloc(i64 1)
%16 = getelementptr inbounds i8*, i8** %7, i64 %13
store i8* %15, i8** %16
%17 = add nuw nsw i32 %14, 1
%18 = icmp eq i8* %15, null
br i1 %18, label %19, label %9
19: ; preds = %12
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %17)
br label %84
21: ; preds = %9, %21
%22 = phi i64 [ %25, %21 ], [ 0, %9 ]
%23 = getelementptr inbounds i8*, i8** %7, i64 %22
%24 = load i8*, i8** %23
tail call void @free(i8* %24)
%25 = add nuw nsw i64 %22, 1
%26 = icmp eq i64 %25, 4194304
br i1 %26, label %27, label %21
27: ; preds = %21
tail call void @free(i8* %6)
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.7, i64 0, i64 0))
%29 = tail call dereferenceable_or_null(16777216) i8* @malloc(i64 16777216)
%30 = bitcast i8* %29 to i32**
%31 = add nuw nsw i32 %3, 6291456
br label %35
32: ; preds = %35
%33 = add nuw nsw i64 %36, 1
%34 = icmp eq i64 %33, 2097152
br i1 %34, label %45, label %35
35: ; preds = %27, %32
%36 = phi i64 [ 0, %27 ], [ %33, %32 ]
%37 = phi i32 [ %8, %27 ], [ %41, %32 ]
%38 = tail call dereferenceable_or_null(4) i8* @malloc(i64 4)
%39 = getelementptr inbounds i32*, i32** %30, i64 %36
%40 = bitcast i32** %39 to i8**
store i8* %38, i8** %40
%41 = add nuw nsw i32 %37, 1
%42 = icmp eq i8* %38, null
br i1 %42, label %43, label %32
43: ; preds = %35
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %41)
br label %84
45: ; preds = %32, %45
%46 = phi i64 [ %50, %45 ], [ 0, %32 ]
%47 = getelementptr inbounds i32*, i32** %30, i64 %46
%48 = bitcast i32** %47 to i8**
%49 = load i8*, i8** %48
tail call void @free(i8* %49)
%50 = add nuw nsw i64 %46, 1
%51 = icmp eq i64 %50, 2097152
br i1 %51, label %52, label %45
52: ; preds = %45
tail call void @free(i8* %29)
%53 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.8, i64 0, i64 0))
%54 = tail call dereferenceable_or_null(8388608) i8* @malloc(i64 8388608)
%55 = bitcast i8* %54 to i8**
%56 = add nuw nsw i32 %3, 7340032
br label %60
57: ; preds = %60
%58 = add nuw nsw i64 %61, 1
%59 = icmp eq i64 %58, 1048576
br i1 %59, label %73, label %60
60: ; preds = %52, %57
%61 = phi i64 [ 0, %52 ], [ %58, %57 ]
%62 = phi i32 [ %31, %52 ], [ %69, %57 ]
%63 = tail call i32 (...) @rand()
%64 = srem i32 %63, 5
%65 = add nsw i32 %64, 1
%66 = sext i32 %65 to i64
%67 = tail call i8* @malloc(i64 %66)
%68 = getelementptr inbounds i8*, i8** %55, i64 %61
store i8* %67, i8** %68
%69 = add nuw nsw i32 %62, 1
%70 = icmp eq i8* %67, null
br i1 %70, label %71, label %57
71: ; preds = %60
%72 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %69)
br label %84
73: ; preds = %57, %73
%74 = phi i64 [ %77, %73 ], [ 0, %57 ]
%75 = getelementptr inbounds i8*, i8** %55, i64 %74
%76 = load i8*, i8** %75
tail call void @free(i8* %76)
%77 = add nuw nsw i64 %74, 1
%78 = icmp eq i64 %77, 1048576
br i1 %78, label %79, label %73
79: ; preds = %73
tail call void @free(i8* %54)
%80 = add nuw nsw i32 %2, 1
%81 = icmp eq i32 %80, 5
br i1 %81, label %82, label %1
82: ; preds = %79
%83 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
br label %84
84: ; preds = %71, %43, %19, %82
%85 = phi i32 [ 0, %82 ], [ -1, %19 ], [ -1, %43 ], [ -1, %71 ]
ret i32 %85
}