#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 */
scalar_t__ myalloc(int);
int /*<<< orphan*/ myallocinit(int);
int /*<<< orphan*/ myfree(char *);
int /*<<< orphan*/ mygc();
int /*<<< orphan*/ printallocation();
int main() {
  char *p;
  myallocinit(100);
  p = (char *)myalloc(4);
  printallocation();
  myfree(p);
  printallocation();
  p = (char *)myalloc(6);
  printallocation();
  p = (char *)myalloc(10);
  printallocation();
  mygc();
  printallocation();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x64,%edi
call   1060 <myallocinit@plt>
mov    $0x4,%edi
call   1030 <myalloc@plt>
mov    %rax,-0x8(%rbp)
mov    $0x0,%al
call   1040 <printallocation@plt>
mov    -0x8(%rbp),%rdi
call   1070 <myfree@plt>
mov    $0x0,%al
call   1040 <printallocation@plt>
mov    $0x6,%edi
call   1030 <myalloc@plt>
mov    %rax,-0x8(%rbp)
mov    $0x0,%al
call   1040 <printallocation@plt>
mov    $0xa,%edi
call   1030 <myalloc@plt>
mov    %rax,-0x8(%rbp)
mov    $0x0,%al
call   1040 <printallocation@plt>
mov    $0x0,%al
call   1050 <mygc@plt>
mov    $0x0,%al
call   1040 <printallocation@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x64,%edi
call   1060 <myallocinit@plt>
mov    $0x4,%edi
call   1030 <myalloc@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1040 <printallocation@plt>
mov    %rbx,%rdi
call   1070 <myfree@plt>
xor    %eax,%eax
call   1040 <printallocation@plt>
mov    $0x6,%edi
call   1030 <myalloc@plt>
xor    %eax,%eax
call   1040 <printallocation@plt>
mov    $0xa,%edi
call   1030 <myalloc@plt>
xor    %eax,%eax
call   1040 <printallocation@plt>
xor    %eax,%eax
call   1050 <mygc@plt>
xor    %eax,%eax
call   1040 <printallocation@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i8*
%2 = call i32 @myallocinit(i32 100)
%3 = call i64 @myalloc(i32 4)
%4 = inttoptr i64 %3 to i8*
store i8* %4, i8** %1
%5 = call i32 (...) @printallocation()
%6 = load i8*, i8** %1
%7 = call i32 @myfree(i8* %6)
%8 = call i32 (...) @printallocation()
%9 = call i64 @myalloc(i32 6)
%10 = inttoptr i64 %9 to i8*
store i8* %10, i8** %1
%11 = call i32 (...) @printallocation()
%12 = call i64 @myalloc(i32 10)
%13 = inttoptr i64 %12 to i8*
store i8* %13, i8** %1
%14 = call i32 (...) @printallocation()
%15 = call i32 (...) @mygc()
%16 = call i32 (...) @printallocation()
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 @myallocinit(i32 100)
%2 = tail call i64 @myalloc(i32 4)
%3 = inttoptr i64 %2 to i8*
%4 = tail call i32 (...) @printallocation()
%5 = tail call i32 @myfree(i8* %3)
%6 = tail call i32 (...) @printallocation()
%7 = tail call i64 @myalloc(i32 6)
%8 = tail call i32 (...) @printallocation()
%9 = tail call i64 @myalloc(i32 10)
%10 = tail call i32 (...) @printallocation()
%11 = tail call i32 (...) @mygc()
%12 = tail call i32 (...) @printallocation()
ret i32 0
}