#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*/ line;

/* Variables and functions */
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ interpret(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
void repl() {
  char line[1024];
  for (;;) {
    printf("> ");
    if (!fgets(line, sizeof(line), stdin)) {
      printf("\n");
      break;
    }
    interpret(line);
  }
}


x86 assembly (clang, -O0):
<repl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
lea    0xebe(%rip),%rdi
call   1030 <printf@plt>
lea    -0x400(%rbp),%rdi
mov    0x2e93(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   1040 <fgets@plt>
cmp    $0x0,%eax
jne    117b <repl+0x4b>
lea    0xe92(%rip),%rdi
call   1030 <printf@plt>
jmp    118c <repl+0x5c>
lea    -0x400(%rbp),%rdi
call   1050 <interpret@plt>
jmp    113b <repl+0xb>
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<repl>:
push   %r15
push   %r14
push   %rbx
sub    $0x400,%rsp
lea    0xead(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e89(%rip),%r15
mov    (%r15),%edx
mov    %rsp,%rdi
mov    $0x400,%esi
call   1050 <fgets@plt>
test   %eax,%eax
je     11a4 <repl+0x64>
mov    %rsp,%rbx
lea    0xe83(%rip),%r14
nopl   (%rax)
mov    %rbx,%rdi
call   1060 <interpret@plt>
mov    %r14,%rdi
call   1040 <printf@plt>
mov    (%r15),%edx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1050 <fgets@plt>
test   %eax,%eax
jne    1180 <repl+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"> \00"
@stdin = global i32 0
@.str.1 = [2 x i8] c"\0A\00"
define void @repl() {
%1 = alloca [1024 x i8]
br label %2
2: ; preds = %10, %0
%3 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%5 = load i32, i32* @stdin
%6 = call i32 @fgets(i8* %4, i32 1024, i32 %5)
%7 = icmp ne i32 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %13
10: ; preds = %2
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%12 = call i32 @interpret(i8* %11)
br label %2
13: ; preds = %8
ret void
}

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