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

/* Variables and functions */
int /*<<< orphan*/ df_path(int /*<<< orphan*/);
int /*<<< orphan*/ endmntent(int /*<<< orphan*/ *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
struct mntent *getmntent(int /*<<< orphan*/ *);
int /*<<< orphan*/ *setmntent(char *, char *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
void df_all(void) {
  FILE *f;
  struct mntent *mnt;
  f = setmntent("/etc/mtab", "r");
  if (f) {
    while (mnt = getmntent(f))
      df_path(mnt->mnt_dir);
    endmntent(f);
  } else {
    fprintf(stderr, "df: cannot open /etc/mtab: %s\n", strerror(errno));
  }
}


x86 assembly (clang, -O0):
<df_all>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xe91(%rip),%rdi
lea    0xe94(%rip),%rsi
call   1060 <setmntent@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11c4 <df_all+0x64>
jmp    118f <df_all+0x2f>
mov    -0x8(%rbp),%rdi
call   1050 <getmntent@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     11b6 <df_all+0x56>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
call   1070 <df_path@plt>
jmp    118f <df_all+0x2f>
mov    -0x8(%rbp),%rdi
call   1030 <endmntent@plt>
jmp    11f0 <df_all+0x90>
mov    0x2e15(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x14(%rbp),%edi
mov    %rax,%rdx
lea    0xe21(%rip),%rsi
call   1040 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<df_all>:
push   %rbx
lea    0xe98(%rip),%rdi
lea    0xe9b(%rip),%rsi
call   1060 <setmntent@plt>
test   %rax,%rax
je     119f <df_all+0x3f>
mov    %rax,%rbx
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1050 <getmntent@plt>
test   %rax,%rax
je     1196 <df_all+0x36>
mov    (%rax),%edi
call   1070 <df_path@plt>
jmp    1180 <df_all+0x20>
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <endmntent@plt>
mov    0x2e3a(%rip),%rax
mov    (%rax),%ebx
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
lea    0xe4f(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
pop    %rbx
jmp    1040 <fprintf@plt>

LLVM IR (-O0):
%struct.mntent = type { i32 }
@.str = [10 x i8] c"/etc/mtab\00"
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [31 x i8] c"df: cannot open /etc/mtab: %s\0A\00"
@errno = global i32 0
define void @df_all() {
%1 = alloca i32*
%2 = alloca %struct.mntent*
%3 = 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* %3, i32** %1
%4 = load i32*, i32** %1
%5 = icmp ne i32* %4, null
br i1 %5, label %6, label %19
6: ; preds = %0
br label %7
7: ; preds = %11, %6
%8 = load i32*, i32** %1
%9 = call %struct.mntent* @getmntent(i32* %8)
store %struct.mntent* %9, %struct.mntent** %2
%10 = icmp ne %struct.mntent* %9, null
br i1 %10, label %11, label %16
11: ; preds = %7
%12 = load %struct.mntent*, %struct.mntent** %2
%13 = getelementptr inbounds %struct.mntent, %struct.mntent* %12, i32 0, i32 0
%14 = load i32, i32* %13
%15 = call i32 @df_path(i32 %14)
br label %7
16: ; preds = %7
%17 = load i32*, i32** %1
%18 = call i32 @endmntent(i32* %17)
br label %24
19: ; preds = %0
%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 ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %22)
br label %24
24: ; preds = %19, %16
ret void
}

LLVM IR (-O2):
%struct.mntent = type { i32 }
@.str = [10 x i8] c"/etc/mtab\00"
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [31 x i8] c"df: cannot open /etc/mtab: %s\0A\00"
@errno = global i32 0
define void @df_all() {
%1 = 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))
%2 = icmp eq i32* %1, null
br i1 %2, label %15, label %3
3: ; preds = %0
%4 = tail call %struct.mntent* @getmntent(i32* %1)
%5 = icmp eq %struct.mntent* %4, null
br i1 %5, label %13, label %6
6: ; preds = %3, %6
%7 = phi %struct.mntent* [ %11, %6 ], [ %4, %3 ]
%8 = getelementptr inbounds %struct.mntent, %struct.mntent* %7, i64 0, i32 0
%9 = load i32, i32* %8
%10 = tail call i32 @df_path(i32 %9)
%11 = tail call %struct.mntent* @getmntent(i32* %1)
%12 = icmp eq %struct.mntent* %11, null
br i1 %12, label %13, label %6
13: ; preds = %6, %3
%14 = tail call i32 @endmntent(i32* %1)
br label %20
15: ; preds = %0
%16 = load i32, i32* @stderr
%17 = load i32, i32* @errno
%18 = tail call i8* @strerror(i32 %17)
%19 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %18)
br label %20
20: ; preds = %15, %13
ret void
}