#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*/ debug_print(char const *, int, char *, void *,
                               int /*<<< orphan*/, int);
int /*<<< orphan*/ debug_removepointer(void *, char const *, int);
int /*<<< orphan*/ free(void *);
void debug_free(void *ptr, const char *file, int line) {
  debug_print(file, line, "free", ptr, 0, 0);
  free(ptr);
  debug_removepointer(ptr, file, line);
  debug_print(file, line, "free", 0, 0, 1);
}


x86 assembly (clang, -O0):
<debug_free>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x8(%rbp),%rcx
lea    0xeab(%rip),%rdx
xor    %r9d,%r9d
mov    %r9d,%r8d
call   1050 <debug_print@plt>
mov    -0x8(%rbp),%rdi
call   1040 <free@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <debug_removepointer@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    0xe79(%rip),%rdx
xor    %eax,%eax
mov    %eax,%ecx
xor    %r8d,%r8d
mov    $0x1,%r9d
call   1050 <debug_print@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<debug_free>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %rdi,%rbp
lea    0xeb9(%rip),%r15
mov    %rsi,%rdi
mov    %edx,%esi
mov    %r15,%rdx
mov    %rbp,%rcx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1050 <debug_print@plt>
mov    %rbp,%rdi
call   1040 <free@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1030 <debug_removepointer@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %r15,%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
mov    $0x1,%r9d
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <debug_print@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"free\00"
define void @debug_free(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%7 = load i8*, i8** %5
%8 = load i32, i32* %6
%9 = load i8*, i8** %4
%10 = call i32 @debug_print(i8* %7, i32 %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %9, i32 0, i32 0)
%11 = load i8*, i8** %4
%12 = call i32 @free(i8* %11)
%13 = load i8*, i8** %4
%14 = load i8*, i8** %5
%15 = load i32, i32* %6
%16 = call i32 @debug_removepointer(i8* %13, i8* %14, i32 %15)
%17 = load i8*, i8** %5
%18 = load i32, i32* %6
%19 = call i32 @debug_print(i8* %17, i32 %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* null, i32 0, i32 1)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"free\00"
define void @debug_free(i8* %0, i8* %1, i32 %2) {
%4 = tail call i32 @debug_print(i8* %1, i32 %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0, i32 0, i32 0)
%5 = tail call i32 @free(i8* %0)
%6 = tail call i32 @debug_removepointer(i8* %0, i8* %1, i32 %2)
%7 = tail call i32 @debug_print(i8* %1, i32 %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* null, i32 0, i32 1)
ret void
}