#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_copy_dir(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) {
  struct stat s;
  char *stdclib = "/lib64";
  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");
    stdclib = "/lib/x86_64-linux-gnu";
  }
  timetrace_start();
  stdc(stdclib);
  if (stat("/usr/lib/locale", &s) == 0)
    fslib_copy_dir("/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
lea    0xe71(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xe7e(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <stat@plt>
cmp    $0x0,%rax
jne    11e0 <fslib_install_stdc+0x60>
lea    0xe53(%rip),%rdi
mov    $0x1ed,%esi
xor    %ecx,%ecx
mov    %ecx,%edx
call   1090 <mkdir_attr@plt>
lea    0xe3e(%rip),%rdi
lea    0xe48(%rip),%rsi
call   10a0 <selinux_relabel_path@plt>
lea    0xe3c(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1030 <timetrace_start@plt>
mov    -0x10(%rbp),%rdi
call   1070 <stdc@plt>
lea    0xe37(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <stat@plt>
cmp    $0x0,%rax
jne    1216 <fslib_install_stdc+0x96>
lea    0xe1d(%rip),%rdi
call   1050 <fslib_copy_dir@plt>
mov    $0x0,%al
call   1040 <timetrace_end@plt>
mov    %eax,%esi
lea    0xe18(%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
lea    0xe8d(%rip),%rbx
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1060 <stat@plt>
test   %rax,%rax
je     11a4 <fslib_install_stdc+0x24>
lea    0xe5e(%rip),%rbx
jmp    11c7 <fslib_install_stdc+0x47>
lea    0xe5c(%rip),%r14
mov    %r14,%rdi
mov    $0x1ed,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1090 <mkdir_attr@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   10a0 <selinux_relabel_path@plt>
xor    %eax,%eax
call   1030 <timetrace_start@plt>
mov    %rbx,%rdi
call   1070 <stdc@plt>
lea    0xe51(%rip),%rdi
mov    %rsp,%rsi
call   1060 <stat@plt>
test   %rax,%rax
jne    11f6 <fslib_install_stdc+0x76>
lea    0xe3d(%rip),%rdi
call   1050 <fslib_copy_dir@plt>
xor    %eax,%eax
call   1040 <timetrace_end@plt>
lea    0xe3a(%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 = [7 x i8] c"/lib64\00"
@.str.1 = [22 x i8] c"/lib/x86_64-linux-gnu\00"
@.str.2 = [39 x i8] c"/run/firejail/mnt/lib/x86_64-linux-gnu\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 = alloca i8*
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %2
%3 = call i64 @stat(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), %struct.stat* %1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = call i32 @mkdir_attr(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, 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.2, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %8
8: ; preds = %5, %0
%9 = call i32 (...) @timetrace_start()
%10 = load i8*, i8** %2
%11 = call i32 @stdc(i8* %10)
%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 = %8
%15 = call i32 @fslib_copy_dir(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %16
16: ; preds = %14, %8
%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
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [7 x i8] c"/lib64\00"
@.str.1 = [22 x i8] c"/lib/x86_64-linux-gnu\00"
@.str.2 = [39 x i8] c"/run/firejail/mnt/lib/x86_64-linux-gnu\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 = bitcast %struct.stat* %1 to i8*
%3 = call i64 @stat(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), %struct.stat* %1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = call i32 @mkdir_attr(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, 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.2, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %8
8: ; preds = %5, %0
%9 = phi i8* [ getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), %5 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), %0 ]
%10 = call i32 (...) @timetrace_start()
%11 = call i32 @stdc(i8* %9)
%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 = %8
%15 = call i32 @fslib_copy_dir(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %16
16: ; preds = %14, %8
%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
}