#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*/ mkdir(char *, int);
scalar_t__ mount(char *, char *, char *, int /*<<< orphan*/,
                 int /*<<< orphan*/ *);
int /*<<< orphan*/ panic(char *);
int /*<<< orphan*/ puts(char *);
scalar_t__ symlink(char *, char *);
void mount_filesystems(void) {
  puts("\x1b[32m\x1b[1m"
       "[+] Mounting filesystems..."
       "\x1b[0m");
  mkdir("/dev", 0755);
  mkdir("/proc", 0755);
  mkdir("/sys", 0755);
  mkdir("/tmp", 0755);
  mkdir("/run", 0755);
  mkdir("/var", 0755);
  if (mount("none", "/dev", "devtmpfs", 0, NULL))
    panic("devtmpfs mount");
  if (mount("none", "/proc", "proc", 0, NULL))
    panic("procfs mount");
  if (mount("none", "/sys", "sysfs", 0, NULL))
    panic("sysfs mount");
  if (mount("none", "/tmp", "tmpfs", 0, NULL))
    panic("tmpfs mount");
  if (mount("none", "/run", "tmpfs", 0, NULL))
    panic("tmpfs mount");
  if (symlink("/run", "/var/run"))
    panic("run symlink");
  if (symlink("/proc/self/fd", "/dev/fd"))
    panic("fd symlink");
}


x86 assembly (clang, -O0):
<mount_filesystems>:
push   %rbp
mov    %rsp,%rbp
lea    0xea5(%rip),%rdi
call   1040 <puts@plt>
lea    0xec2(%rip),%rdi
mov    $0x1ed,%esi
call   1030 <mkdir@plt>
lea    0xeb6(%rip),%rdi
mov    $0x1ed,%esi
call   1030 <mkdir@plt>
lea    0xeab(%rip),%rdi
mov    $0x1ed,%esi
call   1030 <mkdir@plt>
lea    0xe9f(%rip),%rdi
mov    $0x1ed,%esi
call   1030 <mkdir@plt>
lea    0xed8(%rip),%rdi
mov    $0x1ed,%esi
call   1030 <mkdir@plt>
lea    0xe82(%rip),%rdi
mov    $0x1ed,%esi
call   1030 <mkdir@plt>
lea    0xe76(%rip),%rdi
lea    0xe55(%rip),%rsi
lea    0xe6d(%rip),%rdx
xor    %ecx,%ecx
xor    %eax,%eax
mov    %eax,%r8d
call   1050 <mount@plt>
cmp    $0x0,%rax
je     11fd <mount_filesystems+0xad>
lea    0xe59(%rip),%rdi
call   1070 <panic@plt>
lea    0xe3f(%rip),%rdi
lea    0xe23(%rip),%rsi
lea    0xe1d(%rip),%rdx
xor    %ecx,%ecx
xor    %eax,%eax
mov    %eax,%r8d
call   1050 <mount@plt>
cmp    $0x0,%rax
je     1234 <mount_filesystems+0xe4>
lea    0xe31(%rip),%rdi
call   1070 <panic@plt>
lea    0xe08(%rip),%rdi
lea    0xdf2(%rip),%rsi
lea    0xe24(%rip),%rdx
xor    %ecx,%ecx
xor    %eax,%eax
mov    %eax,%r8d
call   1050 <mount@plt>
cmp    $0x0,%rax
je     126b <mount_filesystems+0x11b>
lea    0xe0d(%rip),%rdi
call   1070 <panic@plt>
lea    0xdd1(%rip),%rdi
lea    0xdc0(%rip),%rsi
lea    0xdcb(%rip),%rdx
xor    %ecx,%ecx
xor    %eax,%eax
mov    %eax,%r8d
call   1050 <mount@plt>
cmp    $0x0,%rax
je     12a2 <mount_filesystems+0x152>
lea    0xdb7(%rip),%rdi
call   1070 <panic@plt>
lea    0xd9a(%rip),%rdi
lea    0xdd3(%rip),%rsi
lea    0xd94(%rip),%rdx
xor    %ecx,%ecx
xor    %eax,%eax
mov    %eax,%r8d
call   1050 <mount@plt>
cmp    $0x0,%rax
je     12d9 <mount_filesystems+0x189>
lea    0xd80(%rip),%rdi
call   1070 <panic@plt>
lea    0xda3(%rip),%rdi
lea    0xd98(%rip),%rsi
call   1060 <symlink@plt>
cmp    $0x0,%rax
je     1302 <mount_filesystems+0x1b2>
lea    0xd8b(%rip),%rdi
call   1070 <panic@plt>
lea    0xd8b(%rip),%rdi
lea    0xd92(%rip),%rsi
call   1060 <symlink@plt>
cmp    $0x0,%rax
je     132b <mount_filesystems+0x1db>
lea    0xd84(%rip),%rdi
call   1070 <panic@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<mount_filesystems>:
push   %rbx
lea    0xea8(%rip),%rdi
call   1040 <puts@plt>
lea    0xec5(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1ed,%esi
call   1030 <mkdir@plt>
lea    0xeb6(%rip),%rdi
mov    $0x1ed,%esi
call   1030 <mkdir@plt>
lea    0xeab(%rip),%rdi
mov    $0x1ed,%esi
call   1030 <mkdir@plt>
lea    0xe9f(%rip),%rdi
mov    $0x1ed,%esi
call   1030 <mkdir@plt>
lea    0xed8(%rip),%rdi
mov    $0x1ed,%esi
call   1030 <mkdir@plt>
lea    0xe82(%rip),%rdi
mov    $0x1ed,%esi
call   1030 <mkdir@plt>
lea    0xe76(%rip),%rdi
lea    0xe74(%rip),%rdx
mov    %rbx,%rsi
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1050 <mount@plt>
test   %rax,%rax
je     11f2 <mount_filesystems+0xa2>
lea    0xe64(%rip),%rdi
call   1070 <panic@plt>
lea    0xe4a(%rip),%rdi
lea    0xe2e(%rip),%rsi
lea    0xe28(%rip),%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1050 <mount@plt>
test   %rax,%rax
je     1222 <mount_filesystems+0xd2>
lea    0xe43(%rip),%rdi
call   1070 <panic@plt>
lea    0xe1a(%rip),%rdi
lea    0xe04(%rip),%rsi
lea    0xe36(%rip),%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1050 <mount@plt>
test   %rax,%rax
je     1252 <mount_filesystems+0x102>
lea    0xe26(%rip),%rdi
call   1070 <panic@plt>
lea    0xdea(%rip),%rdi
lea    0xdd9(%rip),%rsi
lea    0xde4(%rip),%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1050 <mount@plt>
test   %rax,%rax
je     1282 <mount_filesystems+0x132>
lea    0xdd7(%rip),%rdi
call   1070 <panic@plt>
lea    0xdba(%rip),%rdi
lea    0xdf3(%rip),%rsi
lea    0xdb4(%rip),%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1050 <mount@plt>
test   %rax,%rax
je     12b2 <mount_filesystems+0x162>
lea    0xda7(%rip),%rdi
call   1070 <panic@plt>
lea    0xdca(%rip),%rdi
lea    0xdbf(%rip),%rsi
call   1060 <symlink@plt>
test   %rax,%rax
je     12d6 <mount_filesystems+0x186>
lea    0xdb7(%rip),%rdi
call   1070 <panic@plt>
lea    0xdb7(%rip),%rdi
lea    0xdbe(%rip),%rsi
call   1060 <symlink@plt>
test   %rax,%rax
je     12fb <mount_filesystems+0x1ab>
lea    0xdb5(%rip),%rdi
pop    %rbx
jmp    1070 <panic@plt>
pop    %rbx
ret

LLVM IR (-O0):
@.str = [41 x i8] c"\1B[32m\1B[1m[+] Mounting filesystems...\1B[0m\00"
@.str.1 = [5 x i8] c"/dev\00"
@.str.2 = [6 x i8] c"/proc\00"
@.str.3 = [5 x i8] c"/sys\00"
@.str.4 = [5 x i8] c"/tmp\00"
@.str.5 = [5 x i8] c"/run\00"
@.str.6 = [5 x i8] c"/var\00"
@.str.7 = [5 x i8] c"none\00"
@.str.8 = [9 x i8] c"devtmpfs\00"
@.str.9 = [15 x i8] c"devtmpfs mount\00"
@.str.10 = [5 x i8] c"proc\00"
@.str.11 = [13 x i8] c"procfs mount\00"
@.str.12 = [6 x i8] c"sysfs\00"
@.str.13 = [12 x i8] c"sysfs mount\00"
@.str.14 = [6 x i8] c"tmpfs\00"
@.str.15 = [12 x i8] c"tmpfs mount\00"
@.str.16 = [9 x i8] c"/var/run\00"
@.str.17 = [12 x i8] c"run symlink\00"
@.str.18 = [14 x i8] c"/proc/self/fd\00"
@.str.19 = [8 x i8] c"/dev/fd\00"
@.str.20 = [11 x i8] c"fd symlink\00"
define void @mount_filesystems() {
%1 = call i32 @puts(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%2 = call i32 @mkdir(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 493)
%3 = call i32 @mkdir(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 493)
%4 = call i32 @mkdir(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 493)
%5 = call i32 @mkdir(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 493)
%6 = call i32 @mkdir(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 493)
%7 = call i32 @mkdir(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 493)
%8 = call i64 @mount(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i32 0, i32* null)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = call i32 @panic(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
br label %12
12: ; preds = %10, %0
%13 = call i64 @mount(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i32 0, i32* null)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = call i32 @panic(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0))
br label %17
17: ; preds = %15, %12
%18 = call i64 @mount(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0), i32 0, i32* null)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 @panic(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i64 0, i64 0))
br label %22
22: ; preds = %20, %17
%23 = call i64 @mount(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i64 0, i64 0), i32 0, i32* null)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = call i32 @panic(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.15, i64 0, i64 0))
br label %27
27: ; preds = %25, %22
%28 = call i64 @mount(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i64 0, i64 0), i32 0, i32* null)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 @panic(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.15, i64 0, i64 0))
br label %32
32: ; preds = %30, %27
%33 = call i64 @symlink(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.16, i64 0, i64 0))
%34 = icmp ne i64 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %32
%36 = call i32 @panic(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.17, i64 0, i64 0))
br label %37
37: ; preds = %35, %32
%38 = call i64 @symlink(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.18, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.19, i64 0, i64 0))
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %37
%41 = call i32 @panic(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.20, i64 0, i64 0))
br label %42
42: ; preds = %40, %37
ret void
}

LLVM IR (-O2):
@.str = [41 x i8] c"\1B[32m\1B[1m[+] Mounting filesystems...\1B[0m\00"
@.str.1 = [5 x i8] c"/dev\00"
@.str.2 = [6 x i8] c"/proc\00"
@.str.3 = [5 x i8] c"/sys\00"
@.str.4 = [5 x i8] c"/tmp\00"
@.str.5 = [5 x i8] c"/run\00"
@.str.6 = [5 x i8] c"/var\00"
@.str.7 = [5 x i8] c"none\00"
@.str.8 = [9 x i8] c"devtmpfs\00"
@.str.9 = [15 x i8] c"devtmpfs mount\00"
@.str.10 = [5 x i8] c"proc\00"
@.str.11 = [13 x i8] c"procfs mount\00"
@.str.12 = [6 x i8] c"sysfs\00"
@.str.13 = [12 x i8] c"sysfs mount\00"
@.str.14 = [6 x i8] c"tmpfs\00"
@.str.15 = [12 x i8] c"tmpfs mount\00"
@.str.16 = [9 x i8] c"/var/run\00"
@.str.17 = [12 x i8] c"run symlink\00"
@.str.18 = [14 x i8] c"/proc/self/fd\00"
@.str.19 = [8 x i8] c"/dev/fd\00"
@.str.20 = [11 x i8] c"fd symlink\00"
define void @mount_filesystems() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @mkdir(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 493)
%3 = tail call i32 @mkdir(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 493)
%4 = tail call i32 @mkdir(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 493)
%5 = tail call i32 @mkdir(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 493)
%6 = tail call i32 @mkdir(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 493)
%7 = tail call i32 @mkdir(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 493)
%8 = tail call i64 @mount(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i32 0, i32* null)
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %0
%11 = tail call i32 @panic(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
br label %12
12: ; preds = %10, %0
%13 = tail call i64 @mount(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i32 0, i32* null)
%14 = icmp eq i64 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %12
%16 = tail call i32 @panic(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0))
br label %17
17: ; preds = %15, %12
%18 = tail call i64 @mount(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0), i32 0, i32* null)
%19 = icmp eq i64 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %17
%21 = tail call i32 @panic(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i64 0, i64 0))
br label %22
22: ; preds = %20, %17
%23 = tail call i64 @mount(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i64 0, i64 0), i32 0, i32* null)
%24 = icmp eq i64 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %22
%26 = tail call i32 @panic(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.15, i64 0, i64 0))
br label %27
27: ; preds = %25, %22
%28 = tail call i64 @mount(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i64 0, i64 0), i32 0, i32* null)
%29 = icmp eq i64 %28, 0
br i1 %29, label %32, label %30
30: ; preds = %27
%31 = tail call i32 @panic(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.15, i64 0, i64 0))
br label %32
32: ; preds = %30, %27
%33 = tail call i64 @symlink(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.16, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %37, label %35
35: ; preds = %32
%36 = tail call i32 @panic(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.17, i64 0, i64 0))
br label %37
37: ; preds = %35, %32
%38 = tail call i64 @symlink(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.18, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.19, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %42, label %40
40: ; preds = %37
%41 = tail call i32 @panic(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.20, i64 0, i64 0))
br label %42
42: ; preds = %40, %37
ret void
}