#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*/ beyondStack();
scalar_t__ cmpstr(char *, char *);
char *getLn(char *);
int /*<<< orphan*/ listProcesses();
int /*<<< orphan*/ print(char *);
int /*<<< orphan*/ printLn(char *);
void echo_main() {
  char *line;
  int flag = 1;
  while (flag) {
    line = getLn(line);
    if (!cmpstr(line, "")) {
      if (cmpstr(line, "exit")) {
        flag = 0;
      } else if (cmpstr(line, "ps")) {
        listProcesses();
      } else if (cmpstr(line, "beyond stack")) {
        beyondStack();
      } else {
        print("echo: ");
        print(line);
        printLn("");
        print("$ ");
      }
    }
  }
  printLn("");
  print("$ ");
}


x86 assembly (clang, -O0):
<echo_main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x1,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1253 <echo_main+0xf3>
mov    -0x8(%rbp),%rdi
call   1030 <getLn@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe8d(%rip),%rsi
call   1070 <cmpstr@plt>
cmp    $0x0,%rax
jne    124e <echo_main+0xee>
mov    -0x8(%rbp),%rdi
lea    0xe55(%rip),%rsi
call   1070 <cmpstr@plt>
cmp    $0x0,%rax
je     11c6 <echo_main+0x66>
movl   $0x0,-0xc(%rbp)
jmp    1249 <echo_main+0xe9>
mov    -0x8(%rbp),%rdi
lea    0xe34(%rip),%rsi
call   1070 <cmpstr@plt>
cmp    $0x0,%rax
je     11ec <echo_main+0x8c>
mov    $0x0,%al
call   1060 <listProcesses@plt>
jmp    1244 <echo_main+0xe4>
mov    -0x8(%rbp),%rdi
lea    0xe11(%rip),%rsi
call   1070 <cmpstr@plt>
cmp    $0x0,%rax
je     1212 <echo_main+0xb2>
mov    $0x0,%al
call   1080 <beyondStack@plt>
jmp    123f <echo_main+0xdf>
lea    0xdfc(%rip),%rdi
call   1040 <print@plt>
mov    -0x8(%rbp),%rdi
call   1040 <print@plt>
lea    0xdf0(%rip),%rdi
call   1050 <printLn@plt>
lea    0xde2(%rip),%rdi
call   1040 <print@plt>
jmp    1244 <echo_main+0xe4>
jmp    1249 <echo_main+0xe9>
jmp    124e <echo_main+0xee>
jmp    116f <echo_main+0xf>
lea    0xdc4(%rip),%rdi
call   1050 <printLn@plt>
lea    0xdb6(%rip),%rdi
call   1040 <print@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [5 x i8] c"exit\00"
@.str.2 = [3 x i8] c"ps\00"
@.str.3 = [13 x i8] c"beyond stack\00"
@.str.4 = [7 x i8] c"echo: \00"
@.str.5 = [3 x i8] c"$ \00"
define void @echo_main() {
%1 = alloca i8*
%2 = alloca i32
store i32 1, i32* %2
br label %3
3: ; preds = %38, %0
%4 = load i32, i32* %2
%5 = icmp ne i32 %4, 0
br i1 %5, label %6, label %39
6: ; preds = %3
%7 = load i8*, i8** %1
%8 = call i8* @getLn(i8* %7)
store i8* %8, i8** %1
%9 = load i8*, i8** %1
%10 = call i64 @cmpstr(i8* %9, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%11 = icmp ne i64 %10, 0
br i1 %11, label %38, label %12
12: ; preds = %6
%13 = load i8*, i8** %1
%14 = call i64 @cmpstr(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %12
store i32 0, i32* %2
br label %37
17: ; preds = %12
%18 = load i8*, i8** %1
%19 = call i64 @cmpstr(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = call i32 (...) @listProcesses()
br label %36
23: ; preds = %17
%24 = load i8*, i8** %1
%25 = call i64 @cmpstr(i8* %24, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %23
%28 = call i32 (...) @beyondStack()
br label %35
29: ; preds = %23
%30 = call i32 @print(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%31 = load i8*, i8** %1
%32 = call i32 @print(i8* %31)
%33 = call i32 @printLn(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%34 = call i32 @print(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %35
35: ; preds = %29, %27
br label %36
36: ; preds = %35, %21
br label %37
37: ; preds = %36, %16
br label %38
38: ; preds = %37, %6
br label %3
39: ; preds = %3
%40 = call i32 @printLn(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%41 = call i32 @print(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
ret void
}

LLVM IR (-O2):