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

/* Variables and functions */
int /*<<< orphan*/ df_path(int /*<<< orphan*/, int /*<<< orphan*/,
                           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, mnt->mnt_fsname, 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     11d1 <df_all+0x71>
jmp    118f <df_all+0x2f>
mov    -0x8(%rbp),%rdi
call   1050 <getmntent@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     11c3 <df_all+0x63>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%esi
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
call   1070 <df_path@plt>
jmp    118f <df_all+0x2f>
mov    -0x8(%rbp),%rdi
call   1030 <endmntent@plt>
jmp    11fd <df_all+0x9d>
mov    0x2e08(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    0x2df4(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x14(%rbp),%edi
mov    %rax,%rdx
lea    0xe14(%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     11a4 <df_all+0x44>
mov    %rax,%rbx
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1050 <getmntent@plt>
test   %rax,%rax
je     119b <df_all+0x3b>
mov    (%rax),%edi
mov    0x4(%rax),%esi
mov    %edi,%edx
call   1070 <df_path@plt>
jmp    1180 <df_all+0x20>
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <endmntent@plt>
mov    0x2e35(%rip),%rax
mov    (%rax),%ebx
mov    0x2e24(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
lea    0xe4a(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
pop    %rbx
jmp    1040 <fprintf@plt>

LLVM IR (-O0):
%struct.mntent = type { i32, 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 %25
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 %22
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 = load %struct.mntent*, %struct.mntent** %2
%16 = getelementptr inbounds %struct.mntent, %struct.mntent* %15, i32 0, i32 1
%17 = load i32, i32* %16
%18 = load %struct.mntent*, %struct.mntent** %2
%19 = getelementptr inbounds %struct.mntent, %struct.mntent* %18, i32 0, i32 0
%20 = load i32, i32* %19
%21 = call i32 @df_path(i32 %14, i32 %17, i32 %20)
br label %7
22: ; preds = %7
%23 = load i32*, i32** %1
%24 = call i32 @endmntent(i32* %23)
br label %30
25: ; preds = %0
%26 = load i32, i32* @stderr
%27 = load i32, i32* @errno
%28 = call i8* @strerror(i32 %27)
%29 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %28)
br label %30
30: ; preds = %25, %22
ret void
}

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