#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*/ exit(int /*<<< orphan*/);
int get_free_frames();
int /*<<< orphan*/ printf(char *, int, ...);
int main() {
  int free = get_free_frames();
  printf("%d frames (%d KByte) total memory.\n", 1024 * 1024 * 64 / 4096,
         1024 * 1024 * 64 / 1024);
  printf("%d frames (%d KByte) free.\n", free, free * 4);
  printf("%d %% usage.\n", 100 - (free * 100 / (1024 * 1024 * 64 / 4096)));
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <get_free_frames@plt>
mov    %eax,-0x8(%rbp)
lea    0xeb0(%rip),%rdi
mov    $0x4000,%esi
mov    $0x10000,%edx
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
mov    -0x8(%rbp),%edx
shl    $0x2,%edx
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
imul   $0x64,-0x8(%rbp),%eax
mov    $0x4000,%ecx
cltd
idiv   %ecx
mov    $0x64,%esi
sub    %eax,%esi
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1050 <get_free_frames@plt>
mov    %eax,%ebx
lea    0xebf(%rip),%rdi
mov    $0x4000,%esi
mov    $0x10000,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x0(,%rbx,4),%edx
lea    0xec4(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
imul   $0x64,%ebx,%eax
lea    0x3fff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
sar    $0xe,%ecx
mov    $0x64,%esi
sub    %ecx,%esi
lea    0xeb8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %edi,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [36 x i8] c"%d frames (%d KByte) total memory.\0A\00"
@.str.1 = [28 x i8] c"%d frames (%d KByte) free.\0A\00"
@.str.2 = [14 x i8] c"%d %% usage.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 (...) @get_free_frames()
store i32 %3, i32* %2
%4 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 16384, i32 65536)
%5 = load i32, i32* %2
%6 = load i32, i32* %2
%7 = mul nsw i32 %6, 4
%8 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %5, i32 %7)
%9 = load i32, i32* %2
%10 = mul nsw i32 %9, 100
%11 = sdiv i32 %10, 16384
%12 = sub nsw i32 100, %11
%13 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%14 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [36 x i8] c"%d frames (%d KByte) total memory.\0A\00"
@.str.1 = [28 x i8] c"%d frames (%d KByte) free.\0A\00"
@.str.2 = [14 x i8] c"%d %% usage.\0A\00"
define i32 @main() {
%1 = tail call i32 (...) @get_free_frames()
%2 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 16384, i32 65536)
%3 = shl nsw i32 %1, 2
%4 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %1, i32 %3)
%5 = mul nsw i32 %1, 100
%6 = sdiv i32 %5, -16384
%7 = add nsw i32 %6, 100
%8 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%9 = tail call i32 @exit(i32 0)
unreachable
}