#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_two() {
  printf("Test Two: Blocks of 200 bytes\n");
  create_pool(1000);
  int i = 5;
  void *bl1, *bl2, *bl3, *bl4, *bl5;
  while (i) {
    printf("Round: %d...", i);
    bl1 = my_malloc(200);
    bl2 = my_malloc(200);
    bl3 = my_malloc(200);
    bl4 = my_malloc(200);
    bl5 = my_malloc(200);
    my_free(bl1);
    my_free(bl2);
    my_free(bl3);
    my_free(bl4);
    my_free(bl5);
    i--;
    printf("Success.\n");
  }
  destroy_pool();
  return 1;
}


x86 assembly (clang, -O0):
<test_two>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x3e8,%edi
call   1050 <create_pool@plt>
movl   $0x5,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     1221 <test_two+0xd1>
mov    -0x4(%rbp),%esi
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xc8,%edi
call   1030 <my_malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0xc8,%edi
call   1030 <my_malloc@plt>
mov    %rax,-0x18(%rbp)
mov    $0xc8,%edi
call   1030 <my_malloc@plt>
mov    %rax,-0x20(%rbp)
mov    $0xc8,%edi
call   1030 <my_malloc@plt>
mov    %rax,-0x28(%rbp)
mov    $0xc8,%edi
call   1030 <my_malloc@plt>
mov    %rax,-0x30(%rbp)
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    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1177 <test_two+0x27>
mov    $0x0,%al
call   1070 <destroy_pool@plt>
mov    $0x1,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_two>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe9b(%rip),%rdi
call   1040 <puts@plt>
mov    $0x3e8,%edi
call   1060 <create_pool@plt>
lea    0xe78(%rip),%rdi
mov    %rdi,%r14
mov    $0x5,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xc8,%edi
call   1030 <my_malloc@plt>
mov    %rax,%r15
mov    $0xc8,%edi
call   1030 <my_malloc@plt>
mov    %rax,%r12
mov    $0xc8,%edi
call   1030 <my_malloc@plt>
mov    %rax,%r13
mov    $0xc8,%edi
call   1030 <my_malloc@plt>
mov    %rax,%rbx
mov    $0xc8,%edi
call   1030 <my_malloc@plt>
mov    %rax,%rbp
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>
mov    %rbp,%rdi
call   1070 <my_free@plt>
lea    0xe24(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%r15
mov    %r14,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xc8,%edi
call   1030 <my_malloc@plt>
mov    %rax,%r12
mov    $0xc8,%edi
call   1030 <my_malloc@plt>
mov    %rax,%r13
mov    $0xc8,%edi
call   1030 <my_malloc@plt>
mov    %rax,%rbp
mov    $0xc8,%edi
call   1030 <my_malloc@plt>
mov    %rax,%rbx
mov    $0xc8,%edi
call   1030 <my_malloc@plt>
mov    %rax,%r14
mov    %r12,%rdi
call   1070 <my_free@plt>
mov    %r13,%rdi
call   1070 <my_free@plt>
mov    %rbp,%rdi
call   1070 <my_free@plt>
mov    %rbx,%rdi
call   1070 <my_free@plt>
mov    %r14,%rdi
call   1070 <my_free@plt>
lea    0xd9d(%rip),%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xc8,%edi
call   1030 <my_malloc@plt>
mov    %rax,%r14
mov    $0xc8,%edi
call   1030 <my_malloc@plt>
mov    %rax,%r12
mov    $0xc8,%edi
call   1030 <my_malloc@plt>
mov    %rax,%r13
mov    $0xc8,%edi
call   1030 <my_malloc@plt>
mov    %rax,%rbp
mov    $0xc8,%edi
call   1030 <my_malloc@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1070 <my_free@plt>
mov    %r12,%rdi
call   1070 <my_free@plt>
mov    %r13,%rdi
call   1070 <my_free@plt>
mov    %rbp,%rdi
call   1070 <my_free@plt>
mov    %rbx,%rdi
call   1070 <my_free@plt>
lea    0xd19(%rip),%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xc8,%edi
call   1030 <my_malloc@plt>
mov    %rax,%r14
mov    $0xc8,%edi
call   1030 <my_malloc@plt>
mov    %rax,%r12
mov    $0xc8,%edi
call   1030 <my_malloc@plt>
mov    %rax,%r13
mov    $0xc8,%edi
call   1030 <my_malloc@plt>
mov    %rax,%rbp
mov    $0xc8,%edi
call   1030 <my_malloc@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1070 <my_free@plt>
mov    %r12,%rdi
call   1070 <my_free@plt>
mov    %r13,%rdi
call   1070 <my_free@plt>
mov    %rbp,%rdi
call   1070 <my_free@plt>
mov    %rbx,%rdi
call   1070 <my_free@plt>
lea    0xc95(%rip),%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xc8,%edi
call   1030 <my_malloc@plt>
mov    %rax,%r14
mov    $0xc8,%edi
call   1030 <my_malloc@plt>
mov    %rax,%r12
mov    $0xc8,%edi
call   1030 <my_malloc@plt>
mov    %rax,%r13
mov    $0xc8,%edi
call   1030 <my_malloc@plt>
mov    %rax,%rbp
mov    $0xc8,%edi
call   1030 <my_malloc@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1070 <my_free@plt>
mov    %r12,%rdi
call   1070 <my_free@plt>
mov    %r13,%rdi
call   1070 <my_free@plt>
mov    %rbp,%rdi
call   1070 <my_free@plt>
mov    %rbx,%rdi
call   1070 <my_free@plt>
lea    0xc11(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1080 <destroy_pool@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Test Two: Blocks of 200 bytes\0A\00"
@.str.1 = [13 x i8] c"Round: %d...\00"
@.str.2 = [10 x i8] c"Success.\0A\00"
define i32 @test_two() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @create_pool(i32 1000)
store i32 5, i32* %1
br label %9
9: ; preds = %12, %0
%10 = load i32, i32* %1
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %33
12: ; preds = %9
%13 = load i32, i32* %1
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = call i8* @my_malloc(i32 200)
store i8* %15, i8** %2
%16 = call i8* @my_malloc(i32 200)
store i8* %16, i8** %3
%17 = call i8* @my_malloc(i32 200)
store i8* %17, i8** %4
%18 = call i8* @my_malloc(i32 200)
store i8* %18, i8** %5
%19 = call i8* @my_malloc(i32 200)
store i8* %19, i8** %6
%20 = load i8*, i8** %2
%21 = call i32 @my_free(i8* %20)
%22 = load i8*, i8** %3
%23 = call i32 @my_free(i8* %22)
%24 = load i8*, i8** %4
%25 = call i32 @my_free(i8* %24)
%26 = load i8*, i8** %5
%27 = call i32 @my_free(i8* %26)
%28 = load i8*, i8** %6
%29 = call i32 @my_free(i8* %28)
%30 = load i32, i32* %1
%31 = add nsw i32 %30, -1
store i32 %31, i32* %1
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
br label %9
33: ; preds = %9
%34 = call i32 (...) @destroy_pool()
ret i32 1
}

LLVM IR (-O2):
@.str.1 = [13 x i8] c"Round: %d...\00"
@str = [30 x i8] c"Test Two: Blocks of 200 bytes\00"
@str.3 = [9 x i8] c"Success.\00"
define i32 @test_two() {
%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 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 5)
%4 = tail call i8* @my_malloc(i32 200)
%5 = tail call i8* @my_malloc(i32 200)
%6 = tail call i8* @my_malloc(i32 200)
%7 = tail call i8* @my_malloc(i32 200)
%8 = tail call i8* @my_malloc(i32 200)
%9 = tail call i32 @my_free(i8* %4)
%10 = tail call i32 @my_free(i8* %5)
%11 = tail call i32 @my_free(i8* %6)
%12 = tail call i32 @my_free(i8* %7)
%13 = tail call i32 @my_free(i8* %8)
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.3, i64 0, i64 0))
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 4)
%16 = tail call i8* @my_malloc(i32 200)
%17 = tail call i8* @my_malloc(i32 200)
%18 = tail call i8* @my_malloc(i32 200)
%19 = tail call i8* @my_malloc(i32 200)
%20 = tail call i8* @my_malloc(i32 200)
%21 = tail call i32 @my_free(i8* %16)
%22 = tail call i32 @my_free(i8* %17)
%23 = tail call i32 @my_free(i8* %18)
%24 = tail call i32 @my_free(i8* %19)
%25 = tail call i32 @my_free(i8* %20)
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.3, i64 0, i64 0))
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 3)
%28 = tail call i8* @my_malloc(i32 200)
%29 = tail call i8* @my_malloc(i32 200)
%30 = tail call i8* @my_malloc(i32 200)
%31 = tail call i8* @my_malloc(i32 200)
%32 = tail call i8* @my_malloc(i32 200)
%33 = tail call i32 @my_free(i8* %28)
%34 = tail call i32 @my_free(i8* %29)
%35 = tail call i32 @my_free(i8* %30)
%36 = tail call i32 @my_free(i8* %31)
%37 = tail call i32 @my_free(i8* %32)
%38 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.3, i64 0, i64 0))
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 2)
%40 = tail call i8* @my_malloc(i32 200)
%41 = tail call i8* @my_malloc(i32 200)
%42 = tail call i8* @my_malloc(i32 200)
%43 = tail call i8* @my_malloc(i32 200)
%44 = tail call i8* @my_malloc(i32 200)
%45 = tail call i32 @my_free(i8* %40)
%46 = tail call i32 @my_free(i8* %41)
%47 = tail call i32 @my_free(i8* %42)
%48 = tail call i32 @my_free(i8* %43)
%49 = tail call i32 @my_free(i8* %44)
%50 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.3, i64 0, i64 0))
%51 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 1)
%52 = tail call i8* @my_malloc(i32 200)
%53 = tail call i8* @my_malloc(i32 200)
%54 = tail call i8* @my_malloc(i32 200)
%55 = tail call i8* @my_malloc(i32 200)
%56 = tail call i8* @my_malloc(i32 200)
%57 = tail call i32 @my_free(i8* %52)
%58 = tail call i32 @my_free(i8* %53)
%59 = tail call i32 @my_free(i8* %54)
%60 = tail call i32 @my_free(i8* %55)
%61 = tail call i32 @my_free(i8* %56)
%62 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.3, i64 0, i64 0))
%63 = tail call i32 (...) @destroy_pool()
ret i32 1
}