#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*/ fileno(int /*<<< orphan*/);
scalar_t__ gets(char *);
scalar_t__ isatty(int /*<<< orphan*/);
int /*<<< orphan*/ lua_dofile(int /*<<< orphan*/ *);
int /*<<< orphan*/ lua_dostring(char *);
int /*<<< orphan*/ stdin;
void manual_input(void) {
  if (isatty(fileno(stdin))) {
    char buffer[250];
    while (gets(buffer) != 0)
      lua_dostring(buffer);
  } else
    lua_dofile(NULL);
}


x86 assembly (clang, -O0):
<manual_input>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
call   1060 <fileno@plt>
mov    %eax,%edi
call   1030 <isatty@plt>
cmp    $0x0,%rax
je     11ab <manual_input+0x5b>
jmp    117f <manual_input+0x2f>
lea    -0x100(%rbp),%rdi
call   1070 <gets@plt>
cmp    $0x0,%rax
je     11a6 <manual_input+0x56>
lea    -0x100(%rbp),%rdi
call   1040 <lua_dostring@plt>
jmp    117f <manual_input+0x2f>
jmp    11b4 <manual_input+0x64>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <lua_dofile@plt>
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<manual_input>:
push   %rbx
sub    $0x100,%rsp
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
call   1060 <fileno@plt>
mov    %eax,%edi
call   1030 <isatty@plt>
test   %rax,%rax
je     11ae <manual_input+0x5e>
mov    %rsp,%rdi
call   1070 <gets@plt>
test   %rax,%rax
je     11a5 <manual_input+0x55>
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1040 <lua_dostring@plt>
mov    %rbx,%rdi
call   1070 <gets@plt>
test   %rax,%rax
jne    1190 <manual_input+0x40>
add    $0x100,%rsp
pop    %rbx
ret
xor    %edi,%edi
add    $0x100,%rsp
pop    %rbx
jmp    1050 <lua_dofile@plt>

LLVM IR (-O0):
@stdin = global i32 0
define void @manual_input() {
%1 = alloca [250 x i8]
%2 = load i32, i32* @stdin
%3 = call i32 @fileno(i32 %2)
%4 = call i64 @isatty(i32 %3)
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %15
6: ; preds = %0
br label %7
7: ; preds = %11, %6
%8 = getelementptr inbounds [250 x i8], [250 x i8]* %1, i64 0, i64 0
%9 = call i64 @gets(i8* %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %7
%12 = getelementptr inbounds [250 x i8], [250 x i8]* %1, i64 0, i64 0
%13 = call i32 @lua_dostring(i8* %12)
br label %7
14: ; preds = %7
br label %17
15: ; preds = %0
%16 = call i32 @lua_dofile(i32* null)
br label %17
17: ; preds = %15, %14
ret void
}

LLVM IR (-O2):
@stdin = global i32 0
define void @manual_input() {
%1 = alloca [250 x i8]
%2 = load i32, i32* @stdin
%3 = tail call i32 @fileno(i32 %2)
%4 = tail call i64 @isatty(i32 %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %15, label %6
6: ; preds = %0
%7 = getelementptr inbounds [250 x i8], [250 x i8]* %1, i64 0, i64 0
%8 = call i64 @gets(i8* %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %6, %10
%11 = call i32 @lua_dostring(i8* %7)
%12 = call i64 @gets(i8* %7)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %10
14: ; preds = %10, %6
br label %17
15: ; preds = %0
%16 = tail call i32 @lua_dofile(i32* null)
br label %17
17: ; preds = %15, %14
ret void
}