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


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    0xe93(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2e6c(%rip),%rax
mov    (%rax),%esi
call   1070 <next_cmd@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11c8 <main+0x78>
mov    -0x18(%rbp),%rdi
call   1060 <splitline@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     11ba <main+0x6a>
mov    -0x28(%rbp),%rdi
call   1040 <process@plt>
mov    -0x28(%rbp),%rdi
call   1050 <freelist@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
jmp    1171 <main+0x21>
mov    0x2e09(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    0x2e89(%rip),%r12
mov    (%r12),%esi
lea    0xe96(%rip),%rdi
call   1070 <next_cmd@plt>
test   %rax,%rax
je     11be <main+0x6e>
mov    %rax,%rbx
lea    0xe82(%rip),%r14
jmp    119c <main+0x4c>
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     11be <main+0x6e>
mov    %rbx,%rdi
call   1060 <splitline@plt>
test   %rax,%rax
je     1180 <main+0x30>
mov    %rax,%r15
mov    %rax,%rdi
call   1040 <process@plt>
mov    %r15,%rdi
call   1050 <freelist@plt>
jmp    1180 <main+0x30>
mov    0x2e13(%rip),%rax
mov    (%rax),%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
@EXIT_SUCCESS = 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**
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
br label %9
9: ; preds = %23, %2
%10 = load i8*, i8** %7
%11 = load i32, i32* @stdin
%12 = call i8* @next_cmd(i8* %10, i32 %11)
store i8* %12, i8** %6
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %26
14: ; preds = %9
%15 = load i8*, i8** %6
%16 = call i8** @splitline(i8* %15)
store i8** %16, i8*** %8
%17 = icmp ne i8** %16, null
br i1 %17, label %18, label %23
18: ; preds = %14
%19 = load i8**, i8*** %8
%20 = call i32 @process(i8** %19)
%21 = load i8**, i8*** %8
%22 = call i32 @freelist(i8** %21)
br label %23
23: ; preds = %18, %14
%24 = load i8*, i8** %6
%25 = call i32 @free(i8* %24)
br label %9
26: ; preds = %9
%27 = load i32, i32* @EXIT_SUCCESS
ret i32 %27
}

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