#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*/ curr();
int /*<<< orphan*/ error(char *, ...);
scalar_t__ find_root_dir();
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ usage();
int main(int argc, char *argv[], char *envp[]) {
  if (argc < 2) {
    usage();
    return 1;
  }
  if ((strcmp((argv[1]), ("help")) == 0)) {
    usage();
    return 0;
  } else if ((strcmp((argv[1]), ("curr")) == 0)) {
    if (find_root_dir()) {
      curr();
    } else {
      error("Not in a mx project.");
    }
  } else
    error("Unknown command %s. Try 'help'.", argv[1]);
}


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    %rdx,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1187 <main+0x37>
mov    $0x0,%al
call   1060 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    1221 <main+0xd1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe6a(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11b8 <main+0x68>
mov    $0x0,%al
call   1060 <usage@plt>
movl   $0x0,-0x4(%rbp)
jmp    1221 <main+0xd1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe3e(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1206 <main+0xb6>
mov    $0x0,%al
call   1030 <find_root_dir@plt>
cmp    $0x0,%rax
je     11f3 <main+0xa3>
mov    $0x0,%al
call   1050 <curr@plt>
jmp    1201 <main+0xb1>
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1070 <error@plt>
jmp    121c <main+0xcc>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1070 <error@plt>
jmp    1221 <main+0xd1>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x1,%edi
jg     1164 <main+0x14>
xor    %eax,%eax
call   1060 <usage@plt>
mov    $0x1,%ebx
jmp    11d9 <main+0x89>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe8e(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11a7 <main+0x57>
mov    0x8(%rbx),%rdi
lea    0xe7e(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11b2 <main+0x62>
mov    0x8(%rbx),%rsi
lea    0xe83(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1070 <error@plt>
jmp    11d9 <main+0x89>
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <usage@plt>
jmp    11d9 <main+0x89>
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <find_root_dir@plt>
test   %rax,%rax
je     11c9 <main+0x79>
xor    %eax,%eax
call   1050 <curr@plt>
jmp    11d9 <main+0x89>
lea    0xe3a(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1070 <error@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"help\00"
@.str.1 = [5 x i8] c"curr\00"
@.str.2 = [21 x i8] c"Not in a mx project.\00"
@.str.3 = [32 x i8] c"Unknown command %s. Try 'help'.\00"
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %12
10: ; preds = %3
%11 = call i32 (...) @usage()
store i32 1, i32* %4
br label %40
12: ; preds = %3
%13 = load i8**, i8*** %6
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %12
%19 = call i32 (...) @usage()
store i32 0, i32* %4
br label %40
20: ; preds = %12
%21 = load i8**, i8*** %6
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %34
26: ; preds = %20
%27 = call i64 (...) @find_root_dir()
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = call i32 (...) @curr()
br label %33
31: ; preds = %26
%32 = call i32 (i8*, ...) @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
br label %33
33: ; preds = %31, %29
br label %39
34: ; preds = %20
%35 = load i8**, i8*** %6
%36 = getelementptr inbounds i8*, i8** %35, i64 1
%37 = load i8*, i8** %36
%38 = call i32 (i8*, ...) @error(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8* %37)
br label %39
39: ; preds = %34, %33
br label %40
40: ; preds = %10, %18, %39
%41 = load i32, i32* %4
ret i32 %41
}

LLVM IR (-O2):
@.str = [5 x i8] c"help\00"
@.str.1 = [5 x i8] c"curr\00"
@.str.2 = [21 x i8] c"Not in a mx project.\00"
@.str.3 = [32 x i8] c"Unknown command %s. Try 'help'.\00"
define i32 @main(i32 %0, i8** nocapture %1, i8** nocapture readnone %2) {
%4 = icmp slt i32 %0, 2
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 (...) @usage()
br label %28
7: ; preds = %3
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = tail call i32 (...) @usage()
br label %28
14: ; preds = %7
%15 = load i8*, i8** %8
%16 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %25
18: ; preds = %14
%19 = tail call i64 (...) @find_root_dir()
%20 = icmp eq i64 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %18
%22 = tail call i32 (...) @curr()
br label %28
23: ; preds = %18
%24 = tail call i32 (i8*, ...) @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
br label %28
25: ; preds = %14
%26 = load i8*, i8** %8
%27 = tail call i32 (i8*, ...) @error(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8* %26)
br label %28
28: ; preds = %25, %23, %21, %5, %12
%29 = phi i32 [ 1, %5 ], [ 0, %12 ], [ 0, %21 ], [ 0, %23 ], [ 0, %25 ]
ret i32 %29
}