#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 f_blocks;
  int f_bfree;
  int f_bavail;
  int f_frsize;
};
struct mntent {
  char *mnt_type;
  char *mnt_dir;
  char *mnt_fsname;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int errno;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
struct mntent *getmntent(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ statvfs(char *, struct statvfs *);
scalar_t__ strcmp(char *, char *);
int main() {
  struct statvfs vfsbuf;
  double disk_size = 0;
  struct mntent *mp = NULL;
  FILE *fp = NULL;
  fp = fopen("/etc/mtab", "r");
  if (fp == NULL) {
    printf("fopen error = %d\n", errno);
    return -1;
  }
  while ((mp = getmntent(fp)) != NULL) {
    if (strcmp(mp->mnt_type, "ufs") == 0 || strcmp(mp->mnt_type, "ext2") == 0 ||
        strcmp(mp->mnt_type, "ext3") == 0 ||
        strcmp(mp->mnt_type, "ext4") == 0 || strcmp(mp->mnt_type, "xfs") == 0 ||
        strcmp(mp->mnt_type, "vxfs") == 0) {
      if (statvfs(mp->mnt_dir, &vfsbuf) != 0) {
        continue;
      }
      disk_size =
          (double)((vfsbuf.f_blocks - vfsbuf.f_bfree + vfsbuf.f_bavail) *
                   (vfsbuf.f_frsize / 1024)) /
          (1024 * 1024);
      printf("Device:[%6s] Type:[%4s] Size:[%7.2f GB] Directory:[%16s]\n",
             mp->mnt_dir, mp->mnt_type, disk_size, mp->mnt_fsname);
    }
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
lea    0xe7a(%rip),%rdi
lea    0xe7d(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11cc <main+0x6c>
mov    0x2e30(%rip),%rax
mov    (%rax),%esi
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1329 <main+0x1c9>
jmp    11d1 <main+0x71>
mov    -0x30(%rbp),%rdi
call   1060 <getmntent@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     1319 <main+0x1b9>
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
lea    0xe30(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1296 <main+0x136>
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
lea    0xe17(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1296 <main+0x136>
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
lea    0xdff(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1296 <main+0x136>
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
lea    0xde7(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1296 <main+0x136>
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
lea    0xdd0(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1296 <main+0x136>
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
lea    0xdb2(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1314 <main+0x1b4>
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
call   1070 <statvfs@plt>
cmp    $0x0,%rax
je     12b6 <main+0x156>
jmp    11d1 <main+0x71>
mov    -0x18(%rbp),%eax
sub    -0x14(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x400,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
imul   %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  0xd1f(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x28(%rbp),%rax
mov    (%rax),%rdx
movsd  -0x20(%rbp),%xmm0
mov    -0x28(%rbp),%rax
mov    0x10(%rax),%rcx
lea    0xd31(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    11d1 <main+0x71>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe93(%rip),%rdi
lea    0xe96(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     12cd <main+0x16d>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <getmntent@plt>
test   %rax,%rax
je     12c1 <main+0x161>
mov    %rax,%r12
lea    0xe7e(%rip),%r14
lea    0x8(%rsp),%r15
lea    0xe76(%rip),%r13
lea    0xe74(%rip),%rbp
jmp    11ea <main+0x8a>
nopl   (%rax)
mov    0x8(%r12),%rdi
mov    %r15,%rsi
call   1070 <statvfs@plt>
test   %rax,%rax
je     1270 <main+0x110>
mov    %rbx,%rdi
call   1060 <getmntent@plt>
mov    %rax,%r12
test   %rax,%rax
je     12c1 <main+0x161>
mov    (%r12),%rdi
mov    %r14,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11c0 <main+0x60>
mov    (%r12),%rdi
mov    %r13,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11c0 <main+0x60>
mov    (%r12),%rdi
mov    %rbp,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11c0 <main+0x60>
mov    (%r12),%rdi
lea    0xe0c(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11c0 <main+0x60>
mov    (%r12),%rdi
lea    0xdfd(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11c0 <main+0x60>
mov    (%r12),%rdi
lea    0xde3(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    11d6 <main+0x76>
jmp    11c0 <main+0x60>
nopl   0x0(%rax)
mov    0x8(%rsp),%eax
mov    0x14(%rsp),%ecx
sub    0xc(%rsp),%eax
add    0x10(%rsp),%eax
lea    0x3ff(%rcx),%edx
test   %ecx,%ecx
cmovns %ecx,%edx
sar    $0xa,%edx
imul   %eax,%edx
xorps  %xmm0,%xmm0
cvtsi2sd %edx,%xmm0
mulsd  0xd60(%rip),%xmm0
mov    (%r12),%rdx
mov    0x8(%r12),%rsi
mov    0x10(%r12),%rcx
lea    0xd89(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    11d6 <main+0x76>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
jmp    12e9 <main+0x189>
mov    0x2d0c(%rip),%rax
mov    (%rax),%esi
lea    0xd37(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xffffffff,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.statvfs = type { i32, i32, i32, i32 }
%struct.mntent = type { i8*, i8*, i8* }
@.str = [10 x i8] c"/etc/mtab\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [18 x i8] c"fopen error = %d\0A\00"
@errno = global i32 0
@.str.3 = [4 x i8] c"ufs\00"
@.str.4 = [5 x i8] c"ext2\00"
@.str.5 = [5 x i8] c"ext3\00"
@.str.6 = [5 x i8] c"ext4\00"
@.str.7 = [4 x i8] c"xfs\00"
@.str.8 = [5 x i8] c"vxfs\00"
@.str.9 = [58 x i8] c"Device:[%6s] Type:[%4s] Size:[%7.2f GB] Directory:[%16s]\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.statvfs
%3 = alloca double
%4 = alloca %struct.mntent*
%5 = alloca i32*
store i32 0, i32* %1
store double 0.000000e+00, double* %3
store %struct.mntent* null, %struct.mntent** %4
store i32* null, i32** %5
%6 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %5
%7 = load i32*, i32** %5
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %12
9: ; preds = %0
%10 = load i32, i32* @errno
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %10)
store i32 -1, i32* %1
br label %90
12: ; preds = %0
br label %13
13: ; preds = %86, %59, %12
%14 = load i32*, i32** %5
%15 = call %struct.mntent* @getmntent(i32* %14)
store %struct.mntent* %15, %struct.mntent** %4
%16 = icmp ne %struct.mntent* %15, null
br i1 %16, label %17, label %87
17: ; preds = %13
%18 = load %struct.mntent*, %struct.mntent** %4
%19 = getelementptr inbounds %struct.mntent, %struct.mntent* %18, i32 0, i32 0
%20 = load i8*, i8** %19
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %53, label %23
23: ; preds = %17
%24 = load %struct.mntent*, %struct.mntent** %4
%25 = getelementptr inbounds %struct.mntent, %struct.mntent* %24, i32 0, i32 0
%26 = load i8*, i8** %25
%27 = call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %53, label %29
29: ; preds = %23
%30 = load %struct.mntent*, %struct.mntent** %4
%31 = getelementptr inbounds %struct.mntent, %struct.mntent* %30, i32 0, i32 0
%32 = load i8*, i8** %31
%33 = call i64 @strcmp(i8* %32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %53, label %35
35: ; preds = %29
%36 = load %struct.mntent*, %struct.mntent** %4
%37 = getelementptr inbounds %struct.mntent, %struct.mntent* %36, i32 0, i32 0
%38 = load i8*, i8** %37
%39 = call i64 @strcmp(i8* %38, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%40 = icmp eq i64 %39, 0
br i1 %40, label %53, label %41
41: ; preds = %35
%42 = load %struct.mntent*, %struct.mntent** %4
%43 = getelementptr inbounds %struct.mntent, %struct.mntent* %42, i32 0, i32 0
%44 = load i8*, i8** %43
%45 = call i64 @strcmp(i8* %44, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%46 = icmp eq i64 %45, 0
br i1 %46, label %53, label %47
47: ; preds = %41
%48 = load %struct.mntent*, %struct.mntent** %4
%49 = getelementptr inbounds %struct.mntent, %struct.mntent* %48, i32 0, i32 0
%50 = load i8*, i8** %49
%51 = call i64 @strcmp(i8* %50, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %86
53: ; preds = %47, %41, %35, %29, %23, %17
%54 = load %struct.mntent*, %struct.mntent** %4
%55 = getelementptr inbounds %struct.mntent, %struct.mntent* %54, i32 0, i32 1
%56 = load i8*, i8** %55
%57 = call i64 @statvfs(i8* %56, %struct.statvfs* %2)
%58 = icmp ne i64 %57, 0
br i1 %58, label %59, label %60
59: ; preds = %53
br label %13
60: ; preds = %53
%61 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %2, i32 0, i32 0
%62 = load i32, i32* %61
%63 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %2, i32 0, i32 1
%64 = load i32, i32* %63
%65 = sub nsw i32 %62, %64
%66 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %2, i32 0, i32 2
%67 = load i32, i32* %66
%68 = add nsw i32 %65, %67
%69 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %2, i32 0, i32 3
%70 = load i32, i32* %69
%71 = sdiv i32 %70, 1024
%72 = mul nsw i32 %68, %71
%73 = sitofp i32 %72 to double
%74 = fdiv double %73, 0x4130000000000000
store double %74, double* %3
%75 = load %struct.mntent*, %struct.mntent** %4
%76 = getelementptr inbounds %struct.mntent, %struct.mntent* %75, i32 0, i32 1
%77 = load i8*, i8** %76
%78 = load %struct.mntent*, %struct.mntent** %4
%79 = getelementptr inbounds %struct.mntent, %struct.mntent* %78, i32 0, i32 0
%80 = load i8*, i8** %79
%81 = load double, double* %3
%82 = load %struct.mntent*, %struct.mntent** %4
%83 = getelementptr inbounds %struct.mntent, %struct.mntent* %82, i32 0, i32 2
%84 = load i8*, i8** %83
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.9, i64 0, i64 0), i8* %77, i8* %80, double %81, i8* %84)
br label %86
86: ; preds = %60, %47
br label %13
87: ; preds = %13
%88 = load i32*, i32** %5
%89 = call i32 @fclose(i32* %88)
store i32 0, i32* %1
br label %90
90: ; preds = %87, %9
%91 = load i32, i32* %1
ret i32 %91
}

LLVM IR (-O2):
%struct.statvfs = type { i32, i32, i32, i32 }
%struct.mntent = type { i8*, i8*, i8* }
@.str = [10 x i8] c"/etc/mtab\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [18 x i8] c"fopen error = %d\0A\00"
@errno = global i32 0
@.str.3 = [4 x i8] c"ufs\00"
@.str.4 = [5 x i8] c"ext2\00"
@.str.5 = [5 x i8] c"ext3\00"
@.str.6 = [5 x i8] c"ext4\00"
@.str.7 = [4 x i8] c"xfs\00"
@.str.8 = [5 x i8] c"vxfs\00"
@.str.9 = [58 x i8] c"Device:[%6s] Type:[%4s] Size:[%7.2f GB] Directory:[%16s]\0A\00"
define i32 @main() {
%1 = alloca %struct.statvfs
%2 = bitcast %struct.statvfs* %1 to i8*
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %13, label %5
5: ; preds = %0
%6 = call %struct.mntent* @getmntent(i32* %3)
%7 = icmp eq %struct.mntent* %6, null
br i1 %7, label %66, label %8
8: ; preds = %5
%9 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %1, i64 0, i32 0
%10 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %1, i64 0, i32 1
%11 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %1, i64 0, i32 2
%12 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %1, i64 0, i32 3
br label %16
13: ; preds = %0
%14 = load i32, i32* @errno
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %14)
br label %68
16: ; preds = %8, %63
%17 = phi %struct.mntent* [ %6, %8 ], [ %64, %63 ]
%18 = getelementptr inbounds %struct.mntent, %struct.mntent* %17, i64 0, i32 0
%19 = load i8*, i8** %18
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %42, label %22
22: ; preds = %16
%23 = load i8*, i8** %18
%24 = call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %42, label %26
26: ; preds = %22
%27 = load i8*, i8** %18
%28 = call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %42, label %30
30: ; preds = %26
%31 = load i8*, i8** %18
%32 = call i64 @strcmp(i8* %31, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %42, label %34
34: ; preds = %30
%35 = load i8*, i8** %18
%36 = call i64 @strcmp(i8* %35, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %42, label %38
38: ; preds = %34
%39 = load i8*, i8** %18
%40 = call i64 @strcmp(i8* %39, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %63
42: ; preds = %38, %34, %30, %26, %22, %16
%43 = getelementptr inbounds %struct.mntent, %struct.mntent* %17, i64 0, i32 1
%44 = load i8*, i8** %43
%45 = call i64 @statvfs(i8* %44, %struct.statvfs* %1)
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %63
47: ; preds = %42
%48 = load i32, i32* %9
%49 = load i32, i32* %10
%50 = sub i32 %48, %49
%51 = load i32, i32* %11
%52 = add nsw i32 %50, %51
%53 = load i32, i32* %12
%54 = sdiv i32 %53, 1024
%55 = mul nsw i32 %54, %52
%56 = sitofp i32 %55 to double
%57 = fmul double %56, 0x3EB0000000000000
%58 = load i8*, i8** %43
%59 = load i8*, i8** %18
%60 = getelementptr inbounds %struct.mntent, %struct.mntent* %17, i64 0, i32 2
%61 = load i8*, i8** %60
%62 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.9, i64 0, i64 0), i8* %58, i8* %59, double %57, i8* %61)
br label %63
63: ; preds = %38, %47, %42
%64 = call %struct.mntent* @getmntent(i32* %3)
%65 = icmp eq %struct.mntent* %64, null
br i1 %65, label %66, label %16
66: ; preds = %63, %5
%67 = call i32 @fclose(i32* %3)
br label %68
68: ; preds = %66, %13
%69 = phi i32 [ -1, %13 ], [ 0, %66 ]
ret i32 %69
}