#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*/ IN_WaitButton();
int MM_PurgableBlocks();
int MM_UsedBlocks();
int MM_UsedMemory();
int /*<<< orphan*/ US_CPrint(char *);
int /*<<< orphan*/ US_CenterWindow(int, int);
int /*<<< orphan*/ US_PrintF(char *, int);
int VL_MemUsed();
int VL_NumSurfaces();
int /*<<< orphan*/ VL_Present();
void CK_DebugMemory() {
  US_CenterWindow(16, 10);
  US_CPrint("Memory Usage:\n");
  US_CPrint("-------------\n");
  US_PrintF("In Use      : %dk\n", MM_UsedMemory() / 1024);
  US_PrintF("Blocks      : %d\n", MM_UsedBlocks());
  US_PrintF("Purgable    : %d\n", MM_PurgableBlocks());
  US_PrintF("GFX Mem Used: %dk\n", VL_MemUsed() / 1024);
  US_PrintF("GFX Surfaces: %d\n", VL_NumSurfaces());
  VL_Present();
  IN_WaitButton();
}


x86 assembly (clang, -O0):
<CK_DebugMemory>:
push   %rbp
mov    %rsp,%rbp
mov    $0x10,%edi
mov    $0xa,%esi
call   1090 <US_CenterWindow@plt>
lea    0xe46(%rip),%rdi
call   1060 <US_CPrint@plt>
lea    0xe49(%rip),%rdi
call   1060 <US_CPrint@plt>
mov    $0x0,%al
call   1050 <MM_UsedMemory@plt>
mov    $0x400,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xe3b(%rip),%rdi
call   10c0 <US_PrintF@plt>
mov    $0x0,%al
call   10a0 <MM_UsedBlocks@plt>
mov    %eax,%esi
lea    0xe39(%rip),%rdi
call   10c0 <US_PrintF@plt>
mov    $0x0,%al
call   10b0 <MM_PurgableBlocks@plt>
mov    %eax,%esi
lea    0xe36(%rip),%rdi
call   10c0 <US_PrintF@plt>
mov    $0x0,%al
call   1030 <VL_MemUsed@plt>
mov    $0x400,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xe2b(%rip),%rdi
call   10c0 <US_PrintF@plt>
mov    $0x0,%al
call   1040 <VL_NumSurfaces@plt>
mov    %eax,%esi
lea    0xe29(%rip),%rdi
call   10c0 <US_PrintF@plt>
mov    $0x0,%al
call   1080 <VL_Present@plt>
mov    $0x0,%al
call   1070 <IN_WaitButton@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<CK_DebugMemory>:
push   %rax
mov    $0x10,%edi
mov    $0xa,%esi
call   1090 <US_CenterWindow@plt>
lea    0xe49(%rip),%rdi
call   1060 <US_CPrint@plt>
lea    0xe4c(%rip),%rdi
call   1060 <US_CPrint@plt>
xor    %eax,%eax
call   1050 <MM_UsedMemory@plt>
lea    0x3ff(%rax),%esi
test   %eax,%eax
cmovns %eax,%esi
sar    $0xa,%esi
lea    0xe3a(%rip),%rdi
call   10c0 <US_PrintF@plt>
xor    %eax,%eax
call   10a0 <MM_UsedBlocks@plt>
lea    0xe3a(%rip),%rdi
mov    %eax,%esi
call   10c0 <US_PrintF@plt>
xor    %eax,%eax
call   10b0 <MM_PurgableBlocks@plt>
lea    0xe37(%rip),%rdi
mov    %eax,%esi
call   10c0 <US_PrintF@plt>
xor    %eax,%eax
call   1030 <VL_MemUsed@plt>
lea    0x3ff(%rax),%esi
test   %eax,%eax
cmovns %eax,%esi
sar    $0xa,%esi
lea    0xe26(%rip),%rdi
call   10c0 <US_PrintF@plt>
xor    %eax,%eax
call   1040 <VL_NumSurfaces@plt>
lea    0xe26(%rip),%rdi
mov    %eax,%esi
call   10c0 <US_PrintF@plt>
xor    %eax,%eax
call   1080 <VL_Present@plt>
xor    %eax,%eax
pop    %rcx
jmp    1070 <IN_WaitButton@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"Memory Usage:\0A\00"
@.str.1 = [15 x i8] c"-------------\0A\00"
@.str.2 = [19 x i8] c"In Use : %dk\0A\00"
@.str.3 = [18 x i8] c"Blocks : %d\0A\00"
@.str.4 = [18 x i8] c"Purgable : %d\0A\00"
@.str.5 = [19 x i8] c"GFX Mem Used: %dk\0A\00"
@.str.6 = [18 x i8] c"GFX Surfaces: %d\0A\00"
define void @CK_DebugMemory() {
%1 = call i32 @US_CenterWindow(i32 16, i32 10)
%2 = call i32 @US_CPrint(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @US_CPrint(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 (...) @MM_UsedMemory()
%5 = sdiv i32 %4, 1024
%6 = call i32 @US_PrintF(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %5)
%7 = call i32 (...) @MM_UsedBlocks()
%8 = call i32 @US_PrintF(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %7)
%9 = call i32 (...) @MM_PurgableBlocks()
%10 = call i32 @US_PrintF(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %9)
%11 = call i32 (...) @VL_MemUsed()
%12 = sdiv i32 %11, 1024
%13 = call i32 @US_PrintF(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %12)
%14 = call i32 (...) @VL_NumSurfaces()
%15 = call i32 @US_PrintF(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 %14)
%16 = call i32 (...) @VL_Present()
%17 = call i32 (...) @IN_WaitButton()
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"Memory Usage:\0A\00"
@.str.1 = [15 x i8] c"-------------\0A\00"
@.str.2 = [19 x i8] c"In Use : %dk\0A\00"
@.str.3 = [18 x i8] c"Blocks : %d\0A\00"
@.str.4 = [18 x i8] c"Purgable : %d\0A\00"
@.str.5 = [19 x i8] c"GFX Mem Used: %dk\0A\00"
@.str.6 = [18 x i8] c"GFX Surfaces: %d\0A\00"
define void @CK_DebugMemory() {
%1 = tail call i32 @US_CenterWindow(i32 16, i32 10)
%2 = tail call i32 @US_CPrint(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @US_CPrint(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 (...) @MM_UsedMemory()
%5 = sdiv i32 %4, 1024
%6 = tail call i32 @US_PrintF(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %5)
%7 = tail call i32 (...) @MM_UsedBlocks()
%8 = tail call i32 @US_PrintF(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %7)
%9 = tail call i32 (...) @MM_PurgableBlocks()
%10 = tail call i32 @US_PrintF(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %9)
%11 = tail call i32 (...) @VL_MemUsed()
%12 = sdiv i32 %11, 1024
%13 = tail call i32 @US_PrintF(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %12)
%14 = tail call i32 (...) @VL_NumSurfaces()
%15 = tail call i32 @US_PrintF(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 %14)
%16 = tail call i32 (...) @VL_Present()
%17 = tail call i32 (...) @IN_WaitButton()
ret void
}