#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_MGC_VAL;
int /*<<< orphan*/ exit(int);
int mount(char *, char *, char *, int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
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);
    }
    rc = mount(argv[2], argv[3], "ext2", MS_MGC_VAL, NULL);
    if (rc) {
      perror("");
      exit(1);
    }
  } else if (!strcmp("umount", argv[1])) {
    if (argc < 3) {
      exit(1);
    }
    rc = umount(argv[2]);
    if (rc) {
      perror("");
      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    117a <main+0x2a>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe7d(%rip),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11fd <main+0xad>
cmpl   $0x4,-0x8(%rbp)
jge    11ab <main+0x5b>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
mov    0x2e1e(%rip),%rax
mov    (%rax),%ecx
lea    0xe35(%rip),%rdx
xor    %eax,%eax
mov    %eax,%r8d
call   1040 <mount@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11f8 <main+0xa8>
lea    0xe1b(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
jmp    1268 <main+0x118>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xdf9(%rip),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1263 <main+0x113>
cmpl   $0x3,-0x8(%rbp)
jge    122e <main+0xde>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <umount@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     125e <main+0x10e>
lea    0xdb5(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
jmp    1263 <main+0x113>
jmp    1268 <main+0x118>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
cmp    $0x1,%edi
jle    11b8 <main+0x68>
mov    %rsi,%r14
mov    %edi,%ebp
mov    0x8(%rsi),%rbx
lea    0xe9d(%rip),%rdi
mov    %rbx,%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
jne    11a0 <main+0x50>
cmp    $0x3,%ebp
jbe    11b8 <main+0x68>
mov    0x10(%r14),%rdi
mov    0x18(%r14),%rsi
mov    0x2e57(%rip),%rax
mov    (%rax),%ecx
lea    0xe6e(%rip),%rdx
xor    %r8d,%r8d
call   1040 <mount@plt>
test   %eax,%eax
je     11cf <main+0x7f>
jmp    11d6 <main+0x86>
lea    0xe5e(%rip),%rdi
mov    %rbx,%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
jne    11cf <main+0x7f>
cmp    $0x2,%ebp
ja     11c2 <main+0x72>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    0x10(%r14),%rdi
call   1030 <umount@plt>
test   %eax,%eax
jne    11d6 <main+0x86>
xor    %edi,%edi
call   1070 <exit@plt>
lea    0xe27(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"mount\00"
@.str.1 = [5 x i8] c"ext2\00"
@MS_MGC_VAL = global i32 0
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [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 %37, 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 i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 2
%25 = load i8*, i8** %24
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 3
%28 = load i8*, i8** %27
%29 = load i32, i32* @MS_MGC_VAL
%30 = call i32 @mount(i8* %25, i8* %28, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %29, i32* null)
store i32 %30, i32* %6
%31 = load i32, i32* %6
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %22
%34 = call i32 @perror(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%35 = call i32 @exit(i32 1)
unreachable
36: ; preds = %22
br label %60
37: ; preds = %11
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 1
%40 = load i8*, i8** %39
%41 = call i32 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %40)
%42 = icmp ne i32 %41, 0
br i1 %42, label %59, label %43
43: ; preds = %37
%44 = load i32, i32* %4
%45 = icmp slt i32 %44, 3
br i1 %45, label %46, label %48
46: ; preds = %43
%47 = call i32 @exit(i32 1)
unreachable
48: ; preds = %43
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 2
%51 = load i8*, i8** %50
%52 = call i32 @umount(i8* %51)
store i32 %52, i32* %6
%53 = load i32, i32* %6
%54 = icmp ne i32 %53, 0
br i1 %54, label %55, label %58
55: ; preds = %48
%56 = call i32 @perror(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%57 = call i32 @exit(i32 1)
unreachable
58: ; preds = %48
br label %59
59: ; preds = %58, %37
br label %60
60: ; preds = %59, %36
%61 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [6 x i8] c"mount\00"
@.str.1 = [5 x i8] c"ext2\00"
@MS_MGC_VAL = global i32 0
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [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 %26
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 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
%18 = getelementptr inbounds i8*, i8** %1, i64 3
%19 = load i8*, i8** %18
%20 = load i32, i32* @MS_MGC_VAL
%21 = tail call i32 @mount(i8* %17, i8* %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %20, i32* null)
%22 = icmp eq i32 %21, 0
br i1 %22, label %41, label %23
23: ; preds = %15
%24 = tail call i32 @perror(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%25 = tail call i32 @exit(i32 1)
unreachable
26: ; preds = %6
%27 = tail call i32 @strcmp(i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* dereferenceable(1) %8)
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %41
29: ; preds = %26
%30 = icmp ult i32 %0, 3
br i1 %30, label %31, label %33
31: ; preds = %29
%32 = tail call i32 @exit(i32 1)
unreachable
33: ; preds = %29
%34 = getelementptr inbounds i8*, i8** %1, i64 2
%35 = load i8*, i8** %34
%36 = tail call i32 @umount(i8* %35)
%37 = icmp eq i32 %36, 0
br i1 %37, label %41, label %38
38: ; preds = %33
%39 = tail call i32 @perror(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%40 = tail call i32 @exit(i32 1)
unreachable
41: ; preds = %26, %33, %15
%42 = tail call i32 @exit(i32 0)
unreachable
}