#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 */
typedef int /*<<< orphan*/ mode_t;

/* Variables and functions */
int /*<<< orphan*/ die(int /*<<< orphan*/, char *);
int /*<<< orphan*/ mkdir(char *, int);
scalar_t__ mount(char *, char *, char *, int /*<<< orphan*/,
                 int /*<<< orphan*/ *);
int /*<<< orphan*/ umask(int /*<<< orphan*/);
void mountproc(void) {
  mode_t mask;
  mask = umask(0);
  mkdir("proc", 0755);
  umask(mask);
  if (mount("proc", "proc", "proc", 0, NULL) < 0)
    die(0, "Failed to mount /proc in new root filesystem");
}


x86 assembly (clang, -O0):
<mountproc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %edi,%edi
call   1050 <umask@plt>
mov    %eax,-0x4(%rbp)
lea    0xea7(%rip),%rdi
mov    $0x1ed,%esi
call   1030 <mkdir@plt>
mov    -0x4(%rbp),%edi
call   1050 <umask@plt>
lea    0xe8e(%rip),%rdx
xor    %ecx,%ecx
xor    %eax,%eax
mov    %eax,%r8d
mov    %rdx,%rdi
mov    %rdx,%rsi
call   1040 <mount@plt>
cmp    $0x0,%rax
jge    119c <mountproc+0x5c>
xor    %edi,%edi
lea    0xe6e(%rip),%rsi
call   1060 <die@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mountproc>:
push   %rbp
push   %rbx
push   %rax
xor    %edi,%edi
call   1050 <umask@plt>
mov    %eax,%ebp
lea    0xead(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1ed,%esi
call   1030 <mkdir@plt>
mov    %ebp,%edi
call   1050 <umask@plt>
mov    %rbx,%rdi
mov    %rbx,%rsi
mov    %rbx,%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1040 <mount@plt>
test   %rax,%rax
js     1186 <mountproc+0x46>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe78(%rip),%rsi
xor    %edi,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1060 <die@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"proc\00"
@.str.1 = [45 x i8] c"Failed to mount /proc in new root filesystem\00"
define void @mountproc() {
%1 = alloca i32
%2 = call i32 @umask(i32 0)
store i32 %2, i32* %1
%3 = call i32 @mkdir(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 493)
%4 = load i32, i32* %1
%5 = call i32 @umask(i32 %4)
%6 = call i64 @mount(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 0, i32* null)
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @die(i32 0, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0))
br label %10
10: ; preds = %8, %0
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"proc\00"
@.str.1 = [45 x i8] c"Failed to mount /proc in new root filesystem\00"
define void @mountproc() {
%1 = tail call i32 @umask(i32 0)
%2 = tail call i32 @mkdir(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 493)
%3 = tail call i32 @umask(i32 %1)
%4 = tail call i64 @mount(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 0, i32* null)
%5 = icmp slt i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = tail call i32 @die(i32 0, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0))
br label %8
8: ; preds = %6, %0
ret void
}