#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(double *);
int /*<<< orphan*/ printallocation();
int main() {
  double *p1, *p2;
  myallocinit(56);
  printallocation();
  p1 = (double *)myalloc(20);
  printallocation();
  p2 = (double *)myalloc(10);
  printallocation();
  myfree(p1);
  printallocation();
  myfree(p2);
  printallocation();
  p1 = (double *)myalloc(20);
  printallocation();
  p2 = (double *)myalloc(24);
  printallocation();
  myfree(p1);
  printallocation();
  myfree(p2);
  printallocation();
  p1 = (double *)myalloc(56);
  printallocation();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x38,%edi
call   1050 <myallocinit@plt>
mov    $0x0,%al
call   1040 <printallocation@plt>
mov    $0x14,%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,-0x10(%rbp)
mov    $0x0,%al
call   1040 <printallocation@plt>
mov    -0x8(%rbp),%rdi
call   1060 <myfree@plt>
mov    $0x0,%al
call   1040 <printallocation@plt>
mov    -0x10(%rbp),%rdi
call   1060 <myfree@plt>
mov    $0x0,%al
call   1040 <printallocation@plt>
mov    $0x14,%edi
call   1030 <myalloc@plt>
mov    %rax,-0x8(%rbp)
mov    $0x0,%al
call   1040 <printallocation@plt>
mov    $0x18,%edi
call   1030 <myalloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1040 <printallocation@plt>
mov    -0x8(%rbp),%rdi
call   1060 <myfree@plt>
mov    $0x0,%al
call   1040 <printallocation@plt>
mov    -0x10(%rbp),%rdi
call   1060 <myfree@plt>
mov    $0x0,%al
call   1040 <printallocation@plt>
mov    $0x38,%edi
call   1030 <myalloc@plt>
mov    %rax,-0x8(%rbp)
mov    $0x0,%al
call   1040 <printallocation@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x38,%edi
call   1050 <myallocinit@plt>
xor    %eax,%eax
call   1040 <printallocation@plt>
mov    $0x14,%edi
call   1030 <myalloc@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1040 <printallocation@plt>
mov    $0xa,%edi
call   1030 <myalloc@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1040 <printallocation@plt>
mov    %r14,%rdi
call   1060 <myfree@plt>
xor    %eax,%eax
call   1040 <printallocation@plt>
mov    %rbx,%rdi
call   1060 <myfree@plt>
xor    %eax,%eax
call   1040 <printallocation@plt>
mov    $0x14,%edi
call   1030 <myalloc@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1040 <printallocation@plt>
mov    $0x18,%edi
call   1030 <myalloc@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1040 <printallocation@plt>
mov    %r14,%rdi
call   1060 <myfree@plt>
xor    %eax,%eax
call   1040 <printallocation@plt>
mov    %rbx,%rdi
call   1060 <myfree@plt>
xor    %eax,%eax
call   1040 <printallocation@plt>
mov    $0x38,%edi
call   1030 <myalloc@plt>
xor    %eax,%eax
call   1040 <printallocation@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca double*
%2 = alloca double*
%3 = call i32 @myallocinit(i32 56)
%4 = call i32 (...) @printallocation()
%5 = call i64 @myalloc(i32 20)
%6 = inttoptr i64 %5 to double*
store double* %6, double** %1
%7 = call i32 (...) @printallocation()
%8 = call i64 @myalloc(i32 10)
%9 = inttoptr i64 %8 to double*
store double* %9, double** %2
%10 = call i32 (...) @printallocation()
%11 = load double*, double** %1
%12 = call i32 @myfree(double* %11)
%13 = call i32 (...) @printallocation()
%14 = load double*, double** %2
%15 = call i32 @myfree(double* %14)
%16 = call i32 (...) @printallocation()
%17 = call i64 @myalloc(i32 20)
%18 = inttoptr i64 %17 to double*
store double* %18, double** %1
%19 = call i32 (...) @printallocation()
%20 = call i64 @myalloc(i32 24)
%21 = inttoptr i64 %20 to double*
store double* %21, double** %2
%22 = call i32 (...) @printallocation()
%23 = load double*, double** %1
%24 = call i32 @myfree(double* %23)
%25 = call i32 (...) @printallocation()
%26 = load double*, double** %2
%27 = call i32 @myfree(double* %26)
%28 = call i32 (...) @printallocation()
%29 = call i64 @myalloc(i32 56)
%30 = inttoptr i64 %29 to double*
store double* %30, double** %1
%31 = call i32 (...) @printallocation()
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 @myallocinit(i32 56)
%2 = tail call i32 (...) @printallocation()
%3 = tail call i64 @myalloc(i32 20)
%4 = inttoptr i64 %3 to double*
%5 = tail call i32 (...) @printallocation()
%6 = tail call i64 @myalloc(i32 10)
%7 = inttoptr i64 %6 to double*
%8 = tail call i32 (...) @printallocation()
%9 = tail call i32 @myfree(double* %4)
%10 = tail call i32 (...) @printallocation()
%11 = tail call i32 @myfree(double* %7)
%12 = tail call i32 (...) @printallocation()
%13 = tail call i64 @myalloc(i32 20)
%14 = inttoptr i64 %13 to double*
%15 = tail call i32 (...) @printallocation()
%16 = tail call i64 @myalloc(i32 24)
%17 = inttoptr i64 %16 to double*
%18 = tail call i32 (...) @printallocation()
%19 = tail call i32 @myfree(double* %14)
%20 = tail call i32 (...) @printallocation()
%21 = tail call i32 @myfree(double* %17)
%22 = tail call i32 (...) @printallocation()
%23 = tail call i64 @myalloc(i32 56)
%24 = tail call i32 (...) @printallocation()
ret i32 0
}