#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 dummy;
};
struct mntent {
  int /*<<< orphan*/ mnt_dir;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
struct mntent *getmntent(int /*<<< orphan*/ *);
int /*<<< orphan*/ *setmntent(char *, char *);
scalar_t__ statvfs(int /*<<< orphan*/, struct statvfs *);
int main(int argc, char *argv[]) {
  FILE *f;
  struct mntent *ent;
  struct statvfs buf;
  f = setmntent("/etc/mtab", "r");
  if (f == NULL)
    return 1;
  while ((ent = getmntent(f)) != NULL) {
    if (statvfs(ent->mnt_dir, &buf) != 0)
      return 1;
  }
  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)
lea    0xeb3(%rip),%rdi
lea    0xeb6(%rip),%rsi
call   1040 <setmntent@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1174 <main+0x44>
movl   $0x1,-0x4(%rbp)
jmp    11c1 <main+0x91>
jmp    1179 <main+0x49>
mov    -0x18(%rbp),%rdi
call   1030 <getmntent@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     11ba <main+0x8a>
mov    -0x20(%rbp),%rax
mov    (%rax),%edi
lea    -0x28(%rbp),%rsi
call   1050 <statvfs@plt>
cmp    $0x0,%rax
je     11b5 <main+0x85>
movl   $0x1,-0x4(%rbp)
jmp    11c1 <main+0x91>
jmp    1179 <main+0x49>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
lea    0xec4(%rip),%rsi
call   1040 <setmntent@plt>
mov    $0x1,%r14d
test   %rax,%rax
je     1181 <main+0x51>
mov    %rax,%rbx
lea    0x8(%rsp),%rbp
xchg   %ax,%ax
mov    %rbx,%rdi
call   1030 <getmntent@plt>
test   %rax,%rax
je     117e <main+0x4e>
mov    (%rax),%edi
mov    %rbp,%rsi
call   1050 <statvfs@plt>
test   %rax,%rax
je     1160 <main+0x30>
jmp    1181 <main+0x51>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.mntent = type { i32 }
%struct.statvfs = type { i32 }
@.str = [10 x i8] c"/etc/mtab\00"
@.str.1 = [2 x i8] c"r\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca %struct.mntent*
%8 = alloca %struct.statvfs
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32* @setmntent(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* %9, i32** %6
%10 = load i32*, i32** %6
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %13
12: ; preds = %2
store i32 1, i32* %3
br label %27
13: ; preds = %2
br label %14
14: ; preds = %25, %13
%15 = load i32*, i32** %6
%16 = call %struct.mntent* @getmntent(i32* %15)
store %struct.mntent* %16, %struct.mntent** %7
%17 = icmp ne %struct.mntent* %16, null
br i1 %17, label %18, label %26
18: ; preds = %14
%19 = load %struct.mntent*, %struct.mntent** %7
%20 = getelementptr inbounds %struct.mntent, %struct.mntent* %19, i32 0, i32 0
%21 = load i32, i32* %20
%22 = call i64 @statvfs(i32 %21, %struct.statvfs* %8)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %18
store i32 1, i32* %3
br label %27
25: ; preds = %18
br label %14
26: ; preds = %14
store i32 0, i32* %3
br label %27
27: ; preds = %26, %24, %12
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
%struct.statvfs = type { i32 }
%struct.mntent = type { i32 }
@.str = [10 x i8] c"/etc/mtab\00"
@.str.1 = [2 x i8] c"r\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.statvfs
%4 = bitcast %struct.statvfs* %3 to i8*
%5 = tail call i32* @setmntent(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))
%6 = icmp eq i32* %5, null
br i1 %6, label %15, label %7
7: ; preds = %2, %10
%8 = call %struct.mntent* @getmntent(i32* %5)
%9 = icmp eq %struct.mntent* %8, null
br i1 %9, label %15, label %10
10: ; preds = %7
%11 = getelementptr inbounds %struct.mntent, %struct.mntent* %8, i64 0, i32 0
%12 = load i32, i32* %11
%13 = call i64 @statvfs(i32 %12, %struct.statvfs* %3)
%14 = icmp eq i64 %13, 0
br i1 %14, label %7, label %15
15: ; preds = %7, %10, %2
%16 = phi i32 [ 1, %2 ], [ 0, %7 ], [ 1, %10 ]
ret i32 %16
}