#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
void *malloc(int);
void *my_malloc(int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ setup(int, int, void *);
int main() {
  FILE *pFile;
  pFile = fopen("test5_output.txt", "w");
  int size;
  int RAM_SIZE = 1 << 20;
  void *RAM = malloc(RAM_SIZE);
  setup(3, RAM_SIZE, RAM);
  size = 240 * 1024;
  void *a = my_malloc(size);
  if ((int)a == -1)
    fprintf(pFile, "This size can not be allocated!");
  else {
    fprintf(pFile, "start of the chunk a: %f K\n",
            (float)((int)a - (int)RAM) / 1024);
    fprintf(pFile, "End of the chunk a: %f K\n\n",
            (float)((int)a + size - (int)RAM) / 1024);
  }
  size = 100 * 1024;
  void *b = my_malloc(size);
  if ((int)b == -1)
    fprintf(pFile, "This size can not be allocated!");
  else {
    fprintf(pFile, "start of the chunk b: %f K\n",
            (float)((int)b - (int)RAM) / 1024);
    fprintf(pFile, "End of the chunk b: %f K\n\n",
            (float)((int)b + size - (int)RAM) / 1024);
  }
  size = 240 * 1024;
  void *c = my_malloc(size);
  if ((int)c == -1)
    fprintf(pFile, "This size can not be allocated!");
  else {
    fprintf(pFile, "start of the chunk c: %f K\n",
            (float)((int)c - (int)RAM) / 1024);
    fprintf(pFile, "End of the chunk c: %f K\n\n",
            (float)((int)c + size - (int)RAM) / 1024);
  }
  size = 100 * 1024;
  void *d = my_malloc(size);
  if ((int)d == -1)
    fprintf(pFile, "This size can not be allocated!");
  else {
    fprintf(pFile, "start of the chunk d: %f K\n",
            (float)((int)d - (int)RAM) / 1024);
    fprintf(pFile, "End of the chunk d: %f K\n\n",
            (float)((int)d + size - (int)RAM) / 1024);
  }
  size = 100 * 1024;
  void *e = my_malloc(size);
  if ((int)e == -1)
    fprintf(pFile, "This size can not be allocated!");
  else {
    fprintf(pFile, "start of the chunk e: %f K\n",
            (float)((int)e - (int)RAM) / 1024);
    fprintf(pFile, "End of the chunk e: %f K\n\n",
            (float)((int)e + size - (int)RAM) / 1024);
  }
  size = 200 * 1024;
  void *f = my_malloc(size);
  if ((int)f == -1)
    fprintf(pFile, "This size can not be allocated!");
  else {
    fprintf(pFile, "start of the chunk f: %f K\n",
            (float)((int)f - (int)RAM) / 1024);
    fprintf(pFile, "End of the chunk f: %f K\n\n",
            (float)((int)f + size - (int)RAM) / 1024);
  }
  fclose(pFile);
  printf("Done: Output written to %s\n", "test5_output.txt");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe7e(%rip),%rdi
lea    0xe88(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
movl   $0x100000,-0x18(%rbp)
mov    -0x18(%rbp),%edi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    $0x3,%edi
call   1090 <setup@plt>
movl   $0x3c000,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <my_malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    $0xffffffff,%eax
jne    11f1 <main+0x81>
mov    -0x10(%rbp),%rdi
lea    0xe32(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    1254 <main+0xe4>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %ecx,%eax
cvtsi2ss %eax,%xmm0
movss  0xdf5(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe1d(%rip),%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rax
add    -0x14(%rbp),%eax
mov    -0x20(%rbp),%rcx
sub    %ecx,%eax
cvtsi2ss %eax,%xmm0
movss  0xdc2(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe06(%rip),%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
movl   $0x19000,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <my_malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    $0xffffffff,%eax
jne    128b <main+0x11b>
mov    -0x10(%rbp),%rdi
lea    0xd98(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    12ee <main+0x17e>
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %ecx,%eax
cvtsi2ss %eax,%xmm0
movss  0xd5b(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdba(%rip),%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rax
add    -0x14(%rbp),%eax
mov    -0x20(%rbp),%rcx
sub    %ecx,%eax
cvtsi2ss %eax,%xmm0
movss  0xd28(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xda3(%rip),%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
movl   $0x3c000,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <my_malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    $0xffffffff,%eax
jne    1325 <main+0x1b5>
mov    -0x10(%rbp),%rdi
lea    0xcfe(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    1388 <main+0x218>
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %ecx,%eax
cvtsi2ss %eax,%xmm0
movss  0xcc1(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd57(%rip),%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rax
add    -0x14(%rbp),%eax
mov    -0x20(%rbp),%rcx
sub    %ecx,%eax
cvtsi2ss %eax,%xmm0
movss  0xc8e(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd40(%rip),%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
movl   $0x19000,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <my_malloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
cmp    $0xffffffff,%eax
jne    13bf <main+0x24f>
mov    -0x10(%rbp),%rdi
lea    0xc64(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    1422 <main+0x2b2>
mov    -0x10(%rbp),%rdi
mov    -0x40(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %ecx,%eax
cvtsi2ss %eax,%xmm0
movss  0xc27(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xcf4(%rip),%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x40(%rbp),%rax
add    -0x14(%rbp),%eax
mov    -0x20(%rbp),%rcx
sub    %ecx,%eax
cvtsi2ss %eax,%xmm0
movss  0xbf4(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xcdd(%rip),%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
movl   $0x19000,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <my_malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
cmp    $0xffffffff,%eax
jne    1459 <main+0x2e9>
mov    -0x10(%rbp),%rdi
lea    0xbca(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    14bc <main+0x34c>
mov    -0x10(%rbp),%rdi
mov    -0x48(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %ecx,%eax
cvtsi2ss %eax,%xmm0
movss  0xb8d(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xc91(%rip),%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x48(%rbp),%rax
add    -0x14(%rbp),%eax
mov    -0x20(%rbp),%rcx
sub    %ecx,%eax
cvtsi2ss %eax,%xmm0
movss  0xb5a(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xc7a(%rip),%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
movl   $0x32000,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <my_malloc@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
cmp    $0xffffffff,%eax
jne    14f3 <main+0x383>
mov    -0x10(%rbp),%rdi
lea    0xb30(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    1556 <main+0x3e6>
mov    -0x10(%rbp),%rdi
mov    -0x50(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %ecx,%eax
cvtsi2ss %eax,%xmm0
movss  0xaf3(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xc2e(%rip),%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x50(%rbp),%rax
add    -0x14(%rbp),%eax
mov    -0x20(%rbp),%rcx
sub    %ecx,%eax
cvtsi2ss %eax,%xmm0
movss  0xac0(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xc17(%rip),%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xc1b(%rip),%rdi
lea    0xa97(%rip),%rsi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
lea    0xe78(%rip),%rdi
lea    0xe82(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r15
mov    $0x100000,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
mov    $0x3,%edi
mov    $0x100000,%esi
mov    %rax,%rdx
call   10a0 <setup@plt>
mov    $0x3c000,%edi
call   1030 <my_malloc@plt>
mov    %rax,%rbx
cmp    $0xffffffff,%ebx
je     121c <main+0x9c>
sub    %r14d,%ebx
cvtsi2ss %ebx,%xmm0
mulss  0xe25(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe51(%rip),%rsi
mov    %r15,%rdi
mov    $0x1,%al
call   1060 <fprintf@plt>
add    $0x3c000,%ebx
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
mulss  0xdfb(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe43(%rip),%rsi
mov    %r15,%rdi
mov    $0x1,%al
call   1060 <fprintf@plt>
jmp    1235 <main+0xb5>
lea    0xdf4(%rip),%rdi
mov    $0x1f,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1090 <fwrite@plt>
mov    $0x19000,%edi
call   1030 <my_malloc@plt>
mov    %rax,%rbx
cmp    $0xffffffff,%ebx
je     129a <main+0x11a>
sub    %r14d,%ebx
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
mulss  0xda7(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe0a(%rip),%rsi
mov    %r15,%rdi
mov    $0x1,%al
call   1060 <fprintf@plt>
add    $0x19000,%ebx
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
mulss  0xd7d(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdfc(%rip),%rsi
mov    %r15,%rdi
mov    $0x1,%al
call   1060 <fprintf@plt>
jmp    12b3 <main+0x133>
lea    0xd76(%rip),%rdi
mov    $0x1f,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1090 <fwrite@plt>
mov    $0x3c000,%edi
call   1030 <my_malloc@plt>
mov    %rax,%rbx
cmp    $0xffffffff,%ebx
je     1318 <main+0x198>
sub    %r14d,%ebx
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
mulss  0xd29(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdc3(%rip),%rsi
mov    %r15,%rdi
mov    $0x1,%al
call   1060 <fprintf@plt>
add    $0x3c000,%ebx
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
mulss  0xcff(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdb5(%rip),%rsi
mov    %r15,%rdi
mov    $0x1,%al
call   1060 <fprintf@plt>
jmp    1331 <main+0x1b1>
lea    0xcf8(%rip),%rdi
mov    $0x1f,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1090 <fwrite@plt>
mov    $0x19000,%edi
call   1030 <my_malloc@plt>
mov    %rax,%rbx
cmp    $0xffffffff,%ebx
je     1396 <main+0x216>
sub    %r14d,%ebx
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
mulss  0xcab(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd7c(%rip),%rsi
mov    %r15,%rdi
mov    $0x1,%al
call   1060 <fprintf@plt>
add    $0x19000,%ebx
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
mulss  0xc81(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd6e(%rip),%rsi
mov    %r15,%rdi
mov    $0x1,%al
call   1060 <fprintf@plt>
jmp    13af <main+0x22f>
lea    0xc7a(%rip),%rdi
mov    $0x1f,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1090 <fwrite@plt>
mov    $0x19000,%edi
call   1030 <my_malloc@plt>
mov    %rax,%rbx
cmp    $0xffffffff,%ebx
je     1414 <main+0x294>
sub    %r14d,%ebx
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
mulss  0xc2d(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd35(%rip),%rsi
mov    %r15,%rdi
mov    $0x1,%al
call   1060 <fprintf@plt>
add    $0x19000,%ebx
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
mulss  0xc03(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd27(%rip),%rsi
mov    %r15,%rdi
mov    $0x1,%al
call   1060 <fprintf@plt>
jmp    142d <main+0x2ad>
lea    0xbfc(%rip),%rdi
mov    $0x1f,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1090 <fwrite@plt>
mov    $0x32000,%edi
call   1030 <my_malloc@plt>
mov    %rax,%rbx
cmp    $0xffffffff,%ebx
je     1492 <main+0x312>
sub    %r14d,%ebx
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
mulss  0xbaf(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xcee(%rip),%rsi
mov    %r15,%rdi
mov    $0x1,%al
call   1060 <fprintf@plt>
add    $0x32000,%ebx
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
mulss  0xb85(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xce0(%rip),%rsi
mov    %r15,%rdi
mov    $0x1,%al
call   1060 <fprintf@plt>
jmp    14ab <main+0x32b>
lea    0xb7e(%rip),%rdi
mov    $0x1f,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1090 <fwrite@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
lea    0xcc7(%rip),%rdi
lea    0xb43(%rip),%rsi
call   1050 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [17 x i8] c"test5_output.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [32 x i8] c"This size can not be allocated!\00"
@.str.3 = [28 x i8] c"start of the chunk a: %f K\0A\00"
@.str.4 = [27 x i8] c"End of the chunk a: %f K\0A\0A\00"
@.str.5 = [28 x i8] c"start of the chunk b: %f K\0A\00"
@.str.6 = [27 x i8] c"End of the chunk b: %f K\0A\0A\00"
@.str.7 = [28 x i8] c"start of the chunk c: %f K\0A\00"
@.str.8 = [27 x i8] c"End of the chunk c: %f K\0A\0A\00"
@.str.9 = [28 x i8] c"start of the chunk d: %f K\0A\00"
@.str.10 = [27 x i8] c"End of the chunk d: %f K\0A\0A\00"
@.str.11 = [28 x i8] c"start of the chunk e: %f K\0A\00"
@.str.12 = [27 x i8] c"End of the chunk e: %f K\0A\0A\00"
@.str.13 = [28 x i8] c"start of the chunk f: %f K\0A\00"
@.str.14 = [27 x i8] c"End of the chunk f: %f K\0A\0A\00"
@.str.15 = [28 x i8] c"Done: Output written to %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
store i32 0, i32* %1
%12 = call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %12, i32** %2
store i32 1048576, i32* %4
%13 = load i32, i32* %4
%14 = call i8* @malloc(i32 %13)
store i8* %14, i8** %5
%15 = load i32, i32* %4
%16 = load i8*, i8** %5
%17 = call i32 @setup(i32 3, i32 %15, i8* %16)
store i32 245760, i32* %3
%18 = load i32, i32* %3
%19 = call i8* @my_malloc(i32 %18)
store i8* %19, i8** %6
%20 = load i8*, i8** %6
%21 = ptrtoint i8* %20 to i32
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %26
23: ; preds = %0
%24 = load i32*, i32** %2
%25 = call i32 (i32*, i8*, ...) @fprintf(i32* %24, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %49
26: ; preds = %0
%27 = load i32*, i32** %2
%28 = load i8*, i8** %6
%29 = ptrtoint i8* %28 to i32
%30 = load i8*, i8** %5
%31 = ptrtoint i8* %30 to i32
%32 = sub nsw i32 %29, %31
%33 = sitofp i32 %32 to float
%34 = fdiv float %33, 1.024000e+03
%35 = fpext float %34 to double
%36 = call i32 (i32*, i8*, ...) @fprintf(i32* %27, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), double %35)
%37 = load i32*, i32** %2
%38 = load i8*, i8** %6
%39 = ptrtoint i8* %38 to i32
%40 = load i32, i32* %3
%41 = add nsw i32 %39, %40
%42 = load i8*, i8** %5
%43 = ptrtoint i8* %42 to i32
%44 = sub nsw i32 %41, %43
%45 = sitofp i32 %44 to float
%46 = fdiv float %45, 1.024000e+03
%47 = fpext float %46 to double
%48 = call i32 (i32*, i8*, ...) @fprintf(i32* %37, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), double %47)
br label %49
49: ; preds = %26, %23
store i32 102400, i32* %3
%50 = load i32, i32* %3
%51 = call i8* @my_malloc(i32 %50)
store i8* %51, i8** %7
%52 = load i8*, i8** %7
%53 = ptrtoint i8* %52 to i32
%54 = icmp eq i32 %53, -1
br i1 %54, label %55, label %58
55: ; preds = %49
%56 = load i32*, i32** %2
%57 = call i32 (i32*, i8*, ...) @fprintf(i32* %56, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %81
58: ; preds = %49
%59 = load i32*, i32** %2
%60 = load i8*, i8** %7
%61 = ptrtoint i8* %60 to i32
%62 = load i8*, i8** %5
%63 = ptrtoint i8* %62 to i32
%64 = sub nsw i32 %61, %63
%65 = sitofp i32 %64 to float
%66 = fdiv float %65, 1.024000e+03
%67 = fpext float %66 to double
%68 = call i32 (i32*, i8*, ...) @fprintf(i32* %59, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), double %67)
%69 = load i32*, i32** %2
%70 = load i8*, i8** %7
%71 = ptrtoint i8* %70 to i32
%72 = load i32, i32* %3
%73 = add nsw i32 %71, %72
%74 = load i8*, i8** %5
%75 = ptrtoint i8* %74 to i32
%76 = sub nsw i32 %73, %75
%77 = sitofp i32 %76 to float
%78 = fdiv float %77, 1.024000e+03
%79 = fpext float %78 to double
%80 = call i32 (i32*, i8*, ...) @fprintf(i32* %69, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), double %79)
br label %81
81: ; preds = %58, %55
store i32 245760, i32* %3
%82 = load i32, i32* %3
%83 = call i8* @my_malloc(i32 %82)
store i8* %83, i8** %8
%84 = load i8*, i8** %8
%85 = ptrtoint i8* %84 to i32
%86 = icmp eq i32 %85, -1
br i1 %86, label %87, label %90
87: ; preds = %81
%88 = load i32*, i32** %2
%89 = call i32 (i32*, i8*, ...) @fprintf(i32* %88, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %113
90: ; preds = %81
%91 = load i32*, i32** %2
%92 = load i8*, i8** %8
%93 = ptrtoint i8* %92 to i32
%94 = load i8*, i8** %5
%95 = ptrtoint i8* %94 to i32
%96 = sub nsw i32 %93, %95
%97 = sitofp i32 %96 to float
%98 = fdiv float %97, 1.024000e+03
%99 = fpext float %98 to double
%100 = call i32 (i32*, i8*, ...) @fprintf(i32* %91, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), double %99)
%101 = load i32*, i32** %2
%102 = load i8*, i8** %8
%103 = ptrtoint i8* %102 to i32
%104 = load i32, i32* %3
%105 = add nsw i32 %103, %104
%106 = load i8*, i8** %5
%107 = ptrtoint i8* %106 to i32
%108 = sub nsw i32 %105, %107
%109 = sitofp i32 %108 to float
%110 = fdiv float %109, 1.024000e+03
%111 = fpext float %110 to double
%112 = call i32 (i32*, i8*, ...) @fprintf(i32* %101, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0), double %111)
br label %113
113: ; preds = %90, %87
store i32 102400, i32* %3
%114 = load i32, i32* %3
%115 = call i8* @my_malloc(i32 %114)
store i8* %115, i8** %9
%116 = load i8*, i8** %9
%117 = ptrtoint i8* %116 to i32
%118 = icmp eq i32 %117, -1
br i1 %118, label %119, label %122
119: ; preds = %113
%120 = load i32*, i32** %2
%121 = call i32 (i32*, i8*, ...) @fprintf(i32* %120, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %145
122: ; preds = %113
%123 = load i32*, i32** %2
%124 = load i8*, i8** %9
%125 = ptrtoint i8* %124 to i32
%126 = load i8*, i8** %5
%127 = ptrtoint i8* %126 to i32
%128 = sub nsw i32 %125, %127
%129 = sitofp i32 %128 to float
%130 = fdiv float %129, 1.024000e+03
%131 = fpext float %130 to double
%132 = call i32 (i32*, i8*, ...) @fprintf(i32* %123, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0), double %131)
%133 = load i32*, i32** %2
%134 = load i8*, i8** %9
%135 = ptrtoint i8* %134 to i32
%136 = load i32, i32* %3
%137 = add nsw i32 %135, %136
%138 = load i8*, i8** %5
%139 = ptrtoint i8* %138 to i32
%140 = sub nsw i32 %137, %139
%141 = sitofp i32 %140 to float
%142 = fdiv float %141, 1.024000e+03
%143 = fpext float %142 to double
%144 = call i32 (i32*, i8*, ...) @fprintf(i32* %133, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0), double %143)
br label %145
145: ; preds = %122, %119
store i32 102400, i32* %3
%146 = load i32, i32* %3
%147 = call i8* @my_malloc(i32 %146)
store i8* %147, i8** %10
%148 = load i8*, i8** %10
%149 = ptrtoint i8* %148 to i32
%150 = icmp eq i32 %149, -1
br i1 %150, label %151, label %154
151: ; preds = %145
%152 = load i32*, i32** %2
%153 = call i32 (i32*, i8*, ...) @fprintf(i32* %152, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %177
154: ; preds = %145
%155 = load i32*, i32** %2
%156 = load i8*, i8** %10
%157 = ptrtoint i8* %156 to i32
%158 = load i8*, i8** %5
%159 = ptrtoint i8* %158 to i32
%160 = sub nsw i32 %157, %159
%161 = sitofp i32 %160 to float
%162 = fdiv float %161, 1.024000e+03
%163 = fpext float %162 to double
%164 = call i32 (i32*, i8*, ...) @fprintf(i32* %155, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.11, i64 0, i64 0), double %163)
%165 = load i32*, i32** %2
%166 = load i8*, i8** %10
%167 = ptrtoint i8* %166 to i32
%168 = load i32, i32* %3
%169 = add nsw i32 %167, %168
%170 = load i8*, i8** %5
%171 = ptrtoint i8* %170 to i32
%172 = sub nsw i32 %169, %171
%173 = sitofp i32 %172 to float
%174 = fdiv float %173, 1.024000e+03
%175 = fpext float %174 to double
%176 = call i32 (i32*, i8*, ...) @fprintf(i32* %165, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.12, i64 0, i64 0), double %175)
br label %177
177: ; preds = %154, %151
store i32 204800, i32* %3
%178 = load i32, i32* %3
%179 = call i8* @my_malloc(i32 %178)
store i8* %179, i8** %11
%180 = load i8*, i8** %11
%181 = ptrtoint i8* %180 to i32
%182 = icmp eq i32 %181, -1
br i1 %182, label %183, label %186
183: ; preds = %177
%184 = load i32*, i32** %2
%185 = call i32 (i32*, i8*, ...) @fprintf(i32* %184, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %209
186: ; preds = %177
%187 = load i32*, i32** %2
%188 = load i8*, i8** %11
%189 = ptrtoint i8* %188 to i32
%190 = load i8*, i8** %5
%191 = ptrtoint i8* %190 to i32
%192 = sub nsw i32 %189, %191
%193 = sitofp i32 %192 to float
%194 = fdiv float %193, 1.024000e+03
%195 = fpext float %194 to double
%196 = call i32 (i32*, i8*, ...) @fprintf(i32* %187, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.13, i64 0, i64 0), double %195)
%197 = load i32*, i32** %2
%198 = load i8*, i8** %11
%199 = ptrtoint i8* %198 to i32
%200 = load i32, i32* %3
%201 = add nsw i32 %199, %200
%202 = load i8*, i8** %5
%203 = ptrtoint i8* %202 to i32
%204 = sub nsw i32 %201, %203
%205 = sitofp i32 %204 to float
%206 = fdiv float %205, 1.024000e+03
%207 = fpext float %206 to double
%208 = call i32 (i32*, i8*, ...) @fprintf(i32* %197, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.14, i64 0, i64 0), double %207)
br label %209
209: ; preds = %186, %183
%210 = load i32*, i32** %2
%211 = call i32 @fclose(i32* %210)
%212 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.15, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"test5_output.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [32 x i8] c"This size can not be allocated!\00"
@.str.3 = [28 x i8] c"start of the chunk a: %f K\0A\00"
@.str.4 = [27 x i8] c"End of the chunk a: %f K\0A\0A\00"
@.str.5 = [28 x i8] c"start of the chunk b: %f K\0A\00"
@.str.6 = [27 x i8] c"End of the chunk b: %f K\0A\0A\00"
@.str.7 = [28 x i8] c"start of the chunk c: %f K\0A\00"
@.str.8 = [27 x i8] c"End of the chunk c: %f K\0A\0A\00"
@.str.9 = [28 x i8] c"start of the chunk d: %f K\0A\00"
@.str.10 = [27 x i8] c"End of the chunk d: %f K\0A\0A\00"
@.str.11 = [28 x i8] c"start of the chunk e: %f K\0A\00"
@.str.12 = [27 x i8] c"End of the chunk e: %f K\0A\0A\00"
@.str.13 = [28 x i8] c"start of the chunk f: %f K\0A\00"
@.str.14 = [27 x i8] c"End of the chunk f: %f K\0A\0A\00"
@.str.15 = [28 x i8] c"Done: Output written to %s\0A\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call dereferenceable_or_null(1048576) i8* @malloc(i32 1048576)
%3 = tail call i32 @setup(i32 3, i32 1048576, i8* %2)
%4 = tail call i8* @my_malloc(i32 245760)
%5 = ptrtoint i8* %4 to i64
%6 = trunc i64 %5 to i32
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = tail call i64 @fwrite(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i64 31, i64 1, i32* %1)
br label %24
10: ; preds = %0
%11 = ptrtoint i8* %2 to i64
%12 = trunc i64 %11 to i32
%13 = sub nsw i32 %6, %12
%14 = sitofp i32 %13 to float
%15 = fmul float %14, 0x3F50000000000000
%16 = fpext float %15 to double
%17 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), double %16)
%18 = sub i32 245760, %12
%19 = add i32 %18, %6
%20 = sitofp i32 %19 to float
%21 = fmul float %20, 0x3F50000000000000
%22 = fpext float %21 to double
%23 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), double %22)
br label %24
24: ; preds = %10, %8
%25 = tail call i8* @my_malloc(i32 102400)
%26 = ptrtoint i8* %25 to i64
%27 = trunc i64 %26 to i32
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %31
29: ; preds = %24
%30 = tail call i64 @fwrite(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i64 31, i64 1, i32* %1)
br label %45
31: ; preds = %24
%32 = ptrtoint i8* %2 to i64
%33 = trunc i64 %32 to i32
%34 = sub nsw i32 %27, %33
%35 = sitofp i32 %34 to float
%36 = fmul float %35, 0x3F50000000000000
%37 = fpext float %36 to double
%38 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), double %37)
%39 = sub i32 102400, %33
%40 = add i32 %39, %27
%41 = sitofp i32 %40 to float
%42 = fmul float %41, 0x3F50000000000000
%43 = fpext float %42 to double
%44 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), double %43)
br label %45
45: ; preds = %31, %29
%46 = tail call i8* @my_malloc(i32 245760)
%47 = ptrtoint i8* %46 to i64
%48 = trunc i64 %47 to i32
%49 = icmp eq i32 %48, -1
br i1 %49, label %50, label %52
50: ; preds = %45
%51 = tail call i64 @fwrite(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i64 31, i64 1, i32* %1)
br label %66
52: ; preds = %45
%53 = ptrtoint i8* %2 to i64
%54 = trunc i64 %53 to i32
%55 = sub nsw i32 %48, %54
%56 = sitofp i32 %55 to float
%57 = fmul float %56, 0x3F50000000000000
%58 = fpext float %57 to double
%59 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), double %58)
%60 = sub i32 245760, %54
%61 = add i32 %60, %48
%62 = sitofp i32 %61 to float
%63 = fmul float %62, 0x3F50000000000000
%64 = fpext float %63 to double
%65 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0), double %64)
br label %66
66: ; preds = %52, %50
%67 = tail call i8* @my_malloc(i32 102400)
%68 = ptrtoint i8* %67 to i64
%69 = trunc i64 %68 to i32
%70 = icmp eq i32 %69, -1
br i1 %70, label %71, label %73
71: ; preds = %66
%72 = tail call i64 @fwrite(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i64 31, i64 1, i32* %1)
br label %87
73: ; preds = %66
%74 = ptrtoint i8* %2 to i64
%75 = trunc i64 %74 to i32
%76 = sub nsw i32 %69, %75
%77 = sitofp i32 %76 to float
%78 = fmul float %77, 0x3F50000000000000
%79 = fpext float %78 to double
%80 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0), double %79)
%81 = sub i32 102400, %75
%82 = add i32 %81, %69
%83 = sitofp i32 %82 to float
%84 = fmul float %83, 0x3F50000000000000
%85 = fpext float %84 to double
%86 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0), double %85)
br label %87
87: ; preds = %73, %71
%88 = tail call i8* @my_malloc(i32 102400)
%89 = ptrtoint i8* %88 to i64
%90 = trunc i64 %89 to i32
%91 = icmp eq i32 %90, -1
br i1 %91, label %92, label %94
92: ; preds = %87
%93 = tail call i64 @fwrite(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i64 31, i64 1, i32* %1)
br label %108
94: ; preds = %87
%95 = ptrtoint i8* %2 to i64
%96 = trunc i64 %95 to i32
%97 = sub nsw i32 %90, %96
%98 = sitofp i32 %97 to float
%99 = fmul float %98, 0x3F50000000000000
%100 = fpext float %99 to double
%101 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.11, i64 0, i64 0), double %100)
%102 = sub i32 102400, %96
%103 = add i32 %102, %90
%104 = sitofp i32 %103 to float
%105 = fmul float %104, 0x3F50000000000000
%106 = fpext float %105 to double
%107 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.12, i64 0, i64 0), double %106)
br label %108
108: ; preds = %94, %92
%109 = tail call i8* @my_malloc(i32 204800)
%110 = ptrtoint i8* %109 to i64
%111 = trunc i64 %110 to i32
%112 = icmp eq i32 %111, -1
br i1 %112, label %113, label %115
113: ; preds = %108
%114 = tail call i64 @fwrite(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i64 31, i64 1, i32* %1)
br label %129
115: ; preds = %108
%116 = ptrtoint i8* %2 to i64
%117 = trunc i64 %116 to i32
%118 = sub nsw i32 %111, %117
%119 = sitofp i32 %118 to float
%120 = fmul float %119, 0x3F50000000000000
%121 = fpext float %120 to double
%122 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.13, i64 0, i64 0), double %121)
%123 = sub i32 204800, %117
%124 = add i32 %123, %111
%125 = sitofp i32 %124 to float
%126 = fmul float %125, 0x3F50000000000000
%127 = fpext float %126 to double
%128 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.14, i64 0, i64 0), double %127)
br label %129
129: ; preds = %115, %113
%130 = tail call i32 @fclose(i32* %1)
%131 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.15, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
ret i32 0
}