#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*/ SIGINT;
int /*<<< orphan*/ SIGQUIT;
int /*<<< orphan*/ SIG_IGN;
int execute(char **);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ freelist(char **);
char *next_cmd(char *, int /*<<< orphan*/);
int /*<<< orphan*/ signal(int /*<<< orphan*/, int /*<<< orphan*/);
char **splitline(char *);
int /*<<< orphan*/ stdin;
int main(int argc, char *argv[]) {
  char *cmdline, *prompt, **arglist;
  int result;
  prompt = ">>> ";
  signal(SIGINT, SIG_IGN);
  signal(SIGQUIT, SIG_IGN);
  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    0x2e60(%rip),%rax
mov    (%rax),%edi
mov    0x2e3f(%rip),%rax
mov    (%rax),%esi
call   1050 <signal@plt>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
mov    0x2e28(%rip),%rax
mov    (%rax),%esi
call   1050 <signal@plt>
mov    -0x20(%rbp),%rdi
mov    0x2e26(%rip),%rax
mov    (%rax),%esi
call   1080 <next_cmd@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1209 <main+0xa9>
mov    -0x18(%rbp),%rdi
call   1070 <splitline@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     11fb <main+0x9b>
mov    -0x28(%rbp),%rdi
call   1040 <execute@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
call   1060 <freelist@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
jmp    11af <main+0x4f>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
mov    0x2e58(%rip),%rbx
mov    (%rbx),%esi
call   1050 <signal@plt>
mov    0x2e52(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%esi
call   1050 <signal@plt>
mov    0x2e4a(%rip),%r12
mov    (%r12),%esi
lea    0xe5f(%rip),%rdi
call   1080 <next_cmd@plt>
test   %rax,%rax
je     11fe <main+0x9e>
mov    %rax,%rbx
lea    0xe4b(%rip),%r14
jmp    11dc <main+0x7c>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <free@plt>
mov    (%r12),%esi
mov    %r14,%rdi
call   1080 <next_cmd@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11fe <main+0x9e>
mov    %rbx,%rdi
call   1070 <splitline@plt>
test   %rax,%rax
je     11c0 <main+0x60>
mov    %rax,%r15
mov    %rax,%rdi
call   1040 <execute@plt>
mov    %r15,%rdi
call   1060 <freelist@plt>
jmp    11c0 <main+0x60>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c">>> \00"
@SIGINT = global i32 0
@SIG_IGN = global i32 0
@SIGQUIT = global i32 0
@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 ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %7
%10 = load i32, i32* @SIGINT
%11 = load i32, i32* @SIG_IGN
%12 = call i32 @signal(i32 %10, i32 %11)
%13 = load i32, i32* @SIGQUIT
%14 = load i32, i32* @SIG_IGN
%15 = call i32 @signal(i32 %13, i32 %14)
br label %16
16: ; preds = %30, %2
%17 = load i8*, i8** %7
%18 = load i32, i32* @stdin
%19 = call i8* @next_cmd(i8* %17, i32 %18)
store i8* %19, i8** %6
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %33
21: ; preds = %16
%22 = load i8*, i8** %6
%23 = call i8** @splitline(i8* %22)
store i8** %23, i8*** %8
%24 = icmp ne i8** %23, null
br i1 %24, label %25, label %30
25: ; preds = %21
%26 = load i8**, i8*** %8
%27 = call i32 @execute(i8** %26)
store i32 %27, i32* %9
%28 = load i8**, i8*** %8
%29 = call i32 @freelist(i8** %28)
br label %30
30: ; preds = %25, %21
%31 = load i8*, i8** %6
%32 = call i32 @free(i8* %31)
br label %16
33: ; preds = %16
ret i32 0
}

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