#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 {
  char *f_bsize;
  char *f_blocks;
  char *f_bfree;
  char *f_bavail;
  char *f_files;
  char *f_ffree;
  char *f_favail;
};

/* Variables and functions */
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *, char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ statvfs(char *, struct statvfs *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  int errors = 0;
  char *myname;
  struct statvfs vfs;
  char *path = "/media/datammc";
  if (argc == 2) {
    printf("statvfs'ing %s\n", argv[1]);
    path = argv[1];
  } else if (argc > 2) {
    printf("Too many arguments supplied.\n");
    return 1;
  } else {
    printf(
        "Please specify the path to any file within the mounted filesystem\n");
    return 1;
  }
  if (statvfs(path, &vfs) != 0) {
    fprintf(stderr, "%s: %s: statfs failed: %s\n", myname, path,
            strerror(errno));
    errors++;
    return 1;
  }
  printf("\tf_bsize: %ld\n", vfs.f_bsize);
  printf("\tf_blocks: %ld\n", vfs.f_blocks);
  printf("\tf_bfree: %ld\n", vfs.f_bfree);
  printf("\tf_bavail: %ld\n", vfs.f_bavail);
  printf("\tf_files: %ld\n", vfs.f_files);
  printf("\tf_ffree: %ld\n", vfs.f_ffree);
  printf("\tf_favail: %ld\n", vfs.f_favail);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xe99(%rip),%rax
mov    %rax,-0x60(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    119c <main+0x5c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x60(%rbp)
jmp    11da <main+0x9a>
cmpl   $0x2,-0x8(%rbp)
jle    11c0 <main+0x80>
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12cf <main+0x18f>
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12cf <main+0x18f>
mov    -0x60(%rbp),%rdi
lea    -0x58(%rbp),%rsi
call   1050 <statvfs@plt>
cmp    $0x0,%rax
je     124a <main+0x10a>
mov    0x2de8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x74(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x60(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    0x2dc4(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0x74(%rbp),%edi
mov    -0x70(%rbp),%rdx
mov    -0x68(%rbp),%rcx
mov    %rax,%r8
lea    0xe50(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
movl   $0x1,-0x4(%rbp)
jmp    12cf <main+0x18f>
mov    -0x58(%rbp),%rsi
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x50(%rbp),%rsi
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x48(%rbp),%rsi
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x40(%rbp),%rsi
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%rsi
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%rsi
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rsi
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x38,%rsp
cmp    $0x2,%edi
jne    11bb <main+0x6b>
mov    %rsi,%rbx
mov    0x8(%rsi),%rsi
lea    0xe97(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rbx),%rbx
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1060 <statvfs@plt>
test   %rax,%rax
je     11dc <main+0x8c>
mov    0x2e53(%rip),%rax
mov    (%rax),%ebp
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe6c(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rcx
mov    %rax,%r8
call   1050 <fprintf@plt>
mov    $0x1,%ebp
jmp    1260 <main+0x110>
jle    11c6 <main+0x76>
lea    0xf15(%rip),%rdi
jmp    11cd <main+0x7d>
lea    0xeca(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebp
jmp    1260 <main+0x110>
mov    (%rsp),%rsi
lea    0xe44(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rsi
lea    0xe40(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%rsi
lea    0xe3d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rsp),%rsi
lea    0xe39(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x20(%rsp),%rsi
lea    0xe36(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x28(%rsp),%rsi
lea    0xe32(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x30(%rsp),%rsi
lea    0xe2e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%eax
add    $0x38,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.statvfs = type { i8*, i8*, i8*, i8*, i8*, i8*, i8* }
@.str = [15 x i8] c"/media/datammc\00"
@.str.1 = [16 x i8] c"statvfs'ing %s\0A\00"
@.str.2 = [30 x i8] c"Too many arguments supplied.\0A\00"
@.str.3 = [67 x i8] c"Please specify the path to any file within the mounted filesystem\0A\00"
@stderr = global i32 0
@.str.4 = [27 x i8] c"%s: %s: statfs failed: %s\0A\00"
@errno = global i32 0
@.str.5 = [15 x i8] c"\09f_bsize: %ld\0A\00"
@.str.6 = [16 x i8] c"\09f_blocks: %ld\0A\00"
@.str.7 = [15 x i8] c"\09f_bfree: %ld\0A\00"
@.str.8 = [16 x i8] c"\09f_bavail: %ld\0A\00"
@.str.9 = [15 x i8] c"\09f_files: %ld\0A\00"
@.str.10 = [15 x i8] c"\09f_ffree: %ld\0A\00"
@.str.11 = [16 x i8] c"\09f_favail: %ld\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca %struct.statvfs
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8** %9
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 2
br i1 %11, label %12, label %20
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
store i8* %19, i8** %9
br label %27
20: ; preds = %2
%21 = load i32, i32* %4
%22 = icmp sgt i32 %21, 2
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %62
25: ; preds = %20
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %62
27: ; preds = %12
%28 = load i8*, i8** %9
%29 = call i64 @statvfs(i8* %28, %struct.statvfs* %8)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %40
31: ; preds = %27
%32 = load i32, i32* @stderr
%33 = load i8*, i8** %7
%34 = load i8*, i8** %9
%35 = load i32, i32* @errno
%36 = call i8* @strerror(i32 %35)
%37 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* %33, i8* %34, i8* %36)
%38 = load i32, i32* %6
%39 = add nsw i32 %38, 1
store i32 %39, i32* %6
store i32 1, i32* %3
br label %62
40: ; preds = %27
%41 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %8, i32 0, i32 0
%42 = load i8*, i8** %41
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8* %42)
%44 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %8, i32 0, i32 1
%45 = load i8*, i8** %44
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i8* %45)
%47 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %8, i32 0, i32 2
%48 = load i8*, i8** %47
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i8* %48)
%50 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %8, i32 0, i32 3
%51 = load i8*, i8** %50
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8* %51)
%53 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %8, i32 0, i32 4
%54 = load i8*, i8** %53
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0), i8* %54)
%56 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %8, i32 0, i32 5
%57 = load i8*, i8** %56
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0), i8* %57)
%59 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %8, i32 0, i32 6
%60 = load i8*, i8** %59
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0), i8* %60)
store i32 0, i32* %3
br label %62
62: ; preds = %40, %31, %25, %23
%63 = load i32, i32* %3
ret i32 %63
}

LLVM IR (-O2):
%struct.statvfs = type { i8*, i8*, i8*, i8*, i8*, i8*, i8* }
@.str.1 = [16 x i8] c"statvfs'ing %s\0A\00"
@stderr = global i32 0
@.str.4 = [27 x i8] c"%s: %s: statfs failed: %s\0A\00"
@errno = global i32 0
@.str.5 = [15 x i8] c"\09f_bsize: %ld\0A\00"
@.str.6 = [16 x i8] c"\09f_blocks: %ld\0A\00"
@.str.7 = [15 x i8] c"\09f_bfree: %ld\0A\00"
@.str.8 = [16 x i8] c"\09f_bavail: %ld\0A\00"
@.str.9 = [15 x i8] c"\09f_files: %ld\0A\00"
@.str.10 = [15 x i8] c"\09f_ffree: %ld\0A\00"
@.str.11 = [16 x i8] c"\09f_favail: %ld\0A\00"
@str = [66 x i8] c"Please specify the path to any file within the mounted filesystem\00"
@str.12 = [29 x i8] c"Too many arguments supplied.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.statvfs
%4 = bitcast %struct.statvfs* %3 to i8*
%5 = icmp eq i32 %0, 2
br i1 %5, label %6, label %13
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = load i8*, i8** %7
%11 = call i64 @statvfs(i8* %10, %struct.statvfs* %3)
%12 = icmp eq i64 %11, 0
br i1 %12, label %24, label %19
13: ; preds = %2
%14 = icmp sgt i32 %0, 2
br i1 %14, label %15, label %17
15: ; preds = %13
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.12, i64 0, i64 0))
br label %46
17: ; preds = %13
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @str, i64 0, i64 0))
br label %46
19: ; preds = %6
%20 = load i32, i32* @stderr
%21 = load i32, i32* @errno
%22 = call i8* @strerror(i32 %21)
%23 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* undef, i8* %10, i8* %22)
br label %46
24: ; preds = %6
%25 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %3, i64 0, i32 0
%26 = load i8*, i8** %25
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8* %26)
%28 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %3, i64 0, i32 1
%29 = load i8*, i8** %28
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i8* %29)
%31 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %3, i64 0, i32 2
%32 = load i8*, i8** %31
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i8* %32)
%34 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %3, i64 0, i32 3
%35 = load i8*, i8** %34
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8* %35)
%37 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %3, i64 0, i32 4
%38 = load i8*, i8** %37
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0), i8* %38)
%40 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %3, i64 0, i32 5
%41 = load i8*, i8** %40
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0), i8* %41)
%43 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %3, i64 0, i32 6
%44 = load i8*, i8** %43
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0), i8* %44)
br label %46
46: ; preds = %24, %19, %17, %15
%47 = phi i32 [ 1, %19 ], [ 0, %24 ], [ 1, %15 ], [ 1, %17 ]
ret i32 %47
}