#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);
int /*<<< orphan*/ my_free(void *);
void *my_malloc(int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ setup(int, int, void *);
int main() {
  FILE *pFile;
  pFile = fopen("test4_output.txt", "w");
  int size;
  int RAM_SIZE = 1 << 20;
  void *RAM = malloc(RAM_SIZE);
  setup(3, RAM_SIZE, RAM);
  size = 100 * 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 = 200 * 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 = 200 * 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);
  }
  my_free(a);
  my_free(b);
  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);
  }
  my_free(e);
  my_free(c);
  size = 500 * 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", "test4_output.txt");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe6e(%rip),%rdi
lea    0xe78(%rip),%rsi
call   1090 <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   10a0 <setup@plt>
movl   $0x19000,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <my_malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    $0xffffffff,%eax
jne    1201 <main+0x81>
mov    -0x10(%rbp),%rdi
lea    0xe22(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    1264 <main+0xe4>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %ecx,%eax
cvtsi2ss %eax,%xmm0
movss  0xde5(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe0d(%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  0xdb2(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdf6(%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    129b <main+0x11b>
mov    -0x10(%rbp),%rdi
lea    0xd88(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    12fe <main+0x17e>
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %ecx,%eax
cvtsi2ss %eax,%xmm0
movss  0xd4b(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdaa(%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  0xd18(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd93(%rip),%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
movl   $0x32000,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <my_malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    $0xffffffff,%eax
jne    1335 <main+0x1b5>
mov    -0x10(%rbp),%rdi
lea    0xcee(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    1398 <main+0x218>
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %ecx,%eax
cvtsi2ss %eax,%xmm0
movss  0xcb1(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd47(%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  0xc7e(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd30(%rip),%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
movl   $0x32000,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <my_malloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
cmp    $0xffffffff,%eax
jne    13cf <main+0x24f>
mov    -0x10(%rbp),%rdi
lea    0xc54(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    1432 <main+0x2b2>
mov    -0x10(%rbp),%rdi
mov    -0x40(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %ecx,%eax
cvtsi2ss %eax,%xmm0
movss  0xc17(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xce4(%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  0xbe4(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xccd(%rip),%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
mov    -0x28(%rbp),%rdi
call   1080 <my_free@plt>
mov    -0x30(%rbp),%rdi
call   1080 <my_free@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    147b <main+0x2fb>
mov    -0x10(%rbp),%rdi
lea    0xba8(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    14de <main+0x35e>
mov    -0x10(%rbp),%rdi
mov    -0x48(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %ecx,%eax
cvtsi2ss %eax,%xmm0
movss  0xb6b(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xc6f(%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  0xb38(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xc58(%rip),%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
mov    -0x48(%rbp),%rdi
call   1080 <my_free@plt>
mov    -0x38(%rbp),%rdi
call   1080 <my_free@plt>
movl   $0x7d000,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <my_malloc@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
cmp    $0xffffffff,%eax
jne    1527 <main+0x3a7>
mov    -0x10(%rbp),%rdi
lea    0xafc(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    158a <main+0x40a>
mov    -0x10(%rbp),%rdi
mov    -0x50(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %ecx,%eax
cvtsi2ss %eax,%xmm0
movss  0xabf(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xbfa(%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  0xa8c(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xbe3(%rip),%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xbe7(%rip),%rdi
lea    0xa63(%rip),%rsi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe62(%rip),%rdi
lea    0xe6c(%rip),%rsi
call   1090 <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   10b0 <setup@plt>
mov    $0x19000,%edi
call   1030 <my_malloc@plt>
mov    %rax,%rbp
cmp    $0xffffffff,%ebp
je     1234 <main+0xa4>
mov    %ebp,%ebx
sub    %r14d,%ebx
cvtsi2ss %ebx,%xmm0
mulss  0xe0d(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe39(%rip),%rsi
mov    %r15,%rdi
mov    $0x1,%al
call   1060 <fprintf@plt>
add    $0x19000,%ebx
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
mulss  0xde3(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe2b(%rip),%rsi
mov    %r15,%rdi
mov    $0x1,%al
call   1060 <fprintf@plt>
jmp    124d <main+0xbd>
lea    0xddc(%rip),%rdi
mov    $0x1f,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   10a0 <fwrite@plt>
mov    $0x19000,%edi
call   1030 <my_malloc@plt>
mov    %rax,%r13
cmp    $0xffffffff,%r13d
je     12b6 <main+0x126>
mov    %r13d,%ebx
sub    %r14d,%ebx
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
mulss  0xd8b(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdee(%rip),%rsi
mov    %r15,%rdi
mov    $0x1,%al
call   1060 <fprintf@plt>
add    $0x19000,%ebx
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
mulss  0xd61(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xde0(%rip),%rsi
mov    %r15,%rdi
mov    $0x1,%al
call   1060 <fprintf@plt>
jmp    12cf <main+0x13f>
lea    0xd5a(%rip),%rdi
mov    $0x1f,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   10a0 <fwrite@plt>
mov    $0x32000,%edi
call   1030 <my_malloc@plt>
mov    %rax,%r12
cmp    $0xffffffff,%r12d
je     1338 <main+0x1a8>
mov    %r12d,%ebx
sub    %r14d,%ebx
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
mulss  0xd09(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xda3(%rip),%rsi
mov    %r15,%rdi
mov    $0x1,%al
call   1060 <fprintf@plt>
add    $0x32000,%ebx
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
mulss  0xcdf(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd95(%rip),%rsi
mov    %r15,%rdi
mov    $0x1,%al
call   1060 <fprintf@plt>
jmp    1351 <main+0x1c1>
lea    0xcd8(%rip),%rdi
mov    $0x1f,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   10a0 <fwrite@plt>
mov    $0x32000,%edi
call   1030 <my_malloc@plt>
mov    %rax,%rbx
cmp    $0xffffffff,%ebx
je     13b6 <main+0x226>
sub    %r14d,%ebx
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
mulss  0xc8b(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd5c(%rip),%rsi
mov    %r15,%rdi
mov    $0x1,%al
call   1060 <fprintf@plt>
add    $0x32000,%ebx
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
mulss  0xc61(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd4e(%rip),%rsi
mov    %r15,%rdi
mov    $0x1,%al
call   1060 <fprintf@plt>
jmp    13cf <main+0x23f>
lea    0xc5a(%rip),%rdi
mov    $0x1f,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   10a0 <fwrite@plt>
mov    %rbp,%rdi
call   1080 <my_free@plt>
mov    %r13,%rdi
call   1080 <my_free@plt>
mov    $0x19000,%edi
call   1030 <my_malloc@plt>
mov    %rax,%rbx
cmp    $0xffffffff,%ebx
je     1446 <main+0x2b6>
mov    %ebx,%ebp
sub    %r14d,%ebp
xorps  %xmm0,%xmm0
cvtsi2ss %ebp,%xmm0
mulss  0xbfb(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd03(%rip),%rsi
mov    %r15,%rdi
mov    $0x1,%al
call   1060 <fprintf@plt>
add    $0x19000,%ebp
xorps  %xmm0,%xmm0
cvtsi2ss %ebp,%xmm0
mulss  0xbd1(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xcf5(%rip),%rsi
mov    %r15,%rdi
mov    $0x1,%al
call   1060 <fprintf@plt>
jmp    145f <main+0x2cf>
lea    0xbca(%rip),%rdi
mov    $0x1f,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   10a0 <fwrite@plt>
mov    %rbx,%rdi
call   1080 <my_free@plt>
mov    %r12,%rdi
call   1080 <my_free@plt>
mov    $0x7d000,%edi
call   1030 <my_malloc@plt>
mov    %rax,%rbx
cmp    $0xffffffff,%ebx
je     14d4 <main+0x344>
sub    %r14d,%ebx
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
mulss  0xb6d(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xcac(%rip),%rsi
mov    %r15,%rdi
mov    $0x1,%al
call   1060 <fprintf@plt>
add    $0x7d000,%ebx
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
mulss  0xb43(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xc9e(%rip),%rsi
mov    %r15,%rdi
mov    $0x1,%al
call   1060 <fprintf@plt>
jmp    14ed <main+0x35d>
lea    0xb3c(%rip),%rdi
mov    $0x1f,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   10a0 <fwrite@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
lea    0xc85(%rip),%rdi
lea    0xb01(%rip),%rsi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"test4_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 102400, 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 204800, 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 204800, 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
%146 = load i8*, i8** %6
%147 = call i32 @my_free(i8* %146)
%148 = load i8*, i8** %7
%149 = call i32 @my_free(i8* %148)
store i32 102400, i32* %3
%150 = load i32, i32* %3
%151 = call i8* @my_malloc(i32 %150)
store i8* %151, i8** %10
%152 = load i8*, i8** %10
%153 = ptrtoint i8* %152 to i32
%154 = icmp eq i32 %153, -1
br i1 %154, label %155, label %158
155: ; preds = %145
%156 = load i32*, i32** %2
%157 = call i32 (i32*, i8*, ...) @fprintf(i32* %156, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %181
158: ; preds = %145
%159 = load i32*, i32** %2
%160 = load i8*, i8** %10
%161 = ptrtoint i8* %160 to i32
%162 = load i8*, i8** %5
%163 = ptrtoint i8* %162 to i32
%164 = sub nsw i32 %161, %163
%165 = sitofp i32 %164 to float
%166 = fdiv float %165, 1.024000e+03
%167 = fpext float %166 to double
%168 = call i32 (i32*, i8*, ...) @fprintf(i32* %159, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.11, i64 0, i64 0), double %167)
%169 = load i32*, i32** %2
%170 = load i8*, i8** %10
%171 = ptrtoint i8* %170 to i32
%172 = load i32, i32* %3
%173 = add nsw i32 %171, %172
%174 = load i8*, i8** %5
%175 = ptrtoint i8* %174 to i32
%176 = sub nsw i32 %173, %175
%177 = sitofp i32 %176 to float
%178 = fdiv float %177, 1.024000e+03
%179 = fpext float %178 to double
%180 = call i32 (i32*, i8*, ...) @fprintf(i32* %169, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.12, i64 0, i64 0), double %179)
br label %181
181: ; preds = %158, %155
%182 = load i8*, i8** %10
%183 = call i32 @my_free(i8* %182)
%184 = load i8*, i8** %8
%185 = call i32 @my_free(i8* %184)
store i32 512000, i32* %3
%186 = load i32, i32* %3
%187 = call i8* @my_malloc(i32 %186)
store i8* %187, i8** %11
%188 = load i8*, i8** %11
%189 = ptrtoint i8* %188 to i32
%190 = icmp eq i32 %189, -1
br i1 %190, label %191, label %194
191: ; preds = %181
%192 = load i32*, i32** %2
%193 = call i32 (i32*, i8*, ...) @fprintf(i32* %192, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %217
194: ; preds = %181
%195 = load i32*, i32** %2
%196 = load i8*, i8** %11
%197 = ptrtoint i8* %196 to i32
%198 = load i8*, i8** %5
%199 = ptrtoint i8* %198 to i32
%200 = sub nsw i32 %197, %199
%201 = sitofp i32 %200 to float
%202 = fdiv float %201, 1.024000e+03
%203 = fpext float %202 to double
%204 = call i32 (i32*, i8*, ...) @fprintf(i32* %195, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.13, i64 0, i64 0), double %203)
%205 = load i32*, i32** %2
%206 = load i8*, i8** %11
%207 = ptrtoint i8* %206 to i32
%208 = load i32, i32* %3
%209 = add nsw i32 %207, %208
%210 = load i8*, i8** %5
%211 = ptrtoint i8* %210 to i32
%212 = sub nsw i32 %209, %211
%213 = sitofp i32 %212 to float
%214 = fdiv float %213, 1.024000e+03
%215 = fpext float %214 to double
%216 = call i32 (i32*, i8*, ...) @fprintf(i32* %205, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.14, i64 0, i64 0), double %215)
br label %217
217: ; preds = %194, %191
%218 = load i32*, i32** %2
%219 = call i32 @fclose(i32* %218)
%220 = 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"test4_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 102400)
%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 102400, %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 204800)
%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 204800, %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 204800)
%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 204800, %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 i32 @my_free(i8* %4)
%89 = tail call i32 @my_free(i8* %25)
%90 = tail call i8* @my_malloc(i32 102400)
%91 = ptrtoint i8* %90 to i64
%92 = trunc i64 %91 to i32
%93 = icmp eq i32 %92, -1
br i1 %93, label %94, label %96
94: ; preds = %87
%95 = 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 %110
96: ; preds = %87
%97 = ptrtoint i8* %2 to i64
%98 = trunc i64 %97 to i32
%99 = sub nsw i32 %92, %98
%100 = sitofp i32 %99 to float
%101 = fmul float %100, 0x3F50000000000000
%102 = fpext float %101 to double
%103 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.11, i64 0, i64 0), double %102)
%104 = sub i32 102400, %98
%105 = add i32 %104, %92
%106 = sitofp i32 %105 to float
%107 = fmul float %106, 0x3F50000000000000
%108 = fpext float %107 to double
%109 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.12, i64 0, i64 0), double %108)
br label %110
110: ; preds = %96, %94
%111 = tail call i32 @my_free(i8* %90)
%112 = tail call i32 @my_free(i8* %46)
%113 = tail call i8* @my_malloc(i32 512000)
%114 = ptrtoint i8* %113 to i64
%115 = trunc i64 %114 to i32
%116 = icmp eq i32 %115, -1
br i1 %116, label %117, label %119
117: ; preds = %110
%118 = 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 %133
119: ; preds = %110
%120 = ptrtoint i8* %2 to i64
%121 = trunc i64 %120 to i32
%122 = sub nsw i32 %115, %121
%123 = sitofp i32 %122 to float
%124 = fmul float %123, 0x3F50000000000000
%125 = fpext float %124 to double
%126 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.13, i64 0, i64 0), double %125)
%127 = sub i32 512000, %121
%128 = add i32 %127, %115
%129 = sitofp i32 %128 to float
%130 = fmul float %129, 0x3F50000000000000
%131 = fpext float %130 to double
%132 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.14, i64 0, i64 0), double %131)
br label %133
133: ; preds = %119, %117
%134 = tail call i32 @fclose(i32* %1)
%135 = 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
}