#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();
char *my_malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int test_four() {
  printf("Test Four: Storing characters\n");
  create_pool(1000);
  char *bl1 = my_malloc(200);
  char *bl2 = my_malloc(200);
  char *bl3 = my_malloc(200);
  char *bl4 = my_malloc(200);
  char *bl5 = my_malloc(200);
  int i;
  for (i = 0; i < 199; i++) {
    bl1[i] = 'A';
    bl2[i] = 'B';
    bl3[i] = 'C';
    bl4[i] = 'D';
    bl5[i] = 'E';
  }
  bl1[199] = '\0';
  bl2[199] = '\0';
  bl3[199] = '\0';
  bl4[199] = '\0';
  bl5[199] = '\0';
  printf("%s\n", bl1);
  printf("%s\n", bl2);
  printf("%s\n", bl3);
  printf("%s\n", bl4);
  printf("%s\n", bl5);
  printf("Test Four Complete.\n");
  destroy_pool();
  return 1;
}


x86 assembly (clang, -O0):
<test_four>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x3e8,%edi
call   1050 <create_pool@plt>
mov    $0xc8,%edi
call   1030 <my_malloc@plt>
mov    %rax,-0x8(%rbp)
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)
movl   $0x0,-0x2c(%rbp)
cmpl   $0xc7,-0x2c(%rbp)
jge    1204 <test_four+0xc4>
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movb   $0x41,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movb   $0x42,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movb   $0x43,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movb   $0x44,(%rax,%rcx,1)
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movb   $0x45,(%rax,%rcx,1)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11ad <test_four+0x6d>
mov    -0x8(%rbp),%rax
movb   $0x0,0xc7(%rax)
mov    -0x10(%rbp),%rax
movb   $0x0,0xc7(%rax)
mov    -0x18(%rbp),%rax
movb   $0x0,0xc7(%rax)
mov    -0x20(%rbp),%rax
movb   $0x0,0xc7(%rax)
mov    -0x28(%rbp),%rax
movb   $0x0,0xc7(%rax)
mov    -0x8(%rbp),%rsi
lea    0xdd9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xdc7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xdb5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xda3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rsi
lea    0xd91(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd87(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <destroy_pool@plt>
mov    $0x1,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_four>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
lea    0xeb0(%rip),%rdi
call   1040 <puts@plt>
mov    $0x3e8,%edi
call   1050 <create_pool@plt>
mov    $0xc8,%edi
call   1030 <my_malloc@plt>
mov    %rax,%r14
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,%rbx
mov    $0xc8,%edi
call   1030 <my_malloc@plt>
mov    %rax,%r13
add    $0x1,%rax
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
movb   $0x41,(%r14,%rcx,1)
movb   $0x42,(%r15,%rcx,1)
movb   $0x43,(%r12,%rcx,1)
movb   $0x44,(%rbx,%rcx,1)
movb   $0x45,-0x1(%rax,%rcx,1)
cmp    $0xc6,%rcx
je     11f2 <test_four+0xb2>
movb   $0x41,0x1(%r14,%rcx,1)
movb   $0x42,0x1(%r15,%rcx,1)
movb   $0x43,0x1(%r12,%rcx,1)
movb   $0x44,0x1(%rbx,%rcx,1)
movb   $0x45,(%rax,%rcx,1)
add    $0x2,%rcx
jmp    11b0 <test_four+0x70>
movb   $0x0,0xc7(%r14)
movb   $0x0,0xc7(%r15)
movb   $0x0,0xc7(%r12)
movb   $0x0,0xc7(%rbx)
movb   $0x0,0xc7(%r13)
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    %r13,%rdi
call   1040 <puts@plt>
lea    0xdd5(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1060 <destroy_pool@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Test Four: Storing characters\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [21 x i8] c"Test Four Complete.\0A\00"
define i32 @test_four() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%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)
%9 = call i8* @my_malloc(i32 200)
store i8* %9, i8** %1
%10 = call i8* @my_malloc(i32 200)
store i8* %10, i8** %2
%11 = call i8* @my_malloc(i32 200)
store i8* %11, i8** %3
%12 = call i8* @my_malloc(i32 200)
store i8* %12, i8** %4
%13 = call i8* @my_malloc(i32 200)
store i8* %13, i8** %5
store i32 0, i32* %6
br label %14
14: ; preds = %38, %0
%15 = load i32, i32* %6
%16 = icmp slt i32 %15, 199
br i1 %16, label %17, label %41
17: ; preds = %14
%18 = load i8*, i8** %1
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
store i8 65, i8* %21
%22 = load i8*, i8** %2
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
store i8 66, i8* %25
%26 = load i8*, i8** %3
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
store i8 67, i8* %29
%30 = load i8*, i8** %4
%31 = load i32, i32* %6
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
store i8 68, i8* %33
%34 = load i8*, i8** %5
%35 = load i32, i32* %6
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
store i8 69, i8* %37
br label %38
38: ; preds = %17
%39 = load i32, i32* %6
%40 = add nsw i32 %39, 1
store i32 %40, i32* %6
br label %14
41: ; preds = %14
%42 = load i8*, i8** %1
%43 = getelementptr inbounds i8, i8* %42, i64 199
store i8 0, i8* %43
%44 = load i8*, i8** %2
%45 = getelementptr inbounds i8, i8* %44, i64 199
store i8 0, i8* %45
%46 = load i8*, i8** %3
%47 = getelementptr inbounds i8, i8* %46, i64 199
store i8 0, i8* %47
%48 = load i8*, i8** %4
%49 = getelementptr inbounds i8, i8* %48, i64 199
store i8 0, i8* %49
%50 = load i8*, i8** %5
%51 = getelementptr inbounds i8, i8* %50, i64 199
store i8 0, i8* %51
%52 = load i8*, i8** %1
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %52)
%54 = load i8*, i8** %2
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %54)
%56 = load i8*, i8** %3
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %56)
%58 = load i8*, i8** %4
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %58)
%60 = load i8*, i8** %5
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %60)
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%63 = call i32 (...) @destroy_pool()
ret i32 1
}

LLVM IR (-O2):
@str = [30 x i8] c"Test Four: Storing characters\00"
@str.3 = [20 x i8] c"Test Four Complete.\00"
define i32 @test_four() {
%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 i8* @my_malloc(i32 200)
%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)
br label %8
8: ; preds = %17, %0
%9 = phi i64 [ 0, %0 ], [ %23, %17 ]
%10 = getelementptr inbounds i8, i8* %3, i64 %9
store i8 65, i8* %10
%11 = getelementptr inbounds i8, i8* %4, i64 %9
store i8 66, i8* %11
%12 = getelementptr inbounds i8, i8* %5, i64 %9
store i8 67, i8* %12
%13 = getelementptr inbounds i8, i8* %6, i64 %9
store i8 68, i8* %13
%14 = getelementptr inbounds i8, i8* %7, i64 %9
store i8 69, i8* %14
%15 = or i64 %9, 1
%16 = icmp eq i64 %15, 199
br i1 %16, label %24, label %17
17: ; preds = %8
%18 = getelementptr inbounds i8, i8* %3, i64 %15
store i8 65, i8* %18
%19 = getelementptr inbounds i8, i8* %4, i64 %15
store i8 66, i8* %19
%20 = getelementptr inbounds i8, i8* %5, i64 %15
store i8 67, i8* %20
%21 = getelementptr inbounds i8, i8* %6, i64 %15
store i8 68, i8* %21
%22 = getelementptr inbounds i8, i8* %7, i64 %15
store i8 69, i8* %22
%23 = add nuw nsw i64 %9, 2
br label %8
24: ; preds = %8
%25 = getelementptr inbounds i8, i8* %3, i64 199
store i8 0, i8* %25
%26 = getelementptr inbounds i8, i8* %4, i64 199
store i8 0, i8* %26
%27 = getelementptr inbounds i8, i8* %5, i64 199
store i8 0, i8* %27
%28 = getelementptr inbounds i8, i8* %6, i64 199
store i8 0, i8* %28
%29 = getelementptr inbounds i8, i8* %7, i64 199
store i8 0, i8* %29
%30 = tail call i32 @puts(i8* dereferenceable(1) %3)
%31 = tail call i32 @puts(i8* dereferenceable(1) %4)
%32 = tail call i32 @puts(i8* dereferenceable(1) %5)
%33 = tail call i32 @puts(i8* dereferenceable(1) %6)
%34 = tail call i32 @puts(i8* dereferenceable(1) %7)
%35 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.3, i64 0, i64 0))
%36 = tail call i32 (...) @destroy_pool()
ret i32 1
}