#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*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
void memListPrintEntry(int mtype, int item, size_t size, void *ptr,
                       const char *caller, const char *file, int line) {
  switch (mtype) {
  case 0:
    fprintf(stderr, "[%-7s ", "Malloc");
    break;
  case 1:
    fprintf(stderr, "[%-7s ", "Calloc");
    break;
  case 2:
    fprintf(stderr, "[%-7s ", "Realloc");
    break;
  case 3:
    fprintf(stderr, "[%-7s ", "Free");
    break;
  }
  fprintf(stderr, "memory item %3d ", item);
  fprintf(stderr, "(%6zu byte) ", size);
  fprintf(stderr, "at %p", ptr);
  if (file != NULL) {
    fprintf(stderr, " line %4d", line);
    fprintf(stderr, " file %s", file);
  }
  if (caller != NULL)
    fprintf(stderr, " (%s)", caller);
  fprintf(stderr, "]\n");
}


x86 assembly (clang, -O0):
<memListPrintEntry>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x10(%rbp),%eax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x30(%rbp)
sub    $0x3,%rax
ja     11dd <memListPrintEntry+0xcd>
mov    -0x30(%rbp),%rax
lea    0xeb3(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2e83(%rip),%rax
mov    (%rax),%edi
lea    0xeaa(%rip),%rsi
lea    0xeaa(%rip),%rdx
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11dd <memListPrintEntry+0xcd>
mov    0x2e60(%rip),%rax
mov    (%rax),%edi
lea    0xe87(%rip),%rsi
lea    0xe8e(%rip),%rdx
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11dd <memListPrintEntry+0xcd>
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
lea    0xe64(%rip),%rsi
lea    0xe72(%rip),%rdx
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11dd <memListPrintEntry+0xcd>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
lea    0xe41(%rip),%rsi
lea    0xe57(%rip),%rdx
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2dfc(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
lea    0xe42(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2de2(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe38(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2dc7(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe2a(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
cmpq   $0x0,-0x28(%rbp)
je     126d <memListPrintEntry+0x15d>
mov    0x2da1(%rip),%rax
mov    (%rax),%edi
mov    0x10(%rbp),%edx
lea    0xe0b(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2d87(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
lea    0xdfa(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
cmpq   $0x0,-0x20(%rbp)
je     1293 <memListPrintEntry+0x183>
mov    0x2d61(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xddd(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2d46(%rip),%rax
mov    (%rax),%edi
lea    0xdcc(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<memListPrintEntry>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,%r12
mov    %r8,%r14
mov    %rcx,%r13
mov    %rdx,%rbx
mov    %esi,%ebp
mov    0x40(%rsp),%eax
mov    %eax,0x4(%rsp)
cmp    $0x3,%edi
ja     115e <memListPrintEntry+0x4e>
movslq %edi,%rax
lea    0xf24(%rip),%rcx
movslq (%rcx,%rax,4),%rdx
add    %rcx,%rdx
mov    0x2e92(%rip),%rax
mov    (%rax),%edi
lea    0xea9(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    0x2e7b(%rip),%r15
mov    (%r15),%edi
lea    0xeb3(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r15),%edi
lea    0xeb1(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r15),%edi
lea    0xeaa(%rip),%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
test   %r12,%r12
je     11ce <memListPrintEntry+0xbe>
mov    (%r15),%edi
lea    0xe97(%rip),%rsi
mov    0x4(%rsp),%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r15),%edi
lea    0xe8c(%rip),%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
test   %r14,%r14
je     11e7 <memListPrintEntry+0xd7>
mov    (%r15),%edi
lea    0xe7c(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r15),%edi
lea    0xe6e(%rip),%rsi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fprintf@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [7 x i8] c"[%-7s \00"
@.str.1 = [7 x i8] c"Malloc\00"
@.str.2 = [7 x i8] c"Calloc\00"
@.str.3 = [8 x i8] c"Realloc\00"
@.str.4 = [5 x i8] c"Free\00"
@.str.5 = [17 x i8] c"memory item %3d \00"
@.str.6 = [13 x i8] c"(%6zu byte) \00"
@.str.7 = [6 x i8] c"at %p\00"
@.str.8 = [10 x i8] c" line %4d\00"
@.str.9 = [9 x i8] c" file %s\00"
@.str.10 = [6 x i8] c" (%s)\00"
@.str.11 = [3 x i8] c"]\0A\00"
define void @memListPrintEntry(i32 %0, i32 %1, i64 %2, i8* %3, i8* %4, i8* %5, i32 %6) {
%8 = alloca i32
%9 = alloca i32
%10 = alloca i64
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i32
store i32 %0, i32* %8
store i32 %1, i32* %9
store i64 %2, i64* %10
store i8* %3, i8** %11
store i8* %4, i8** %12
store i8* %5, i8** %13
store i32 %6, i32* %14
%15 = load i32, i32* %8
switch i32 %15, label %28 [
i32 0, label %16
i32 1, label %19
i32 2, label %22
i32 3, label %25
]
16: ; preds = %7
%17 = load i32, i32* @stderr
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %28
19: ; preds = %7
%20 = load i32, i32* @stderr
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %28
22: ; preds = %7
%23 = load i32, i32* @stderr
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %28
25: ; preds = %7
%26 = load i32, i32* @stderr
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %28
28: ; preds = %7, %25, %22, %19, %16
%29 = load i32, i32* @stderr
%30 = load i32, i32* %9
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 %30)
%32 = load i32, i32* @stderr
%33 = load i64, i64* %10
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i64 %33)
%35 = load i32, i32* @stderr
%36 = load i8*, i8** %11
%37 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8* %36)
%38 = load i8*, i8** %13
%39 = icmp ne i8* %38, null
br i1 %39, label %40, label %47
40: ; preds = %28
%41 = load i32, i32* @stderr
%42 = load i32, i32* %14
%43 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i32 %42)
%44 = load i32, i32* @stderr
%45 = load i8*, i8** %13
%46 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i8* %45)
br label %47
47: ; preds = %40, %28
%48 = load i8*, i8** %12
%49 = icmp ne i8* %48, null
br i1 %49, label %50, label %54
50: ; preds = %47
%51 = load i32, i32* @stderr
%52 = load i8*, i8** %12
%53 = call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i8* %52)
br label %54
54: ; preds = %50, %47
%55 = load i32, i32* @stderr
%56 = call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [7 x i8] c"[%-7s \00"
@.str.1 = [7 x i8] c"Malloc\00"
@.str.2 = [7 x i8] c"Calloc\00"
@.str.3 = [8 x i8] c"Realloc\00"
@.str.4 = [5 x i8] c"Free\00"
@.str.5 = [17 x i8] c"memory item %3d \00"
@.str.6 = [13 x i8] c"(%6zu byte) \00"
@.str.7 = [6 x i8] c"at %p\00"
@.str.8 = [10 x i8] c" line %4d\00"
@.str.9 = [9 x i8] c" file %s\00"
@.str.10 = [6 x i8] c" (%s)\00"
@.str.11 = [3 x i8] c"]\0A\00"
@reltable.memListPrintEntry = [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.1 to i64), i64 ptrtoint ([4 x i32]* @reltable.memListPrintEntry to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.2 to i64), i64 ptrtoint ([4 x i32]* @reltable.memListPrintEntry to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.3 to i64), i64 ptrtoint ([4 x i32]* @reltable.memListPrintEntry to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.4 to i64), i64 ptrtoint ([4 x i32]* @reltable.memListPrintEntry to i64)) to i32)]
define void @memListPrintEntry(i32 %0, i32 %1, i64 %2, i8* %3, i8* %4, i8* %5, i32 %6) {
%8 = icmp ult i32 %0, 4
br i1 %8, label %9, label %15
9: ; preds = %7
%10 = sext i32 %0 to i64
%11 = shl i64 %10, 2
%12 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.memListPrintEntry to i8*), i64 %11)
%13 = load i32, i32* @stderr
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %12)
br label %15
15: ; preds = %7, %9
%16 = load i32, i32* @stderr
%17 = tail call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 %1)
%18 = load i32, i32* @stderr
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i64 %2)
%20 = load i32, i32* @stderr
%21 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8* %3)
%22 = icmp eq i8* %5, null
br i1 %22, label %28, label %23
23: ; preds = %15
%24 = load i32, i32* @stderr
%25 = tail call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i32 %6)
%26 = load i32, i32* @stderr
%27 = tail call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i8* %5)
br label %28
28: ; preds = %23, %15
%29 = icmp eq i8* %4, null
br i1 %29, label %33, label %30
30: ; preds = %28
%31 = load i32, i32* @stderr
%32 = tail call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i8* %4)
br label %33
33: ; preds = %30, %28
%34 = load i32, i32* @stderr
%35 = tail call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
ret void
}