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

/* 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_used(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 - fs.f_bfree), 1024);
}


x86 assembly (clang, -O0):
<disk_used>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <statvfs@plt>
cmp    $0x0,%rax
jge    1170 <disk_used+0x40>
mov    -0x10(%rbp),%rsi
lea    0xea2(%rip),%rdi
call   1030 <warn@plt>
movq   $0x0,-0x8(%rbp)
jmp    118a <disk_used+0x5a>
mov    -0x20(%rbp),%edi
mov    -0x1c(%rbp),%eax
sub    -0x18(%rbp),%eax
imul   %eax,%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_used>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    %rsp,%rsi
call   1050 <statvfs@plt>
test   %rax,%rax
js     115d <disk_used+0x2d>
mov    0x4(%rsp),%edi
sub    0x8(%rsp),%edi
imul   (%rsp),%edi
mov    $0x400,%esi
call   1040 <fmt_human@plt>
jmp    116e <disk_used+0x3e>
lea    0xe9c(%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, i32 }
@.str = [14 x i8] c"statvfs '%s':\00"
define i8* @disk_used(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 %21
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 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %4, i32 0, i32 2
%17 = load i32, i32* %16
%18 = sub nsw i32 %15, %17
%19 = mul nsw i32 %13, %18
%20 = call i8* @fmt_human(i32 %19, i32 1024)
store i8* %20, i8** %2
br label %21
21: ; preds = %11, %8
%22 = load i8*, i8** %2
ret i8* %22
}

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