#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 */
struct statvfs {
  int f_bfree;
  int f_bsize;
};

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ perror(char *);
char *smprintf(char *, double);
scalar_t__ statvfs(char *, struct statvfs *);
char *freespace(void) {
  struct statvfs vfs;
  if (statvfs("/", &vfs) < 0) {
    perror("statvfs");
    exit(1);
  }
  return smprintf("%.2f GB", (double)(vfs.f_bfree * vfs.f_bsize) / 1073741824);
}


x86 assembly (clang, -O0):
<freespace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb9(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <statvfs@plt>
cmp    $0x0,%rax
jge    1178 <freespace+0x38>
lea    0xea1(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x8(%rbp),%eax
imul   -0x4(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  0xe75(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe7c(%rip),%rdi
call   1030 <smprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<freespace>:
push   %rax
lea    0xec0(%rip),%rdi
mov    %rsp,%rsi
call   1040 <statvfs@plt>
test   %rax,%rax
js     1177 <freespace+0x37>
mov    0x4(%rsp),%eax
imul   (%rsp),%eax
cvtsi2sd %eax,%xmm0
mulsd  0xe97(%rip),%xmm0
lea    0xea2(%rip),%rdi
call   1030 <smprintf@plt>
pop    %rcx
ret
lea    0xe8c(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.statvfs = type { i32, i32 }
@.str = [2 x i8] c"/\00"
@.str.1 = [8 x i8] c"statvfs\00"
@.str.2 = [8 x i8] c"%.2f GB\00"
define i8* @freespace() {
%1 = alloca %struct.statvfs
%2 = call i64 @statvfs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %struct.statvfs* %1)
%3 = icmp slt i64 %2, 0
br i1 %3, label %4, label %7
4: ; preds = %0
%5 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @exit(i32 1)
unreachable
7: ; preds = %0
%8 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %1, i32 0, i32 0
%9 = load i32, i32* %8
%10 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %1, i32 0, i32 1
%11 = load i32, i32* %10
%12 = mul nsw i32 %9, %11
%13 = sitofp i32 %12 to double
%14 = fdiv double %13, 0x41D0000000000000
%15 = call i8* @smprintf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), double %14)
ret i8* %15
}

LLVM IR (-O2):
%struct.statvfs = type { i32, i32 }
@.str = [2 x i8] c"/\00"
@.str.1 = [8 x i8] c"statvfs\00"
@.str.2 = [8 x i8] c"%.2f GB\00"
define i8* @freespace() {
%1 = alloca %struct.statvfs
%2 = bitcast %struct.statvfs* %1 to i8*
%3 = call i64 @statvfs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %struct.statvfs* %1)
%4 = icmp slt i64 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @exit(i32 1)
unreachable
8: ; preds = %0
%9 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %1, i64 0, i32 0
%10 = load i32, i32* %9
%11 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %1, i64 0, i32 1
%12 = load i32, i32* %11
%13 = mul nsw i32 %12, %10
%14 = sitofp i32 %13 to double
%15 = fmul double %14, 0x3E10000000000000
%16 = call i8* @smprintf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), double %15)
ret i8* %16
}