#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 {
  scalar_t__ f_bfree;
  scalar_t__ f_bsize;
};

/* Variables and functions */
scalar_t__ atoll(char *);
int errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ printf(char *, unsigned long long);
scalar_t__ statvfs(char *, struct statvfs *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  if (argc < 2) {
    fprintf(stderr, "freespace: not enough arguments, argc=%d\n", argc);
    return 1;
  }
  struct statvfs buf;
  if (statvfs(argv[1], &buf) != 0) {
    fprintf(stderr, "freespace: statvfs failed: %d\n", errno);
    return 2;
  }
  unsigned long long bytesfree =
      (unsigned long long)buf.f_bsize * (unsigned long long)buf.f_bfree;
  if (argc >= 3) {
    unsigned long long required = (unsigned long long)atoll(argv[2]);
    if (bytesfree >= required)
      return 0;
    else
      return 1;
  } else {
    printf("%llu\n", bytesfree);
    return 0;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1184 <main+0x44>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
lea    0xe8d(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    122e <main+0xee>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x20(%rbp),%rsi
call   1060 <statvfs@plt>
cmp    $0x0,%rax
je     11c9 <main+0x89>
mov    0x2e3a(%rip),%rax
mov    (%rax),%edi
mov    0x2e29(%rip),%rax
mov    (%rax),%edx
lea    0xe72(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    122e <main+0xee>
mov    -0x18(%rbp),%rax
imul   -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpl   $0x3,-0x8(%rbp)
jl     1217 <main+0xd7>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1040 <atoll@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x30(%rbp),%rax
jb     120b <main+0xcb>
movl   $0x0,-0x4(%rbp)
jmp    122e <main+0xee>
movl   $0x1,-0x4(%rbp)
jmp    122e <main+0xee>
mov    -0x28(%rbp),%rsi
lea    0xe27(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
cmp    $0x1,%edi
jg     116e <main+0x2e>
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
lea    0xea0(%rip),%rsi
mov    %ebx,%edx
call   1050 <fprintf@plt>
mov    $0x1,%eax
jmp    11dd <main+0x9d>
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
mov    %rsp,%rsi
call   1060 <statvfs@plt>
test   %rax,%rax
je     11a7 <main+0x67>
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
mov    0x2e46(%rip),%rax
mov    (%rax),%edx
lea    0xe8f(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x2,%eax
jmp    11dd <main+0x9d>
mov    (%rsp),%r15
imul   0x8(%rsp),%r15
cmp    $0x3,%ebx
jb     11cc <main+0x8c>
mov    0x10(%r14),%rdi
call   1040 <atoll@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%r15
setb   %al
jmp    11dd <main+0x9d>
lea    0xe76(%rip),%rdi
mov    %r15,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.statvfs = type { i64, i64 }
@stderr = global i32 0
@.str = [42 x i8] c"freespace: not enough arguments, argc=%d\0A\00"
@.str.1 = [31 x i8] c"freespace: statvfs failed: %d\0A\00"
@errno = global i32 0
@.str.2 = [6 x i8] c"%llu\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.statvfs
%7 = alloca i64
%8 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i32, i32* %4
%14 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i32 %13)
store i32 1, i32* %3
br label %46
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i64 @statvfs(i8* %18, %struct.statvfs* %6)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %15
%22 = load i32, i32* @stderr
%23 = load i32, i32* @errno
%24 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %23)
store i32 2, i32* %3
br label %46
25: ; preds = %15
%26 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %6, i32 0, i32 1
%27 = load i64, i64* %26
%28 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %6, i32 0, i32 0
%29 = load i64, i64* %28
%30 = mul i64 %27, %29
store i64 %30, i64* %7
%31 = load i32, i32* %4
%32 = icmp sge i32 %31, 3
br i1 %32, label %33, label %43
33: ; preds = %25
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 2
%36 = load i8*, i8** %35
%37 = call i64 @atoll(i8* %36)
store i64 %37, i64* %8
%38 = load i64, i64* %7
%39 = load i64, i64* %8
%40 = icmp uge i64 %38, %39
br i1 %40, label %41, label %42
41: ; preds = %33
store i32 0, i32* %3
br label %46
42: ; preds = %33
store i32 1, i32* %3
br label %46
43: ; preds = %25
%44 = load i64, i64* %7
%45 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 %44)
store i32 0, i32* %3
br label %46
46: ; preds = %43, %42, %41, %21, %11
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
%struct.statvfs = type { i64, i64 }
@stderr = global i32 0
@.str = [42 x i8] c"freespace: not enough arguments, argc=%d\0A\00"
@.str.1 = [31 x i8] c"freespace: statvfs failed: %d\0A\00"
@errno = global i32 0
@.str.2 = [6 x i8] c"%llu\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.statvfs
%4 = icmp slt i32 %0, 2
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %35
8: ; preds = %2
%9 = bitcast %struct.statvfs* %3 to i8*
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = call i64 @statvfs(i8* %11, %struct.statvfs* %3)
%13 = icmp eq i64 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %8
%15 = load i32, i32* @stderr
%16 = load i32, i32* @errno
%17 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %16)
br label %33
18: ; preds = %8
%19 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %3, i64 0, i32 1
%20 = load i64, i64* %19
%21 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %3, i64 0, i32 0
%22 = load i64, i64* %21
%23 = mul i64 %22, %20
%24 = icmp ugt i32 %0, 2
br i1 %24, label %25, label %31
25: ; preds = %18
%26 = getelementptr inbounds i8*, i8** %1, i64 2
%27 = load i8*, i8** %26
%28 = call i64 @atoll(i8* %27)
%29 = icmp ult i64 %23, %28
%30 = zext i1 %29 to i32
br label %33
31: ; preds = %18
%32 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 %23)
br label %33
33: ; preds = %25, %31, %14
%34 = phi i32 [ 2, %14 ], [ %30, %25 ], [ 0, %31 ]
br label %35
35: ; preds = %33, %5
%36 = phi i32 [ 1, %5 ], [ %34, %33 ]
ret i32 %36
}