#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 {
  unsigned long long f_frsize;
  unsigned long long f_blocks;
};

/* Variables and functions */
int statvfs(char const *, struct statvfs *);
int getBytesTotal(const char *path, unsigned long long *bytes) {
  struct statvfs buf;
  int res;
  if ((res = statvfs(path, &buf)) && res != 0) {
    return -1;
  }
  *bytes = buf.f_frsize * buf.f_blocks;
  return 0;
}


x86 assembly (clang, -O0):
<getBytesTotal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1030 <statvfs@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0x0,%eax
je     114f <getBytesTotal+0x3f>
cmpl   $0x0,-0x2c(%rbp)
je     114f <getBytesTotal+0x3f>
movl   $0xffffffff,-0x4(%rbp)
jmp    1166 <getBytesTotal+0x56>
mov    -0x28(%rbp),%rcx
imul   -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getBytesTotal>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %rsp,%rsi
call   1030 <statvfs@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
test   %ecx,%ecx
jne    113a <getBytesTotal+0x2a>
mov    0x8(%rsp),%rax
imul   (%rsp),%rax
mov    %rax,(%rbx)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.statvfs = type { i64, i64 }
define i32 @getBytesTotal(i8* %0, i64* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64*
%6 = alloca %struct.statvfs
%7 = alloca i32
store i8* %0, i8** %4
store i64* %1, i64** %5
%8 = load i8*, i8** %4
%9 = call i32 @statvfs(i8* %8, %struct.statvfs* %6)
store i32 %9, i32* %7
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i32, i32* %7
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %11
store i32 -1, i32* %3
br label %22
15: ; preds = %11, %2
%16 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %6, i32 0, i32 0
%17 = load i64, i64* %16
%18 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %6, i32 0, i32 1
%19 = load i64, i64* %18
%20 = mul i64 %17, %19
%21 = load i64*, i64** %5
store i64 %20, i64* %21
store i32 0, i32* %3
br label %22
22: ; preds = %15, %14
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
%struct.statvfs = type { i64, i64 }
define i32 @getBytesTotal(i8* nocapture %0, i64* nocapture writeonly %1) {
%3 = alloca %struct.statvfs
%4 = bitcast %struct.statvfs* %3 to i8*
%5 = call i32 @statvfs(i8* %0, %struct.statvfs* %3)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %13
7: ; preds = %2
%8 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %3, i64 0, i32 0
%9 = load i64, i64* %8
%10 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %3, i64 0, i32 1
%11 = load i64, i64* %10
%12 = mul i64 %11, %9
store i64 %12, i64* %1
br label %13
13: ; preds = %2, %7
%14 = phi i32 [ 0, %7 ], [ -1, %2 ]
ret i32 %14
}