#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 execute(char **);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ freelist(char **);
char *next_cmd(char *, int /*<<< orphan*/);
int /*<<< orphan*/ setup();
char **splitline(char *);
int /*<<< orphan*/ stdin;
int main(int argc, char *argv[]) {
  char *cmdline, *prompt, **arglist;
  int result;
  prompt = (char *)">";
  setup();
  while ((cmdline = next_cmd(prompt, stdin)) != NULL) {
    if ((arglist = splitline(cmdline)) != NULL) {
      result = execute(arglist);
      freelist(arglist);
    }
    free(cmdline);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe83(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1080 <setup@plt>
mov    -0x20(%rbp),%rdi
mov    0x2e55(%rip),%rax
mov    (%rax),%esi
call   1070 <next_cmd@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11e2 <main+0x82>
mov    -0x18(%rbp),%rdi
call   1060 <splitline@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     11d4 <main+0x74>
mov    -0x28(%rbp),%rdi
call   1040 <execute@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <freelist@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
jmp    1188 <main+0x28>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1080 <setup@plt>
mov    0x2e72(%rip),%r12
mov    (%r12),%esi
lea    0xe7f(%rip),%rdi
call   1070 <next_cmd@plt>
test   %rax,%rax
je     11de <main+0x7e>
mov    %rax,%rbx
lea    0xe6b(%rip),%r14
jmp    11bc <main+0x5c>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <free@plt>
mov    (%r12),%esi
mov    %r14,%rdi
call   1070 <next_cmd@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11de <main+0x7e>
mov    %rbx,%rdi
call   1060 <splitline@plt>
test   %rax,%rax
je     11a0 <main+0x40>
mov    %rax,%r15
mov    %rax,%rdi
call   1040 <execute@plt>
mov    %r15,%rdi
call   1050 <freelist@plt>
jmp    11a0 <main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c">\00"
@stdin = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8**
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %7
%10 = call i32 (...) @setup()
br label %11
11: ; preds = %25, %2
%12 = load i8*, i8** %7
%13 = load i32, i32* @stdin
%14 = call i8* @next_cmd(i8* %12, i32 %13)
store i8* %14, i8** %6
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %28
16: ; preds = %11
%17 = load i8*, i8** %6
%18 = call i8** @splitline(i8* %17)
store i8** %18, i8*** %8
%19 = icmp ne i8** %18, null
br i1 %19, label %20, label %25
20: ; preds = %16
%21 = load i8**, i8*** %8
%22 = call i32 @execute(i8** %21)
store i32 %22, i32* %9
%23 = load i8**, i8*** %8
%24 = call i32 @freelist(i8** %23)
br label %25
25: ; preds = %20, %16
%26 = load i8*, i8** %6
%27 = call i32 @free(i8* %26)
br label %11
28: ; preds = %11
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c">\00"
@stdin = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @setup()
%4 = load i32, i32* @stdin
%5 = tail call i8* @next_cmd(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = icmp eq i8* %5, null
br i1 %6, label %19, label %7
7: ; preds = %2, %14
%8 = phi i8* [ %17, %14 ], [ %5, %2 ]
%9 = tail call i8** @splitline(i8* %8)
%10 = icmp eq i8** %9, null
br i1 %10, label %14, label %11
11: ; preds = %7
%12 = tail call i32 @execute(i8** %9)
%13 = tail call i32 @freelist(i8** %9)
br label %14
14: ; preds = %11, %7
%15 = tail call i32 @free(i8* %8)
%16 = load i32, i32* @stdin
%17 = tail call i8* @next_cmd(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %7
19: ; preds = %14, %2
ret i32 0
}