#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 *, void *, char const *, int, size_t);
void *realloc(void *, size_t);
void *debug_realloc(void *ptr, size_t size, const char *filename, int line) {
  debug_print("-free", ptr, filename, line, 0);
  void *p = realloc(ptr, size);
  debug_print("+realloc", p, filename, line, size);
  return p;
}


x86 assembly (clang, -O0):
<debug_realloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
lea    0xeb7(%rip),%rdi
xor    %eax,%eax
mov    %eax,%r8d
call   1040 <debug_print@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <realloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%r8
lea    0xe8c(%rip),%rdi
call   1040 <debug_print@plt>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<debug_realloc>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %rdi,%rbp
lea    0xec6(%rip),%rdi
mov    %rbp,%rsi
xor    %r8d,%r8d
call   1040 <debug_print@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
call   1030 <realloc@plt>
mov    %rax,%rbp
lea    0xeac(%rip),%rdi
mov    %rax,%rsi
mov    %rbx,%rdx
mov    %r14d,%ecx
mov    %r15,%r8
call   1040 <debug_print@plt>
mov    %rbp,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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