#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 */
void *calloc(size_t, size_t);
int /*<<< orphan*/ debug_addpointer(void *, size_t, char const *, int);
int /*<<< orphan*/ debug_print(char const *, int, char *, void *, size_t, int);
void *debug_calloc(size_t nmemb, size_t size, const char *file, int line) {
  void *ptr;
  debug_print(file, line, "calloc", 0, size, 0);
  ptr = calloc(nmemb, size);
  debug_addpointer(ptr, size, file, line);
  debug_print(file, line, "calloc", ptr, size, 1);
  return ptr;
}


x86 assembly (clang, -O0):
<debug_calloc>:
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    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x10(%rbp),%r8
lea    0xea7(%rip),%rdx
xor    %eax,%eax
mov    %eax,%ecx
xor    %r9d,%r9d
call   1050 <debug_print@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <calloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
call   1040 <debug_addpointer@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x28(%rbp),%rcx
mov    -0x10(%rbp),%r8
lea    0xe60(%rip),%rdx
mov    $0x1,%r9d
call   1050 <debug_print@plt>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<debug_calloc>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %rdx,%r13
mov    %rsi,%rbx
mov    %rdi,%r15
lea    0xeb2(%rip),%r12
mov    %rdx,%rdi
mov    %ecx,%esi
mov    %r12,%rdx
xor    %ecx,%ecx
mov    %rbx,%r8
xor    %r9d,%r9d
call   1050 <debug_print@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <calloc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
mov    %r14d,%ecx
call   1040 <debug_addpointer@plt>
mov    %r13,%rdi
mov    %r14d,%esi
mov    %r12,%rdx
mov    %rbp,%rcx
mov    %rbx,%r8
mov    $0x1,%r9d
call   1050 <debug_print@plt>
mov    %rbp,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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