#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 {
  char *mnt_dir;
  int /*<<< orphan*/ mnt_opts;
  int /*<<< orphan*/ mnt_type;
  int /*<<< orphan*/ mnt_fsname;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ _PATH_MNTTAB;
int /*<<< orphan*/ endmntent(int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
struct mntent *getmntent(int /*<<< orphan*/ *);
scalar_t__ mount_one(int /*<<< orphan*/, char *, int /*<<< orphan*/, int,
                     int /*<<< orphan*/);
int /*<<< orphan*/ *setmntent(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int mount_all() {
  struct mntent *m;
  FILE *f = NULL;
  f = setmntent(_PATH_MNTTAB, "r");
  if (!f)
    exit(EXIT_FAILURE);
  while ((m = getmntent(f))) {
    int mount_flags = 0;
    if (mount_one(m->mnt_fsname, m->mnt_dir, m->mnt_type, mount_flags,
                  m->mnt_opts) != 0) {
      fprintf(stderr, "Can't mount on %s\n", m->mnt_dir);
      exit(EXIT_FAILURE);
    }
  }
  endmntent(f);
  return 0;
}


x86 assembly (clang, -O0):
<mount_all>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movq   $0x0,-0x10(%rbp)
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
lea    0xe80(%rip),%rsi
call   1070 <setmntent@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11a2 <mount_all+0x42>
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
jmp    11a7 <mount_all+0x47>
mov    -0x10(%rbp),%rdi
call   1060 <getmntent@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
je     1223 <mount_all+0xc3>
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%edi
mov    -0x8(%rbp),%rax
mov    (%rax),%rsi
mov    -0x8(%rbp),%rax
mov    0xc(%rax),%edx
mov    -0x14(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%r8d
call   1050 <mount_one@plt>
cmp    $0x0,%rax
je     121e <mount_all+0xbe>
mov    0x2de5(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
mov    (%rax),%rdx
lea    0xdf7(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2dc1(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
jmp    11a7 <mount_all+0x47>
mov    -0x10(%rbp),%rdi
call   1030 <endmntent@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mount_all>:
push   %r14
push   %rbx
push   %rax
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
lea    0xe8c(%rip),%rsi
call   1070 <setmntent@plt>
test   %rax,%rax
je     11d1 <mount_all+0x71>
mov    %rax,%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1060 <getmntent@plt>
test   %rax,%rax
je     11df <mount_all+0x7f>
mov    %rax,%rbx
mov    0x10(%rax),%edi
mov    (%rax),%rsi
mov    0xc(%rax),%edx
mov    0x8(%rax),%r8d
xor    %ecx,%ecx
call   1050 <mount_one@plt>
test   %rax,%rax
je     1190 <mount_all+0x30>
mov    0x2e20(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe36(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e00(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    %r14,%rdi
call   1030 <endmntent@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.mntent = type { i8*, i32, i32, i32 }
@_PATH_MNTTAB = global i32 0
@.str = [2 x i8] c"r\00"
@EXIT_FAILURE = global i32 0
@stderr = global i32 0
@.str.1 = [19 x i8] c"Can't mount on %s\0A\00"
define i32 @mount_all() {
%1 = alloca %struct.mntent*
%2 = alloca i32*
%3 = alloca i32
store i32* null, i32** %2
%4 = load i32, i32* @_PATH_MNTTAB
%5 = call i32* @setmntent(i32 %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %5, i32** %2
%6 = load i32*, i32** %2
%7 = icmp ne i32* %6, null
br i1 %7, label %11, label %8
8: ; preds = %0
%9 = load i32, i32* @EXIT_FAILURE
%10 = call i32 @exit(i32 %9)
unreachable
11: ; preds = %0
br label %12
12: ; preds = %40, %11
%13 = load i32*, i32** %2
%14 = call %struct.mntent* @getmntent(i32* %13)
store %struct.mntent* %14, %struct.mntent** %1
%15 = icmp ne %struct.mntent* %14, null
br i1 %15, label %16, label %41
16: ; preds = %12
store i32 0, i32* %3
%17 = load %struct.mntent*, %struct.mntent** %1
%18 = getelementptr inbounds %struct.mntent, %struct.mntent* %17, i32 0, i32 3
%19 = load i32, i32* %18
%20 = load %struct.mntent*, %struct.mntent** %1
%21 = getelementptr inbounds %struct.mntent, %struct.mntent* %20, i32 0, i32 0
%22 = load i8*, i8** %21
%23 = load %struct.mntent*, %struct.mntent** %1
%24 = getelementptr inbounds %struct.mntent, %struct.mntent* %23, i32 0, i32 2
%25 = load i32, i32* %24
%26 = load i32, i32* %3
%27 = load %struct.mntent*, %struct.mntent** %1
%28 = getelementptr inbounds %struct.mntent, %struct.mntent* %27, i32 0, i32 1
%29 = load i32, i32* %28
%30 = call i64 @mount_one(i32 %19, i8* %22, i32 %25, i32 %26, i32 %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %40
32: ; preds = %16
%33 = load i32, i32* @stderr
%34 = load %struct.mntent*, %struct.mntent** %1
%35 = getelementptr inbounds %struct.mntent, %struct.mntent* %34, i32 0, i32 0
%36 = load i8*, i8** %35
%37 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %36)
%38 = load i32, i32* @EXIT_FAILURE
%39 = call i32 @exit(i32 %38)
unreachable
40: ; preds = %16
br label %12
41: ; preds = %12
%42 = load i32*, i32** %2
%43 = call i32 @endmntent(i32* %42)
ret i32 0
}

LLVM IR (-O2):
%struct.mntent = type { i8*, i32, i32, i32 }
@_PATH_MNTTAB = global i32 0
@.str = [2 x i8] c"r\00"
@EXIT_FAILURE = global i32 0
@stderr = global i32 0
@.str.1 = [19 x i8] c"Can't mount on %s\0A\00"
define i32 @mount_all() {
%1 = load i32, i32* @_PATH_MNTTAB
%2 = tail call i32* @setmntent(i32 %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %4, label %7
4: ; preds = %0
%5 = load i32, i32* @EXIT_FAILURE
%6 = tail call i32 @exit(i32 %5)
unreachable
7: ; preds = %0, %10
%8 = tail call %struct.mntent* @getmntent(i32* %2)
%9 = icmp eq %struct.mntent* %8, null
br i1 %9, label %28, label %10
10: ; preds = %7
%11 = getelementptr inbounds %struct.mntent, %struct.mntent* %8, i64 0, i32 3
%12 = load i32, i32* %11
%13 = getelementptr inbounds %struct.mntent, %struct.mntent* %8, i64 0, i32 0
%14 = load i8*, i8** %13
%15 = getelementptr inbounds %struct.mntent, %struct.mntent* %8, i64 0, i32 2
%16 = load i32, i32* %15
%17 = getelementptr inbounds %struct.mntent, %struct.mntent* %8, i64 0, i32 1
%18 = load i32, i32* %17
%19 = tail call i64 @mount_one(i32 %12, i8* %14, i32 %16, i32 0, i32 %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %7, label %21
21: ; preds = %10
%22 = getelementptr inbounds %struct.mntent, %struct.mntent* %8, i64 0, i32 0
%23 = load i32, i32* @stderr
%24 = load i8*, i8** %22
%25 = tail call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %24)
%26 = load i32, i32* @EXIT_FAILURE
%27 = tail call i32 @exit(i32 %26)
unreachable
28: ; preds = %7
%29 = tail call i32 @endmntent(i32* %2)
ret i32 0
}