#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*/ MS_BIND;
int /*<<< orphan*/ dbg_test_dir(char *);
int /*<<< orphan*/ empty_dev_shm();
int /*<<< orphan*/ fwarning(char *);
int /*<<< orphan*/ mkdir_attr(char *, int, int /*<<< orphan*/,
                              int /*<<< orphan*/);
int mount(char *, char *, char *, int /*<<< orphan*/, char *);
void mount_dev_shm(void) {
  mkdir_attr("/dev/shm", 01777, 0, 0);
  int rv = mount("/run/firejail/mnt/dev"
                 "/shm",
                 "/dev/shm", "none", MS_BIND, "mode=01777,gid=0");
  if (rv == -1) {
    fwarning("cannot mount the old /dev/shm in private-dev\n");
    dbg_test_dir("/run/firejail/mnt/dev"
                 "/shm");
    empty_dev_shm();
    return;
  }
}


x86 assembly (clang, -O0):
<mount_dev_shm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb2(%rip),%rdi
mov    $0x3ff,%esi
xor    %ecx,%ecx
mov    %ecx,%edx
call   1060 <mkdir_attr@plt>
mov    0x2e74(%rip),%rax
mov    (%rax),%ecx
lea    0xe83(%rip),%rdi
lea    0xe8d(%rip),%rsi
lea    0xe8f(%rip),%rdx
lea    0xe8d(%rip),%r8
call   1040 <mount@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0xffffffff,-0x4(%rbp)
jne    11c3 <mount_dev_shm+0x73>
lea    0xe85(%rip),%rdi
call   1070 <fwarning@plt>
lea    0xe49(%rip),%rdi
call   1030 <dbg_test_dir@plt>
mov    $0x0,%al
call   1050 <empty_dev_shm@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mount_dev_shm>:
push   %rbx
lea    0xeb9(%rip),%rbx
mov    %rbx,%rdi
mov    $0x3ff,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1060 <mkdir_attr@plt>
mov    0x2e78(%rip),%rax
mov    (%rax),%ecx
lea    0xe87(%rip),%rdi
lea    0xe9a(%rip),%rdx
lea    0xe98(%rip),%r8
mov    %rbx,%rsi
call   1040 <mount@plt>
cmp    $0xffffffff,%eax
je     1196 <mount_dev_shm+0x46>
pop    %rbx
ret
lea    0xe93(%rip),%rdi
call   1070 <fwarning@plt>
lea    0xe57(%rip),%rdi
call   1030 <dbg_test_dir@plt>
xor    %eax,%eax
pop    %rbx
jmp    1050 <empty_dev_shm@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"/dev/shm\00"
@.str.1 = [26 x i8] c"/run/firejail/mnt/dev/shm\00"
@.str.2 = [5 x i8] c"none\00"
@MS_BIND = global i32 0
@.str.3 = [17 x i8] c"mode=01777,gid=0\00"
@.str.4 = [46 x i8] c"cannot mount the old /dev/shm in private-dev\0A\00"
define void @mount_dev_shm() {
%1 = alloca i32
%2 = call i32 @mkdir_attr(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 1023, i32 0, i32 0)
%3 = load i32, i32* @MS_BIND
%4 = call i32 @mount(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %3, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
store i32 %4, i32* %1
%5 = load i32, i32* %1
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %11
7: ; preds = %0
%8 = call i32 @fwarning(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0))
%9 = call i32 @dbg_test_dir(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 (...) @empty_dev_shm()
br label %11
11: ; preds = %7, %0
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"/dev/shm\00"
@.str.1 = [26 x i8] c"/run/firejail/mnt/dev/shm\00"
@.str.2 = [5 x i8] c"none\00"
@MS_BIND = global i32 0
@.str.3 = [17 x i8] c"mode=01777,gid=0\00"
@.str.4 = [46 x i8] c"cannot mount the old /dev/shm in private-dev\0A\00"
define void @mount_dev_shm() {
%1 = tail call i32 @mkdir_attr(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 1023, i32 0, i32 0)
%2 = load i32, i32* @MS_BIND
%3 = tail call i32 @mount(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %2, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %9
5: ; preds = %0
%6 = tail call i32 @fwarning(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0))
%7 = tail call i32 @dbg_test_dir(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i32 (...) @empty_dev_shm()
br label %9
9: ; preds = %0, %5
ret void
}