#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ create_pool(int);
int /*<<< orphan*/ destroy_pool();
int /*<<< orphan*/ my_free(void *);
void *my_malloc(int);
int /*<<< orphan*/ printf(char *);
int test_five() {
  printf("Test Five: Request and Return\n");
  create_pool(1000);
  printf("Request 1000...");
  void *bl1 = my_malloc(1000);
  my_free(bl1);
  printf("Complete.\n");
  printf("Request 250*4...");
  bl1 = my_malloc(250);
  void *bl2 = my_malloc(250);
  void *bl3 = my_malloc(250);
  void *bl4 = my_malloc(250);
  my_free(bl1);
  my_free(bl2);
  my_free(bl3);
  my_free(bl4);
  printf("Complete.\n");
  printf("Request 100*10...");
  bl1 = my_malloc(100);
  bl2 = my_malloc(100);
  bl3 = my_malloc(100);
  bl4 = my_malloc(100);
  void *bl5 = my_malloc(100);
  void *bl6 = my_malloc(100);
  void *bl7 = my_malloc(100);
  void *bl8 = my_malloc(100);
  void *bl9 = my_malloc(100);
  void *bl10 = my_malloc(100);
  my_free(bl1);
  my_free(bl2);
  my_free(bl3);
  my_free(bl4);
  my_free(bl5);
  my_free(bl6);
  my_free(bl7);
  my_free(bl8);
  my_free(bl9);
  my_free(bl10);
  printf("Complete.\n");
  printf("Test Five Complete.\n");
  destroy_pool();
  return 1;
}


x86 assembly (clang, -O0):
<test_five>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
lea    0xea1(%rip),%rdi
call   1040 <printf@plt>
mov    $0x3e8,%edi
call   1050 <create_pool@plt>
lea    0xeaa(%rip),%rdi
call   1040 <printf@plt>
mov    $0x3e8,%edi
call   1030 <my_malloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <my_free@plt>
lea    0xec4(%rip),%rdi
call   1040 <printf@plt>
lea    0xe8b(%rip),%rdi
call   1040 <printf@plt>
mov    $0xfa,%edi
call   1030 <my_malloc@plt>
mov    %rax,-0x8(%rbp)
mov    $0xfa,%edi
call   1030 <my_malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0xfa,%edi
call   1030 <my_malloc@plt>
mov    %rax,-0x18(%rbp)
mov    $0xfa,%edi
call   1030 <my_malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <my_free@plt>
mov    -0x10(%rbp),%rdi
call   1060 <my_free@plt>
mov    -0x18(%rbp),%rdi
call   1060 <my_free@plt>
mov    -0x20(%rbp),%rdi
call   1060 <my_free@plt>
lea    0xe50(%rip),%rdi
call   1040 <printf@plt>
lea    0xe28(%rip),%rdi
call   1040 <printf@plt>
mov    $0x64,%edi
call   1030 <my_malloc@plt>
mov    %rax,-0x8(%rbp)
mov    $0x64,%edi
call   1030 <my_malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x64,%edi
call   1030 <my_malloc@plt>
mov    %rax,-0x18(%rbp)
mov    $0x64,%edi
call   1030 <my_malloc@plt>
mov    %rax,-0x20(%rbp)
mov    $0x64,%edi
call   1030 <my_malloc@plt>
mov    %rax,-0x28(%rbp)
mov    $0x64,%edi
call   1030 <my_malloc@plt>
mov    %rax,-0x30(%rbp)
mov    $0x64,%edi
call   1030 <my_malloc@plt>
mov    %rax,-0x38(%rbp)
mov    $0x64,%edi
call   1030 <my_malloc@plt>
mov    %rax,-0x40(%rbp)
mov    $0x64,%edi
call   1030 <my_malloc@plt>
mov    %rax,-0x48(%rbp)
mov    $0x64,%edi
call   1030 <my_malloc@plt>
mov    %rax,-0x50(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <my_free@plt>
mov    -0x10(%rbp),%rdi
call   1060 <my_free@plt>
mov    -0x18(%rbp),%rdi
call   1060 <my_free@plt>
mov    -0x20(%rbp),%rdi
call   1060 <my_free@plt>
mov    -0x28(%rbp),%rdi
call   1060 <my_free@plt>
mov    -0x30(%rbp),%rdi
call   1060 <my_free@plt>
mov    -0x38(%rbp),%rdi
call   1060 <my_free@plt>
mov    -0x40(%rbp),%rdi
call   1060 <my_free@plt>
mov    -0x48(%rbp),%rdi
call   1060 <my_free@plt>
mov    -0x50(%rbp),%rdi
call   1060 <my_free@plt>
lea    0xd52(%rip),%rdi
call   1040 <printf@plt>
lea    0xd3c(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1070 <destroy_pool@plt>
mov    $0x1,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_five>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xebe(%rip),%rdi
call   1040 <puts@plt>
mov    $0x3e8,%edi
call   1060 <create_pool@plt>
lea    0xe75(%rip),%rdi
call   1050 <printf@plt>
mov    $0x3e8,%edi
call   1030 <my_malloc@plt>
mov    %rax,%rdi
call   1070 <my_free@plt>
lea    0xeb2(%rip),%r12
mov    %r12,%rdi
call   1040 <puts@plt>
lea    0xe58(%rip),%rdi
call   1050 <printf@plt>
mov    $0xfa,%edi
call   1030 <my_malloc@plt>
mov    %rax,%r14
mov    $0xfa,%edi
call   1030 <my_malloc@plt>
mov    %rax,%r15
mov    $0xfa,%edi
call   1030 <my_malloc@plt>
mov    %rax,%rbx
mov    $0xfa,%edi
call   1030 <my_malloc@plt>
mov    %rax,%rbp
mov    %r14,%rdi
call   1070 <my_free@plt>
mov    %r15,%rdi
call   1070 <my_free@plt>
mov    %rbx,%rdi
call   1070 <my_free@plt>
mov    %rbp,%rdi
call   1070 <my_free@plt>
mov    %r12,%rdi
call   1040 <puts@plt>
lea    0xe01(%rip),%rdi
call   1050 <printf@plt>
mov    $0x64,%edi
call   1030 <my_malloc@plt>
mov    %rax,0x20(%rsp)
mov    $0x64,%edi
call   1030 <my_malloc@plt>
mov    %rax,0x18(%rsp)
mov    $0x64,%edi
call   1030 <my_malloc@plt>
mov    %rax,0x10(%rsp)
mov    $0x64,%edi
call   1030 <my_malloc@plt>
mov    %rax,0x8(%rsp)
mov    $0x64,%edi
call   1030 <my_malloc@plt>
mov    %rax,%rbp
mov    $0x64,%edi
call   1030 <my_malloc@plt>
mov    %rax,%r14
mov    $0x64,%edi
call   1030 <my_malloc@plt>
mov    %rax,%r15
mov    $0x64,%edi
call   1030 <my_malloc@plt>
mov    %rax,%r12
mov    $0x64,%edi
call   1030 <my_malloc@plt>
mov    %rax,%r13
mov    $0x64,%edi
call   1030 <my_malloc@plt>
mov    %rax,%rbx
mov    0x20(%rsp),%rdi
call   1070 <my_free@plt>
mov    0x18(%rsp),%rdi
call   1070 <my_free@plt>
mov    0x10(%rsp),%rdi
call   1070 <my_free@plt>
mov    0x8(%rsp),%rdi
call   1070 <my_free@plt>
mov    %rbp,%rdi
call   1070 <my_free@plt>
mov    %r14,%rdi
call   1070 <my_free@plt>
mov    %r15,%rdi
call   1070 <my_free@plt>
mov    %r12,%rdi
call   1070 <my_free@plt>
mov    %r13,%rdi
call   1070 <my_free@plt>
mov    %rbx,%rdi
call   1070 <my_free@plt>
lea    0xd4d(%rip),%rdi
call   1040 <puts@plt>
lea    0xd37(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1080 <destroy_pool@plt>
mov    $0x1,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Test Five: Request and Return\0A\00"
@.str.1 = [16 x i8] c"Request 1000...\00"
@.str.2 = [11 x i8] c"Complete.\0A\00"
@.str.3 = [17 x i8] c"Request 250*4...\00"
@.str.4 = [18 x i8] c"Request 100*10...\00"
@.str.5 = [21 x i8] c"Test Five Complete.\0A\00"
define i32 @test_five() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @create_pool(i32 1000)
%13 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%14 = call i8* @my_malloc(i32 1000)
store i8* %14, i8** %1
%15 = load i8*, i8** %1
%16 = call i32 @my_free(i8* %15)
%17 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%19 = call i8* @my_malloc(i32 250)
store i8* %19, i8** %1
%20 = call i8* @my_malloc(i32 250)
store i8* %20, i8** %2
%21 = call i8* @my_malloc(i32 250)
store i8* %21, i8** %3
%22 = call i8* @my_malloc(i32 250)
store i8* %22, i8** %4
%23 = load i8*, i8** %1
%24 = call i32 @my_free(i8* %23)
%25 = load i8*, i8** %2
%26 = call i32 @my_free(i8* %25)
%27 = load i8*, i8** %3
%28 = call i32 @my_free(i8* %27)
%29 = load i8*, i8** %4
%30 = call i32 @my_free(i8* %29)
%31 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%32 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%33 = call i8* @my_malloc(i32 100)
store i8* %33, i8** %1
%34 = call i8* @my_malloc(i32 100)
store i8* %34, i8** %2
%35 = call i8* @my_malloc(i32 100)
store i8* %35, i8** %3
%36 = call i8* @my_malloc(i32 100)
store i8* %36, i8** %4
%37 = call i8* @my_malloc(i32 100)
store i8* %37, i8** %5
%38 = call i8* @my_malloc(i32 100)
store i8* %38, i8** %6
%39 = call i8* @my_malloc(i32 100)
store i8* %39, i8** %7
%40 = call i8* @my_malloc(i32 100)
store i8* %40, i8** %8
%41 = call i8* @my_malloc(i32 100)
store i8* %41, i8** %9
%42 = call i8* @my_malloc(i32 100)
store i8* %42, i8** %10
%43 = load i8*, i8** %1
%44 = call i32 @my_free(i8* %43)
%45 = load i8*, i8** %2
%46 = call i32 @my_free(i8* %45)
%47 = load i8*, i8** %3
%48 = call i32 @my_free(i8* %47)
%49 = load i8*, i8** %4
%50 = call i32 @my_free(i8* %49)
%51 = load i8*, i8** %5
%52 = call i32 @my_free(i8* %51)
%53 = load i8*, i8** %6
%54 = call i32 @my_free(i8* %53)
%55 = load i8*, i8** %7
%56 = call i32 @my_free(i8* %55)
%57 = load i8*, i8** %8
%58 = call i32 @my_free(i8* %57)
%59 = load i8*, i8** %9
%60 = call i32 @my_free(i8* %59)
%61 = load i8*, i8** %10
%62 = call i32 @my_free(i8* %61)
%63 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%64 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%65 = call i32 (...) @destroy_pool()
ret i32 1
}

LLVM IR (-O2):
@.str.1 = [16 x i8] c"Request 1000...\00"
@.str.3 = [17 x i8] c"Request 250*4...\00"
@.str.4 = [18 x i8] c"Request 100*10...\00"
@str = [30 x i8] c"Test Five: Request and Return\00"
@str.8 = [10 x i8] c"Complete.\00"
@str.9 = [20 x i8] c"Test Five Complete.\00"
define i32 @test_five() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @create_pool(i32 1000)
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i8* @my_malloc(i32 1000)
%5 = tail call i32 @my_free(i8* %4)
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.8, i64 0, i64 0))
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%8 = tail call i8* @my_malloc(i32 250)
%9 = tail call i8* @my_malloc(i32 250)
%10 = tail call i8* @my_malloc(i32 250)
%11 = tail call i8* @my_malloc(i32 250)
%12 = tail call i32 @my_free(i8* %8)
%13 = tail call i32 @my_free(i8* %9)
%14 = tail call i32 @my_free(i8* %10)
%15 = tail call i32 @my_free(i8* %11)
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.8, i64 0, i64 0))
%17 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%18 = tail call i8* @my_malloc(i32 100)
%19 = tail call i8* @my_malloc(i32 100)
%20 = tail call i8* @my_malloc(i32 100)
%21 = tail call i8* @my_malloc(i32 100)
%22 = tail call i8* @my_malloc(i32 100)
%23 = tail call i8* @my_malloc(i32 100)
%24 = tail call i8* @my_malloc(i32 100)
%25 = tail call i8* @my_malloc(i32 100)
%26 = tail call i8* @my_malloc(i32 100)
%27 = tail call i8* @my_malloc(i32 100)
%28 = tail call i32 @my_free(i8* %18)
%29 = tail call i32 @my_free(i8* %19)
%30 = tail call i32 @my_free(i8* %20)
%31 = tail call i32 @my_free(i8* %21)
%32 = tail call i32 @my_free(i8* %22)
%33 = tail call i32 @my_free(i8* %23)
%34 = tail call i32 @my_free(i8* %24)
%35 = tail call i32 @my_free(i8* %25)
%36 = tail call i32 @my_free(i8* %26)
%37 = tail call i32 @my_free(i8* %27)
%38 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.8, i64 0, i64 0))
%39 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.9, i64 0, i64 0))
%40 = tail call i32 (...) @destroy_pool()
ret i32 1
}