#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*/ printf(char *, float);
long syscall(int);
int main(void) {
  float fragmentation_percent;
  long used = syscall(401);
  long free = syscall(400);
  fragmentation_percent = (float)free / (float)used;
  printf("Amount free: %ld.\n", free);
  printf("Amount used: %ld.\n", used);
  printf("Amount frag: %.2f%%.\n", fragmentation_percent);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x191,%edi
call   1040 <syscall@plt>
mov    %rax,-0x10(%rbp)
mov    $0x190,%edi
call   1040 <syscall@plt>
mov    %rax,-0x18(%rbp)
cvtsi2ssq -0x18(%rbp),%xmm0
cvtsi2ssq -0x10(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
cvtsi2ssq -0x18(%rbp),%xmm0
lea    0xe93(%rip),%rdi
call   1030 <printf@plt>
cvtsi2ssq -0x10(%rbp),%xmm0
lea    0xe94(%rip),%rdi
call   1030 <printf@plt>
movss  -0x8(%rbp),%xmm0
lea    0xe96(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    $0x191,%edi
call   1040 <syscall@plt>
mov    %rax,%rbx
mov    $0x190,%edi
call   1040 <syscall@plt>
cvtsi2ss %rax,%xmm0
cvtsi2ss %rbx,%xmm2
movss  %xmm2,0x8(%rsp)
movaps %xmm0,%xmm1
divss  %xmm2,%xmm1
movss  %xmm1,0xc(%rsp)
lea    0xea0(%rip),%rdi
call   1030 <printf@plt>
lea    0xea7(%rip),%rdi
movss  0x8(%rsp),%xmm0
call   1030 <printf@plt>
lea    0xea8(%rip),%rdi
movss  0xc(%rsp),%xmm0
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Amount free: %ld.\0A\00"
@.str.1 = [19 x i8] c"Amount used: %ld.\0A\00"
@.str.2 = [22 x i8] c"Amount frag: %.2f%%.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca i64
%4 = alloca i64
store i32 0, i32* %1
%5 = call i64 @syscall(i32 401)
store i64 %5, i64* %3
%6 = call i64 @syscall(i32 400)
store i64 %6, i64* %4
%7 = load i64, i64* %4
%8 = sitofp i64 %7 to float
%9 = load i64, i64* %3
%10 = sitofp i64 %9 to float
%11 = fdiv float %8, %10
store float %11, float* %2
%12 = load i64, i64* %4
%13 = sitofp i64 %12 to float
%14 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), float %13)
%15 = load i64, i64* %3
%16 = sitofp i64 %15 to float
%17 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), float %16)
%18 = load float, float* %2
%19 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), float %18)
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"Amount free: %ld.\0A\00"
@.str.1 = [19 x i8] c"Amount used: %ld.\0A\00"
@.str.2 = [22 x i8] c"Amount frag: %.2f%%.\0A\00"
define i32 @main() {
%1 = tail call i64 @syscall(i32 401)
%2 = tail call i64 @syscall(i32 400)
%3 = sitofp i64 %2 to float
%4 = sitofp i64 %1 to float
%5 = fdiv float %3, %4
%6 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), float %3)
%7 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), float %4)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), float %5)
ret i32 0
}