#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 execute(char *);
int /*<<< orphan*/ fgets_eof(char *, int);
int /*<<< orphan*/ init_script();
int /*<<< orphan*/ print_message();
int /*<<< orphan*/ printf(char *, ...);
int main() {
  init_script();
  print_message();
  char linebuf[0x1000];
  int errorno;
  while (1) {
    printf(">> ");
    fgets_eof(linebuf, 0x1000);
    if (errorno = execute(linebuf)) {
      printf("error occured, eno=%d\n", errorno);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1020,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1060 <init_script@plt>
mov    $0x0,%al
call   1030 <print_message@plt>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x1010(%rbp),%rdi
mov    $0x1000,%esi
call   1070 <fgets_eof@plt>
lea    -0x1010(%rbp),%rdi
call   1050 <execute@plt>
mov    %eax,-0x1014(%rbp)
cmp    $0x0,%eax
je     11be <main+0x6e>
mov    -0x1014(%rbp),%esi
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1170 <main+0x20>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x1000,%rsp
xor    %eax,%eax
call   1060 <init_script@plt>
xor    %eax,%eax
call   1030 <print_message@plt>
lea    0xe8f(%rip),%r14
mov    %rsp,%rbx
lea    0xe89(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x1000,%esi
call   1070 <fgets_eof@plt>
mov    %rbx,%rdi
call   1050 <execute@plt>
test   %eax,%eax
je     1180 <main+0x30>
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1180 <main+0x30>

LLVM IR (-O0):
@.str = [4 x i8] c">> \00"
@.str.1 = [23 x i8] c"error occured, eno=%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4096 x i8]
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (...) @init_script()
%5 = call i32 (...) @print_message()
br label %6
6: ; preds = %0, %16
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%9 = call i32 @fgets_eof(i8* %8, i32 4096)
%10 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%11 = call i32 @execute(i8* %10)
store i32 %11, i32* %3
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %6
%14 = load i32, i32* %3
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %13, %6
br label %6
}

LLVM IR (-O2):
@.str = [4 x i8] c">> \00"
@.str.1 = [23 x i8] c"error occured, eno=%d\0A\00"
define i32 @main() {
%1 = alloca [4096 x i8]
%2 = tail call i32 (...) @init_script()
%3 = tail call i32 (...) @print_message()
%4 = getelementptr inbounds [4096 x i8], [4096 x i8]* %1, i64 0, i64 0
br label %5
5: ; preds = %12, %0
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @fgets_eof(i8* %4, i32 4096)
%8 = call i32 @execute(i8* %4)
%9 = icmp eq i32 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %5
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %8)
br label %12
12: ; preds = %10, %5
br label %5
}