#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 {
  scalar_t__ st_uid;
  int /*<<< orphan*/ st_mode;
};

/* Variables and functions */
scalar_t__ S_ISDIR(int /*<<< orphan*/);
scalar_t__ S_ISREG(int /*<<< orphan*/);
int /*<<< orphan*/ assert(char const *);
int /*<<< orphan*/ fslib_mount_dir(char const *);
int /*<<< orphan*/ fslib_mount_file(char const *);
scalar_t__ is_lib_64(char const *);
scalar_t__ stat_as_user(char const *, struct stat *);
int /*<<< orphan*/ valid_full_path(char const *);
void fslib_mount(const char *full_path) {
  assert(full_path);
  struct stat s;
  if (*full_path == '\0' || !valid_full_path(full_path) ||
      stat_as_user(full_path, &s) != 0 || s.st_uid != 0)
    return;
  if (S_ISDIR(s.st_mode))
    fslib_mount_dir(full_path);
  else if (S_ISREG(s.st_mode) && is_lib_64(full_path))
    fslib_mount_file(full_path);
}


x86 assembly (clang, -O0):
<fslib_mount>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <assert@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11d9 <fslib_mount+0x59>
mov    -0x8(%rbp),%rdi
call   10a0 <valid_full_path@plt>
cmp    $0x0,%eax
je     11d9 <fslib_mount+0x59>
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1080 <stat_as_user@plt>
cmp    $0x0,%rax
jne    11d9 <fslib_mount+0x59>
cmpq   $0x0,-0x18(%rbp)
je     11de <fslib_mount+0x5e>
jmp    1231 <fslib_mount+0xb1>
mov    -0x10(%rbp),%edi
call   1050 <S_ISDIR@plt>
cmp    $0x0,%rax
je     11fe <fslib_mount+0x7e>
mov    -0x8(%rbp),%rdi
call   1040 <fslib_mount_dir@plt>
jmp    1231 <fslib_mount+0xb1>
mov    -0x10(%rbp),%edi
call   1090 <S_ISREG@plt>
cmp    $0x0,%rax
je     122c <fslib_mount+0xac>
mov    -0x8(%rbp),%rdi
call   1030 <is_lib_64@plt>
cmp    $0x0,%rax
je     122c <fslib_mount+0xac>
mov    -0x8(%rbp),%rdi
call   1060 <fslib_mount_file@plt>
jmp    1231 <fslib_mount+0xb1>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fslib_mount>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
call   1070 <assert@plt>
cmpb   $0x0,(%rbx)
je     11ea <fslib_mount+0x6a>
mov    %rbx,%rdi
call   10a0 <valid_full_path@plt>
test   %eax,%eax
je     11ea <fslib_mount+0x6a>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1080 <stat_as_user@plt>
or     (%rsp),%rax
jne    11ea <fslib_mount+0x6a>
mov    0x8(%rsp),%edi
call   1050 <S_ISDIR@plt>
test   %rax,%rax
je     11c7 <fslib_mount+0x47>
mov    %rbx,%rdi
call   1040 <fslib_mount_dir@plt>
jmp    11ea <fslib_mount+0x6a>
mov    0x8(%rsp),%edi
call   1090 <S_ISREG@plt>
test   %rax,%rax
je     11ea <fslib_mount+0x6a>
mov    %rbx,%rdi
call   1030 <is_lib_64@plt>
test   %rax,%rax
je     11ea <fslib_mount+0x6a>
mov    %rbx,%rdi
call   1060 <fslib_mount_file@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.stat = type { i64, i32 }
define void @fslib_mount(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.stat
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @assert(i8* %4)
%6 = load i8*, i8** %2
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp eq i32 %8, 0
br i1 %9, label %22, label %10
10: ; preds = %1
%11 = load i8*, i8** %2
%12 = call i32 @valid_full_path(i8* %11)
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %22
14: ; preds = %10
%15 = load i8*, i8** %2
%16 = call i64 @stat_as_user(i8* %15, %struct.stat* %3)
%17 = icmp ne i64 %16, 0
br i1 %17, label %22, label %18
18: ; preds = %14
%19 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 0
%20 = load i64, i64* %19
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %18, %14, %10, %1
br label %44
23: ; preds = %18
%24 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 1
%25 = load i32, i32* %24
%26 = call i64 @S_ISDIR(i32 %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %23
%29 = load i8*, i8** %2
%30 = call i32 @fslib_mount_dir(i8* %29)
br label %44
31: ; preds = %23
%32 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 1
%33 = load i32, i32* %32
%34 = call i64 @S_ISREG(i32 %33)
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %43
36: ; preds = %31
%37 = load i8*, i8** %2
%38 = call i64 @is_lib_64(i8* %37)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %36
%41 = load i8*, i8** %2
%42 = call i32 @fslib_mount_file(i8* %41)
br label %43
43: ; preds = %40, %36, %31
br label %44
44: ; preds = %22, %43, %28
ret void
}

LLVM IR (-O2):
%struct.stat = type { i64, i32 }
define void @fslib_mount(i8* %0) {
%2 = alloca %struct.stat
%3 = tail call i32 @assert(i8* %0)
%4 = bitcast %struct.stat* %2 to i8*
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 0
br i1 %6, label %33, label %7
7: ; preds = %1
%8 = tail call i32 @valid_full_path(i8* %0)
%9 = icmp eq i32 %8, 0
br i1 %9, label %33, label %10
10: ; preds = %7
%11 = call i64 @stat_as_user(i8* %0, %struct.stat* %2)
%12 = icmp ne i64 %11, 0
%13 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 0
%14 = load i64, i64* %13
%15 = icmp ne i64 %14, 0
%16 = select i1 %12, i1 true, i1 %15
br i1 %16, label %33, label %17
17: ; preds = %10
%18 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 1
%19 = load i32, i32* %18
%20 = call i64 @S_ISDIR(i32 %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %17
%23 = call i32 @fslib_mount_dir(i8* %0)
br label %33
24: ; preds = %17
%25 = load i32, i32* %18
%26 = call i64 @S_ISREG(i32 %25)
%27 = icmp eq i64 %26, 0
br i1 %27, label %33, label %28
28: ; preds = %24
%29 = call i64 @is_lib_64(i8* %0)
%30 = icmp eq i64 %29, 0
br i1 %30, label %33, label %31
31: ; preds = %28
%32 = call i32 @fslib_mount_file(i8* %0)
br label %33
33: ; preds = %22, %31, %28, %24, %1, %7, %10
ret void
}