#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 */
typedef int /*<<< orphan*/ sigset_t;

/* Variables and functions */
int /*<<< orphan*/ SIGCHLD;
int /*<<< orphan*/ SIG_BLOCK;
int /*<<< orphan*/ SIG_SETMASK;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ execl(char *, char *, char *, char *, char *, char const *,
                         int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
int fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, char *);
int /*<<< orphan*/ geteuid();
int /*<<< orphan*/ setuid(int /*<<< orphan*/);
int /*<<< orphan*/ sigaddset(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ sigemptyset(int /*<<< orphan*/ *);
int sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int waitpid(int, int *, int /*<<< orphan*/);
int remove_mount(const char *progname, const char *mnt) {
  int res;
  int status;
  sigset_t blockmask;
  sigset_t oldmask;
  sigemptyset(&blockmask);
  sigaddset(&blockmask, SIGCHLD);
  res = sigprocmask(SIG_BLOCK, &blockmask, &oldmask);
  if (res == -1) {
    fprintf(stderr, "%s: sigprocmask: %s\n", progname, strerror(errno));
    return -1;
  }
  res = fork();
  if (res == -1) {
    fprintf(stderr, "%s: fork: %s\n", progname, strerror(errno));
    goto out_restore;
  }
  if (res == 0) {
    sigprocmask(SIG_SETMASK, &oldmask, NULL);
    setuid(geteuid());
    execl("/bin/umount", "/bin/umount", "--no-canonicalize", "-i", "--fake",
          mnt, 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));
  if (status != 0)
    res = -1;
out_restore:
  sigprocmask(SIG_SETMASK, &oldmask, NULL);
  return res;
}


x86 assembly (clang, -O0):
<remove_mount>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x24(%rbp),%rdi
call   1060 <sigemptyset@plt>
mov    0x2e10(%rip),%rax
mov    (%rax),%esi
lea    -0x24(%rbp),%rdi
call   10c0 <sigaddset@plt>
mov    0x2dde(%rip),%rax
mov    (%rax),%edi
lea    -0x24(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1030 <sigprocmask@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    1242 <remove_mount+0x92>
mov    0x2dcb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    0x2daf(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x34(%rbp),%edi
mov    -0x30(%rbp),%rdx
mov    %rax,%rcx
lea    0xdcf(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13ba <remove_mount+0x20a>
mov    $0x0,%al
call   10d0 <fork@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    1293 <remove_mount+0xe3>
mov    0x2d73(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    0x2d57(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x44(%rbp),%edi
mov    -0x40(%rbp),%rdx
mov    %rax,%rcx
lea    0xd8c(%rip),%rsi
call   1050 <fprintf@plt>
jmp    139e <remove_mount+0x1ee>
cmpl   $0x0,-0x1c(%rbp)
jne    1335 <remove_mount+0x185>
mov    0x2d44(%rip),%rax
mov    (%rax),%edi
lea    -0x28(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigprocmask@plt>
mov    $0x0,%al
call   1040 <geteuid@plt>
mov    %eax,%edi
call   1090 <setuid@plt>
mov    -0x18(%rbp),%r9
lea    0xd57(%rip),%rsi
lea    0xd5c(%rip),%rdx
lea    0xd67(%rip),%rcx
lea    0xd63(%rip),%r8
xor    %eax,%eax
mov    %rsi,%rdi
movq   $0x0,(%rsp)
call   10b0 <execl@plt>
mov    0x2cd6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    0x2cba(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x54(%rbp),%edi
mov    -0x50(%rbp),%rdx
mov    %rax,%rcx
lea    0xd25(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x1c(%rbp),%edi
lea    -0x20(%rbp),%rsi
xor    %edx,%edx
call   1070 <waitpid@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    1388 <remove_mount+0x1d8>
mov    0x2c79(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x64(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    0x2c5d(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x64(%rbp),%edi
mov    -0x60(%rbp),%rdx
mov    %rax,%rcx
lea    0xcef(%rip),%rsi
call   1050 <fprintf@plt>
cmpl   $0x0,-0x20(%rbp)
je     1399 <remove_mount+0x1e9>
movl   $0xffffffff,-0x1c(%rbp)
jmp    139e <remove_mount+0x1ee>
mov    0x2c43(%rip),%rax
mov    (%rax),%edi
lea    -0x28(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigprocmask@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remove_mount>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x14(%rsp),%rbp
mov    %rbp,%rdi
call   1060 <sigemptyset@plt>
mov    0x2e0c(%rip),%rax
mov    (%rax),%esi
mov    %rbp,%rdi
call   10c0 <sigaddset@plt>
mov    0x2ddb(%rip),%rax
mov    (%rax),%edi
lea    0xc(%rsp),%rdx
mov    %rbp,%rsi
call   1030 <sigprocmask@plt>
cmp    $0xffffffff,%eax
je     1261 <remove_mount+0xb1>
xor    %eax,%eax
call   10d0 <fork@plt>
cmp    $0xffffffff,%eax
je     1293 <remove_mount+0xe3>
test   %eax,%eax
je     12e5 <remove_mount+0x135>
lea    0x10(%rsp),%rsi
xor    %r15d,%r15d
mov    %eax,%edi
xor    %edx,%edx
call   1070 <waitpid@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
jne    1256 <remove_mount+0xa6>
mov    0x2da0(%rip),%rax
mov    (%rax),%r14d
mov    0x2d8e(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
lea    0xe2a(%rip),%rsi
mov    %r14d,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
call   1050 <fprintf@plt>
cmp    0x10(%rsp),%r15d
sbb    %ebx,%ebx
or     %ebp,%ebx
jmp    12c3 <remove_mount+0x113>
mov    0x2d68(%rip),%rax
mov    (%rax),%ebp
mov    0x2d57(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
lea    0xd81(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
call   1050 <fprintf@plt>
mov    $0xffffffff,%ebx
jmp    12d8 <remove_mount+0x128>
mov    0x2d36(%rip),%rax
mov    (%rax),%ebp
mov    0x2d25(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
lea    0xd64(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
call   1050 <fprintf@plt>
mov    $0xffffffff,%ebx
mov    0x2d1e(%rip),%rax
mov    (%rax),%edi
lea    0xc(%rsp),%rsi
xor    %edx,%edx
call   1030 <sigprocmask@plt>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2cfc(%rip),%rax
mov    (%rax),%edi
lea    0xc(%rsp),%rsi
xor    %edx,%edx
call   1030 <sigprocmask@plt>
xor    %eax,%eax
call   1040 <geteuid@plt>
mov    %eax,%edi
call   1090 <setuid@plt>
movq   $0x0,(%rsp)
lea    0xd0c(%rip),%rdi
lea    0xd11(%rip),%rdx
lea    0xd1c(%rip),%rcx
lea    0xd18(%rip),%r8
mov    %rdi,%rsi
mov    %r14,%r9
call   10b0 <execl@plt>
mov    0x2c92(%rip),%rax
mov    (%rax),%ebp
mov    0x2c81(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
lea    0xcf6(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

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

LLVM IR (-O2):
@SIGCHLD = global i32 0
@SIG_BLOCK = global i32 0
@stderr = global i32 0
@.str = [21 x i8] c"%s: sigprocmask: %s\0A\00"
@errno = global i32 0
@.str.1 = [14 x i8] c"%s: fork: %s\0A\00"
@SIG_SETMASK = global i32 0
@.str.2 = [12 x i8] c"/bin/umount\00"
@.str.3 = [18 x i8] c"--no-canonicalize\00"
@.str.4 = [3 x i8] c"-i\00"
@.str.5 = [7 x i8] c"--fake\00"
@.str.6 = [39 x i8] c"%s: failed to execute /bin/umount: %s\0A\00"
@.str.7 = [17 x i8] c"%s: waitpid: %s\0A\00"
define i32 @remove_mount(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = call i32 @sigemptyset(i32* %4)
%10 = load i32, i32* @SIGCHLD
%11 = call i32 @sigaddset(i32* %4, i32 %10)
%12 = load i32, i32* @SIG_BLOCK
%13 = call i32 @sigprocmask(i32 %12, i32* %4, i32* %5)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %20
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = load i32, i32* @errno
%18 = call i8* @strerror(i32 %17)
%19 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %18)
br label %54
20: ; preds = %2
%21 = call i32 (...) @fork()
switch i32 %21, label %38 [
i32 -1, label %22
i32 0, label %27
]
22: ; preds = %20
%23 = load i32, i32* @stderr
%24 = load i32, i32* @errno
%25 = call i8* @strerror(i32 %24)
%26 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %25)
br label %50
27: ; preds = %20
%28 = load i32, i32* @SIG_SETMASK
%29 = call i32 @sigprocmask(i32 %28, i32* %5, i32* null)
%30 = call i32 (...) @geteuid()
%31 = call i32 @setuid(i32 %30)
%32 = 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 ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* %1, i32* null)
%33 = load i32, i32* @stderr
%34 = load i32, i32* @errno
%35 = call i8* @strerror(i32 %34)
%36 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0), i8* %0, i8* %35)
%37 = call i32 @exit(i32 1)
unreachable
38: ; preds = %20
%39 = call i32 @waitpid(i32 %21, i32* %3, i32 0)
%40 = icmp eq i32 %39, -1
br i1 %40, label %41, label %46
41: ; preds = %38
%42 = load i32, i32* @stderr
%43 = load i32, i32* @errno
%44 = call i8* @strerror(i32 %43)
%45 = call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i8* %0, i8* %44)
br label %46
46: ; preds = %41, %38
%47 = load i32, i32* %3
%48 = icmp eq i32 %47, 0
%49 = select i1 %48, i32 %39, i32 -1
br label %50
50: ; preds = %46, %22
%51 = phi i32 [ -1, %22 ], [ %49, %46 ]
%52 = load i32, i32* @SIG_SETMASK
%53 = call i32 @sigprocmask(i32 %52, i32* %5, i32* null)
br label %54
54: ; preds = %50, %15
%55 = phi i32 [ -1, %15 ], [ %51, %50 ]
ret i32 %55
}