#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 */
struct stat {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ fmessage(char *, int /*<<< orphan*/);
int /*<<< orphan*/ fslib_mount(char *);
int /*<<< orphan*/ mkdir_attr(char *, int, int /*<<< orphan*/,
                              int /*<<< orphan*/);
int /*<<< orphan*/ selinux_relabel_path(char *, char *);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ stdc(char *);
int /*<<< orphan*/ timetrace_end();
int /*<<< orphan*/ timetrace_start();
void fslib_install_stdc(void) {
  timetrace_start();
  struct stat s;
  if (stat("/lib/x86_64-linux-gnu", &s) == 0) {
    mkdir_attr("/run"
               "/firejail"
               "/mnt"
               "/lib"
               "/x86_64-linux-gnu",
               0755, 0, 0);
    selinux_relabel_path("/run"
                         "/firejail"
                         "/mnt"
                         "/lib"
                         "/x86_64-linux-gnu",
                         "/lib/x86_64-linux-gnu");
    stdc("/lib/x86_64-linux-gnu");
  }
  stdc("/lib64");
  if (stat("/usr/lib/locale", &s) == 0)
    fslib_mount("/usr/lib/locale");
  fmessage("Standard C library installed in %0.2f ms\n", timetrace_end());
}


x86 assembly (clang, -O0):
<fslib_install_stdc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <timetrace_start@plt>
lea    0xe7b(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <stat@plt>
cmp    $0x0,%rax
jne    11dd <fslib_install_stdc+0x5d>
lea    0xe50(%rip),%rdi
mov    $0x1ed,%esi
xor    %ecx,%ecx
mov    %ecx,%edx
call   1090 <mkdir_attr@plt>
lea    0xe3b(%rip),%rdi
lea    0xe45(%rip),%rsi
call   10a0 <selinux_relabel_path@plt>
lea    0xe39(%rip),%rdi
call   1060 <stdc@plt>
lea    0xe43(%rip),%rdi
call   1060 <stdc@plt>
lea    0xe3e(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <stat@plt>
cmp    $0x0,%rax
jne    120f <fslib_install_stdc+0x8f>
lea    0xe24(%rip),%rdi
call   1070 <fslib_mount@plt>
mov    $0x0,%al
call   1040 <timetrace_end@plt>
mov    %eax,%esi
lea    0xe1f(%rip),%rdi
call   1080 <fmessage@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fslib_install_stdc>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1030 <timetrace_start@plt>
lea    0xe7f(%rip),%rdi
mov    %rsp,%rsi
call   1050 <stat@plt>
test   %rax,%rax
jne    11d1 <fslib_install_stdc+0x51>
lea    0xe5a(%rip),%r14
mov    %r14,%rdi
mov    $0x1ed,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1090 <mkdir_attr@plt>
lea    0xe53(%rip),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   10a0 <selinux_relabel_path@plt>
mov    %rbx,%rdi
call   1060 <stdc@plt>
lea    0xe4f(%rip),%rdi
call   1060 <stdc@plt>
lea    0xe4a(%rip),%rdi
mov    %rsp,%rsi
call   1050 <stat@plt>
test   %rax,%rax
jne    11fd <fslib_install_stdc+0x7d>
lea    0xe36(%rip),%rdi
call   1070 <fslib_mount@plt>
xor    %eax,%eax
call   1040 <timetrace_end@plt>
lea    0xe33(%rip),%rdi
mov    %eax,%esi
call   1080 <fmessage@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [22 x i8] c"/lib/x86_64-linux-gnu\00"
@.str.1 = [39 x i8] c"/run/firejail/mnt/lib/x86_64-linux-gnu\00"
@.str.2 = [7 x i8] c"/lib64\00"
@.str.3 = [16 x i8] c"/usr/lib/locale\00"
@.str.4 = [42 x i8] c"Standard C library installed in %0.2f ms\0A\00"
define void @fslib_install_stdc() {
%1 = alloca %struct.stat
%2 = call i32 (...) @timetrace_start()
%3 = call i64 @stat(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), %struct.stat* %1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %9
5: ; preds = %0
%6 = call i32 @mkdir_attr(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i32 493, i32 0, i32 0)
%7 = call i32 @selinux_relabel_path(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @stdc(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %5, %0
%10 = call i32 @stdc(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%11 = call i64 @stat(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), %struct.stat* %1)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = call i32 @fslib_mount(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %15
15: ; preds = %13, %9
%16 = call i32 (...) @timetrace_end()
%17 = call i32 @fmessage(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i32 %16)
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [22 x i8] c"/lib/x86_64-linux-gnu\00"
@.str.1 = [39 x i8] c"/run/firejail/mnt/lib/x86_64-linux-gnu\00"
@.str.2 = [7 x i8] c"/lib64\00"
@.str.3 = [16 x i8] c"/usr/lib/locale\00"
@.str.4 = [42 x i8] c"Standard C library installed in %0.2f ms\0A\00"
define void @fslib_install_stdc() {
%1 = alloca %struct.stat
%2 = tail call i32 (...) @timetrace_start()
%3 = bitcast %struct.stat* %1 to i8*
%4 = call i64 @stat(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), %struct.stat* %1)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %0
%7 = call i32 @mkdir_attr(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i32 493, i32 0, i32 0)
%8 = call i32 @selinux_relabel_path(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @stdc(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %6, %0
%11 = call i32 @stdc(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%12 = call i64 @stat(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), %struct.stat* %1)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = call i32 @fslib_mount(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %16
16: ; preds = %14, %10
%17 = call i32 (...) @timetrace_end()
%18 = call i32 @fmessage(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i32 %17)
ret void
}