#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*/ error(int, 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)
    error(1, 0, "Failed to mount /sys in new root filesystem");
}


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    11a5 <mountsys+0x65>
mov    $0x1,%edi
xor    %esi,%esi
lea    0xe6a(%rip),%rdx
call   1060 <error@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
js     118c <mountsys+0x4c>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe77(%rip),%rdx
mov    $0x1,%edi
xor    %esi,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <error@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"
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 @error(i32 1, i32 0, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0))
br label %10
10: ; preds = %8, %0
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"
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 @error(i32 1, i32 0, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0))
br label %8
8: ; preds = %6, %0
ret void
}