#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 {
  int /*<<< orphan*/ f_bsize;
  int /*<<< orphan*/ f_fsid;
};

/* Variables and functions */
int EINVAL;
int errno;
char *fsid2fsname(int /*<<< orphan*/);
int getopt(int, char **, char *);
int /*<<< orphan*/ print_usage();
int /*<<< orphan*/ printf(char *, ...);
int statvfs(char *, struct statvfs *);
int main(int argc, char **argv) {
  int opt;
  struct statvfs st_buf;
  if (argc < 2) {
    print_usage();
    return -EINVAL;
  }
  while (-1 != (opt = getopt(argc - 1, argv, "h"))) {
    switch (opt) {
    case '?':
    case 'h':
      print_usage();
      return 0;
    default:
      return -EINVAL;
    }
  }
  if (-1 == statvfs(argv[argc - 1], &st_buf)) {
    return -errno;
  }
  printf("block dev  | file system |   size     |  mount point\n");
  printf("           |");
  printf(" %11s |", fsid2fsname(st_buf.f_fsid));
  printf(" %8lu |", st_buf.f_bsize);
  printf("           \n");
  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    118a <main+0x3a>
mov    $0x0,%al
call   1070 <print_usage@plt>
xor    %eax,%eax
mov    0x2e58(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    1299 <main+0x149>
jmp    118f <main+0x3f>
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
mov    -0x10(%rbp),%rsi
lea    0xe60(%rip),%rdx
call   1060 <getopt@plt>
mov    %eax,%ecx
mov    %ecx,-0x14(%rbp)
mov    $0xffffffff,%eax
cmp    %ecx,%eax
je     1202 <main+0xb2>
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x3f,%eax
je     11dc <main+0x8c>
jmp    11cb <main+0x7b>
mov    -0x24(%rbp),%eax
sub    $0x68,%eax
jne    11ef <main+0x9f>
jmp    11dc <main+0x8c>
mov    $0x0,%al
call   1070 <print_usage@plt>
movl   $0x0,-0x4(%rbp)
jmp    1299 <main+0x149>
xor    %eax,%eax
mov    0x2de0(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    1299 <main+0x149>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <statvfs@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    123e <main+0xee>
xor    %eax,%eax
mov    0x2dac(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    1299 <main+0x149>
lea    0xdbd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xde5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%edi
call   1040 <fsid2fsname@plt>
mov    %rax,%rsi
lea    0xdd9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%esi
lea    0xdd0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x1,%edi
jg     117d <main+0x1d>
xor    %ebx,%ebx
xor    %eax,%eax
call   1080 <print_usage@plt>
mov    0x2e60(%rip),%rax
jmp    1227 <main+0xc7>
mov    %rsi,%rbx
mov    %edi,%ebp
add    $0xffffffff,%ebp
lea    0xe74(%rip),%rdx
mov    %ebp,%edi
call   1070 <getopt@plt>
cmp    $0xffffffff,%eax
je     11ad <main+0x4d>
cmp    $0x68,%eax
je     11a2 <main+0x42>
cmp    $0x3f,%eax
jne    1215 <main+0xb5>
xor    %ebx,%ebx
xor    %eax,%eax
call   1080 <print_usage@plt>
jmp    1229 <main+0xc9>
mov    %ebp,%eax
mov    (%rbx,%rax,8),%rdi
mov    %rsp,%rsi
call   1060 <statvfs@plt>
cmp    $0xffffffff,%eax
je     121e <main+0xbe>
lea    0xe58(%rip),%rdi
call   1030 <puts@plt>
lea    0xe2f(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%edi
call   1050 <fsid2fsname@plt>
lea    0xe23(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%esi
lea    0xe17(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe46(%rip),%rdi
call   1030 <puts@plt>
jmp    1229 <main+0xc9>
mov    0x2dbc(%rip),%rax
jmp    1225 <main+0xc5>
mov    0x2dbb(%rip),%rax
xor    %ebx,%ebx
sub    (%rax),%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.statvfs = type { i32, i32 }
@EINVAL = global i32 0
@.str = [2 x i8] c"h\00"
@errno = global i32 0
@.str.1 = [54 x i8] c"block dev | file system | size | mount point\0A\00"
@.str.2 = [13 x i8] c" |\00"
@.str.3 = [8 x i8] c" %11s |\00"
@.str.4 = [8 x i8] c" %8lu |\00"
@.str.5 = [13 x i8] c" \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.statvfs
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = call i32 (...) @print_usage()
%12 = load i32, i32* @EINVAL
%13 = sub nsw i32 0, %12
store i32 %13, i32* %3
br label %51
14: ; preds = %2
br label %15
15: ; preds = %14
%16 = load i32, i32* %4
%17 = sub nsw i32 %16, 1
%18 = load i8**, i8*** %5
%19 = call i32 @getopt(i32 %17, i8** %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 %19, i32* %6
%20 = icmp ne i32 -1, %19
br i1 %20, label %21, label %28
21: ; preds = %15
%22 = load i32, i32* %6
switch i32 %22, label %25 [
i32 63, label %23
i32 104, label %23
]
23: ; preds = %21, %21
%24 = call i32 (...) @print_usage()
store i32 0, i32* %3
br label %51
25: ; preds = %21
%26 = load i32, i32* @EINVAL
%27 = sub nsw i32 0, %26
store i32 %27, i32* %3
br label %51
28: ; preds = %15
%29 = load i8**, i8*** %5
%30 = load i32, i32* %4
%31 = sub nsw i32 %30, 1
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8*, i8** %29, i64 %32
%34 = load i8*, i8** %33
%35 = call i32 @statvfs(i8* %34, %struct.statvfs* %7)
%36 = icmp eq i32 -1, %35
br i1 %36, label %37, label %40
37: ; preds = %28
%38 = load i32, i32* @errno
%39 = sub nsw i32 0, %38
store i32 %39, i32* %3
br label %51
40: ; preds = %28
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%43 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %7, i32 0, i32 1
%44 = load i32, i32* %43
%45 = call i8* @fsid2fsname(i32 %44)
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %45)
%47 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %7, i32 0, i32 0
%48 = load i32, i32* %47
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %48)
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %3
br label %51
51: ; preds = %40, %37, %25, %23, %10
%52 = load i32, i32* %3
ret i32 %52
}

LLVM IR (-O2):
%struct.statvfs = type { i32, i32 }
@EINVAL = global i32 0
@.str = [2 x i8] c"h\00"
@errno = global i32 0
@.str.2 = [13 x i8] c" |\00"
@.str.3 = [8 x i8] c" %11s |\00"
@.str.4 = [8 x i8] c" %8lu |\00"
@str = [53 x i8] c"block dev | file system | size | mount point\00"
@str.6 = [12 x i8] c" \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca %struct.statvfs
%4 = bitcast %struct.statvfs* %3 to i8*
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = tail call i32 (...) @print_usage()
%8 = load i32, i32* @EINVAL
%9 = sub nsw i32 0, %8
br label %38
10: ; preds = %2
%11 = add nsw i32 %0, -1
%12 = tail call i32 @getopt(i32 %11, i8** %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
switch i32 %12, label %15 [
i32 -1, label %18
i32 63, label %13
i32 104, label %13
]
13: ; preds = %10, %10
%14 = tail call i32 (...) @print_usage()
br label %38
15: ; preds = %10
%16 = load i32, i32* @EINVAL
%17 = sub nsw i32 0, %16
br label %38
18: ; preds = %10
%19 = zext i32 %11 to i64
%20 = getelementptr inbounds i8*, i8** %1, i64 %19
%21 = load i8*, i8** %20
%22 = call i32 @statvfs(i8* %21, %struct.statvfs* %3)
%23 = icmp eq i32 %22, -1
br i1 %23, label %24, label %27
24: ; preds = %18
%25 = load i32, i32* @errno
%26 = sub nsw i32 0, %25
br label %38
27: ; preds = %18
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str, i64 0, i64 0))
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%30 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %3, i64 0, i32 1
%31 = load i32, i32* %30
%32 = tail call i8* @fsid2fsname(i32 %31)
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %32)
%34 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %3, i64 0, i32 0
%35 = load i32, i32* %34
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %35)
%37 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.6, i64 0, i64 0))
br label %38
38: ; preds = %27, %24, %15, %13, %6
%39 = phi i32 [ %9, %6 ], [ %17, %15 ], [ 0, %13 ], [ %26, %24 ], [ 0, %27 ]
ret i32 %39
}