#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*/ MS_BIND;
int /*<<< orphan*/ MS_MGC_VAL;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
int mount(char *, char *, char *, int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *, char *);
int umount(char *);
int main(int argc, char **argv) {
  int rc;
  if (argc < 2) {
    exit(1);
  }
  if (!strcmp("mount", argv[1])) {
    if (argc < 4) {
      exit(1);
    }
    if (argc == 5) {
      if (!strcmp("--bind", argv[2])) {
        rc = mount(argv[3], argv[4], NULL, MS_BIND, NULL);
        if (rc) {
          perror("mount");
          exit(1);
        }
      } else {
        fprintf(stderr, "%s: unknown flag %s\n", argv[0], argv[2]);
        exit(1);
      }
    } else {
      rc = mount(argv[2], argv[3], "ext2", MS_MGC_VAL, NULL);
      if (rc) {
        perror("mount");
        exit(1);
      }
    }
  } else if (!strcmp("umount", argv[1])) {
    if (argc < 3) {
      exit(1);
    }
    rc = umount(argv[2]);
    if (rc) {
      perror("umount");
      exit(1);
    }
  }
  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)
cmpl   $0x2,-0x8(%rbp)
jge    118a <main+0x2a>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe89(%rip),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    12ba <main+0x15a>
cmpl   $0x4,-0x8(%rbp)
jge    11bb <main+0x5b>
mov    $0x1,%edi
call   1080 <exit@plt>
cmpl   $0x5,-0x8(%rbp)
jne    1263 <main+0x103>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xe2c(%rip),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1230 <main+0xd0>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rsi
mov    0x2def(%rip),%rax
mov    (%rax),%ecx
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rdx
call   1040 <mount@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     122b <main+0xcb>
lea    0xe06(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    125e <main+0xfe>
mov    0x2da1(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rcx
lea    0xdb8(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    12b5 <main+0x155>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
mov    0x2d56(%rip),%rax
mov    (%rax),%ecx
lea    0xd99(%rip),%rdx
xor    %eax,%eax
mov    %eax,%r8d
call   1040 <mount@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     12b0 <main+0x150>
lea    0xd81(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    12b5 <main+0x155>
jmp    1325 <main+0x1c5>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xd58(%rip),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1320 <main+0x1c0>
cmpl   $0x3,-0x8(%rbp)
jge    12eb <main+0x18b>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <umount@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     131b <main+0x1bb>
lea    0xd15(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    1320 <main+0x1c0>
jmp    1325 <main+0x1c5>
xor    %edi,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x1,%edi
jle    11d6 <main+0x76>
mov    %rsi,%r15
mov    %edi,%ebp
mov    0x8(%rsi),%rbx
lea    0xea6(%rip),%rdi
mov    %rbx,%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
jne    11be <main+0x5e>
cmp    $0x3,%ebp
jbe    11d6 <main+0x76>
mov    0x10(%r15),%r14
cmp    $0x5,%ebp
jne    11e0 <main+0x80>
lea    0xe63(%rip),%rdi
mov    %r14,%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
jne    1220 <main+0xc0>
mov    0x18(%r15),%rdi
mov    0x20(%r15),%rsi
mov    0x2e30(%rip),%rax
mov    (%rax),%ecx
xor    %edx,%edx
jmp    11f7 <main+0x97>
lea    0xe5c(%rip),%rdi
mov    %rbx,%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
jne    1219 <main+0xb9>
cmp    $0x2,%ebp
ja     120c <main+0xac>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    0x18(%r15),%rsi
mov    0x2de5(%rip),%rax
mov    (%rax),%ecx
lea    0xe28(%rip),%rdx
mov    %r14,%rdi
xor    %r8d,%r8d
call   1040 <mount@plt>
test   %eax,%eax
je     1219 <main+0xb9>
lea    0xe18(%rip),%rdi
jmp    124c <main+0xec>
mov    0x10(%r15),%rdi
call   1030 <umount@plt>
test   %eax,%eax
jne    1245 <main+0xe5>
xor    %edi,%edi
call   1080 <exit@plt>
mov    0x2db1(%rip),%rax
mov    (%rax),%edi
mov    (%r15),%rdx
lea    0xdd4(%rip),%rsi
mov    %r14,%rcx
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
lea    0xdd5(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"mount\00"
@.str.1 = [7 x i8] c"--bind\00"
@MS_BIND = global i32 0
@stderr = global i32 0
@.str.2 = [21 x i8] c"%s: unknown flag %s\0A\00"
@.str.3 = [5 x i8] c"ext2\00"
@MS_MGC_VAL = global i32 0
@.str.4 = [7 x i8] c"umount\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 2
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 @exit(i32 1)
unreachable
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @strcmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = icmp ne i32 %15, 0
br i1 %16, label %73, label %17
17: ; preds = %11
%18 = load i32, i32* %4
%19 = icmp slt i32 %18, 4
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %17
%23 = load i32, i32* %4
%24 = icmp eq i32 %23, 5
br i1 %24, label %25, label %57
25: ; preds = %22
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 2
%28 = load i8*, i8** %27
%29 = call i32 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %28)
%30 = icmp ne i32 %29, 0
br i1 %30, label %46, label %31
31: ; preds = %25
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 3
%34 = load i8*, i8** %33
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 4
%37 = load i8*, i8** %36
%38 = load i32, i32* @MS_BIND
%39 = call i32 @mount(i8* %34, i8* %37, i8* null, i32 %38, i32* null)
store i32 %39, i32* %6
%40 = load i32, i32* %6
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %31
%43 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%44 = call i32 @exit(i32 1)
unreachable
45: ; preds = %31
br label %56
46: ; preds = %25
%47 = load i32, i32* @stderr
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 0
%50 = load i8*, i8** %49
%51 = load i8**, i8*** %5
%52 = getelementptr inbounds i8*, i8** %51, i64 2
%53 = load i8*, i8** %52
%54 = call i32 @fprintf(i32 %47, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %50, i8* %53)
%55 = call i32 @exit(i32 1)
unreachable
56: ; preds = %45
br label %72
57: ; preds = %22
%58 = load i8**, i8*** %5
%59 = getelementptr inbounds i8*, i8** %58, i64 2
%60 = load i8*, i8** %59
%61 = load i8**, i8*** %5
%62 = getelementptr inbounds i8*, i8** %61, i64 3
%63 = load i8*, i8** %62
%64 = load i32, i32* @MS_MGC_VAL
%65 = call i32 @mount(i8* %60, i8* %63, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %64, i32* null)
store i32 %65, i32* %6
%66 = load i32, i32* %6
%67 = icmp ne i32 %66, 0
br i1 %67, label %68, label %71
68: ; preds = %57
%69 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%70 = call i32 @exit(i32 1)
unreachable
71: ; preds = %57
br label %72
72: ; preds = %71, %56
br label %96
73: ; preds = %11
%74 = load i8**, i8*** %5
%75 = getelementptr inbounds i8*, i8** %74, i64 1
%76 = load i8*, i8** %75
%77 = call i32 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %76)
%78 = icmp ne i32 %77, 0
br i1 %78, label %95, label %79
79: ; preds = %73
%80 = load i32, i32* %4
%81 = icmp slt i32 %80, 3
br i1 %81, label %82, label %84
82: ; preds = %79
%83 = call i32 @exit(i32 1)
unreachable
84: ; preds = %79
%85 = load i8**, i8*** %5
%86 = getelementptr inbounds i8*, i8** %85, i64 2
%87 = load i8*, i8** %86
%88 = call i32 @umount(i8* %87)
store i32 %88, i32* %6
%89 = load i32, i32* %6
%90 = icmp ne i32 %89, 0
br i1 %90, label %91, label %94
91: ; preds = %84
%92 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%93 = call i32 @exit(i32 1)
unreachable
94: ; preds = %84
br label %95
95: ; preds = %94, %73
br label %96
96: ; preds = %95, %72
%97 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [6 x i8] c"mount\00"
@.str.1 = [7 x i8] c"--bind\00"
@MS_BIND = global i32 0
@stderr = global i32 0
@.str.2 = [21 x i8] c"%s: unknown flag %s\0A\00"
@.str.3 = [5 x i8] c"ext2\00"
@MS_MGC_VAL = global i32 0
@.str.4 = [7 x i8] c"umount\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @exit(i32 1)
unreachable
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @strcmp(i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* dereferenceable(1) %8)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %47
11: ; preds = %6
%12 = icmp ult i32 %0, 4
br i1 %12, label %13, label %15
13: ; preds = %11
%14 = tail call i32 @exit(i32 1)
unreachable
15: ; preds = %11
%16 = icmp eq i32 %0, 5
%17 = getelementptr inbounds i8*, i8** %1, i64 2
%18 = load i8*, i8** %17
br i1 %16, label %19, label %38
19: ; preds = %15
%20 = tail call i32 @strcmp(i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* dereferenceable(1) %18)
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %33
22: ; preds = %19
%23 = getelementptr inbounds i8*, i8** %1, i64 3
%24 = load i8*, i8** %23
%25 = getelementptr inbounds i8*, i8** %1, i64 4
%26 = load i8*, i8** %25
%27 = load i32, i32* @MS_BIND
%28 = tail call i32 @mount(i8* %24, i8* %26, i8* null, i32 %27, i32* null)
%29 = icmp eq i32 %28, 0
br i1 %29, label %62, label %30
30: ; preds = %22
%31 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%32 = tail call i32 @exit(i32 1)
unreachable
33: ; preds = %19
%34 = load i32, i32* @stderr
%35 = load i8*, i8** %1
%36 = tail call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %35, i8* %18)
%37 = tail call i32 @exit(i32 1)
unreachable
38: ; preds = %15
%39 = getelementptr inbounds i8*, i8** %1, i64 3
%40 = load i8*, i8** %39
%41 = load i32, i32* @MS_MGC_VAL
%42 = tail call i32 @mount(i8* %18, i8* %40, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %41, i32* null)
%43 = icmp eq i32 %42, 0
br i1 %43, label %62, label %44
44: ; preds = %38
%45 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%46 = tail call i32 @exit(i32 1)
unreachable
47: ; preds = %6
%48 = tail call i32 @strcmp(i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* dereferenceable(1) %8)
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %62
50: ; preds = %47
%51 = icmp ult i32 %0, 3
br i1 %51, label %52, label %54
52: ; preds = %50
%53 = tail call i32 @exit(i32 1)
unreachable
54: ; preds = %50
%55 = getelementptr inbounds i8*, i8** %1, i64 2
%56 = load i8*, i8** %55
%57 = tail call i32 @umount(i8* %56)
%58 = icmp eq i32 %57, 0
br i1 %58, label %62, label %59
59: ; preds = %54
%60 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%61 = tail call i32 @exit(i32 1)
unreachable
62: ; preds = %47, %54, %22, %38
%63 = tail call i32 @exit(i32 0)
unreachable
}