#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*/);
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);
    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    0xe81(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xe8e(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <stat@plt>
cmp    $0x0,%rax
jne    11bd <fslib_install_stdc+0x4d>
lea    0xe63(%rip),%rdi
mov    $0x1ed,%esi
xor    %ecx,%ecx
mov    %ecx,%edx
call   1090 <mkdir_attr@plt>
lea    0xe5f(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1030 <timetrace_start@plt>
mov    -0x10(%rbp),%rdi
call   1070 <stdc@plt>
lea    0xe5a(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <stat@plt>
cmp    $0x0,%rax
jne    11f3 <fslib_install_stdc+0x83>
lea    0xe40(%rip),%rdi
call   1050 <fslib_copy_dir@plt>
mov    $0x0,%al
call   1040 <timetrace_end@plt>
mov    %eax,%esi
lea    0xe3b(%rip),%rdi
call   1080 <fmessage@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fslib_install_stdc>:
push   %rbx
sub    $0x10,%rsp
lea    0xe9c(%rip),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <stat@plt>
test   %rax,%rax
je     1197 <fslib_install_stdc+0x27>
lea    0xe6b(%rip),%rbx
jmp    11ac <fslib_install_stdc+0x3c>
lea    0xe69(%rip),%rdi
mov    $0x1ed,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1090 <mkdir_attr@plt>
xor    %eax,%eax
call   1030 <timetrace_start@plt>
mov    %rbx,%rdi
call   1070 <stdc@plt>
lea    0xe6c(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1060 <stat@plt>
test   %rax,%rax
jne    11dd <fslib_install_stdc+0x6d>
lea    0xe56(%rip),%rdi
call   1050 <fslib_copy_dir@plt>
xor    %eax,%eax
call   1040 <timetrace_end@plt>
lea    0xe53(%rip),%rdi
mov    %eax,%esi
call   1080 <fmessage@plt>
add    $0x10,%rsp
pop    %rbx
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 %7
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)
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %7
7: ; preds = %5, %0
%8 = call i32 (...) @timetrace_start()
%9 = load i8*, i8** %2
%10 = call i32 @stdc(i8* %9)
%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 = %7
%14 = call i32 @fslib_copy_dir(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %15
15: ; preds = %13, %7
%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 = [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 %7
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)
br label %7
7: ; preds = %5, %0
%8 = 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 ]
%9 = call i32 (...) @timetrace_start()
%10 = call i32 @stdc(i8* %8)
%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 = %7
%14 = call i32 @fslib_copy_dir(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %15
15: ; preds = %13, %7
%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
}