#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 mountsys(void) {
  mode_t mask;
  mask = umask(0);
  mkdir("sys", 0755);
  umask(mask);
  if (mount("sysfs", "sys", "sysfs", 0, NULL) < 0)
    die(0, "Failed to mount /sys in new root filesystem");
  mount("cgroup2", "sys/fs/cgroup", "cgroup2", 0, NULL);
}


x86 assembly (clang, -O0):
<mountsys>:
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    0xe92(%rip),%rdx
lea    0xe87(%rip),%rsi
xor    %ecx,%ecx
xor    %eax,%eax
mov    %eax,%r8d
mov    %rdx,%rdi
call   1040 <mount@plt>
cmp    $0x0,%rax
jge    11a0 <mountsys+0x60>
xor    %edi,%edi
lea    0xe6f(%rip),%rsi
call   1060 <die@plt>
lea    0xe8f(%rip),%rdx
lea    0xe90(%rip),%rsi
xor    %ecx,%ecx
xor    %eax,%eax
mov    %eax,%r8d
mov    %rdx,%rdi
call   1040 <mount@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mountsys>:
push   %r14
push   %rbx
push   %rax
xor    %edi,%edi
call   1050 <umask@plt>
mov    %eax,%ebx
lea    0xeac(%rip),%r14
mov    %r14,%rdi
mov    $0x1ed,%esi
call   1030 <mkdir@plt>
mov    %ebx,%edi
call   1050 <umask@plt>
lea    0xe95(%rip),%rdi
mov    %r14,%rsi
mov    %rdi,%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1040 <mount@plt>
test   %rax,%rax
jns    1192 <mountsys+0x52>
lea    0xe7f(%rip),%rsi
xor    %edi,%edi
call   1060 <die@plt>
lea    0xea5(%rip),%rsi
lea    0xe96(%rip),%rdi
mov    %rdi,%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <mount@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"sys\00"
@.str.1 = [6 x i8] c"sysfs\00"
@.str.2 = [44 x i8] c"Failed to mount /sys in new root filesystem\00"
@.str.3 = [8 x i8] c"cgroup2\00"
@.str.4 = [14 x i8] c"sys/fs/cgroup\00"
define void @mountsys() {
%1 = alloca i32
%2 = call i32 @umask(i32 0)
store i32 %2, i32* %1
%3 = call i32 @mkdir(i8* getelementptr inbounds ([4 x i8], [4 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 ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, 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 ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0))
br label %10
10: ; preds = %8, %0
%11 = call i64 @mount(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 0, i32* null)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"sys\00"
@.str.1 = [6 x i8] c"sysfs\00"
@.str.2 = [44 x i8] c"Failed to mount /sys in new root filesystem\00"
@.str.3 = [8 x i8] c"cgroup2\00"
@.str.4 = [14 x i8] c"sys/fs/cgroup\00"
define void @mountsys() {
%1 = tail call i32 @umask(i32 0)
%2 = tail call i32 @mkdir(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 493)
%3 = tail call i32 @umask(i32 %1)
%4 = tail call i64 @mount(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, 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 ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0))
br label %8
8: ; preds = %6, %0
%9 = tail call i64 @mount(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 0, i32* null)
ret void
}