#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 S_IFCHR;
int /*<<< orphan*/ makedev(int, int);
int /*<<< orphan*/ mknod(char *, int, int /*<<< orphan*/);
scalar_t__ mount_misc(char *, char *);
int mount_all(void) {
  if (mount_misc("proc", "/proc") < 0 || mount_misc("sysfs", "/sys") < 0 ||
      mount_misc("tmpfs", "/dev") < 0)
    return -1;
  mknod("/dev/urandom", 0777 | S_IFCHR, makedev(1, 9));
  mknod("/dev/random", 0777 | S_IFCHR, makedev(1, 8));
  return 0;
}


x86 assembly (clang, -O0):
<mount_all>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec2(%rip),%rdi
lea    0xeba(%rip),%rsi
call   1030 <mount_misc@plt>
cmp    $0x0,%rax
jl     118f <mount_all+0x5f>
lea    0xeaa(%rip),%rdi
lea    0xea9(%rip),%rsi
call   1030 <mount_misc@plt>
cmp    $0x0,%rax
jl     118f <mount_all+0x5f>
lea    0xe98(%rip),%rdi
lea    0xe97(%rip),%rsi
call   1030 <mount_misc@plt>
cmp    $0x0,%rax
jge    119b <mount_all+0x6b>
movl   $0xffffffff,-0x4(%rbp)
jmp    1204 <mount_all+0xd4>
mov    0x2e3e(%rip),%rax
mov    (%rax),%eax
or     $0x1ff,%eax
mov    %eax,-0xc(%rbp)
mov    $0x1,%edi
mov    $0x9,%esi
call   1050 <makedev@plt>
mov    -0xc(%rbp),%esi
mov    %eax,%edx
lea    0xe55(%rip),%rdi
call   1040 <mknod@plt>
mov    0x2e0d(%rip),%rax
mov    (%rax),%eax
or     $0x1ff,%eax
mov    %eax,-0x8(%rbp)
mov    $0x1,%edi
mov    $0x8,%esi
call   1050 <makedev@plt>
mov    -0x8(%rbp),%esi
mov    %eax,%edx
lea    0xe31(%rip),%rdi
call   1040 <mknod@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mount_all>:
push   %rbp
push   %r14
push   %rbx
lea    0xec6(%rip),%rdi
lea    0xebe(%rip),%rsi
call   1030 <mount_misc@plt>
mov    $0xffffffff,%ebx
test   %rax,%rax
js     11d9 <mount_all+0xa9>
lea    0xeaa(%rip),%rdi
lea    0xea9(%rip),%rsi
call   1030 <mount_misc@plt>
test   %rax,%rax
js     11d9 <mount_all+0xa9>
lea    0xe9d(%rip),%rdi
lea    0xe9c(%rip),%rsi
call   1030 <mount_misc@plt>
test   %rax,%rax
js     11d9 <mount_all+0xa9>
mov    0x2e54(%rip),%r14
mov    $0x1ff,%ebx
mov    (%r14),%ebp
or     %ebx,%ebp
mov    $0x1,%edi
mov    $0x9,%esi
call   1050 <makedev@plt>
lea    0xe70(%rip),%rdi
mov    %ebp,%esi
mov    %eax,%edx
call   1040 <mknod@plt>
or     (%r14),%ebx
mov    $0x1,%edi
mov    $0x8,%esi
call   1050 <makedev@plt>
lea    0xe5b(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
call   1040 <mknod@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"proc\00"
@.str.1 = [6 x i8] c"/proc\00"
@.str.2 = [6 x i8] c"sysfs\00"
@.str.3 = [5 x i8] c"/sys\00"
@.str.4 = [6 x i8] c"tmpfs\00"
@.str.5 = [5 x i8] c"/dev\00"
@.str.6 = [13 x i8] c"/dev/urandom\00"
@S_IFCHR = global i32 0
@.str.7 = [12 x i8] c"/dev/random\00"
define i32 @mount_all() {
%1 = alloca i32
%2 = call i64 @mount_misc(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp slt i64 %2, 0
br i1 %3, label %10, label %4
4: ; preds = %0
%5 = call i64 @mount_misc(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.3, i64 0, i64 0))
%6 = icmp slt i64 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %4
%8 = call i64 @mount_misc(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %7, %4, %0
store i32 -1, i32* %1
br label %20
11: ; preds = %7
%12 = load i32, i32* @S_IFCHR
%13 = or i32 511, %12
%14 = call i32 @makedev(i32 1, i32 9)
%15 = call i32 @mknod(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 %13, i32 %14)
%16 = load i32, i32* @S_IFCHR
%17 = or i32 511, %16
%18 = call i32 @makedev(i32 1, i32 8)
%19 = call i32 @mknod(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i32 %17, i32 %18)
store i32 0, i32* %1
br label %20
20: ; preds = %11, %10
%21 = load i32, i32* %1
ret i32 %21
}

LLVM IR (-O2):
@.str = [5 x i8] c"proc\00"
@.str.1 = [6 x i8] c"/proc\00"
@.str.2 = [6 x i8] c"sysfs\00"
@.str.3 = [5 x i8] c"/sys\00"
@.str.4 = [6 x i8] c"tmpfs\00"
@.str.5 = [5 x i8] c"/dev\00"
@.str.6 = [13 x i8] c"/dev/urandom\00"
@S_IFCHR = global i32 0
@.str.7 = [12 x i8] c"/dev/random\00"
define i32 @mount_all() {
%1 = tail call i64 @mount_misc(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%2 = icmp slt i64 %1, 0
br i1 %2, label %18, label %3
3: ; preds = %0
%4 = tail call i64 @mount_misc(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.3, i64 0, i64 0))
%5 = icmp slt i64 %4, 0
br i1 %5, label %18, label %6
6: ; preds = %3
%7 = tail call i64 @mount_misc(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%8 = icmp slt i64 %7, 0
br i1 %8, label %18, label %9
9: ; preds = %6
%10 = load i32, i32* @S_IFCHR
%11 = or i32 %10, 511
%12 = tail call i32 @makedev(i32 1, i32 9)
%13 = tail call i32 @mknod(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 %11, i32 %12)
%14 = load i32, i32* @S_IFCHR
%15 = or i32 %14, 511
%16 = tail call i32 @makedev(i32 1, i32 8)
%17 = tail call i32 @mknod(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i32 %15, i32 %16)
br label %18
18: ; preds = %0, %3, %6, %9
%19 = phi i32 [ 0, %9 ], [ -1, %6 ], [ -1, %3 ], [ -1, %0 ]
ret i32 %19
}