#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*/ exit(int /*<<< orphan*/);
scalar_t__ feof(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
char getchar();
int /*<<< orphan*/ new_str_copy(char *);
int /*<<< orphan*/ push(int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
void builtin_input() {
  if (feof(stdin) != 0) {
    fprintf(stderr, "input: end of file\n");
    exit(0);
  }
  char s[2];
  s[0] = getchar();
  s[1] = '\0';
  push(new_str_copy(s));
}


x86 assembly (clang, -O0):
<builtin_input>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
call   1050 <feof@plt>
cmp    $0x0,%rax
je     119c <builtin_input+0x3c>
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
lea    0xe70(%rip),%rsi
call   1040 <fprintf@plt>
xor    %edi,%edi
call   1080 <exit@plt>
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %al,-0x2(%rbp)
movb   $0x0,-0x1(%rbp)
lea    -0x2(%rbp),%rdi
call   1060 <new_str_copy@plt>
mov    %eax,%edi
call   1070 <push@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<builtin_input>:
push   %rax
mov    0x2e80(%rip),%rax
mov    (%rax),%edi
call   1050 <feof@plt>
test   %rax,%rax
jne    1197 <builtin_input+0x37>
xor    %eax,%eax
call   1030 <getchar@plt>
mov    %al,0x6(%rsp)
movb   $0x0,0x7(%rsp)
lea    0x6(%rsp),%rdi
call   1060 <new_str_copy@plt>
mov    %eax,%edi
call   1070 <push@plt>
pop    %rax
ret
mov    0x2e3a(%rip),%rax
mov    (%rax),%edi
lea    0xe59(%rip),%rsi
call   1040 <fprintf@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stdin = global i32 0
@stderr = global i32 0
@.str = [20 x i8] c"input: end of file\0A\00"
define void @builtin_input() {
%1 = alloca [2 x i8]
%2 = load i32, i32* @stdin
%3 = call i64 @feof(i32 %2)
%4 = icmp ne i64 %3, 0
br i1 %4, label %5, label %9
5: ; preds = %0
%6 = load i32, i32* @stderr
%7 = call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @exit(i32 0)
unreachable
9: ; preds = %0
%10 = call signext i8 (...) @getchar()
%11 = getelementptr inbounds [2 x i8], [2 x i8]* %1, i64 0, i64 0
store i8 %10, i8* %11
%12 = getelementptr inbounds [2 x i8], [2 x i8]* %1, i64 0, i64 1
store i8 0, i8* %12
%13 = getelementptr inbounds [2 x i8], [2 x i8]* %1, i64 0, i64 0
%14 = call i32 @new_str_copy(i8* %13)
%15 = call i32 @push(i32 %14)
ret void
}

LLVM IR (-O2):
@stdin = global i32 0
@stderr = global i32 0
@.str = [20 x i8] c"input: end of file\0A\00"
define void @builtin_input() {
%1 = alloca [2 x i8]
%2 = load i32, i32* @stdin
%3 = tail call i64 @feof(i32 %2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %9, label %5
5: ; preds = %0
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @exit(i32 0)
unreachable
9: ; preds = %0
%10 = getelementptr inbounds [2 x i8], [2 x i8]* %1, i64 0, i64 0
%11 = tail call signext i8 (...) @getchar()
store i8 %11, i8* %10
%12 = getelementptr inbounds [2 x i8], [2 x i8]* %1, i64 0, i64 1
store i8 0, i8* %12
%13 = call i32 @new_str_copy(i8* %10)
%14 = call i32 @push(i32 %13)
ret void
}