#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*/ clearShell();
int /*<<< orphan*/ echoShellOFF();
int /*<<< orphan*/ echoShellON();
int /*<<< orphan*/ error(char *);
int /*<<< orphan*/ helpShell();
int /*<<< orphan*/ ls();
int /*<<< orphan*/ man(char *);
int /*<<< orphan*/ run(char *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strcmpN(char *, char *, int);
void parser(char *buffer) {
  if (!strcmp("help", buffer)) {
    helpShell();
    return;
  }
  if (!strcmp("clear", buffer)) {
    clearShell();
    return;
  }
  if (!strcmpN("echo", buffer, 4)) {
    if (!strcmp("on", buffer + 5)) {
      echoShellON();
      return;
    }
    echoShellOFF();
    return;
  }
  if (*buffer == '.' && *(buffer + 1) == '\\') {
    run((buffer + 2));
    return;
  }
  if (!strcmpN("man", buffer, 3)) {
    man(buffer + 4);
    return;
  }
  if (!strcmp("ls", buffer)) {
    ls();
    return;
  }
  if (*buffer == '\n') {
    return;
  }
  error(buffer);
}


x86 assembly (clang, -O0):
<parser>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe49(%rip),%rdi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    11d1 <parser+0x31>
mov    $0x0,%al
call   1090 <helpShell@plt>
jmp    12ef <parser+0x14f>
mov    -0x8(%rbp),%rsi
lea    0xe29(%rip),%rdi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    11f6 <parser+0x56>
mov    $0x0,%al
call   1060 <clearShell@plt>
jmp    12ef <parser+0x14f>
mov    -0x8(%rbp),%rsi
lea    0xe0a(%rip),%rdi
mov    $0x4,%edx
call   10b0 <strcmpN@plt>
cmp    $0x0,%eax
jne    1249 <parser+0xa9>
mov    -0x8(%rbp),%rsi
add    $0x5,%rsi
lea    0xded(%rip),%rdi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    123d <parser+0x9d>
mov    $0x0,%al
call   1080 <echoShellON@plt>
jmp    12ef <parser+0x14f>
mov    $0x0,%al
call   10a0 <echoShellOFF@plt>
jmp    12ef <parser+0x14f>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    127c <parser+0xdc>
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x5c,%eax
jne    127c <parser+0xdc>
mov    -0x8(%rbp),%rdi
add    $0x2,%rdi
call   1030 <run@plt>
jmp    12ef <parser+0x14f>
mov    -0x8(%rbp),%rsi
lea    0xd8c(%rip),%rdi
mov    $0x3,%edx
call   10b0 <strcmpN@plt>
cmp    $0x0,%eax
jne    12ac <parser+0x10c>
mov    -0x8(%rbp),%rdi
add    $0x4,%rdi
call   1040 <man@plt>
jmp    12ef <parser+0x14f>
mov    -0x8(%rbp),%rsi
lea    0xd60(%rip),%rdi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    12d1 <parser+0x131>
mov    $0x0,%al
call   1050 <ls@plt>
jmp    12ef <parser+0x14f>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    12e6 <parser+0x146>
jmp    12ef <parser+0x14f>
mov    -0x8(%rbp),%rdi
call   10c0 <error@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parser>:
push   %rbx
mov    %rdi,%rbx
lea    0xe55(%rip),%rdi
mov    %rbx,%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
je     11fa <parser+0x5a>
lea    0xe47(%rip),%rdi
mov    %rbx,%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
je     1202 <parser+0x62>
lea    0xe3a(%rip),%rdi
mov    %rbx,%rsi
mov    $0x4,%edx
call   10b0 <strcmpN@plt>
test   %eax,%eax
je     123c <parser+0x9c>
cmpb   $0x2e,(%rbx)
jne    120a <parser+0x6a>
cmpb   $0x5c,0x1(%rbx)
jne    120a <parser+0x6a>
add    $0x2,%rbx
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <run@plt>
xor    %eax,%eax
pop    %rbx
jmp    1090 <helpShell@plt>
xor    %eax,%eax
pop    %rbx
jmp    1060 <clearShell@plt>
lea    0xe02(%rip),%rdi
mov    %rbx,%rsi
mov    $0x3,%edx
call   10b0 <strcmpN@plt>
test   %eax,%eax
je     125b <parser+0xbb>
lea    0xdee(%rip),%rdi
mov    %rbx,%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
je     1270 <parser+0xd0>
cmpb   $0xa,(%rbx)
jne    1278 <parser+0xd8>
pop    %rbx
ret
add    $0x5,%rbx
lea    0xdc9(%rip),%rdi
mov    %rbx,%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
je     1268 <parser+0xc8>
xor    %eax,%eax
pop    %rbx
jmp    10a0 <echoShellOFF@plt>
add    $0x4,%rbx
mov    %rbx,%rdi
pop    %rbx
jmp    1040 <man@plt>
xor    %eax,%eax
pop    %rbx
jmp    1080 <echoShellON@plt>
xor    %eax,%eax
pop    %rbx
jmp    1050 <ls@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    10c0 <error@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"help\00"
@.str.1 = [6 x i8] c"clear\00"
@.str.2 = [5 x i8] c"echo\00"
@.str.3 = [3 x i8] c"on\00"
@.str.4 = [4 x i8] c"man\00"
@.str.5 = [3 x i8] c"ls\00"
define void @parser(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = call i32 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %3)
%5 = icmp ne i32 %4, 0
br i1 %5, label %8, label %6
6: ; preds = %1
%7 = call i32 (...) @helpShell()
br label %65
8: ; preds = %1
%9 = load i8*, i8** %2
%10 = call i32 @strcmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = icmp ne i32 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %8
%13 = call i32 (...) @clearShell()
br label %65
14: ; preds = %8
%15 = load i8*, i8** %2
%16 = call i32 @strcmpN(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %15, i32 4)
%17 = icmp ne i32 %16, 0
br i1 %17, label %27, label %18
18: ; preds = %14
%19 = load i8*, i8** %2
%20 = getelementptr inbounds i8, i8* %19, i64 5
%21 = call i32 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %20)
%22 = icmp ne i32 %21, 0
br i1 %22, label %25, label %23
23: ; preds = %18
%24 = call i32 (...) @echoShellON()
br label %65
25: ; preds = %18
%26 = call i32 (...) @echoShellOFF()
br label %65
27: ; preds = %14
%28 = load i8*, i8** %2
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 46
br i1 %31, label %32, label %42
32: ; preds = %27
%33 = load i8*, i8** %2
%34 = getelementptr inbounds i8, i8* %33, i64 1
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 92
br i1 %37, label %38, label %42
38: ; preds = %32
%39 = load i8*, i8** %2
%40 = getelementptr inbounds i8, i8* %39, i64 2
%41 = call i32 @run(i8* %40)
br label %65
42: ; preds = %32, %27
%43 = load i8*, i8** %2
%44 = call i32 @strcmpN(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %43, i32 3)
%45 = icmp ne i32 %44, 0
br i1 %45, label %50, label %46
46: ; preds = %42
%47 = load i8*, i8** %2
%48 = getelementptr inbounds i8, i8* %47, i64 4
%49 = call i32 @man(i8* %48)
br label %65
50: ; preds = %42
%51 = load i8*, i8** %2
%52 = call i32 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %51)
%53 = icmp ne i32 %52, 0
br i1 %53, label %56, label %54
54: ; preds = %50
%55 = call i32 (...) @ls()
br label %65
56: ; preds = %50
%57 = load i8*, i8** %2
%58 = load i8, i8* %57
%59 = sext i8 %58 to i32
%60 = icmp eq i32 %59, 10
br i1 %60, label %61, label %62
61: ; preds = %56
br label %65
62: ; preds = %56
%63 = load i8*, i8** %2
%64 = call i32 @error(i8* %63)
br label %65
65: ; preds = %62, %61, %54, %46, %38, %25, %23, %12, %6
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"help\00"
@.str.1 = [6 x i8] c"clear\00"
@.str.2 = [5 x i8] c"echo\00"
@.str.3 = [3 x i8] c"on\00"
@.str.4 = [4 x i8] c"man\00"
@.str.5 = [3 x i8] c"ls\00"
define void @parser(i8* %0) {
%2 = tail call i32 @strcmp(i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* dereferenceable(1) %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 (...) @helpShell()
br label %48
6: ; preds = %1
%7 = tail call i32 @strcmp(i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* dereferenceable(1) %0)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = tail call i32 (...) @clearShell()
br label %48
11: ; preds = %6
%12 = tail call i32 @strcmpN(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %0, i32 4)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %22
14: ; preds = %11
%15 = getelementptr inbounds i8, i8* %0, i64 5
%16 = tail call i32 @strcmp(i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %15)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = tail call i32 (...) @echoShellON()
br label %48
20: ; preds = %14
%21 = tail call i32 (...) @echoShellOFF()
br label %48
22: ; preds = %11
%23 = load i8, i8* %0
%24 = icmp eq i8 %23, 46
br i1 %24, label %25, label %32
25: ; preds = %22
%26 = getelementptr inbounds i8, i8* %0, i64 1
%27 = load i8, i8* %26
%28 = icmp eq i8 %27, 92
br i1 %28, label %29, label %32
29: ; preds = %25
%30 = getelementptr inbounds i8, i8* %0, i64 2
%31 = tail call i32 @run(i8* %30)
br label %48
32: ; preds = %25, %22
%33 = tail call i32 @strcmpN(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %0, i32 3)
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %32
%36 = getelementptr inbounds i8, i8* %0, i64 4
%37 = tail call i32 @man(i8* %36)
br label %48
38: ; preds = %32
%39 = tail call i32 @strcmp(i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %0)
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %38
%42 = tail call i32 (...) @ls()
br label %48
43: ; preds = %38
%44 = load i8, i8* %0
%45 = icmp eq i8 %44, 10
br i1 %45, label %48, label %46
46: ; preds = %43
%47 = tail call i32 @error(i8* %0)
br label %48
48: ; preds = %43, %46, %41, %35, %29, %20, %18, %9, %4
ret void
}