#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 {
  scalar_t__ f_blocks;
  scalar_t__ f_bsize;
};

/* Variables and functions */
char const *bprintf(char *, float);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, char *);
scalar_t__ statvfs(char const *, struct statvfs *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
const char *disk_total(const char *mnt) {
  struct statvfs fs;
  if (statvfs(mnt, &fs) < 0) {
    fprintf(stderr, "statvfs '%s': %s\n", mnt, strerror(errno));
    return NULL;
  }
  return bprintf("%f",
                 (float)fs.f_bsize * (float)fs.f_blocks / 1024 / 1024 / 1024);
}


x86 assembly (clang, -O0):
<disk_total>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <statvfs@plt>
cmp    $0x0,%rax
jge    11a8 <disk_total+0x68>
mov    0x2e76(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    0x2e5a(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rdx
mov    %rax,%rcx
lea    0xe6e(%rip),%rsi
call   1040 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    11ec <disk_total+0xac>
cvtsi2ssq -0x18(%rbp),%xmm0
cvtsi2ssq -0x20(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  0xe40(%rip),%xmm1
divss  %xmm1,%xmm0
movss  0xe34(%rip),%xmm1
divss  %xmm1,%xmm0
movss  0xe28(%rip),%xmm1
divss  %xmm1,%xmm0
lea    0xe33(%rip),%rdi
call   1030 <bprintf@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<disk_total>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
lea    0x8(%rsp),%rsi
call   1050 <statvfs@plt>
test   %rax,%rax
js     118c <disk_total+0x4c>
cvtsi2ssq 0x10(%rsp),%xmm1
cvtsi2ssq 0x8(%rsp),%xmm0
mulss  %xmm1,%xmm0
movss  0xe8e(%rip),%xmm1
mulss  %xmm1,%xmm0
mulss  %xmm1,%xmm0
mulss  %xmm1,%xmm0
lea    0xe91(%rip),%rdi
call   1030 <bprintf@plt>
jmp    11b9 <disk_total+0x79>
mov    0x2e4d(%rip),%rax
mov    (%rax),%ebp
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe5a(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.statvfs = type { i64, i64 }
@stderr = global i32 0
@.str = [18 x i8] c"statvfs '%s': %s\0A\00"
@errno = global i32 0
@.str.1 = [3 x i8] c"%f\00"
define i8* @disk_total(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca %struct.statvfs
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i64 @statvfs(i8* %5, %struct.statvfs* %4)
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %14
8: ; preds = %1
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %3
%11 = load i32, i32* @errno
%12 = call i8* @strerror(i32 %11)
%13 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %10, i8* %12)
store i8* null, i8** %2
br label %26
14: ; preds = %1
%15 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %4, i32 0, i32 1
%16 = load i64, i64* %15
%17 = sitofp i64 %16 to float
%18 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %4, i32 0, i32 0
%19 = load i64, i64* %18
%20 = sitofp i64 %19 to float
%21 = fmul float %17, %20
%22 = fdiv float %21, 1.024000e+03
%23 = fdiv float %22, 1.024000e+03
%24 = fdiv float %23, 1.024000e+03
%25 = call i8* @bprintf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float %24)
store i8* %25, i8** %2
br label %26
26: ; preds = %14, %8
%27 = load i8*, i8** %2
ret i8* %27
}

LLVM IR (-O2):
%struct.statvfs = type { i64, i64 }
@stderr = global i32 0
@.str = [18 x i8] c"statvfs '%s': %s\0A\00"
@errno = global i32 0
@.str.1 = [3 x i8] c"%f\00"
define i8* @disk_total(i8* %0) {
%2 = alloca %struct.statvfs
%3 = bitcast %struct.statvfs* %2 to i8*
%4 = call i64 @statvfs(i8* %0, %struct.statvfs* %2)
%5 = icmp slt i64 %4, 0
br i1 %5, label %6, label %11
6: ; preds = %1
%7 = load i32, i32* @stderr
%8 = load i32, i32* @errno
%9 = call i8* @strerror(i32 %8)
%10 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %9)
br label %23
11: ; preds = %1
%12 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %2, i64 0, i32 1
%13 = load i64, i64* %12
%14 = sitofp i64 %13 to float
%15 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %2, i64 0, i32 0
%16 = load i64, i64* %15
%17 = sitofp i64 %16 to float
%18 = fmul float %14, %17
%19 = fmul float %18, 0x3F50000000000000
%20 = fmul float %19, 0x3F50000000000000
%21 = fmul float %20, 0x3F50000000000000
%22 = call i8* @bprintf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float %21)
br label %23
23: ; preds = %11, %6
%24 = phi i8* [ null, %6 ], [ %22, %11 ]
ret i8* %24
}