#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 */
typedef int /*<<< orphan*/ ssize_t;

/* Variables and functions */
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ getline(char **, int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int run_command(char *);
int /*<<< orphan*/ stdin;
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  char *line;
  ssize_t buffer_size;
  int status;
  do {
    line = NULL;
    buffer_size = 0;
    printf("SQ> ");
    getline(&line, &buffer_size, stdin);
    if (strcmp(line, "exit\n") == 0)
      status = 0;
    else
      status = run_command(line);
    free(line);
  } while (status);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xe84(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e60(%rip),%rax
mov    (%rax),%edx
lea    -0x18(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
call   1070 <getline@plt>
mov    -0x18(%rbp),%rdi
lea    0xe63(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11bd <main+0x6d>
movl   $0x0,-0x20(%rbp)
jmp    11c9 <main+0x79>
mov    -0x18(%rbp),%rdi
call   1060 <run_command@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0x0,-0x20(%rbp)
jne    1166 <main+0x16>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe9b(%rip),%r14
mov    0x2e7c(%rip),%r13
lea    0x8(%rsp),%r15
lea    0x14(%rsp),%r12
lea    0xe88(%rip),%rbx
nopl   (%rax)
movq   $0x0,0x8(%rsp)
movl   $0x0,0x14(%rsp)
mov    %r14,%rdi
call   1040 <printf@plt>
mov    0x0(%r13),%edx
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <getline@plt>
mov    0x8(%rsp),%rdi
mov    %rbx,%rsi
call   1050 <strcmp@plt>
mov    0x8(%rsp),%rdi
test   %rax,%rax
je     11d6 <main+0x86>
call   1060 <run_command@plt>
mov    %eax,%ebp
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
test   %ebp,%ebp
jne    1180 <main+0x30>
jmp    11db <main+0x8b>
call   1030 <free@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"SQ> \00"
@stdin = global i32 0
@.str.1 = [6 x i8] c"exit\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = bitcast i8** %3 to i8*
%6 = bitcast i32* %4 to i8*
br label %7
7: ; preds = %17, %2
store i8* null, i8** %3
store i32 0, i32* %4
%8 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* @stdin
%10 = call i32 @getline(i8** %3, i32* %4, i32 %9)
%11 = load i8*, i8** %3
%12 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
%14 = load i8*, i8** %3
br i1 %13, label %15, label %17
15: ; preds = %7
%16 = call i32 @free(i8* %14)
br label %22
17: ; preds = %7
%18 = call i32 @run_command(i8* %14)
%19 = load i8*, i8** %3
%20 = call i32 @free(i8* %19)
%21 = icmp eq i32 %18, 0
br i1 %21, label %22, label %7
22: ; preds = %17, %15
ret i32 0
}