#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*/ printf(char *);
int read_line(int /*<<< orphan*/, char *);
scalar_t__ shell_repl(char *, int);
int /*<<< orphan*/ stdin;
int run_interactive() {
  char buf[1024];
  int buf_len;
  do {
    printf("SANIC TEEM> ");
    if ((buf_len = read_line(stdin, buf)) <= 0) {
      return buf_len;
    }
  } while (shell_repl(buf, buf_len - 1));
  return 0;
}


x86 assembly (clang, -O0):
<run_interactive>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
lea    0xebe(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e9a(%rip),%rax
mov    (%rax),%edi
lea    -0x410(%rbp),%rsi
call   1050 <read_line@plt>
mov    %eax,-0x414(%rbp)
cmp    $0x0,%eax
jg     1179 <run_interactive+0x49>
mov    -0x414(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11a4 <run_interactive+0x74>
jmp    117e <run_interactive+0x4e>
lea    -0x410(%rbp),%rdi
mov    -0x414(%rbp),%esi
sub    $0x1,%esi
call   1040 <shell_repl@plt>
cmp    $0x0,%rax
jne    113b <run_interactive+0xb>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_interactive>:
push   %r15
push   %r14
push   %rbx
sub    $0x400,%rsp
lea    0xebd(%rip),%r14
mov    0x2e9e(%rip),%r15
mov    %rsp,%rbx
nopl   (%rax)
mov    %r14,%rdi
call   1030 <printf@plt>
mov    (%r15),%edi
mov    %rbx,%rsi
call   1050 <read_line@plt>
test   %eax,%eax
jle    117b <run_interactive+0x4b>
add    $0xffffffff,%eax
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <shell_repl@plt>
test   %rax,%rax
jne    1150 <run_interactive+0x20>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [13 x i8] c"SANIC TEEM> \00"
@stdin = global i32 0
define i32 @run_interactive() {
%1 = alloca i32
%2 = alloca [1024 x i8]
%3 = alloca i32
br label %4
4: ; preds = %13, %0
%5 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* @stdin
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%8 = call i32 @read_line(i32 %6, i8* %7)
store i32 %8, i32* %3
%9 = icmp sle i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %4
%11 = load i32, i32* %3
store i32 %11, i32* %1
br label %20
12: ; preds = %4
br label %13
13: ; preds = %12
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%15 = load i32, i32* %3
%16 = sub nsw i32 %15, 1
%17 = call i64 @shell_repl(i8* %14, i32 %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %4, label %19
19: ; preds = %13
store i32 0, i32* %1
br label %20
20: ; preds = %19, %10
%21 = load i32, i32* %1
ret i32 %21
}

LLVM IR (-O2):
@.str = [13 x i8] c"SANIC TEEM> \00"
@stdin = global i32 0
define i32 @run_interactive() {
%1 = alloca [1024 x i8]
%2 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
br label %3
3: ; preds = %8, %0
%4 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* @stdin
%6 = call i32 @read_line(i32 %5, i8* %2)
%7 = icmp slt i32 %6, 1
br i1 %7, label %12, label %8
8: ; preds = %3
%9 = add nsw i32 %6, -1
%10 = call i64 @shell_repl(i8* %2, i32 %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %3
12: ; preds = %8, %3
%13 = phi i32 [ %6, %3 ], [ 0, %8 ]
ret i32 %13
}