#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 */
scalar_t__ basename(char *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
scalar_t__ getuid();
int sea_umount_filesystem(char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *, char *);
char *strerror(int /*<<< orphan*/);
int main(int argc, char **argv) {
  int force = 0;
  if (argc < 2) {
    fprintf(stderr, "%s: usage: umount [-f] directory\n", argv[0]);
    return 1;
  }
  if (getuid()) {
    fprintf(stderr, "%s: you must be root to use this program\n", argv[0]);
    return 2;
  }
  if (!strcmp(argv[1], "-f"))
    force = 1;
  int ret = sea_umount_filesystem((char *)(argv[force ? 2 : 1]), force);
  if (ret < 0)
    fprintf(stderr, "%s: %s: %s\n", (char *)basename(argv[0]),
            argv[force ? 2 : 1], strerror(errno));
  return ret ? 1 : 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11b1 <main+0x51>
mov    0x2e52(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe62(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12be <main+0x15e>
mov    $0x0,%al
call   1040 <getuid@plt>
cmp    $0x0,%rax
je     11ec <main+0x8c>
mov    0x2e17(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe49(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    12be <main+0x15e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe51(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1210 <main+0xb0>
movl   $0x1,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%esi
mov    $0x1,%ecx
mov    $0x2,%edx
cmp    $0x0,%esi
cmovne %edx,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x14(%rbp),%esi
call   1030 <sea_umount_filesystem@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    12ab <main+0x14b>
mov    0x2d96(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <basename@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%esi
mov    $0x1,%ecx
mov    $0x2,%edx
cmp    $0x0,%esi
cmovne %edx,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    0x2d50(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    %rax,%r8
lea    0xdab(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbx
cmp    $0x1,%edi
jg     1194 <main+0x34>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe7d(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%eax
jmp    1239 <main+0xd9>
xor    %eax,%eax
call   1040 <getuid@plt>
test   %rax,%rax
je     11c1 <main+0x61>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe6f(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x2,%eax
jmp    1239 <main+0xd9>
mov    0x8(%rbx),%rdi
lea    0xe80(%rip),%rsi
call   1050 <strcmp@plt>
xor    %ebp,%ebp
test   %eax,%eax
sete   %bpl
mov    0x8(%rbx,%rbp,8),%rdi
mov    %ebp,%esi
call   1030 <sea_umount_filesystem@plt>
mov    %eax,%r14d
test   %eax,%eax
jns    1231 <main+0xd1>
add    $0x1,%rbp
mov    0x2de9(%rip),%rax
mov    (%rax),%r15d
mov    (%rbx),%rdi
call   1070 <basename@plt>
mov    %rax,%r12
mov    (%rbx,%rbp,8),%rbx
mov    0x2dc8(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
lea    0xe31(%rip),%rsi
mov    %r15d,%edi
mov    %r12,%rdx
mov    %rbx,%rcx
mov    %rax,%r8
xor    %eax,%eax
call   1060 <fprintf@plt>
xor    %eax,%eax
test   %r14d,%r14d
setne  %al
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [34 x i8] c"%s: usage: umount [-f] directory\0A\00"
@.str.1 = [42 x i8] c"%s: you must be root to use this program\0A\00"
@.str.2 = [3 x i8] c"-f\00"
@.str.3 = [12 x i8] c"%s: %s: %s\0A\00"
@errno = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %14)
store i32 1, i32* %3
br label %68
16: ; preds = %2
%17 = call i64 (...) @getuid()
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %16
%20 = load i32, i32* @stderr
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 0
%23 = load i8*, i8** %22
%24 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i8* %23)
store i32 2, i32* %3
br label %68
25: ; preds = %16
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32 @strcmp(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%30 = icmp ne i32 %29, 0
br i1 %30, label %32, label %31
31: ; preds = %25
store i32 1, i32* %6
br label %32
32: ; preds = %31, %25
%33 = load i8**, i8*** %5
%34 = load i32, i32* %6
%35 = icmp ne i32 %34, 0
%36 = zext i1 %35 to i64
%37 = select i1 %35, i32 2, i32 1
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8*, i8** %33, i64 %38
%40 = load i8*, i8** %39
%41 = load i32, i32* %6
%42 = call i32 @sea_umount_filesystem(i8* %40, i32 %41)
store i32 %42, i32* %7
%43 = load i32, i32* %7
%44 = icmp slt i32 %43, 0
br i1 %44, label %45, label %63
45: ; preds = %32
%46 = load i32, i32* @stderr
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 0
%49 = load i8*, i8** %48
%50 = call i64 @basename(i8* %49)
%51 = inttoptr i64 %50 to i8*
%52 = load i8**, i8*** %5
%53 = load i32, i32* %6
%54 = icmp ne i32 %53, 0
%55 = zext i1 %54 to i64
%56 = select i1 %54, i32 2, i32 1
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8*, i8** %52, i64 %57
%59 = load i8*, i8** %58
%60 = load i32, i32* @errno
%61 = call i8* @strerror(i32 %60)
%62 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %51, i8* %59, i8* %61)
br label %63
63: ; preds = %45, %32
%64 = load i32, i32* %7
%65 = icmp ne i32 %64, 0
%66 = zext i1 %65 to i64
%67 = select i1 %65, i32 1, i32 0
store i32 %67, i32* %3
br label %68
68: ; preds = %63, %19, %10
%69 = load i32, i32* %3
ret i32 %69
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [34 x i8] c"%s: usage: umount [-f] directory\0A\00"
@.str.1 = [42 x i8] c"%s: you must be root to use this program\0A\00"
@.str.2 = [3 x i8] c"-f\00"
@.str.3 = [12 x i8] c"%s: %s: %s\0A\00"
@errno = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %38
8: ; preds = %2
%9 = tail call i64 (...) @getuid()
%10 = icmp eq i64 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %8
%12 = load i32, i32* @stderr
%13 = load i8*, i8** %1
%14 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i8* %13)
br label %38
15: ; preds = %8
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = tail call i32 @strcmp(i8* dereferenceable(1) %17, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i32 %18, 0
%20 = select i1 %19, i64 2, i64 1
%21 = zext i1 %19 to i32
%22 = getelementptr inbounds i8*, i8** %1, i64 %20
%23 = load i8*, i8** %22
%24 = tail call i32 @sea_umount_filesystem(i8* %23, i32 %21)
%25 = icmp slt i32 %24, 0
br i1 %25, label %26, label %35
26: ; preds = %15
%27 = load i32, i32* @stderr
%28 = load i8*, i8** %1
%29 = tail call i64 @basename(i8* %28)
%30 = inttoptr i64 %29 to i8*
%31 = load i8*, i8** %22
%32 = load i32, i32* @errno
%33 = tail call i8* @strerror(i32 %32)
%34 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %30, i8* %31, i8* %33)
br label %35
35: ; preds = %26, %15
%36 = icmp ne i32 %24, 0
%37 = zext i1 %36 to i32
br label %38
38: ; preds = %35, %11, %4
%39 = phi i32 [ 1, %4 ], [ 2, %11 ], [ %37, %35 ]
ret i32 %39
}