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

/* Variables and functions */
int errno;
scalar_t__ statvfs(char const *, struct statvfs *);
int disk_usage(const char *path, unsigned long *frsize, unsigned long *blocks,
               unsigned long *bavail, unsigned long *bfree) {
  struct statvfs buf;
  if (statvfs(path, &buf) != 0) {
    return errno;
  }
  *frsize = buf.f_frsize;
  *blocks = buf.f_blocks;
  *bavail = buf.f_bavail;
  *bfree = buf.f_bfree;
  return 0;
}


x86 assembly (clang, -O0):
<disk_usage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1030 <statvfs@plt>
cmp    $0x0,%rax
je     1154 <disk_usage+0x44>
mov    0x2e96(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1187 <disk_usage+0x77>
mov    -0x50(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x48(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x40(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x38(%rbp),%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<disk_usage>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%rbx
lea    0x8(%rsp),%rsi
call   1030 <statvfs@plt>
test   %rax,%rax
je     1141 <disk_usage+0x31>
mov    0x2ea3(%rip),%rax
mov    (%rax),%eax
jmp    1164 <disk_usage+0x54>
mov    0x8(%rsp),%rax
mov    %rax,(%rbx)
mov    0x10(%rsp),%rax
mov    %rax,(%r12)
mov    0x18(%rsp),%rax
mov    %rax,(%r15)
mov    0x20(%rsp),%rax
mov    %rax,(%r14)
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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