#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*/ MNT_DETACH;
scalar_t__ chdir(char *);
scalar_t__ rmdir(char *);
scalar_t__ umount2(char *, int /*<<< orphan*/);
int umount_original_rootfs(char *mount_name) {
  if (mount_name) {
    if (chdir("/"))
      return -1;
    if (umount2(mount_name, MNT_DETACH))
      return -1;
    if (rmdir(mount_name))
      return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<umount_original_rootfs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11b5 <umount_original_rootfs+0x85>
lea    0xeb2(%rip),%rdi
call   1050 <chdir@plt>
cmp    $0x0,%rax
je     1169 <umount_original_rootfs+0x39>
movl   $0xffffffff,-0x4(%rbp)
jmp    11bc <umount_original_rootfs+0x8c>
mov    -0x10(%rbp),%rdi
mov    0x2e6c(%rip),%rax
mov    (%rax),%esi
call   1030 <umount2@plt>
cmp    $0x0,%rax
je     1191 <umount_original_rootfs+0x61>
movl   $0xffffffff,-0x4(%rbp)
jmp    11bc <umount_original_rootfs+0x8c>
mov    -0x10(%rbp),%rdi
call   1040 <rmdir@plt>
cmp    $0x0,%rax
je     11b0 <umount_original_rootfs+0x80>
movl   $0xffffffff,-0x4(%rbp)
jmp    11bc <umount_original_rootfs+0x8c>
jmp    11b5 <umount_original_rootfs+0x85>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<umount_original_rootfs>:
push   %rbp
push   %rbx
push   %rax
test   %rdi,%rdi
je     1174 <umount_original_rootfs+0x44>
mov    %rdi,%rbx
lea    0xebe(%rip),%rdi
call   1050 <chdir@plt>
mov    $0xffffffff,%ebp
test   %rax,%rax
jne    1176 <umount_original_rootfs+0x46>
mov    0x2e88(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1030 <umount2@plt>
test   %rax,%rax
jne    1176 <umount_original_rootfs+0x46>
mov    %rbx,%rdi
call   1040 <rmdir@plt>
test   %rax,%rax
jne    1176 <umount_original_rootfs+0x46>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"/\00"
@MNT_DETACH = global i32 0
define i32 @umount_original_rootfs(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = icmp ne i8* %4, null
br i1 %5, label %6, label %22
6: ; preds = %1
%7 = call i64 @chdir(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %6
store i32 -1, i32* %2
br label %23
10: ; preds = %6
%11 = load i8*, i8** %3
%12 = load i32, i32* @MNT_DETACH
%13 = call i64 @umount2(i8* %11, i32 %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %10
store i32 -1, i32* %2
br label %23
16: ; preds = %10
%17 = load i8*, i8** %3
%18 = call i64 @rmdir(i8* %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %16
store i32 -1, i32* %2
br label %23
21: ; preds = %16
br label %22
22: ; preds = %21, %1
store i32 0, i32* %2
br label %23
23: ; preds = %22, %20, %15, %9
%24 = load i32, i32* %2
ret i32 %24
}

LLVM IR (-O2):
@.str = [2 x i8] c"/\00"
@MNT_DETACH = global i32 0
define i32 @umount_original_rootfs(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %13, label %3
3: ; preds = %1
%4 = tail call i64 @chdir(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %14
6: ; preds = %3
%7 = load i32, i32* @MNT_DETACH
%8 = tail call i64 @umount2(i8* %0, i32 %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %6
%11 = tail call i64 @rmdir(i8* %0)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %10, %1
br label %14
14: ; preds = %10, %6, %3, %13
%15 = phi i32 [ 0, %13 ], [ -1, %3 ], [ -1, %6 ], [ -1, %10 ]
ret i32 %15
}