#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*/ getpid();
char **parse(char *);
int pool(char **);
int /*<<< orphan*/ printf(char *);
char *read_line();
int /*<<< orphan*/ signal_handler(int /*<<< orphan*/);
void shell(void) {
  int status = 1;
  while (status != -1) {
    signal_handler(getpid());
    printf(": ");
    char *line;
    char **args;
    line = read_line();
    if (line != NULL) {
      args = parse(line);
      if (args) {
        status = pool(args);
      }
    }
  }
}


x86 assembly (clang, -O0):
<shell>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x1,-0x4(%rbp)
cmpl   $0xffffffff,-0x4(%rbp)
je     11d7 <shell+0x77>
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,%edi
call   1060 <signal_handler@plt>
lea    0xe72(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <read_line@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11d2 <shell+0x72>
mov    -0x10(%rbp),%rdi
call   1080 <parse@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11cd <shell+0x6d>
mov    -0x18(%rbp),%rdi
call   1030 <pool@plt>
mov    %eax,-0x4(%rbp)
jmp    11d2 <shell+0x72>
jmp    116f <shell+0xf>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shell>:
push   %rbp
push   %rbx
push   %rax
mov    $0x1,%ebp
lea    0xe91(%rip),%rbx
jmp    1185 <shell+0x25>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmp    $0xffffffff,%ebp
je     11c0 <shell+0x60>
xor    %eax,%eax
call   1040 <getpid@plt>
mov    %eax,%edi
call   1060 <signal_handler@plt>
mov    %rbx,%rdi
call   1050 <printf@plt>
xor    %eax,%eax
call   1070 <read_line@plt>
test   %rax,%rax
je     1180 <shell+0x20>
mov    %rax,%rdi
call   1080 <parse@plt>
test   %rax,%rax
je     1180 <shell+0x20>
mov    %rax,%rdi
call   1030 <pool@plt>
mov    %eax,%ebp
jmp    1180 <shell+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c": \00"
define void @shell() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8**
store i32 1, i32* %1
br label %4
4: ; preds = %23, %0
%5 = load i32, i32* %1
%6 = icmp ne i32 %5, -1
br i1 %6, label %7, label %24
7: ; preds = %4
%8 = call i32 (...) @getpid()
%9 = call i32 @signal_handler(i32 %8)
%10 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%11 = call i8* (...) @read_line()
store i8* %11, i8** %2
%12 = load i8*, i8** %2
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %23
14: ; preds = %7
%15 = load i8*, i8** %2
%16 = call i8** @parse(i8* %15)
store i8** %16, i8*** %3
%17 = load i8**, i8*** %3
%18 = icmp ne i8** %17, null
br i1 %18, label %19, label %22
19: ; preds = %14
%20 = load i8**, i8*** %3
%21 = call i32 @pool(i8** %20)
store i32 %21, i32* %1
br label %22
22: ; preds = %19, %14
br label %23
23: ; preds = %22, %7
br label %4
24: ; preds = %4
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c": \00"
define void @shell() {
br label %1
1: ; preds = %0, %13
%2 = phi i32 [ 1, %0 ], [ %14, %13 ]
%3 = tail call i32 (...) @getpid()
%4 = tail call i32 @signal_handler(i32 %3)
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = tail call i8* (...) @read_line()
%7 = icmp eq i8* %6, null
br i1 %7, label %13, label %8
8: ; preds = %1
%9 = tail call i8** @parse(i8* %6)
%10 = icmp eq i8** %9, null
br i1 %10, label %13, label %11
11: ; preds = %8
%12 = tail call i32 @pool(i8** %9)
br label %13
13: ; preds = %8, %11, %1
%14 = phi i32 [ %12, %11 ], [ %2, %8 ], [ %2, %1 ]
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %1
16: ; preds = %13
ret void
}