#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*/ STDIN_FILENO;
int /*<<< orphan*/ display_prompt();
int /*<<< orphan*/ feof(int /*<<< orphan*/);
scalar_t__ isatty(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ run_command_line();
int /*<<< orphan*/ stdin;
int main(int argc, char **argv) {
  while (!feof(stdin)) {
    if (isatty(STDIN_FILENO))
      display_prompt();
    run_command_line();
  }
  printf("\n");
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e7b(%rip),%rax
mov    (%rax),%edi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1189 <main+0x39>
jmp    11b4 <main+0x64>
mov    0x2e40(%rip),%rax
mov    (%rax),%edi
call   1030 <isatty@plt>
cmp    $0x0,%rax
je     11a8 <main+0x58>
mov    $0x0,%al
call   1070 <display_prompt@plt>
mov    $0x0,%al
call   1040 <run_command_line@plt>
jmp    1166 <main+0x16>
lea    0xe45(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e11(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    0x2e8d(%rip),%r14
mov    (%r14),%edi
call   1060 <feof@plt>
test   %eax,%eax
je     1182 <main+0x32>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x2e60(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e47(%rip),%rbx
jmp    11a3 <main+0x53>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <run_command_line@plt>
mov    (%r14),%edi
call   1060 <feof@plt>
test   %eax,%eax
jne    1167 <main+0x17>
mov    (%rbx),%edi
call   1040 <isatty@plt>
test   %rax,%rax
je     1190 <main+0x40>
xor    %eax,%eax
call   1070 <display_prompt@plt>
jmp    1190 <main+0x40>

LLVM IR (-O0):
@stdin = global i32 0
@STDIN_FILENO = global i32 0
@.str = [2 x i8] c"\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %6
6: ; preds = %17, %2
%7 = load i32, i32* @stdin
%8 = call i32 @feof(i32 %7)
%9 = icmp ne i32 %8, 0
%10 = xor i1 %9, true
br i1 %10, label %11, label %19
11: ; preds = %6
%12 = load i32, i32* @STDIN_FILENO
%13 = call i64 @isatty(i32 %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = call i32 (...) @display_prompt()
br label %17
17: ; preds = %15, %11
%18 = call i32 (...) @run_command_line()
br label %6
19: ; preds = %6
%20 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%21 = load i32, i32* @EXIT_SUCCESS
ret i32 %21
}

LLVM IR (-O2):
@stdin = global i32 0
@STDIN_FILENO = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @stdin
%4 = tail call i32 @feof(i32 %3)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %17
6: ; preds = %2, %12
%7 = load i32, i32* @STDIN_FILENO
%8 = tail call i64 @isatty(i32 %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %6
%11 = tail call i32 (...) @display_prompt()
br label %12
12: ; preds = %10, %6
%13 = tail call i32 (...) @run_command_line()
%14 = load i32, i32* @stdin
%15 = tail call i32 @feof(i32 %14)
%16 = icmp eq i32 %15, 0
br i1 %16, label %6, label %17
17: ; preds = %12, %2
%18 = tail call i32 @putchar(i32 10)
%19 = load i32, i32* @EXIT_SUCCESS
ret i32 %19
}