#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 {
  int f_bsize;
  int f_blocks;
  int f_bfree;
  int f_files;
  int f_ffree;
};

/* Variables and functions */
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int statfs(char *, struct statfs *);
int /*<<< orphan*/ stdin;
char *strerror(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  char *name;
  struct statfs stbuf;
  fclose(stdin);
  if (argc < 2)
    name = "/";
  else
    name = argv[1];
  if (statfs(name, &stbuf) == -1) {
    printf("Unable to get disk space of %s: %s\n", name, strerror(errno));
    exit(1);
  }
  printf("Total bytes: %ld\n", stbuf.f_bsize * stbuf.f_blocks);
  printf("Free bytes: %ld\n", stbuf.f_bsize * stbuf.f_bfree);
  printf("Total nodes: %ld\n", stbuf.f_files);
  printf("Free nodes: %ld\n", stbuf.f_ffree);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e7b(%rip),%rax
mov    (%rax),%edi
call   1030 <fclose@plt>
cmpl   $0x2,-0x8(%rbp)
jge    118e <main+0x3e>
lea    0xe7b(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    119a <main+0x4a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1050 <statfs@plt>
cmp    $0xffffffff,%eax
jne    11e5 <main+0x95>
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x38(%rbp),%rsi
mov    %rax,%rdx
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x30(%rbp),%esi
imul   -0x2c(%rbp),%esi
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%esi
imul   -0x28(%rbp),%esi
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%esi
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%esi
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
call   1030 <fclose@plt>
cmp    $0x2,%ebp
jge    1177 <main+0x27>
lea    0xe8b(%rip),%rbx
jmp    117b <main+0x2b>
mov    0x8(%rbx),%rbx
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1050 <statfs@plt>
cmp    $0xffffffff,%eax
jne    11b7 <main+0x67>
mov    0x2e46(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe62(%rip),%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    0x4(%rsp),%esi
imul   (%rsp),%esi
lea    0xe60(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%esi
imul   (%rsp),%esi
lea    0xe5c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%esi
lea    0xe5b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%esi
lea    0xe5b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.statfs = type { i32, i32, i32, i32, i32 }
@stdin = global i32 0
@.str = [2 x i8] c"/\00"
@.str.1 = [36 x i8] c"Unable to get disk space of %s: %s\0A\00"
@errno = global i32 0
@.str.2 = [18 x i8] c"Total bytes: %ld\0A\00"
@.str.3 = [17 x i8] c"Free bytes: %ld\0A\00"
@.str.4 = [18 x i8] c"Total nodes: %ld\0A\00"
@.str.5 = [17 x i8] c"Free nodes: %ld\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca %struct.statfs
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* @stdin
%9 = call i32 @fclose(i32 %8)
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 2
br i1 %11, label %12, label %13
12: ; preds = %2
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %6
br label %17
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
store i8* %16, i8** %6
br label %17
17: ; preds = %13, %12
%18 = load i8*, i8** %6
%19 = call i32 @statfs(i8* %18, %struct.statfs* %7)
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %27
21: ; preds = %17
%22 = load i8*, i8** %6
%23 = load i32, i32* @errno
%24 = call i8* @strerror(i32 %23)
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8* %22, i8* %24)
%26 = call i32 @exit(i32 1)
unreachable
27: ; preds = %17
%28 = getelementptr inbounds %struct.statfs, %struct.statfs* %7, i32 0, i32 0
%29 = load i32, i32* %28
%30 = getelementptr inbounds %struct.statfs, %struct.statfs* %7, i32 0, i32 1
%31 = load i32, i32* %30
%32 = mul nsw i32 %29, %31
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %32)
%34 = getelementptr inbounds %struct.statfs, %struct.statfs* %7, i32 0, i32 0
%35 = load i32, i32* %34
%36 = getelementptr inbounds %struct.statfs, %struct.statfs* %7, i32 0, i32 2
%37 = load i32, i32* %36
%38 = mul nsw i32 %35, %37
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %38)
%40 = getelementptr inbounds %struct.statfs, %struct.statfs* %7, i32 0, i32 3
%41 = load i32, i32* %40
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %41)
%43 = getelementptr inbounds %struct.statfs, %struct.statfs* %7, i32 0, i32 4
%44 = load i32, i32* %43
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 %44)
%46 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.statfs = type { i32, i32, i32, i32, i32 }
@stdin = global i32 0
@.str = [2 x i8] c"/\00"
@.str.1 = [36 x i8] c"Unable to get disk space of %s: %s\0A\00"
@errno = global i32 0
@.str.2 = [18 x i8] c"Total bytes: %ld\0A\00"
@.str.3 = [17 x i8] c"Free bytes: %ld\0A\00"
@.str.4 = [18 x i8] c"Total nodes: %ld\0A\00"
@.str.5 = [17 x i8] c"Free nodes: %ld\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.statfs
%4 = bitcast %struct.statfs* %3 to i8*
%5 = load i32, i32* @stdin
%6 = tail call i32 @fclose(i32 %5)
%7 = icmp slt i32 %0, 2
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
br label %11
11: ; preds = %2, %8
%12 = phi i8* [ %10, %8 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %2 ]
%13 = call i32 @statfs(i8* %12, %struct.statfs* %3)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %20
15: ; preds = %11
%16 = load i32, i32* @errno
%17 = call i8* @strerror(i32 %16)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8* %12, i8* %17)
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %11
%21 = getelementptr inbounds %struct.statfs, %struct.statfs* %3, i64 0, i32 0
%22 = load i32, i32* %21
%23 = getelementptr inbounds %struct.statfs, %struct.statfs* %3, i64 0, i32 1
%24 = load i32, i32* %23
%25 = mul nsw i32 %24, %22
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %21
%28 = getelementptr inbounds %struct.statfs, %struct.statfs* %3, i64 0, i32 2
%29 = load i32, i32* %28
%30 = mul nsw i32 %29, %27
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %30)
%32 = getelementptr inbounds %struct.statfs, %struct.statfs* %3, i64 0, i32 3
%33 = load i32, i32* %32
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %33)
%35 = getelementptr inbounds %struct.statfs, %struct.statfs* %3, i64 0, i32 4
%36 = load i32, i32* %35
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 %36)
%38 = call i32 @exit(i32 0)
unreachable
}