#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 EXIT_SUCCESS;
int /*<<< orphan*/ evaluate(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ prompt();
int /*<<< orphan*/ read(char *);
int /*<<< orphan*/ strlen(char *);
int main(void) {
  char line[1000];
  while (1) {
    prompt();
    read(line);
    if (!strlen(line)) {
      break;
    }
    evaluate(line);
  }
  printf("Bye.\n");
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3f0,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <prompt@plt>
lea    -0x3f0(%rbp),%rdi
call   1060 <read@plt>
lea    -0x3f0(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%eax
jne    118f <main+0x3f>
jmp    11a0 <main+0x50>
lea    -0x3f0(%rbp),%rdi
call   1070 <evaluate@plt>
jmp    1162 <main+0x12>
lea    0xe59(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e2d(%rip),%rax
mov    (%rax),%eax
add    $0x3f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x3f0,%rsp
xor    %eax,%eax
call   1040 <prompt@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1060 <read@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
je     11a3 <main+0x53>
mov    %rsp,%rbx
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1070 <evaluate@plt>
xor    %eax,%eax
call   1040 <prompt@plt>
mov    %rbx,%rdi
call   1060 <read@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jne    1180 <main+0x30>
lea    0xe56(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e2a(%rip),%rax
mov    (%rax),%eax
add    $0x3f0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"Bye.\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [1000 x i8]
store i32 0, i32* %1
br label %3
3: ; preds = %0, %11
%4 = call i32 (...) @prompt()
%5 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%6 = call i32 @read(i8* %5)
%7 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%8 = call i32 @strlen(i8* %7)
%9 = icmp ne i32 %8, 0
br i1 %9, label %11, label %10
10: ; preds = %3
br label %14
11: ; preds = %3
%12 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%13 = call i32 @evaluate(i8* %12)
br label %3
14: ; preds = %10
%15 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%16 = load i32, i32* @EXIT_SUCCESS
ret i32 %16
}

LLVM IR (-O2):
@EXIT_SUCCESS = global i32 0
@str = [5 x i8] c"Bye.\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%3 = call i32 (...) @prompt()
%4 = call i32 @read(i8* %2)
%5 = call i32 @strlen(i8* %2)
%6 = icmp eq i32 %5, 0
br i1 %6, label %13, label %7
7: ; preds = %0, %7
%8 = call i32 @evaluate(i8* %2)
%9 = call i32 (...) @prompt()
%10 = call i32 @read(i8* %2)
%11 = call i32 @strlen(i8* %2)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %7
13: ; preds = %7, %0
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
%15 = load i32, i32* @EXIT_SUCCESS
ret i32 %15
}