#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 mem_allocated();
int mem_free();
float mem_holes();
int mem_largest_free();
int mem_total();
int /*<<< orphan*/ printf(char *, float, ...);
void print_memory_status() {
  printf("%d out of %d bytes allocated.\n", mem_allocated(), mem_total());
  printf(
      "%d bytes are free in %d holes; maximum allocatable block is %d bytes.\n",
      mem_free(), mem_holes(), mem_largest_free());
  printf("Average hole size is %f.\n\n", ((float)mem_free()) / mem_holes());
}


x86 assembly (clang, -O0):
<print_memory_status>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1070 <mem_allocated@plt>
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x18(%rbp)
mov    $0x0,%al
call   1040 <mem_total@plt>
movss  -0x18(%rbp),%xmm0
mov    %eax,%esi
lea    0xe73(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1030 <mem_free@plt>
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x14(%rbp)
mov    $0x0,%al
call   1050 <mem_holes@plt>
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    $0x0,%al
call   1080 <mem_largest_free@plt>
movss  -0x14(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
mov    %eax,%esi
lea    0xe51(%rip),%rdi
mov    $0x2,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1030 <mem_free@plt>
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <mem_holes@plt>
movaps %xmm0,%xmm1
movss  -0x4(%rbp),%xmm0
divss  %xmm1,%xmm0
lea    0xe67(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_memory_status>:
sub    $0x18,%rsp
xor    %eax,%eax
call   1070 <mem_allocated@plt>
cvtsi2ss %eax,%xmm0
movss  %xmm0,0xc(%rsp)
xor    %eax,%eax
call   1040 <mem_total@plt>
lea    0xe7d(%rip),%rdi
movss  0xc(%rsp),%xmm0
mov    %eax,%esi
mov    $0x1,%al
call   1060 <printf@plt>
xor    %eax,%eax
call   1030 <mem_free@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  %xmm0,0xc(%rsp)
xor    %eax,%eax
call   1050 <mem_holes@plt>
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1080 <mem_largest_free@plt>
lea    0xe5a(%rip),%rdi
movss  0xc(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
mov    %eax,%esi
mov    $0x2,%al
call   1060 <printf@plt>
xor    %eax,%eax
call   1030 <mem_free@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  %xmm0,0xc(%rsp)
xor    %eax,%eax
call   1050 <mem_holes@plt>
movss  0xc(%rsp),%xmm1
divss  %xmm0,%xmm1
lea    0xe60(%rip),%rdi
movaps %xmm1,%xmm0
mov    $0x1,%al
add    $0x18,%rsp
jmp    1060 <printf@plt>

LLVM IR (-O0):
@.str = [31 x i8] c"%d out of %d bytes allocated.\0A\00"
@.str.1 = [71 x i8] c"%d bytes are free in %d holes; maximum allocatable block is %d bytes.\0A\00"
@.str.2 = [27 x i8] c"Average hole size is %f.\0A\0A\00"
define void @print_memory_status() {
%1 = call i32 (...) @mem_allocated()
%2 = sitofp i32 %1 to float
%3 = call i32 (...) @mem_total()
%4 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), float %2, i32 %3)
%5 = call i32 (...) @mem_free()
%6 = sitofp i32 %5 to float
%7 = call float (...) @mem_holes()
%8 = fpext float %7 to double
%9 = call i32 (...) @mem_largest_free()
%10 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.1, i64 0, i64 0), float %6, double %8, i32 %9)
%11 = call i32 (...) @mem_free()
%12 = sitofp i32 %11 to float
%13 = call float (...) @mem_holes()
%14 = fdiv float %12, %13
%15 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), float %14)
ret void
}

LLVM IR (-O2):
@.str = [31 x i8] c"%d out of %d bytes allocated.\0A\00"
@.str.1 = [71 x i8] c"%d bytes are free in %d holes; maximum allocatable block is %d bytes.\0A\00"
@.str.2 = [27 x i8] c"Average hole size is %f.\0A\0A\00"
define void @print_memory_status() {
%1 = tail call i32 (...) @mem_allocated()
%2 = sitofp i32 %1 to float
%3 = tail call i32 (...) @mem_total()
%4 = tail call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), float %2, i32 %3)
%5 = tail call i32 (...) @mem_free()
%6 = sitofp i32 %5 to float
%7 = tail call float (...) @mem_holes()
%8 = fpext float %7 to double
%9 = tail call i32 (...) @mem_largest_free()
%10 = tail call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.1, i64 0, i64 0), float %6, double %8, i32 %9)
%11 = tail call i32 (...) @mem_free()
%12 = sitofp i32 %11 to float
%13 = tail call float (...) @mem_holes()
%14 = fdiv float %12, %13
%15 = tail call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), float %14)
ret void
}