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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1080 <setup@plt>
mov    -0x18(%rbp),%rdi
mov    0x2e5c(%rip),%rax
mov    (%rax),%esi
call   1070 <next_cmd@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     11db <main+0x7b>
mov    -0x10(%rbp),%rdi
call   1060 <splitline@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     11cd <main+0x6d>
mov    -0x20(%rbp),%rdi
call   1040 <process@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <freelist@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
jmp    1181 <main+0x21>
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 <process@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 = [3 x i8] c"> \00"
@stdin = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8**
%5 = alloca i32
store i32 0, i32* %1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %3
br label %6
6: ; preds = %20, %0
%7 = load i8*, i8** %3
%8 = load i32, i32* @stdin
%9 = call i8* @next_cmd(i8* %7, i32 %8)
store i8* %9, i8** %2
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %23
11: ; preds = %6
%12 = load i8*, i8** %2
%13 = call i8** @splitline(i8* %12)
store i8** %13, i8*** %4
%14 = icmp ne i8** %13, null
br i1 %14, label %15, label %20
15: ; preds = %11
%16 = load i8**, i8*** %4
%17 = call i32 @process(i8** %16)
store i32 %17, i32* %5
%18 = load i8**, i8*** %4
%19 = call i32 @freelist(i8** %18)
br label %20
20: ; preds = %15, %11
%21 = load i8*, i8** %2
%22 = call i32 @free(i8* %21)
br label %6
23: ; preds = %6
ret i32 0
}

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