#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*/ forgetCommand();
int /*<<< orphan*/ formatCommand(char *, int, char **);
int /*<<< orphan*/ learnCommand();
int /*<<< orphan*/ listCommands();
int /*<<< orphan*/ runCommand(char *);
scalar_t__ strcasecmp(char *, char *);
int /*<<< orphan*/ system(char *);
int main(int argc, char **argv) {
  if (argc == 1) {
    system("echo \"Yes, $(whoami)? :)\"");
  } else if (argc >= 2) {
    char command[100];
    formatCommand(command, argc, argv);
    if (strcasecmp(command, "learn command") == 0) {
      learnCommand();
    } else if (strcasecmp(command, "forget command") == 0) {
      forgetCommand();
    } else if (strcasecmp(command, "list commands") == 0) {
      listCommands();
    } else {
      runCommand(command);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    11a4 <main+0x34>
lea    0xe66(%rip),%rdi
call   1070 <system@plt>
jmp    124d <main+0xdd>
cmpl   $0x2,-0x8(%rbp)
jl     1248 <main+0xd8>
lea    -0x80(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1060 <formatCommand@plt>
lea    -0x80(%rbp),%rdi
lea    0xe51(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11e4 <main+0x74>
mov    $0x0,%al
call   1050 <learnCommand@plt>
jmp    1243 <main+0xd3>
lea    -0x80(%rbp),%rdi
lea    0xe39(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    120a <main+0x9a>
mov    $0x0,%al
call   1040 <forgetCommand@plt>
jmp    123e <main+0xce>
lea    -0x80(%rbp),%rdi
lea    0xe22(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1230 <main+0xc0>
mov    $0x0,%al
call   1080 <listCommands@plt>
jmp    1239 <main+0xc9>
lea    -0x80(%rbp),%rdi
call   1090 <runCommand@plt>
jmp    123e <main+0xce>
jmp    1243 <main+0xd3>
jmp    1248 <main+0xd8>
jmp    124d <main+0xdd>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x70,%rsp
cmp    $0x1,%edi
jne    1188 <main+0x18>
lea    0xe7f(%rip),%rdi
call   1070 <system@plt>
jmp    11f9 <main+0x89>
jle    11f9 <main+0x89>
mov    %rsi,%rdx
mov    %edi,%esi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1060 <formatCommand@plt>
lea    0xe79(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11e0 <main+0x70>
lea    0xe73(%rip),%rsi
mov    %rsp,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11e9 <main+0x79>
lea    0xe6e(%rip),%rsi
mov    %rsp,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11f2 <main+0x82>
mov    %rsp,%rdi
call   1090 <runCommand@plt>
jmp    11f9 <main+0x89>
xor    %eax,%eax
call   1050 <learnCommand@plt>
jmp    11f9 <main+0x89>
xor    %eax,%eax
call   1040 <forgetCommand@plt>
jmp    11f9 <main+0x89>
xor    %eax,%eax
call   1080 <listCommands@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [26 x i8] c"echo \22Yes, $(whoami)? :)\22\00"
@.str.1 = [14 x i8] c"learn command\00"
@.str.2 = [15 x i8] c"forget command\00"
@.str.3 = [14 x i8] c"list commands\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [100 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 @system(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %43
11: ; preds = %2
%12 = load i32, i32* %4
%13 = icmp sge i32 %12, 2
br i1 %13, label %14, label %42
14: ; preds = %11
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%16 = load i32, i32* %4
%17 = load i8**, i8*** %5
%18 = call i32 @formatCommand(i8* %15, i32 %16, i8** %17)
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%20 = call i64 @strcasecmp(i8* %19, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %14
%23 = call i32 (...) @learnCommand()
br label %41
24: ; preds = %14
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%26 = call i64 @strcasecmp(i8* %25, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %24
%29 = call i32 (...) @forgetCommand()
br label %40
30: ; preds = %24
%31 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%32 = call i64 @strcasecmp(i8* %31, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %30
%35 = call i32 (...) @listCommands()
br label %39
36: ; preds = %30
%37 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%38 = call i32 @runCommand(i8* %37)
br label %39
39: ; preds = %36, %34
br label %40
40: ; preds = %39, %28
br label %41
41: ; preds = %40, %22
br label %42
42: ; preds = %41, %11
br label %43
43: ; preds = %42, %9
ret i32 0
}

LLVM IR (-O2):
@.str = [26 x i8] c"echo \22Yes, $(whoami)? :)\22\00"
@.str.1 = [14 x i8] c"learn command\00"
@.str.2 = [15 x i8] c"forget command\00"
@.str.3 = [14 x i8] c"list commands\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [100 x i8]
%4 = icmp eq i32 %0, 1
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @system(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %29
7: ; preds = %2
%8 = icmp sgt i32 %0, 1
br i1 %8, label %9, label %29
9: ; preds = %7
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%11 = call i32 @formatCommand(i8* %10, i32 %0, i8** %1)
%12 = call i64 @strcasecmp(i8* %10, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = call i32 (...) @learnCommand()
br label %28
16: ; preds = %9
%17 = call i64 @strcasecmp(i8* %10, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = call i32 (...) @forgetCommand()
br label %28
21: ; preds = %16
%22 = call i64 @strcasecmp(i8* %10, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = call i32 (...) @listCommands()
br label %28
26: ; preds = %21
%27 = call i32 @runCommand(i8* %10)
br label %28
28: ; preds = %19, %26, %24, %14
br label %29
29: ; preds = %7, %28, %5
ret i32 0
}