#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 const *, char *,
                         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 exec_umount(const char *progname, const char *rel_mnt, int lazy) {
  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", "-i", rel_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));
  if (status != 0) {
    res = -1;
  }
out_restore:
  sigprocmask(SIG_SETMASK, &oldmask, NULL);
  return res;
}


x86 assembly (clang, -O0):
<exec_umount>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
lea    -0x28(%rbp),%rdi
call   1060 <sigemptyset@plt>
mov    0x2e0d(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdi
call   10c0 <sigaddset@plt>
mov    0x2ddb(%rip),%rax
mov    (%rax),%edi
lea    -0x28(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
call   1030 <sigprocmask@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0xffffffff,-0x20(%rbp)
jne    1245 <exec_umount+0x95>
mov    0x2dc8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    0x2dac(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x3c(%rbp),%edi
mov    -0x38(%rbp),%rdx
mov    %rax,%rcx
lea    0xdcc(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13c0 <exec_umount+0x210>
mov    $0x0,%al
call   10d0 <fork@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0xffffffff,-0x20(%rbp)
jne    1296 <exec_umount+0xe6>
mov    0x2d70(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    0x2d54(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x4c(%rbp),%edi
mov    -0x48(%rbp),%rdx
mov    %rax,%rcx
lea    0xd89(%rip),%rsi
call   1050 <fprintf@plt>
jmp    13a4 <exec_umount+0x1f4>
cmpl   $0x0,-0x20(%rbp)
jne    133b <exec_umount+0x18b>
mov    0x2d41(%rip),%rax
mov    (%rax),%edi
lea    -0x2c(%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),%rcx
mov    -0x1c(%rbp),%edx
xor    %eax,%eax
mov    %eax,%r8d
lea    0xd5b(%rip),%rax
cmp    $0x0,%edx
cmovne %rax,%r8
lea    0xd3e(%rip),%rsi
lea    0xd43(%rip),%rdx
xor    %eax,%eax
mov    %eax,%r9d
mov    %rsi,%rdi
call   10b0 <execl@plt>
mov    0x2cd0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    0x2cb4(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x5c(%rbp),%edi
mov    -0x58(%rbp),%rdx
mov    %rax,%rcx
lea    0xd09(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x20(%rbp),%edi
lea    -0x24(%rbp),%rsi
xor    %edx,%edx
call   1070 <waitpid@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0xffffffff,-0x20(%rbp)
jne    138e <exec_umount+0x1de>
mov    0x2c73(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    0x2c57(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x6c(%rbp),%edi
mov    -0x68(%rbp),%rdx
mov    %rax,%rcx
lea    0xcd3(%rip),%rsi
call   1050 <fprintf@plt>
cmpl   $0x0,-0x24(%rbp)
je     139f <exec_umount+0x1ef>
movl   $0xffffffff,-0x20(%rbp)
jmp    13a4 <exec_umount+0x1f4>
mov    0x2c3d(%rip),%rax
mov    (%rax),%edi
lea    -0x2c(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigprocmask@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<exec_umount>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%r15
lea    0x14(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <sigemptyset@plt>
mov    0x2e0a(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   10c0 <sigaddset@plt>
mov    0x2dd9(%rip),%rax
mov    (%rax),%edi
lea    0xc(%rsp),%rdx
mov    %rbx,%rsi
call   1030 <sigprocmask@plt>
cmp    $0xffffffff,%eax
je     1261 <exec_umount+0xb1>
xor    %eax,%eax
call   10d0 <fork@plt>
cmp    $0xffffffff,%eax
je     1293 <exec_umount+0xe3>
test   %eax,%eax
je     12e5 <exec_umount+0x135>
lea    0x10(%rsp),%rsi
xor    %r14d,%r14d
mov    %eax,%edi
xor    %edx,%edx
call   1070 <waitpid@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
jne    1256 <exec_umount+0xa6>
mov    0x2d9e(%rip),%rax
mov    (%rax),%ebx
mov    0x2d8d(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
lea    0xe13(%rip),%rsi
mov    %ebx,%edi
mov    %r15,%rdx
mov    %rax,%rcx
call   1050 <fprintf@plt>
cmp    0x10(%rsp),%r14d
sbb    %ebx,%ebx
or     %ebp,%ebx
jmp    12c3 <exec_umount+0x113>
mov    0x2d68(%rip),%rax
mov    (%rax),%ebx
mov    0x2d57(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
lea    0xd81(%rip),%rsi
mov    %ebx,%edi
mov    %r15,%rdx
mov    %rax,%rcx
call   1050 <fprintf@plt>
mov    $0xffffffff,%ebx
jmp    12d8 <exec_umount+0x128>
mov    0x2d36(%rip),%rax
mov    (%rax),%ebx
mov    0x2d25(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
lea    0xd64(%rip),%rsi
mov    %ebx,%edi
mov    %r15,%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
xor    %ebx,%ebx
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>
test   %ebp,%ebp
lea    0xd1f(%rip),%r8
cmove  %rbx,%r8
lea    0xd05(%rip),%rdi
lea    0xd0a(%rip),%rdx
mov    %rdi,%rsi
mov    %r14,%rcx
xor    %r9d,%r9d
call   10b0 <execl@plt>
mov    0x2c96(%rip),%rax
mov    (%rax),%ebx
mov    0x2c85(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
lea    0xce4(%rip),%rsi
mov    %ebx,%edi
mov    %r15,%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 = [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 @exec_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
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%12 = call i32 @sigemptyset(i32* %10)
%13 = load i32, i32* @SIGCHLD
%14 = call i32 @sigaddset(i32* %10, i32 %13)
%15 = load i32, i32* @SIG_BLOCK
%16 = call i32 @sigprocmask(i32 %15, i32* %10, i32* %11)
store i32 %16, i32* %8
%17 = load i32, i32* %8
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %25
19: ; preds = %3
%20 = load i32, i32* @stderr
%21 = load i8*, i8** %5
%22 = load i32, i32* @errno
%23 = call i8* @strerror(i32 %22)
%24 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %21, i8* %23)
store i32 -1, i32* %4
br label %75
25: ; preds = %3
%26 = call i32 (...) @fork()
store i32 %26, i32* %8
%27 = load i32, i32* %8
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %35
29: ; preds = %25
%30 = load i32, i32* @stderr
%31 = load i8*, i8** %5
%32 = load i32, i32* @errno
%33 = call i8* @strerror(i32 %32)
%34 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %31, i8* %33)
br label %71
35: ; preds = %25
%36 = load i32, i32* %8
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %55
38: ; preds = %35
%39 = load i32, i32* @SIG_SETMASK
%40 = call i32 @sigprocmask(i32 %39, i32* %11, i32* null)
%41 = call i32 (...) @geteuid()
%42 = call i32 @setuid(i32 %41)
%43 = load i8*, i8** %6
%44 = load i32, i32* %7
%45 = icmp ne i32 %44, 0
%46 = zext i1 %45 to i64
%47 = select i1 %45, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* null
%48 = 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* %43, i8* %47, i32* null)
%49 = load i32, i32* @stderr
%50 = load i8*, i8** %5
%51 = load i32, i32* @errno
%52 = call i8* @strerror(i32 %51)
%53 = call i32 @fprintf(i32 %49, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0), i8* %50, i8* %52)
%54 = call i32 @exit(i32 1)
unreachable
55: ; preds = %35
%56 = load i32, i32* %8
%57 = call i32 @waitpid(i32 %56, i32* %9, i32 0)
store i32 %57, i32* %8
%58 = load i32, i32* %8
%59 = icmp eq i32 %58, -1
br i1 %59, label %60, label %66
60: ; preds = %55
%61 = load i32, i32* @stderr
%62 = load i8*, i8** %5
%63 = load i32, i32* @errno
%64 = call i8* @strerror(i32 %63)
%65 = call i32 @fprintf(i32 %61, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i8* %62, i8* %64)
br label %66
66: ; preds = %60, %55
%67 = load i32, i32* %9
%68 = icmp ne i32 %67, 0
br i1 %68, label %69, label %70
69: ; preds = %66
store i32 -1, i32* %8
br label %70
70: ; preds = %69, %66
br label %71
71: ; preds = %70, %29
%72 = load i32, i32* @SIG_SETMASK
%73 = call i32 @sigprocmask(i32 %72, i32* %11, i32* null)
%74 = load i32, i32* %8
store i32 %74, i32* %4
br label %75
75: ; preds = %71, %19
%76 = load i32, i32* %4
ret i32 %76
}

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