#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 statfs {
  unsigned long long f_bsize;
  unsigned long long f_bavail;
};

/* Variables and functions */
int /*<<< orphan*/ logcat(char *, unsigned long long, unsigned long long,
                          unsigned long long, unsigned long long);
int /*<<< orphan*/ statfs(char const *, struct statfs *);
long File_GetFreeSpace(const char *drive) {
  struct statfs diskInfo;
  unsigned long long blocksize;
  unsigned long long availableDisk;
  statfs(drive, &diskInfo);
  blocksize = diskInfo.f_bsize;
  availableDisk = diskInfo.f_bavail * blocksize;
  logcat("Disk_available = %llu GB = %llu MB = %lluKB = %lluB\n",
         availableDisk >> 30, availableDisk >> 20, availableDisk >> 10,
         availableDisk);
  return availableDisk;
}


x86 assembly (clang, -O0):
<File_GetFreeSpace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <statfs@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
imul   -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
shr    $0x1e,%rsi
mov    -0x28(%rbp),%rdx
shr    $0x14,%rdx
mov    -0x28(%rbp),%rcx
shr    $0xa,%rcx
mov    -0x28(%rbp),%r8
lea    0xe8f(%rip),%rdi
call   1030 <logcat@plt>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<File_GetFreeSpace>:
push   %rbx
sub    $0x10,%rsp
mov    %rsp,%rsi
call   1040 <statfs@plt>
mov    0x8(%rsp),%rbx
imul   (%rsp),%rbx
mov    %rbx,%rsi
shr    $0x1e,%rsi
mov    %rbx,%rdx
shr    $0x14,%rdx
mov    %rbx,%rcx
shr    $0xa,%rcx
lea    0xead(%rip),%rdi
mov    %rbx,%r8
call   1030 <logcat@plt>
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.statfs = type { i64, i64 }
@.str = [53 x i8] c"Disk_available = %llu GB = %llu MB = %lluKB = %lluB\0A\00"
define i64 @File_GetFreeSpace(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.statfs
%4 = alloca i64
%5 = alloca i64
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i32 @statfs(i8* %6, %struct.statfs* %3)
%8 = getelementptr inbounds %struct.statfs, %struct.statfs* %3, i32 0, i32 0
%9 = load i64, i64* %8
store i64 %9, i64* %4
%10 = getelementptr inbounds %struct.statfs, %struct.statfs* %3, i32 0, i32 1
%11 = load i64, i64* %10
%12 = load i64, i64* %4
%13 = mul i64 %11, %12
store i64 %13, i64* %5
%14 = load i64, i64* %5
%15 = lshr i64 %14, 30
%16 = load i64, i64* %5
%17 = lshr i64 %16, 20
%18 = load i64, i64* %5
%19 = lshr i64 %18, 10
%20 = load i64, i64* %5
%21 = call i32 @logcat(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i64 %15, i64 %17, i64 %19, i64 %20)
%22 = load i64, i64* %5
ret i64 %22
}

LLVM IR (-O2):
%struct.statfs = type { i64, i64 }
@.str = [53 x i8] c"Disk_available = %llu GB = %llu MB = %lluKB = %lluB\0A\00"
define i64 @File_GetFreeSpace(i8* %0) {
%2 = alloca %struct.statfs
%3 = bitcast %struct.statfs* %2 to i8*
%4 = call i32 @statfs(i8* %0, %struct.statfs* %2)
%5 = getelementptr inbounds %struct.statfs, %struct.statfs* %2, i64 0, i32 0
%6 = load i64, i64* %5
%7 = getelementptr inbounds %struct.statfs, %struct.statfs* %2, i64 0, i32 1
%8 = load i64, i64* %7
%9 = mul i64 %8, %6
%10 = lshr i64 %9, 30
%11 = lshr i64 %9, 20
%12 = lshr i64 %9, 10
%13 = call i32 @logcat(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i64 %10, i64 %11, i64 %12, i64 %9)
ret i64 %9
}