#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*/ execute(char **);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ parse(char *, char **);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ read_line(char *);
scalar_t__ strcmp(char *, char *);
int main(void) {
  char line[256];
  char *argv[256];
  printf("<<< welcome to craSh - a very simple command interpreter >>>\n");
  while (true) {
    printf("craSh> ");
    read_line(line);
    parse(line, argv);
    if (strcmp(argv[0], "exit") == 0)
      exit(0);
    execute(argv);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x910,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe87(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
lea    -0x110(%rbp),%rdi
call   1060 <read_line@plt>
lea    -0x110(%rbp),%rdi
lea    -0x910(%rbp),%rsi
call   1070 <parse@plt>
mov    -0x910(%rbp),%rdi
lea    0xe8f(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11cd <main+0x6d>
xor    %edi,%edi
call   1080 <exit@plt>
lea    -0x910(%rbp),%rdi
call   1040 <execute@plt>
jmp    117e <main+0x1e>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x908,%rsp
lea    0xe88(%rip),%rdi
call   1030 <puts@plt>
lea    0xe6f(%rip),%rdi
call   1040 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1070 <read_line@plt>
lea    0x100(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <parse@plt>
mov    0x100(%rsp),%rdi
lea    0xe48(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1228 <main+0xb8>
lea    0x100(%rsp),%r15
lea    0xe27(%rip),%r14
mov    %rsp,%rbx
lea    0xe25(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15,%rdi
call   1050 <execute@plt>
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1070 <read_line@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <parse@plt>
mov    0x100(%rsp),%rdi
mov    %r12,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    11f0 <main+0x80>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [62 x i8] c"<<< welcome to craSh - a very simple command interpreter >>>\0A\00"
@.str.1 = [8 x i8] c"craSh> \00"
@.str.2 = [5 x i8] c"exit\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [256 x i8]
%3 = alloca [256 x i8*]
store i32 0, i32* %1
%4 = call i32 @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %0, %18
%6 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%8 = call i32 @read_line(i8* %7)
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%10 = getelementptr inbounds [256 x i8*], [256 x i8*]* %3, i64 0, i64 0
%11 = call i32 @parse(i8* %9, i8** %10)
%12 = getelementptr inbounds [256 x i8*], [256 x i8*]* %3, i64 0, i64 0
%13 = load i8*, i8** %12
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %5
%17 = call i32 @exit(i32 0)
unreachable
18: ; preds = %5
%19 = getelementptr inbounds [256 x i8*], [256 x i8*]* %3, i64 0, i64 0
%20 = call i32 @execute(i8** %19)
br label %5
}

LLVM IR (-O2):
@.str.1 = [8 x i8] c"craSh> \00"
@.str.2 = [5 x i8] c"exit\00"
@str = [61 x i8] c"<<< welcome to craSh - a very simple command interpreter >>>\00"
define i32 @main() {
%1 = alloca [256 x i8]
%2 = alloca [256 x i8*]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%4 = bitcast [256 x i8*]* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @str, i64 0, i64 0))
%6 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @read_line(i8* %3)
%8 = getelementptr inbounds [256 x i8*], [256 x i8*]* %2, i64 0, i64 0
%9 = call i32 @parse(i8* %3, i8** %8)
%10 = load i8*, i8** %8
%11 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %15, %0
%14 = call i32 @exit(i32 0)
unreachable
15: ; preds = %0, %15
%16 = call i32 @execute(i8** %8)
%17 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 @read_line(i8* %3)
%19 = call i32 @parse(i8* %3, i8** %8)
%20 = load i8*, i8** %8
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %13, label %15
}