#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 */

/* Variables and functions */
int /*<<< orphan*/ AT_FDCWD;
int /*<<< orphan*/ FSCONFIG_CMD_CREATE;
int /*<<< orphan*/ FSCONFIG_SET_STRING;
int /*<<< orphan*/ MOUNT_ATTR_RDONLY;
int /*<<< orphan*/ MOVE_MOUNT_F_EMPTY_PATH;
int close(int);
int /*<<< orphan*/ exit(int);
int fsconfig(int, int /*<<< orphan*/, char *, char *, int /*<<< orphan*/);
int fsmount(int, int /*<<< orphan*/, int /*<<< orphan*/);
int fsopen(char *, int /*<<< orphan*/);
int /*<<< orphan*/ mount_error(int, char *);
scalar_t__ move_mount(int, char *, int /*<<< orphan*/, char *,
                      int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int main(int argc, char *argv[]) {
  int fsfd, mfd;
  fsfd = fsopen("afs", 0);
  if (fsfd == -1) {
    perror("fsopen");
    exit(1);
  }
  do {
    if (fsconfig(fsfd, FSCONFIG_SET_STRING, "source",
                 "#grand.central.org:root.cell.", 0) == -1)
      mount_error(fsfd, "source" ?: "create");
  } while (0);
  do {
    if (fsconfig(fsfd, FSCONFIG_CMD_CREATE, NULL, NULL, 0) == -1)
      mount_error(fsfd, NULL ?: "create");
  } while (0);
  mfd = fsmount(fsfd, 0, MOUNT_ATTR_RDONLY);
  if (mfd < 0)
    mount_error(fsfd, "fsmount");
  do {
    if ((close(fsfd)) == -1) {
      perror("close(fsfd)");
      exit(1);
    }
  } while (0);
  if (move_mount(mfd, "", AT_FDCWD, "/mnt", MOVE_MOUNT_F_EMPTY_PATH) < 0) {
    perror("move_mount");
    exit(1);
  }
  do {
    if ((close(mfd)) == -1) {
      perror("close(mfd)");
      exit(1);
    }
  } while (0);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe63(%rip),%rdi
xor    %esi,%esi
call   1030 <fsopen@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    11c7 <main+0x47>
lea    0xe4c(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
jmp    11cc <main+0x4c>
mov    -0x14(%rbp),%edi
mov    0x2df2(%rip),%rax
mov    (%rax),%esi
lea    0xe2c(%rip),%rdx
lea    0xe2c(%rip),%rcx
xor    %r8d,%r8d
call   10a0 <fsconfig@plt>
cmp    $0xffffffff,%eax
jne    1206 <main+0x86>
mov    -0x14(%rbp),%edi
lea    0xe0a(%rip),%rsi
call   1040 <mount_error@plt>
jmp    120b <main+0x8b>
jmp    1210 <main+0x90>
mov    -0x14(%rbp),%edi
mov    0x2db6(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
mov    %eax,%ecx
xor    %r8d,%r8d
mov    %rcx,%rdx
call   10a0 <fsconfig@plt>
cmp    $0xffffffff,%eax
jne    1243 <main+0xc3>
mov    -0x14(%rbp),%edi
lea    0xdf2(%rip),%rsi
call   1040 <mount_error@plt>
jmp    1248 <main+0xc8>
mov    -0x14(%rbp),%edi
mov    0x2d8e(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <fsmount@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1277 <main+0xf7>
mov    -0x14(%rbp),%edi
lea    0xdc5(%rip),%rsi
call   1040 <mount_error@plt>
jmp    127c <main+0xfc>
mov    -0x14(%rbp),%edi
call   1050 <close@plt>
cmp    $0xffffffff,%eax
jne    12a3 <main+0x123>
lea    0xdab(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
jmp    12a8 <main+0x128>
mov    -0x18(%rbp),%edi
mov    0x2d06(%rip),%rax
mov    (%rax),%edx
mov    0x2d35(%rip),%rax
mov    (%rax),%r8d
lea    0xda0(%rip),%rsi
lea    0xd7f(%rip),%rcx
call   1060 <move_mount@plt>
cmp    $0x0,%rax
jge    12f1 <main+0x171>
lea    0xd6e(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
jmp    12f6 <main+0x176>
mov    -0x18(%rbp),%edi
call   1050 <close@plt>
cmp    $0xffffffff,%eax
jne    131d <main+0x19d>
lea    0xd4d(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
jmp    1322 <main+0x1a2>
xor    %edi,%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xe76(%rip),%rdi
xor    %esi,%esi
call   1030 <fsopen@plt>
cmp    $0xffffffff,%eax
jne    11a2 <main+0x22>
lea    0xe67(%rip),%rdi
jmp    1286 <main+0x106>
mov    %eax,%ebx
mov    0x2e1d(%rip),%rax
mov    (%rax),%esi
lea    0xe57(%rip),%rdx
lea    0xe57(%rip),%rcx
mov    %ebx,%edi
xor    %r8d,%r8d
call   10a0 <fsconfig@plt>
cmp    $0xffffffff,%eax
jne    11d8 <main+0x58>
lea    0xe3a(%rip),%rsi
mov    %ebx,%edi
call   1040 <mount_error@plt>
mov    0x2df1(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   10a0 <fsconfig@plt>
cmp    $0xffffffff,%eax
jne    1202 <main+0x82>
lea    0xe35(%rip),%rsi
mov    %ebx,%edi
call   1040 <mount_error@plt>
mov    0x2dd7(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
xor    %esi,%esi
call   1080 <fsmount@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    1228 <main+0xa8>
lea    0xe16(%rip),%rsi
mov    %ebx,%edi
call   1040 <mount_error@plt>
mov    %ebx,%edi
call   1050 <close@plt>
cmp    $0xffffffff,%eax
jne    123d <main+0xbd>
lea    0xe04(%rip),%rdi
jmp    1286 <main+0x106>
mov    0x2d74(%rip),%rax
mov    (%rax),%edx
mov    0x2da3(%rip),%rax
mov    (%rax),%r8d
lea    0xe0e(%rip),%rsi
lea    0xded(%rip),%rcx
mov    %ebp,%edi
call   1060 <move_mount@plt>
test   %rax,%rax
jns    1273 <main+0xf3>
lea    0xddf(%rip),%rdi
jmp    1286 <main+0x106>
mov    %ebp,%edi
call   1050 <close@plt>
cmp    $0xffffffff,%eax
jne    1295 <main+0x115>
lea    0xdd5(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"afs\00"
@.str.1 = [7 x i8] c"fsopen\00"
@FSCONFIG_SET_STRING = global i32 0
@.str.2 = [7 x i8] c"source\00"
@.str.3 = [30 x i8] c"#grand.central.org:root.cell.\00"
@.str.4 = [7 x i8] c"create\00"
@FSCONFIG_CMD_CREATE = global i32 0
@MOUNT_ATTR_RDONLY = global i32 0
@.str.5 = [8 x i8] c"fsmount\00"
@.str.6 = [12 x i8] c"close(fsfd)\00"
@.str.7 = [1 x i8] zeroinitializer
@AT_FDCWD = global i32 0
@.str.8 = [5 x i8] c"/mnt\00"
@MOVE_MOUNT_F_EMPTY_PATH = global i32 0
@.str.9 = [11 x i8] c"move_mount\00"
@.str.10 = [11 x i8] c"close(mfd)\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 @fsopen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 0)
store i32 %8, i32* %6
%9 = load i32, i32* %6
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %2
br label %15
15: ; preds = %14
%16 = load i32, i32* %6
%17 = load i32, i32* @FSCONFIG_SET_STRING
%18 = call i32 @fsconfig(i32 %16, i32 %17, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i32 0)
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %23
20: ; preds = %15
%21 = load i32, i32* %6
%22 = call i32 @mount_error(i32 %21, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %23
23: ; preds = %20, %15
br label %24
24: ; preds = %23
br label %25
25: ; preds = %24
%26 = load i32, i32* %6
%27 = load i32, i32* @FSCONFIG_CMD_CREATE
%28 = call i32 @fsconfig(i32 %26, i32 %27, i8* null, i8* null, i32 0)
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %33
30: ; preds = %25
%31 = load i32, i32* %6
%32 = call i32 @mount_error(i32 %31, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %33
33: ; preds = %30, %25
br label %34
34: ; preds = %33
%35 = load i32, i32* %6
%36 = load i32, i32* @MOUNT_ATTR_RDONLY
%37 = call i32 @fsmount(i32 %35, i32 0, i32 %36)
store i32 %37, i32* %7
%38 = load i32, i32* %7
%39 = icmp slt i32 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %34
%41 = load i32, i32* %6
%42 = call i32 @mount_error(i32 %41, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
br label %43
43: ; preds = %40, %34
br label %44
44: ; preds = %43
%45 = load i32, i32* %6
%46 = call i32 @close(i32 %45)
%47 = icmp eq i32 %46, -1
br i1 %47, label %48, label %51
48: ; preds = %44
%49 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
%50 = call i32 @exit(i32 1)
unreachable
51: ; preds = %44
br label %52
52: ; preds = %51
%53 = load i32, i32* %7
%54 = load i32, i32* @AT_FDCWD
%55 = load i32, i32* @MOVE_MOUNT_F_EMPTY_PATH
%56 = call i64 @move_mount(i32 %53, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0), i32 %54, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i32 %55)
%57 = icmp slt i64 %56, 0
br i1 %57, label %58, label %61
58: ; preds = %52
%59 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0))
%60 = call i32 @exit(i32 1)
unreachable
61: ; preds = %52
br label %62
62: ; preds = %61
%63 = load i32, i32* %7
%64 = call i32 @close(i32 %63)
%65 = icmp eq i32 %64, -1
br i1 %65, label %66, label %69
66: ; preds = %62
%67 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0))
%68 = call i32 @exit(i32 1)
unreachable
69: ; preds = %62
br label %70
70: ; preds = %69
%71 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [4 x i8] c"afs\00"
@.str.1 = [7 x i8] c"fsopen\00"
@FSCONFIG_SET_STRING = global i32 0
@.str.2 = [7 x i8] c"source\00"
@.str.3 = [30 x i8] c"#grand.central.org:root.cell.\00"
@.str.4 = [7 x i8] c"create\00"
@FSCONFIG_CMD_CREATE = global i32 0
@MOUNT_ATTR_RDONLY = global i32 0
@.str.5 = [8 x i8] c"fsmount\00"
@.str.6 = [12 x i8] c"close(fsfd)\00"
@.str.7 = [1 x i8] zeroinitializer
@AT_FDCWD = global i32 0
@.str.8 = [5 x i8] c"/mnt\00"
@MOVE_MOUNT_F_EMPTY_PATH = global i32 0
@.str.9 = [11 x i8] c"move_mount\00"
@.str.10 = [11 x i8] c"close(mfd)\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @fsopen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 0)
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %2
%9 = load i32, i32* @FSCONFIG_SET_STRING
%10 = tail call i32 @fsconfig(i32 %3, i32 %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i32 0)
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = tail call i32 @mount_error(i32 %3, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %14
14: ; preds = %8, %12
%15 = load i32, i32* @FSCONFIG_CMD_CREATE
%16 = tail call i32 @fsconfig(i32 %3, i32 %15, i8* null, i8* null, i32 0)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = tail call i32 @mount_error(i32 %3, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %20
20: ; preds = %18, %14
%21 = load i32, i32* @MOUNT_ATTR_RDONLY
%22 = tail call i32 @fsmount(i32 %3, i32 0, i32 %21)
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = tail call i32 @mount_error(i32 %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
br label %26
26: ; preds = %20, %24
%27 = tail call i32 @close(i32 %3)
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = tail call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
%31 = tail call i32 @exit(i32 1)
unreachable
32: ; preds = %26
%33 = load i32, i32* @AT_FDCWD
%34 = load i32, i32* @MOVE_MOUNT_F_EMPTY_PATH
%35 = tail call i64 @move_mount(i32 %22, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0), i32 %33, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i32 %34)
%36 = icmp slt i64 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %32
%38 = tail call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0))
%39 = tail call i32 @exit(i32 1)
unreachable
40: ; preds = %32
%41 = tail call i32 @close(i32 %22)
%42 = icmp eq i32 %41, -1
br i1 %42, label %43, label %46
43: ; preds = %40
%44 = tail call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0))
%45 = tail call i32 @exit(i32 1)
unreachable
46: ; preds = %40
%47 = tail call i32 @exit(i32 0)
unreachable
}