#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 */
char EOF;
int /*<<< orphan*/ feof(int /*<<< orphan*/);
char getchar();
int /*<<< orphan*/ input_putchar(char);
int /*<<< orphan*/ stdin;
int input_read() {
  while (!feof(stdin)) {
    char c = getchar();
    if ((c == EOF) || (c == '\r') || (c == '\n'))
      break;
    input_putchar(c);
  }
  input_putchar('\0');
  if (!feof(stdin))
    return 1;
  else
    return 0;
}


x86 assembly (clang, -O0):
<input_read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2ea9(%rip),%rax
mov    (%rax),%edi
call   1040 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    115b <input_read+0x2b>
jmp    11a8 <input_read+0x78>
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
mov    0x2e70(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1195 <input_read+0x65>
movsbl -0x5(%rbp),%eax
cmp    $0xd,%eax
je     1195 <input_read+0x65>
movsbl -0x5(%rbp),%eax
cmp    $0xa,%eax
jne    119a <input_read+0x6a>
jmp    11a8 <input_read+0x78>
movsbl -0x5(%rbp),%edi
call   1050 <input_putchar@plt>
jmp    1138 <input_read+0x8>
xor    %edi,%edi
call   1050 <input_putchar@plt>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
call   1040 <feof@plt>
cmp    $0x0,%eax
jne    11d2 <input_read+0xa2>
movl   $0x1,-0x4(%rbp)
jmp    11d9 <input_read+0xa9>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<input_read>:
push   %r14
push   %rbx
push   %rax
mov    0x2ead(%rip),%rbx
mov    (%rbx),%edi
call   1040 <feof@plt>
test   %eax,%eax
je     1165 <input_read+0x35>
xor    %edi,%edi
call   1050 <input_putchar@plt>
mov    (%rbx),%edi
call   1040 <feof@plt>
xor    %ecx,%ecx
test   %eax,%eax
sete   %cl
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e74(%rip),%r14
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <getchar@plt>
cmp    (%r14),%al
je     1146 <input_read+0x16>
cmp    $0xa,%al
je     1146 <input_read+0x16>
cmp    $0xd,%al
je     1146 <input_read+0x16>
movsbl %al,%edi
call   1050 <input_putchar@plt>
mov    (%rbx),%edi
call   1040 <feof@plt>
test   %eax,%eax
je     1170 <input_read+0x40>
jmp    1146 <input_read+0x16>

LLVM IR (-O0):
@stdin = global i32 0
@EOF = global i8 0
define i32 @input_read() {
%1 = alloca i32
%2 = alloca i8
br label %3
3: ; preds = %24, %0
%4 = load i32, i32* @stdin
%5 = call i32 @feof(i32 %4)
%6 = icmp ne i32 %5, 0
%7 = xor i1 %6, true
br i1 %7, label %8, label %27
8: ; preds = %3
%9 = call signext i8 (...) @getchar()
store i8 %9, i8* %2
%10 = load i8, i8* %2
%11 = sext i8 %10 to i32
%12 = load i8, i8* @EOF
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %11, %13
br i1 %14, label %23, label %15
15: ; preds = %8
%16 = load i8, i8* %2
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 13
br i1 %18, label %23, label %19
19: ; preds = %15
%20 = load i8, i8* %2
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 10
br i1 %22, label %23, label %24
23: ; preds = %19, %15, %8
br label %27
24: ; preds = %19
%25 = load i8, i8* %2
%26 = call i32 @input_putchar(i8 signext %25)
br label %3
27: ; preds = %23, %3
%28 = call i32 @input_putchar(i8 signext 0)
%29 = load i32, i32* @stdin
%30 = call i32 @feof(i32 %29)
%31 = icmp ne i32 %30, 0
br i1 %31, label %33, label %32
32: ; preds = %27
store i32 1, i32* %1
br label %34
33: ; preds = %27
store i32 0, i32* %1
br label %34
34: ; preds = %33, %32
%35 = load i32, i32* %1
ret i32 %35
}

LLVM IR (-O2):
@stdin = global i32 0
@EOF = global i8 0
define i32 @input_read() {
%1 = load i32, i32* @stdin
%2 = tail call i32 @feof(i32 %1)
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %15
4: ; preds = %0, %10
%5 = tail call signext i8 (...) @getchar()
%6 = load i8, i8* @EOF
%7 = freeze i8 %6
%8 = icmp eq i8 %5, %7
br i1 %8, label %15, label %9
9: ; preds = %4
switch i8 %5, label %10 [
i8 13, label %15
i8 10, label %15
]
10: ; preds = %9
%11 = tail call i32 @input_putchar(i8 signext %5)
%12 = load i32, i32* @stdin
%13 = tail call i32 @feof(i32 %12)
%14 = icmp eq i32 %13, 0
br i1 %14, label %4, label %15
15: ; preds = %10, %9, %9, %4, %0
%16 = tail call i32 @input_putchar(i8 signext 0)
%17 = load i32, i32* @stdin
%18 = tail call i32 @feof(i32 %17)
%19 = icmp eq i32 %18, 0
%20 = zext i1 %19 to i32
ret i32 %20
}