#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_frsize;
  int f_blocks;
};

/* Variables and functions */
char const *fmt_human(int, int);
scalar_t__ statvfs(char const *, struct statvfs *);
int /*<<< orphan*/ warn(char *, char const *);
const char *disk_total(const char *path) {
  struct statvfs fs;
  if (statvfs(path, &fs) < 0) {
    warn("statvfs '%s':", path);
    return NULL;
  }
  return fmt_human(fs.f_frsize * fs.f_blocks, 1024);
}


x86 assembly (clang, -O0):
<disk_total>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <statvfs@plt>
cmp    $0x0,%rax
jge    1170 <disk_total+0x40>
mov    -0x10(%rbp),%rsi
lea    0xea2(%rip),%rdi
call   1030 <warn@plt>
movq   $0x0,-0x8(%rbp)
jmp    1185 <disk_total+0x55>
mov    -0x18(%rbp),%edi
imul   -0x14(%rbp),%edi
mov    $0x400,%esi
call   1040 <fmt_human@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<disk_total>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0x8(%rsp),%rsi
call   1050 <statvfs@plt>
test   %rax,%rax
js     115c <disk_total+0x2c>
mov    0xc(%rsp),%edi
imul   0x8(%rsp),%edi
mov    $0x400,%esi
call   1040 <fmt_human@plt>
jmp    116d <disk_total+0x3d>
lea    0xe9d(%rip),%rdi
mov    %rbx,%rsi
call   1030 <warn@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.statvfs = type { i32, i32 }
@.str = [14 x i8] c"statvfs '%s':\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 %11
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i32 @warn(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %9)
store i8* null, i8** %2
br label %18
11: ; preds = %1
%12 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %4, i32 0, i32 0
%13 = load i32, i32* %12
%14 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %4, i32 0, i32 1
%15 = load i32, i32* %14
%16 = mul nsw i32 %13, %15
%17 = call i8* @fmt_human(i32 %16, i32 1024)
store i8* %17, i8** %2
br label %18
18: ; preds = %11, %8
%19 = load i8*, i8** %2
ret i8* %19
}

LLVM IR (-O2):
%struct.statvfs = type { i32, i32 }
@.str = [14 x i8] c"statvfs '%s':\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 %8
6: ; preds = %1
%7 = call i32 @warn(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %15
8: ; preds = %1
%9 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %2, i64 0, i32 0
%10 = load i32, i32* %9
%11 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %2, i64 0, i32 1
%12 = load i32, i32* %11
%13 = mul nsw i32 %12, %10
%14 = call i8* @fmt_human(i32 %13, i32 1024)
br label %15
15: ; preds = %8, %6
%16 = phi i8* [ null, %6 ], [ %14, %8 ]
ret i8* %16
}