#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 */
typedef int /*<<< orphan*/ buffers;

/* Variables and functions */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ free(void *);
void *malloc(int);
int /*<<< orphan*/ memset(void *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int const rand();
int /*<<< orphan*/ usleep(int);
int main() {
  printf("Approximate configured runtime is %d seconds.\n", 600);
  const int LOOP_COUNT = 600 * 1000 / 2 / 5;
  const int BUFFER_FILL_RANGE = 8192 - 4096;
  const int PERIODIC_CHUNK_RANGE = 200 - 40;
  int i, sz, idx, allocatedBuffers = 0;
  void *buffers[5000];
  void *preloadChunks[2000];
  memset(buffers, 0, sizeof(buffers));
  printf("Starting test...\n");
  for (i = 0; i < LOOP_COUNT; i++) {
    if (i < 2000) {
      preloadChunks[i] = malloc(65536);
      memset(preloadChunks[i], 0, 65536);
    } else if (i == 2000) {
      printf("Finished preloading long-lived chunks.\n");
    }
    if (i % 4 == 0 && allocatedBuffers > 0) {
      idx = rand() % 5000;
      if (buffers[idx]) {
        free(buffers[idx]);
        buffers[idx] = NULL;
        allocatedBuffers--;
      }
    }
    idx = rand() % 5000;
    if (buffers[idx]) {
      free(buffers[idx]);
    } else {
      allocatedBuffers++;
    }
    sz = 4096 + (rand() % BUFFER_FILL_RANGE);
    buffers[idx] = malloc(sz > 2097152 ? sz : 2097152);
    memset(buffers[idx], 0, sz);
    if (i % (5 * 200) == 0) {
      printf("Progress - %f, fill ratio - %f\n", (double)i / (double)LOOP_COUNT,
             (double)allocatedBuffers / (double)5000);
    }
    usleep(5000);
  }
  printf("Draining remaining buffers...\n");
  for (i = 0; i < 5000; i++) {
    if (buffers[i]) {
      free(buffers[i]);
    }
  }
  printf("Starting quiesced period...\n");
  for (i = 0; i < LOOP_COUNT; i++) {
    sz = 40 + (rand() % PERIODIC_CHUNK_RANGE);
    void *periodicChunk = malloc(sz);
    memset(periodicChunk, 0, sz);
    usleep(100);
    free(periodicChunk);
    usleep(5000 - 100);
    if (i % (5 * 200) == 0) {
      printf("Progress - %f\n", (double)i / (double)LOOP_COUNT);
    }
  }
  printf("Freeing long-lived chunks...\n");
  for (i = 0; i < 2000; i++) {
    free(preloadChunks[i]);
  }
  printf("Test finished.\n");
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xdaf0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe87(%rip),%rdi
mov    $0x258,%esi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xea60,-0x8(%rbp)
movl   $0x1000,-0xc(%rbp)
movl   $0xa0,-0x10(%rbp)
movl   $0x0,-0x20(%rbp)
lea    -0x9c60(%rbp),%rdi
xor    %esi,%esi
mov    $0x9c40,%edx
call   1050 <memset@plt>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0xea60,-0x14(%rbp)
jge    13ce <main+0x25e>
cmpl   $0x7d0,-0x14(%rbp)
jge    1229 <main+0xb9>
mov    $0x10000,%edi
call   1060 <malloc@plt>
mov    %rax,%rcx
movslq -0x14(%rbp),%rax
mov    %rcx,-0xdae0(%rbp,%rax,8)
ff
movslq -0x14(%rbp),%rax
mov    -0xdae0(%rbp,%rax,8),%rdi
ff
xor    %esi,%esi
mov    $0x10000,%edx
call   1050 <memset@plt>
jmp    1249 <main+0xd9>
cmpl   $0x7d0,-0x14(%rbp)
jne    1244 <main+0xd4>
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1249 <main+0xd9>
mov    -0x14(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    12bb <main+0x14b>
cmpl   $0x0,-0x20(%rbp)
jle    12bb <main+0x14b>
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0x1388,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
cmpq   $0x0,-0x9c60(%rbp,%rax,8)
je     12b6 <main+0x146>
movslq -0x1c(%rbp),%rax
mov    -0x9c60(%rbp,%rax,8),%rdi
ff
call   1030 <free@plt>
movslq -0x1c(%rbp),%rax
movq   $0x0,-0x9c60(%rbp,%rax,8)
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
jmp    12bb <main+0x14b>
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0x1388,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
cmpq   $0x0,-0x9c60(%rbp,%rax,8)
je     12f6 <main+0x186>
movslq -0x1c(%rbp),%rax
mov    -0x9c60(%rbp,%rax,8),%rdi
ff
call   1030 <free@plt>
jmp    12ff <main+0x18f>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0x1000,%ecx
cltd
idiv   %ecx
add    $0x1000,%edx
mov    %edx,-0x18(%rbp)
cmpl   $0x200000,-0x18(%rbp)
jle    1332 <main+0x1c2>
mov    -0x18(%rbp),%eax
mov    %eax,-0xdaec(%rbp)
jmp    1342 <main+0x1d2>
mov    $0x200000,%eax
mov    %eax,-0xdaec(%rbp)
jmp    1342 <main+0x1d2>
mov    -0xdaec(%rbp),%edi
call   1060 <malloc@plt>
mov    %rax,%rcx
movslq -0x1c(%rbp),%rax
mov    %rcx,-0x9c60(%rbp,%rax,8)
ff
movslq -0x1c(%rbp),%rax
mov    -0x9c60(%rbp,%rax,8),%rdi
ff
mov    -0x18(%rbp),%edx
xor    %esi,%esi
call   1050 <memset@plt>
mov    -0x14(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    13b6 <main+0x246>
cvtsi2sdl -0x14(%rbp),%xmm0
movsd  0xc6d(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsi2sdl -0x20(%rbp),%xmm1
movsd  0xc64(%rip),%xmm2
divsd  %xmm2,%xmm1
lea    0xcca(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    $0x1388,%edi
call   1090 <usleep@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11d9 <main+0x69>
lea    0xcc4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x1388,-0x14(%rbp)
jge    1427 <main+0x2b7>
movslq -0x14(%rbp),%rax
cmpq   $0x0,-0x9c60(%rbp,%rax,8)
je     1414 <main+0x2a4>
movslq -0x14(%rbp),%rax
mov    -0x9c60(%rbp,%rax,8),%rdi
ff
call   1030 <free@plt>
jmp    1419 <main+0x2a9>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    13e3 <main+0x273>
lea    0xc8a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0xea60,-0x14(%rbp)
jge    14e4 <main+0x374>
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0xa0,%ecx
cltd
idiv   %ecx
add    $0x28,%edx
mov    %edx,-0x18(%rbp)
mov    -0x18(%rbp),%edi
call   1060 <malloc@plt>
mov    %rax,-0xdae8(%rbp)
mov    -0xdae8(%rbp),%rdi
mov    -0x18(%rbp),%edx
xor    %esi,%esi
call   1050 <memset@plt>
mov    $0x64,%edi
call   1090 <usleep@plt>
mov    -0xdae8(%rbp),%rdi
call   1030 <free@plt>
mov    $0x1324,%edi
call   1090 <usleep@plt>
mov    -0x14(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    14d1 <main+0x361>
cvtsi2sdl -0x14(%rbp),%xmm0
movsd  0xb41(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xc0b(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    14d6 <main+0x366>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    143c <main+0x2cc>
lea    0xbf9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x7d0,-0x14(%rbp)
jge    1525 <main+0x3b5>
movslq -0x14(%rbp),%rax
mov    -0xdae0(%rbp,%rax,8),%rdi
ff
call   1030 <free@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    14f9 <main+0x389>
lea    0xbd6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xdad8,%rsp
lea    0xe80(%rip),%rdi
mov    $0x258,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
mov    $0x9c40,%edx
call   1060 <memset@plt>
lea    0xeba(%rip),%rdi
call   1040 <puts@plt>
xor    %r12d,%r12d
xor    %ebx,%ebx
xor    %r13d,%r13d
jmp    11ef <main+0x6f>
nopl   0x0(%rax,%rax,1)
mov    $0x1388,%edi
call   10a0 <usleep@plt>
add    $0x1,%rbx
add    $0xffffffff,%r12d
cmp    $0xea60,%rbx
je     135e <main+0x1de>
movzwl %bx,%eax
shr    $0x3,%eax
imul   $0x20c5,%eax,%ebp
shr    $0x14,%ebp
cmp    $0x7cf,%rbx
ja     1230 <main+0xb0>
mov    $0x10000,%edi
call   1070 <malloc@plt>
mov    %rax,0x9c50(%rsp,%rbx,8)
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x10000,%edx
call   1060 <memset@plt>
jmp    1245 <main+0xc5>
nopw   0x0(%rax,%rax,1)
cmp    $0x7d0,%rbx
jne    1245 <main+0xc5>
lea    0xead(%rip),%rdi
call   1040 <puts@plt>
imul   $0x3e8,%ebp,%r14d
test   $0x3,%bl
jne    129a <main+0x11a>
test   %r13d,%r13d
jle    129a <main+0x11a>
xor    %eax,%eax
call   1090 <rand@plt>
cltq
imul   $0x68db8bad,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x2b,%rcx
add    %edx,%ecx
imul   $0x1388,%ecx,%ecx
sub    %ecx,%eax
movslq %eax,%rbp
mov    0x10(%rsp,%rbp,8),%rdi
test   %rdi,%rdi
je     129a <main+0x11a>
call   1030 <free@plt>
movq   $0x0,0x10(%rsp,%rbp,8)
add    $0xffffffff,%r13d
add    %r12d,%r14d
xor    %eax,%eax
call   1090 <rand@plt>
cltq
imul   $0x68db8bad,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x2b,%rcx
add    %edx,%ecx
imul   $0x1388,%ecx,%ecx
sub    %ecx,%eax
movslq %eax,%r15
mov    0x10(%rsp,%r15,8),%rdi
test   %rdi,%rdi
je     12e0 <main+0x160>
call   1030 <free@plt>
jmp    12e4 <main+0x164>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r13d
xor    %eax,%eax
call   1090 <rand@plt>
lea    0xfff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xfffff000,%ecx
neg    %ecx
lea    (%rax,%rcx,1),%ebp
add    $0x1000,%ebp
mov    $0x200000,%edi
call   1070 <malloc@plt>
mov    %rax,0x10(%rsp,%r15,8)
mov    %rax,%rdi
xor    %esi,%esi
mov    %ebp,%edx
call   1060 <memset@plt>
test   %r14w,%r14w
jne    11d0 <main+0x50>
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
divsd  0xcc5(%rip),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %r13d,%xmm1
divsd  0xcbd(%rip),%xmm1
lea    0xcf5(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
jmp    11d0 <main+0x50>
lea    0xd22(%rip),%rdi
call   1040 <puts@plt>
xor    %ebx,%ebx
jmp    137d <main+0x1fd>
xchg   %ax,%ax
add    $0x1,%rbx
cmp    $0x1388,%rbx
je     138e <main+0x20e>
mov    0x10(%rsp,%rbx,8),%rdi
test   %rdi,%rdi
je     1370 <main+0x1f0>
call   1030 <free@plt>
jmp    1370 <main+0x1f0>
lea    0xd10(%rip),%rdi
call   1040 <puts@plt>
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0xcbc(%rip),%r14
xor    %r15d,%r15d
xor    %r12d,%r12d
jmp    13e9 <main+0x269>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  0x8(%rsp),%xmm0
addsd  0xc42(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
add    $0xffffffff,%r12d
add    $0x1,%r15d
cmp    $0xffff15a0,%r12d
je     1484 <main+0x304>
movzwl %r15w,%eax
shr    $0x3,%eax
imul   $0x20c5,%eax,%eax
shr    $0x14,%eax
imul   $0xfffffc18,%eax,%r13d
xor    %eax,%eax
call   1090 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
shl    $0x5,%ecx
lea    (%rcx,%rcx,4),%ecx
neg    %ecx
lea    (%rax,%rcx,1),%ebp
add    $0x28,%ebp
mov    %ebp,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
mov    %ebp,%edx
call   1060 <memset@plt>
mov    $0x64,%edi
call   10a0 <usleep@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0x1324,%edi
call   10a0 <usleep@plt>
cmp    %r12w,%r13w
jne    13c0 <main+0x240>
movsd  0x8(%rsp),%xmm0
divsd  0xb8b(%rip),%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
jmp    13c0 <main+0x240>
lea    0xc36(%rip),%rdi
call   1040 <puts@plt>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x9c50(%rsp,%rbx,8),%rdi
call   1030 <free@plt>
add    $0x1,%rbx
cmp    $0x7d0,%rbx
jne    14a0 <main+0x320>
lea    0xc1d(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [47 x i8] c"Approximate configured runtime is %d seconds.\0A\00"
@.str.1 = [18 x i8] c"Starting test...\0A\00"
@.str.2 = [40 x i8] c"Finished preloading long-lived chunks.\0A\00"
@.str.3 = [32 x i8] c"Progress - %f, fill ratio - %f\0A\00"
@.str.4 = [31 x i8] c"Draining remaining buffers...\0A\00"
@.str.5 = [29 x i8] c"Starting quiesced period...\0A\00"
@.str.6 = [15 x i8] c"Progress - %f\0A\00"
@.str.7 = [30 x i8] c"Freeing long-lived chunks...\0A\00"
@.str.8 = [16 x i8] c"Test finished.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [5000 x i8*]
%10 = alloca [2000 x i8*]
%11 = alloca i8*
store i32 0, i32* %1
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 600)
store i32 60000, i32* %2
store i32 4096, i32* %3
store i32 160, i32* %4
store i32 0, i32* %8
%13 = getelementptr inbounds [5000 x i8*], [5000 x i8*]* %9, i64 0, i64 0
%14 = bitcast i8** %13 to i8*
%15 = call i32 @memset(i8* %14, i32 0, i32 40000)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %5
br label %17
17: ; preds = %117, %0
%18 = load i32, i32* %5
%19 = icmp slt i32 %18, 60000
br i1 %19, label %20, label %120
20: ; preds = %17
%21 = load i32, i32* %5
%22 = icmp slt i32 %21, 2000
br i1 %22, label %23, label %33
23: ; preds = %20
%24 = call i8* @malloc(i32 65536)
%25 = load i32, i32* %5
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [2000 x i8*], [2000 x i8*]* %10, i64 0, i64 %26
store i8* %24, i8** %27
%28 = load i32, i32* %5
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [2000 x i8*], [2000 x i8*]* %10, i64 0, i64 %29
%31 = load i8*, i8** %30
%32 = call i32 @memset(i8* %31, i32 0, i32 65536)
br label %39
33: ; preds = %20
%34 = load i32, i32* %5
%35 = icmp eq i32 %34, 2000
br i1 %35, label %36, label %38
36: ; preds = %33
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
br label %38
38: ; preds = %36, %33
br label %39
39: ; preds = %38, %23
%40 = load i32, i32* %5
%41 = srem i32 %40, 4
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %66
43: ; preds = %39
%44 = load i32, i32* %8
%45 = icmp sgt i32 %44, 0
br i1 %45, label %46, label %66
46: ; preds = %43
%47 = call i32 (...) @rand()
%48 = srem i32 %47, 5000
store i32 %48, i32* %7
%49 = load i32, i32* %7
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [5000 x i8*], [5000 x i8*]* %9, i64 0, i64 %50
%52 = load i8*, i8** %51
%53 = icmp ne i8* %52, null
br i1 %53, label %54, label %65
54: ; preds = %46
%55 = load i32, i32* %7
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [5000 x i8*], [5000 x i8*]* %9, i64 0, i64 %56
%58 = load i8*, i8** %57
%59 = call i32 @free(i8* %58)
%60 = load i32, i32* %7
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [5000 x i8*], [5000 x i8*]* %9, i64 0, i64 %61
store i8* null, i8** %62
%63 = load i32, i32* %8
%64 = add nsw i32 %63, -1
store i32 %64, i32* %8
br label %65
65: ; preds = %54, %46
br label %66
66: ; preds = %65, %43, %39
%67 = call i32 (...) @rand()
%68 = srem i32 %67, 5000
store i32 %68, i32* %7
%69 = load i32, i32* %7
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [5000 x i8*], [5000 x i8*]* %9, i64 0, i64 %70
%72 = load i8*, i8** %71
%73 = icmp ne i8* %72, null
br i1 %73, label %74, label %80
74: ; preds = %66
%75 = load i32, i32* %7
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds [5000 x i8*], [5000 x i8*]* %9, i64 0, i64 %76
%78 = load i8*, i8** %77
%79 = call i32 @free(i8* %78)
br label %83
80: ; preds = %66
%81 = load i32, i32* %8
%82 = add nsw i32 %81, 1
store i32 %82, i32* %8
br label %83
83: ; preds = %80, %74
%84 = call i32 (...) @rand()
%85 = srem i32 %84, 4096
%86 = add nsw i32 4096, %85
store i32 %86, i32* %6
%87 = load i32, i32* %6
%88 = icmp sgt i32 %87, 2097152
br i1 %88, label %89, label %91
89: ; preds = %83
%90 = load i32, i32* %6
br label %92
91: ; preds = %83
br label %92
92: ; preds = %91, %89
%93 = phi i32 [ %90, %89 ], [ 2097152, %91 ]
%94 = call i8* @malloc(i32 %93)
%95 = load i32, i32* %7
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds [5000 x i8*], [5000 x i8*]* %9, i64 0, i64 %96
store i8* %94, i8** %97
%98 = load i32, i32* %7
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds [5000 x i8*], [5000 x i8*]* %9, i64 0, i64 %99
%101 = load i8*, i8** %100
%102 = load i32, i32* %6
%103 = call i32 @memset(i8* %101, i32 0, i32 %102)
%104 = load i32, i32* %5
%105 = srem i32 %104, 1000
%106 = icmp eq i32 %105, 0
br i1 %106, label %107, label %115
107: ; preds = %92
%108 = load i32, i32* %5
%109 = sitofp i32 %108 to double
%110 = fdiv double %109, 6.000000e+04
%111 = load i32, i32* %8
%112 = sitofp i32 %111 to double
%113 = fdiv double %112, 5.000000e+03
%114 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), double %110, double %113)
br label %115
115: ; preds = %107, %92
%116 = call i32 @usleep(i32 5000)
br label %117
117: ; preds = %115
%118 = load i32, i32* %5
%119 = add nsw i32 %118, 1
store i32 %119, i32* %5
br label %17
120: ; preds = %17
%121 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %5
br label %122
122: ; preds = %138, %120
%123 = load i32, i32* %5
%124 = icmp slt i32 %123, 5000
br i1 %124, label %125, label %141
125: ; preds = %122
%126 = load i32, i32* %5
%127 = sext i32 %126 to i64
%128 = getelementptr inbounds [5000 x i8*], [5000 x i8*]* %9, i64 0, i64 %127
%129 = load i8*, i8** %128
%130 = icmp ne i8* %129, null
br i1 %130, label %131, label %137
131: ; preds = %125
%132 = load i32, i32* %5
%133 = sext i32 %132 to i64
%134 = getelementptr inbounds [5000 x i8*], [5000 x i8*]* %9, i64 0, i64 %133
%135 = load i8*, i8** %134
%136 = call i32 @free(i8* %135)
br label %137
137: ; preds = %131, %125
br label %138
138: ; preds = %137
%139 = load i32, i32* %5
%140 = add nsw i32 %139, 1
store i32 %140, i32* %5
br label %122
141: ; preds = %122
%142 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %5
br label %143
143: ; preds = %168, %141
%144 = load i32, i32* %5
%145 = icmp slt i32 %144, 60000
br i1 %145, label %146, label %171
146: ; preds = %143
%147 = call i32 (...) @rand()
%148 = srem i32 %147, 160
%149 = add nsw i32 40, %148
store i32 %149, i32* %6
%150 = load i32, i32* %6
%151 = call i8* @malloc(i32 %150)
store i8* %151, i8** %11
%152 = load i8*, i8** %11
%153 = load i32, i32* %6
%154 = call i32 @memset(i8* %152, i32 0, i32 %153)
%155 = call i32 @usleep(i32 100)
%156 = load i8*, i8** %11
%157 = call i32 @free(i8* %156)
%158 = call i32 @usleep(i32 4900)
%159 = load i32, i32* %5
%160 = srem i32 %159, 1000
%161 = icmp eq i32 %160, 0
br i1 %161, label %162, label %167
162: ; preds = %146
%163 = load i32, i32* %5
%164 = sitofp i32 %163 to double
%165 = fdiv double %164, 6.000000e+04
%166 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), double %165)
br label %167
167: ; preds = %162, %146
br label %168
168: ; preds = %167
%169 = load i32, i32* %5
%170 = add nsw i32 %169, 1
store i32 %170, i32* %5
br label %143
171: ; preds = %143
%172 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %5
br label %173
173: ; preds = %182, %171
%174 = load i32, i32* %5
%175 = icmp slt i32 %174, 2000
br i1 %175, label %176, label %185
176: ; preds = %173
%177 = load i32, i32* %5
%178 = sext i32 %177 to i64
%179 = getelementptr inbounds [2000 x i8*], [2000 x i8*]* %10, i64 0, i64 %178
%180 = load i8*, i8** %179
%181 = call i32 @free(i8* %180)
br label %182
182: ; preds = %176
%183 = load i32, i32* %5
%184 = add nsw i32 %183, 1
store i32 %184, i32* %5
br label %173
185: ; preds = %173
%186 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0))
%187 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [47 x i8] c"Approximate configured runtime is %d seconds.\0A\00"
@.str.3 = [32 x i8] c"Progress - %f, fill ratio - %f\0A\00"
@.str.6 = [15 x i8] c"Progress - %f\0A\00"
@str = [17 x i8] c"Starting test...\00"
@str.9 = [30 x i8] c"Draining remaining buffers...\00"
@str.10 = [28 x i8] c"Starting quiesced period...\00"
@str.11 = [29 x i8] c"Freeing long-lived chunks...\00"
@str.12 = [15 x i8] c"Test finished.\00"
@str.13 = [39 x i8] c"Finished preloading long-lived chunks.\00"
define i32 @main() {
%1 = alloca [5000 x i8*]
%2 = alloca [2000 x i8*]
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 600)
%4 = bitcast [5000 x i8*]* %1 to i8*
%5 = bitcast [2000 x i8*]* %2 to i8*
%6 = call i32 @memset(i8* %4, i32 0, i32 40000)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
br label %8
8: ; preds = %0, %64
%9 = phi i64 [ 0, %0 ], [ %66, %64 ]
%10 = phi i32 [ 0, %0 ], [ %49, %64 ]
%11 = trunc i64 %9 to i32
%12 = icmp ult i64 %9, 2000
br i1 %12, label %13, label %17
13: ; preds = %8
%14 = call dereferenceable_or_null(65536) i8* @malloc(i32 65536)
%15 = getelementptr inbounds [2000 x i8*], [2000 x i8*]* %2, i64 0, i64 %9
store i8* %14, i8** %15
%16 = call i32 @memset(i8* %14, i32 0, i32 65536)
br label %21
17: ; preds = %8
%18 = icmp eq i64 %9, 2000
br i1 %18, label %19, label %21
19: ; preds = %17
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.13, i64 0, i64 0))
br label %21
21: ; preds = %17, %19, %13
%22 = and i32 %11, 3
%23 = icmp eq i32 %22, 0
%24 = icmp sgt i32 %10, 0
%25 = select i1 %23, i1 %24, i1 false
br i1 %25, label %26, label %36
26: ; preds = %21
%27 = call i32 (...) @rand()
%28 = srem i32 %27, 5000
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [5000 x i8*], [5000 x i8*]* %1, i64 0, i64 %29
%31 = load i8*, i8** %30
%32 = icmp eq i8* %31, null
br i1 %32, label %36, label %33
33: ; preds = %26
%34 = call i32 @free(i8* %31)
store i8* null, i8** %30
%35 = add nsw i32 %10, -1
br label %36
36: ; preds = %26, %33, %21
%37 = phi i32 [ %35, %33 ], [ %10, %26 ], [ %10, %21 ]
%38 = call i32 (...) @rand()
%39 = srem i32 %38, 5000
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [5000 x i8*], [5000 x i8*]* %1, i64 0, i64 %40
%42 = load i8*, i8** %41
%43 = icmp eq i8* %42, null
br i1 %43, label %46, label %44
44: ; preds = %36
%45 = call i32 @free(i8* %42)
br label %48
46: ; preds = %36
%47 = add nsw i32 %37, 1
br label %48
48: ; preds = %46, %44
%49 = phi i32 [ %37, %44 ], [ %47, %46 ]
%50 = call i32 (...) @rand()
%51 = srem i32 %50, 4096
%52 = add nsw i32 %51, 4096
%53 = call dereferenceable_or_null(2097152) i8* @malloc(i32 2097152)
store i8* %53, i8** %41
%54 = call i32 @memset(i8* %53, i32 0, i32 %52)
%55 = trunc i64 %9 to i16
%56 = urem i16 %55, 1000
%57 = icmp eq i16 %56, 0
br i1 %57, label %58, label %64
58: ; preds = %48
%59 = sitofp i32 %11 to double
%60 = fdiv double %59, 6.000000e+04
%61 = sitofp i32 %49 to double
%62 = fdiv double %61, 5.000000e+03
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), double %60, double %62)
br label %64
64: ; preds = %58, %48
%65 = call i32 @usleep(i32 5000)
%66 = add nuw nsw i64 %9, 1
%67 = icmp eq i64 %66, 60000
br i1 %67, label %68, label %8
68: ; preds = %64
%69 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.9, i64 0, i64 0))
br label %70
70: ; preds = %68, %77
%71 = phi i64 [ 0, %68 ], [ %78, %77 ]
%72 = getelementptr inbounds [5000 x i8*], [5000 x i8*]* %1, i64 0, i64 %71
%73 = load i8*, i8** %72
%74 = icmp eq i8* %73, null
br i1 %74, label %77, label %75
75: ; preds = %70
%76 = call i32 @free(i8* %73)
br label %77
77: ; preds = %70, %75
%78 = add nuw nsw i64 %71, 1
%79 = icmp eq i64 %78, 5000
br i1 %79, label %80, label %70
80: ; preds = %77
%81 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.10, i64 0, i64 0))
br label %82
82: ; preds = %80, %99
%83 = phi i32 [ 0, %80 ], [ %100, %99 ]
%84 = call i32 (...) @rand()
%85 = srem i32 %84, 160
%86 = add nsw i32 %85, 40
%87 = call i8* @malloc(i32 %86)
%88 = call i32 @memset(i8* %87, i32 0, i32 %86)
%89 = call i32 @usleep(i32 100)
%90 = call i32 @free(i8* %87)
%91 = call i32 @usleep(i32 4900)
%92 = trunc i32 %83 to i16
%93 = urem i16 %92, 1000
%94 = icmp eq i16 %93, 0
br i1 %94, label %95, label %99
95: ; preds = %82
%96 = sitofp i32 %83 to double
%97 = fdiv double %96, 6.000000e+04
%98 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), double %97)
br label %99
99: ; preds = %95, %82
%100 = add nuw nsw i32 %83, 1
%101 = icmp eq i32 %100, 60000
br i1 %101, label %102, label %82
102: ; preds = %99
%103 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.11, i64 0, i64 0))
br label %104
104: ; preds = %102, %104
%105 = phi i64 [ 0, %102 ], [ %109, %104 ]
%106 = getelementptr inbounds [2000 x i8*], [2000 x i8*]* %2, i64 0, i64 %105
%107 = load i8*, i8** %106
%108 = call i32 @free(i8* %107)
%109 = add nuw nsw i64 %105, 1
%110 = icmp eq i64 %109, 2000
br i1 %110, label %111, label %104
111: ; preds = %104
%112 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.12, i64 0, i64 0))
%113 = call i32 @exit(i32 0)
unreachable
}