#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*/ errno;
int /*<<< orphan*/ execl(char *, char *, char *, char const *, char *,
                         int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
int fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *,
                           char const *, ...);
int /*<<< orphan*/ geteuid();
int /*<<< orphan*/ mtab_needs_update(char const *);
int /*<<< orphan*/ setuid(int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int umount2(char const *, int);
int waitpid(int, int *, int /*<<< orphan*/);
int fuse_mnt_umount(const char *progname, const char *mnt, int lazy) {
  int res;
  int status;
  if (!mtab_needs_update(mnt)) {
    res = umount2(mnt, lazy ? 2 : 0);
    if (res == -1)
      fprintf(stderr, "%s: failed to unmount %s: %s\n", progname, mnt,
              strerror(errno));
    return res;
  }
  res = fork();
  if (res == -1) {
    fprintf(stderr, "%s: fork: %s\n", progname, strerror(errno));
    return -1;
  }
  if (res == 0) {
    setuid(geteuid());
    execl("/bin/umount", "/bin/umount", "-i", mnt, lazy ? "-l" : NULL, NULL);
    fprintf(stderr, "%s: failed to execute /bin/umount: %s\n", progname,
            strerror(errno));
    exit(1);
  }
  res = waitpid(res, &status, 0);
  if (res == -1) {
    fprintf(stderr, "%s: waitpid: %s\n", progname, strerror(errno));
    return -1;
  }
  if (status != 0)
    return -1;
  return 0;
}


x86 assembly (clang, -O0):
<fuse_mnt_umount>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <mtab_needs_update@plt>
cmp    $0x0,%eax
jne    123c <fuse_mnt_umount+0x9c>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%ecx
xor    %esi,%esi
mov    $0x2,%eax
cmp    $0x0,%ecx
cmovne %eax,%esi
call   1030 <umount2@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0xffffffff,-0x20(%rbp)
jne    1231 <fuse_mnt_umount+0x91>
mov    0x2dee(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    0x2dca(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x3c(%rbp),%edi
mov    -0x38(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    %rax,%r8
lea    0xdd6(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    13a5 <fuse_mnt_umount+0x205>
mov    $0x0,%al
call   10c0 <fork@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0xffffffff,-0x20(%rbp)
jne    1296 <fuse_mnt_umount+0xf6>
mov    0x2d89(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    0x2d6d(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x4c(%rbp),%edi
mov    -0x48(%rbp),%rdx
mov    %rax,%rcx
lea    0xd9b(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13a5 <fuse_mnt_umount+0x205>
cmpl   $0x0,-0x20(%rbp)
jne    1327 <fuse_mnt_umount+0x187>
mov    $0x0,%al
call   1040 <geteuid@plt>
mov    %eax,%edi
call   1090 <setuid@plt>
mov    -0x18(%rbp),%rcx
mov    -0x1c(%rbp),%edx
xor    %eax,%eax
mov    %eax,%r8d
lea    0xd7a(%rip),%rax
cmp    $0x0,%edx
cmovne %rax,%r8
lea    0xd5d(%rip),%rsi
lea    0xd62(%rip),%rdx
xor    %eax,%eax
mov    %eax,%r9d
mov    %rsi,%rdi
call   10b0 <execl@plt>
mov    0x2cf6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    0x2cda(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x5c(%rbp),%edi
mov    -0x58(%rbp),%rdx
mov    %rax,%rcx
lea    0xd28(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x20(%rbp),%edi
lea    -0x24(%rbp),%rsi
xor    %edx,%edx
call   1060 <waitpid@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0xffffffff,-0x20(%rbp)
jne    1388 <fuse_mnt_umount+0x1e8>
mov    0x2c97(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    0x2c7b(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x6c(%rbp),%edi
mov    -0x68(%rbp),%rdx
mov    %rax,%rcx
lea    0xcf0(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13a5 <fuse_mnt_umount+0x205>
cmpl   $0x0,-0x24(%rbp)
je     139e <fuse_mnt_umount+0x1fe>
movl   $0xffffffff,-0x4(%rbp)
jmp    13a5 <fuse_mnt_umount+0x205>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fuse_mnt_umount>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1070 <mtab_needs_update@plt>
test   %eax,%eax
je     11ef <fuse_mnt_umount+0x4f>
xor    %eax,%eax
call   10c0 <fork@plt>
cmp    $0xffffffff,%eax
je     123c <fuse_mnt_umount+0x9c>
test   %eax,%eax
je     1299 <fuse_mnt_umount+0xf9>
lea    0x4(%rsp),%rsi
xor    %ebx,%ebx
mov    %eax,%edi
xor    %edx,%edx
call   1060 <waitpid@plt>
cmp    $0xffffffff,%eax
je     125c <fuse_mnt_umount+0xbc>
cmp    0x4(%rsp),%ebx
sbb    %eax,%eax
jmp    128e <fuse_mnt_umount+0xee>
xor    %esi,%esi
test   %ebp,%ebp
setne  %sil
add    %esi,%esi
mov    %rbx,%rdi
call   1030 <umount2@plt>
cmp    $0xffffffff,%eax
jne    128e <fuse_mnt_umount+0xee>
mov    0x2dcf(%rip),%rax
mov    (%rax),%ebp
mov    0x2dbe(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
lea    0xdd8(%rip),%rsi
mov    %ebp,%edi
mov    %r14,%rdx
mov    %rbx,%rcx
mov    %rax,%r8
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    1289 <fuse_mnt_umount+0xe9>
mov    0x2d9d(%rip),%rax
mov    (%rax),%ebx
mov    0x2d8c(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
lea    0xdc4(%rip),%rsi
jmp    127a <fuse_mnt_umount+0xda>
mov    0x2d7d(%rip),%rax
mov    (%rax),%ebx
mov    0x2d6c(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
lea    0xdeb(%rip),%rsi
mov    %ebx,%edi
mov    %r14,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %r15d,%r15d
xor    %eax,%eax
call   1040 <geteuid@plt>
mov    %eax,%edi
call   1090 <setuid@plt>
test   %ebp,%ebp
lea    0xd88(%rip),%r8
cmove  %r15,%r8
lea    0xd6e(%rip),%rdi
lea    0xd73(%rip),%rdx
mov    %rdi,%rsi
mov    %rbx,%rcx
xor    %r9d,%r9d
call   10b0 <execl@plt>
mov    0x2d06(%rip),%rax
mov    (%rax),%ebx
mov    0x2cf5(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
lea    0xd4d(%rip),%rsi
mov    %ebx,%edi
mov    %r14,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [30 x i8] c"%s: failed to unmount %s: %s\0A\00"
@errno = global i32 0
@.str.1 = [14 x i8] c"%s: fork: %s\0A\00"
@.str.2 = [12 x i8] c"/bin/umount\00"
@.str.3 = [3 x i8] c"-i\00"
@.str.4 = [3 x i8] c"-l\00"
@.str.5 = [39 x i8] c"%s: failed to execute /bin/umount: %s\0A\00"
@.str.6 = [17 x i8] c"%s: waitpid: %s\0A\00"
define i32 @fuse_mnt_umount(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%10 = load i8*, i8** %6
%11 = call i32 @mtab_needs_update(i8* %10)
%12 = icmp ne i32 %11, 0
br i1 %12, label %31, label %13
13: ; preds = %3
%14 = load i8*, i8** %6
%15 = load i32, i32* %7
%16 = icmp ne i32 %15, 0
%17 = zext i1 %16 to i64
%18 = select i1 %16, i32 2, i32 0
%19 = call i32 @umount2(i8* %14, i32 %18)
store i32 %19, i32* %8
%20 = load i32, i32* %8
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %29
22: ; preds = %13
%23 = load i32, i32* @stderr
%24 = load i8*, i8** %5
%25 = load i8*, i8** %6
%26 = load i32, i32* @errno
%27 = call i8* @strerror(i32 %26)
%28 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %24, i8* %25, i8* %27)
br label %29
29: ; preds = %22, %13
%30 = load i32, i32* %8
store i32 %30, i32* %4
br label %75
31: ; preds = %3
%32 = call i32 (...) @fork()
store i32 %32, i32* %8
%33 = load i32, i32* %8
%34 = icmp eq i32 %33, -1
br i1 %34, label %35, label %41
35: ; preds = %31
%36 = load i32, i32* @stderr
%37 = load i8*, i8** %5
%38 = load i32, i32* @errno
%39 = call i8* @strerror(i32 %38)
%40 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %37, i8* %39)
store i32 -1, i32* %4
br label %75
41: ; preds = %31
%42 = load i32, i32* %8
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %59
44: ; preds = %41
%45 = call i32 (...) @geteuid()
%46 = call i32 @setuid(i32 %45)
%47 = load i8*, i8** %6
%48 = load i32, i32* %7
%49 = icmp ne i32 %48, 0
%50 = zext i1 %49 to i64
%51 = select i1 %49, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* null
%52 = call i32 @execl(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %47, i8* %51, i32* null)
%53 = load i32, i32* @stderr
%54 = load i8*, i8** %5
%55 = load i32, i32* @errno
%56 = call i8* @strerror(i32 %55)
%57 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0), i8* %54, i8* %56)
%58 = call i32 @exit(i32 1)
unreachable
59: ; preds = %41
%60 = load i32, i32* %8
%61 = call i32 @waitpid(i32 %60, i32* %9, i32 0)
store i32 %61, i32* %8
%62 = load i32, i32* %8
%63 = icmp eq i32 %62, -1
br i1 %63, label %64, label %70
64: ; preds = %59
%65 = load i32, i32* @stderr
%66 = load i8*, i8** %5
%67 = load i32, i32* @errno
%68 = call i8* @strerror(i32 %67)
%69 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %65, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i8* %66, i8* %68)
store i32 -1, i32* %4
br label %75
70: ; preds = %59
%71 = load i32, i32* %9
%72 = icmp ne i32 %71, 0
br i1 %72, label %73, label %74
73: ; preds = %70
store i32 -1, i32* %4
br label %75
74: ; preds = %70
store i32 0, i32* %4
br label %75
75: ; preds = %74, %73, %64, %35, %29
%76 = load i32, i32* %4
ret i32 %76
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [30 x i8] c"%s: failed to unmount %s: %s\0A\00"
@errno = global i32 0
@.str.1 = [14 x i8] c"%s: fork: %s\0A\00"
@.str.2 = [12 x i8] c"/bin/umount\00"
@.str.3 = [3 x i8] c"-i\00"
@.str.4 = [3 x i8] c"-l\00"
@.str.5 = [39 x i8] c"%s: failed to execute /bin/umount: %s\0A\00"
@.str.6 = [17 x i8] c"%s: waitpid: %s\0A\00"
define i32 @fuse_mnt_umount(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
%6 = tail call i32 @mtab_needs_update(i8* %1)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %18
8: ; preds = %3
%9 = icmp eq i32 %2, 0
%10 = select i1 %9, i32 0, i32 2
%11 = tail call i32 @umount2(i8* %1, i32 %10)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %48
13: ; preds = %8
%14 = load i32, i32* @stderr
%15 = load i32, i32* @errno
%16 = tail call i8* @strerror(i32 %15)
%17 = tail call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1, i8* %16)
br label %48
18: ; preds = %3
%19 = tail call i32 (...) @fork()
switch i32 %19, label %36 [
i32 -1, label %20
i32 0, label %25
]
20: ; preds = %18
%21 = load i32, i32* @stderr
%22 = load i32, i32* @errno
%23 = tail call i8* @strerror(i32 %22)
%24 = tail call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %23)
br label %48
25: ; preds = %18
%26 = tail call i32 (...) @geteuid()
%27 = tail call i32 @setuid(i32 %26)
%28 = icmp eq i32 %2, 0
%29 = select i1 %28, i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0)
%30 = tail call i32 @execl(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %1, i8* %29, i32* null)
%31 = load i32, i32* @stderr
%32 = load i32, i32* @errno
%33 = tail call i8* @strerror(i32 %32)
%34 = tail call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0), i8* %0, i8* %33)
%35 = tail call i32 @exit(i32 1)
unreachable
36: ; preds = %18
%37 = call i32 @waitpid(i32 %19, i32* %4, i32 0)
%38 = icmp eq i32 %37, -1
br i1 %38, label %39, label %44
39: ; preds = %36
%40 = load i32, i32* @stderr
%41 = load i32, i32* @errno
%42 = call i8* @strerror(i32 %41)
%43 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i8* %0, i8* %42)
br label %48
44: ; preds = %36
%45 = load i32, i32* %4
%46 = icmp ne i32 %45, 0
%47 = sext i1 %46 to i32
br label %48
48: ; preds = %44, %8, %13, %39, %20
%49 = phi i32 [ -1, %20 ], [ -1, %39 ], [ -1, %13 ], [ %11, %8 ], [ %47, %44 ]
ret i32 %49
}