#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*/ my_free(void *);
int /*<<< orphan*/ my_mallinfo();
void *my_malloc(int);
int /*<<< orphan*/ my_mallopt(int);
void simpleFirstFitTesting(void) {
  my_mallopt(1);
  void *test1 = my_malloc(20);
  void *test2 = my_malloc(10);
  void *test3 = my_malloc(30);
  my_mallinfo();
  my_free(test2);
  my_mallinfo();
  test2 = my_malloc(2);
  my_mallinfo();
  my_free(test1);
  my_free(test3);
  test1 = my_malloc(19);
  test3 = my_malloc(30);
  my_mallinfo();
  my_free(test1);
  my_free(test2);
  my_free(test3);
}


x86 assembly (clang, -O0):
<simpleFirstFitTesting>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x1,%edi
call   1060 <my_mallopt@plt>
mov    $0x14,%edi
call   1030 <my_malloc@plt>
mov    %rax,-0x8(%rbp)
mov    $0xa,%edi
call   1030 <my_malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x1e,%edi
call   1030 <my_malloc@plt>
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1040 <my_mallinfo@plt>
mov    -0x10(%rbp),%rdi
call   1050 <my_free@plt>
mov    $0x0,%al
call   1040 <my_mallinfo@plt>
mov    $0x2,%edi
call   1030 <my_malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1040 <my_mallinfo@plt>
mov    -0x8(%rbp),%rdi
call   1050 <my_free@plt>
mov    -0x18(%rbp),%rdi
call   1050 <my_free@plt>
mov    $0x13,%edi
call   1030 <my_malloc@plt>
mov    %rax,-0x8(%rbp)
mov    $0x1e,%edi
call   1030 <my_malloc@plt>
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1040 <my_mallinfo@plt>
mov    -0x8(%rbp),%rdi
call   1050 <my_free@plt>
mov    -0x10(%rbp),%rdi
call   1050 <my_free@plt>
mov    -0x18(%rbp),%rdi
call   1050 <my_free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<simpleFirstFitTesting>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    $0x1,%edi
call   1060 <my_mallopt@plt>
mov    $0x14,%edi
call   1030 <my_malloc@plt>
mov    %rax,%r14
mov    $0xa,%edi
call   1030 <my_malloc@plt>
mov    %rax,%rbx
mov    $0x1e,%edi
call   1030 <my_malloc@plt>
mov    %rax,%r15
xor    %eax,%eax
call   1040 <my_mallinfo@plt>
mov    %rbx,%rdi
call   1050 <my_free@plt>
xor    %eax,%eax
call   1040 <my_mallinfo@plt>
mov    $0x2,%edi
call   1030 <my_malloc@plt>
mov    %rax,%r12
xor    %eax,%eax
call   1040 <my_mallinfo@plt>
mov    %r14,%rdi
call   1050 <my_free@plt>
mov    %r15,%rdi
call   1050 <my_free@plt>
mov    $0x13,%edi
call   1030 <my_malloc@plt>
mov    %rax,%rbx
mov    $0x1e,%edi
call   1030 <my_malloc@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1040 <my_mallinfo@plt>
mov    %rbx,%rdi
call   1050 <my_free@plt>
mov    %r12,%rdi
call   1050 <my_free@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1050 <my_free@plt>

LLVM IR (-O0):
define void @simpleFirstFitTesting() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i8*
%4 = call i32 @my_mallopt(i32 1)
%5 = call i8* @my_malloc(i32 20)
store i8* %5, i8** %1
%6 = call i8* @my_malloc(i32 10)
store i8* %6, i8** %2
%7 = call i8* @my_malloc(i32 30)
store i8* %7, i8** %3
%8 = call i32 (...) @my_mallinfo()
%9 = load i8*, i8** %2
%10 = call i32 @my_free(i8* %9)
%11 = call i32 (...) @my_mallinfo()
%12 = call i8* @my_malloc(i32 2)
store i8* %12, i8** %2
%13 = call i32 (...) @my_mallinfo()
%14 = load i8*, i8** %1
%15 = call i32 @my_free(i8* %14)
%16 = load i8*, i8** %3
%17 = call i32 @my_free(i8* %16)
%18 = call i8* @my_malloc(i32 19)
store i8* %18, i8** %1
%19 = call i8* @my_malloc(i32 30)
store i8* %19, i8** %3
%20 = call i32 (...) @my_mallinfo()
%21 = load i8*, i8** %1
%22 = call i32 @my_free(i8* %21)
%23 = load i8*, i8** %2
%24 = call i32 @my_free(i8* %23)
%25 = load i8*, i8** %3
%26 = call i32 @my_free(i8* %25)
ret void
}

LLVM IR (-O2):
define void @simpleFirstFitTesting() {
%1 = tail call i32 @my_mallopt(i32 1)
%2 = tail call i8* @my_malloc(i32 20)
%3 = tail call i8* @my_malloc(i32 10)
%4 = tail call i8* @my_malloc(i32 30)
%5 = tail call i32 (...) @my_mallinfo()
%6 = tail call i32 @my_free(i8* %3)
%7 = tail call i32 (...) @my_mallinfo()
%8 = tail call i8* @my_malloc(i32 2)
%9 = tail call i32 (...) @my_mallinfo()
%10 = tail call i32 @my_free(i8* %2)
%11 = tail call i32 @my_free(i8* %4)
%12 = tail call i8* @my_malloc(i32 19)
%13 = tail call i8* @my_malloc(i32 30)
%14 = tail call i32 (...) @my_mallinfo()
%15 = tail call i32 @my_free(i8* %12)
%16 = tail call i32 @my_free(i8* %8)
%17 = tail call i32 @my_free(i8* %13)
ret void
}