#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*/ do_mount();
int /*<<< orphan*/ do_umount();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
char *strrchr(char const *, char);
int main(int argc, char **argv) {
  char const *prog = argv[0];
  char const *last_slash = strrchr(prog, '/');
  if (last_slash)
    prog = last_slash + 1;
  if (prog[0] == 'u')
    do_umount();
  else
    do_mount();
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x2f,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     118a <main+0x4a>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x75,%eax
jne    11a6 <main+0x66>
mov    $0x0,%al
call   1060 <do_umount@plt>
jmp    11ad <main+0x6d>
mov    $0x0,%al
call   1040 <do_mount@plt>
xor    %edi,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    (%rsi),%rbx
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1030 <strrchr@plt>
lea    0x1(%rax),%rcx
test   %rax,%rax
cmove  %rbx,%rcx
cmpb   $0x75,(%rcx)
jne    116f <main+0x2f>
xor    %eax,%eax
call   1060 <do_umount@plt>
xor    %edi,%edi
call   1050 <exit@plt>
xor    %eax,%eax
call   1040 <do_mount@plt>
xor    %edi,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i8**, i8*** %5
%9 = getelementptr inbounds i8*, i8** %8, i64 0
%10 = load i8*, i8** %9
store i8* %10, i8** %6
%11 = load i8*, i8** %6
%12 = call i8* @strrchr(i8* %11, i8 signext 47)
store i8* %12, i8** %7
%13 = load i8*, i8** %7
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %18
15: ; preds = %2
%16 = load i8*, i8** %7
%17 = getelementptr inbounds i8, i8* %16, i64 1
store i8* %17, i8** %6
br label %18
18: ; preds = %15, %2
%19 = load i8*, i8** %6
%20 = getelementptr inbounds i8, i8* %19, i64 0
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 117
br i1 %23, label %24, label %26
24: ; preds = %18
%25 = call i32 (...) @do_umount()
br label %28
26: ; preds = %18
%27 = call i32 (...) @do_mount()
br label %28
28: ; preds = %26, %24
%29 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i8*, i8** %1
%4 = tail call i8* @strrchr(i8* dereferenceable(1) %3, i8 signext 47)
%5 = icmp eq i8* %4, null
%6 = getelementptr inbounds i8, i8* %4, i64 1
%7 = select i1 %5, i8* %3, i8* %6
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 117
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = tail call i32 (...) @do_umount()
br label %14
12: ; preds = %2
%13 = tail call i32 (...) @do_mount()
br label %14
14: ; preds = %12, %10
%15 = tail call i32 @exit(i32 0)
unreachable
}