#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*/ fragments();
int /*<<< orphan*/ print_free();
void *talloc(int);
int /*<<< orphan*/ tfree(void *);
int main(int argc, char **argv) {
  void *ptr1 = talloc(21);
  tfree(ptr1);
  void *ptr2 = talloc(7);
  void *ptr3 = talloc(7);
  void *ptr4 = talloc(7);
  tfree(ptr2);
  tfree(ptr4);
  void *ptr5 = talloc(5);
  tfree(ptr5);
  print_free();
  fragments();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x15,%edi
call   1050 <talloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <tfree@plt>
mov    $0x7,%edi
call   1050 <talloc@plt>
mov    %rax,-0x20(%rbp)
mov    $0x7,%edi
call   1050 <talloc@plt>
mov    %rax,-0x28(%rbp)
mov    $0x7,%edi
call   1050 <talloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <tfree@plt>
mov    -0x30(%rbp),%rdi
call   1040 <tfree@plt>
mov    $0x5,%edi
call   1050 <talloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
call   1040 <tfree@plt>
mov    $0x0,%al
call   1030 <print_free@plt>
mov    $0x0,%al
call   1060 <fragments@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x15,%edi
call   1050 <talloc@plt>
mov    %rax,%rdi
call   1040 <tfree@plt>
mov    $0x7,%edi
call   1050 <talloc@plt>
mov    %rax,%r14
mov    $0x7,%edi
call   1050 <talloc@plt>
mov    $0x7,%edi
call   1050 <talloc@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1040 <tfree@plt>
mov    %rbx,%rdi
call   1040 <tfree@plt>
mov    $0x5,%edi
call   1050 <talloc@plt>
mov    %rax,%rdi
call   1040 <tfree@plt>
xor    %eax,%eax
call   1030 <print_free@plt>
xor    %eax,%eax
call   1060 <fragments@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call i8* @talloc(i32 21)
store i8* %11, i8** %6
%12 = load i8*, i8** %6
%13 = call i32 @tfree(i8* %12)
%14 = call i8* @talloc(i32 7)
store i8* %14, i8** %7
%15 = call i8* @talloc(i32 7)
store i8* %15, i8** %8
%16 = call i8* @talloc(i32 7)
store i8* %16, i8** %9
%17 = load i8*, i8** %7
%18 = call i32 @tfree(i8* %17)
%19 = load i8*, i8** %9
%20 = call i32 @tfree(i8* %19)
%21 = call i8* @talloc(i32 5)
store i8* %21, i8** %10
%22 = load i8*, i8** %10
%23 = call i32 @tfree(i8* %22)
%24 = call i32 (...) @print_free()
%25 = call i32 (...) @fragments()
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i8* @talloc(i32 21)
%4 = tail call i32 @tfree(i8* %3)
%5 = tail call i8* @talloc(i32 7)
%6 = tail call i8* @talloc(i32 7)
%7 = tail call i8* @talloc(i32 7)
%8 = tail call i32 @tfree(i8* %5)
%9 = tail call i32 @tfree(i8* %7)
%10 = tail call i8* @talloc(i32 5)
%11 = tail call i32 @tfree(i8* %10)
%12 = tail call i32 (...) @print_free()
%13 = tail call i32 (...) @fragments()
ret i32 0
}