#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 PATH_MAX;
scalar_t__ check_home_directory(char *);
int /*<<< orphan*/ error(char *);
int /*<<< orphan*/ make_home_directory(char *);
scalar_t__ mount(char const *, char *, char *, int /*<<< orphan*/, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char const *);
void mount_home(const char *src) {
  char dst[PATH_MAX];
  snprintf(dst, sizeof dst, "%s%s", "/usr/lib/fw32", src);
  if (check_home_directory(dst))
    return;
  make_home_directory(dst);
  if (mount(src, dst, "", MS_BIND, ""))
    error("Failed to mount home directory.\n");
}


x86 assembly (clang, -O0):
<mount_home>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e8d(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x28(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x18(%rbp)
mov    %eax,%esi
mov    -0x8(%rbp),%r8
lea    0xe6b(%rip),%rdx
lea    0xe69(%rip),%rcx
call   1040 <snprintf@plt>
mov    -0x28(%rbp),%rdi
call   1050 <check_home_directory@plt>
cmp    $0x0,%rax
je     11c0 <mount_home+0x70>
movl   $0x1,-0x1c(%rbp)
jmp    1206 <mount_home+0xb6>
mov    -0x28(%rbp),%rdi
call   1060 <make_home_directory@plt>
mov    -0x28(%rbp),%rsi
mov    -0x8(%rbp),%rdi
mov    0x2e08(%rip),%rax
mov    (%rax),%ecx
lea    0xe52(%rip),%r8
mov    %r8,%rdx
call   1030 <mount@plt>
cmp    $0x0,%rax
je     11ff <mount_home+0xaf>
lea    0xe19(%rip),%rdi
call   1070 <error@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mount_home>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
mov    %rdi,%r14
mov    0x2e8f(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rbx
mov    %rsi,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe82(%rip),%rdx
lea    0xe80(%rip),%rcx
mov    %rbx,%rdi
mov    %r14,%r8
call   1040 <snprintf@plt>
mov    %rbx,%rdi
call   1050 <check_home_directory@plt>
test   %rax,%rax
jne    11d4 <mount_home+0x84>
mov    %rbx,%rdi
call   1060 <make_home_directory@plt>
mov    0x2e34(%rip),%rax
mov    (%rax),%ecx
lea    0xe7e(%rip),%rdx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %rdx,%r8
call   1030 <mount@plt>
test   %rax,%rax
je     11d4 <mount_home+0x84>
lea    0xe44(%rip),%rdi
call   1070 <error@plt>
lea    -0x10(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@PATH_MAX = global i32 0
@.str = [5 x i8] c"%s%s\00"
@.str.1 = [14 x i8] c"/usr/lib/fw32\00"
@.str.2 = [1 x i8] zeroinitializer
@MS_BIND = global i32 0
@.str.3 = [33 x i8] c"Failed to mount home directory.\0A\00"
define void @mount_home(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i32, i32* @PATH_MAX
%7 = zext i32 %6 to i64
%8 = call i8* @llvm.stacksave()
store i8* %8, i8** %3
%9 = alloca i8, i64 %7
store i64 %7, i64* %4
%10 = trunc i64 %7 to i32
%11 = load i8*, i8** %2
%12 = call i32 @snprintf(i8* %9, i32 %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = call i64 @check_home_directory(i8* %9)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %1
store i32 1, i32* %5
br label %25
16: ; preds = %1
%17 = call i32 @make_home_directory(i8* %9)
%18 = load i8*, i8** %2
%19 = load i32, i32* @MS_BIND
%20 = call i64 @mount(i8* %18, i8* %9, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i32 %19, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %16
%23 = call i32 @error(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
br label %24
24: ; preds = %22, %16
store i32 0, i32* %5
br label %25
25: ; preds = %24, %15
%26 = load i8*, i8** %3
%27 = load i32, i32* %5
switch i32 %27, label %29 [
i32 0, label %28
i32 1, label %28
]
28: ; preds = %25, %25
ret void
29: ; preds = %25
unreachable
}

LLVM IR (-O2):
@PATH_MAX = global i32 0
@.str = [5 x i8] c"%s%s\00"
@.str.1 = [14 x i8] c"/usr/lib/fw32\00"
@.str.2 = [1 x i8] zeroinitializer
@MS_BIND = global i32 0
@.str.3 = [33 x i8] c"Failed to mount home directory.\0A\00"
define void @mount_home(i8* %0) {
%2 = load i32, i32* @PATH_MAX
%3 = zext i32 %2 to i64
%4 = alloca i8, i64 %3
%5 = call i32 @snprintf(i8* %4, i32 %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%6 = call i64 @check_home_directory(i8* %4)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %15
8: ; preds = %1
%9 = call i32 @make_home_directory(i8* %4)
%10 = load i32, i32* @MS_BIND
%11 = call i64 @mount(i8* %0, i8* %4, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i32 %10, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %8
%14 = call i32 @error(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
br label %15
15: ; preds = %8, %13, %1
ret void
}