#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 EOF;
int getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(int);
main() {
  int c;
  while ((c = getchar()) != EOF) {
    if (getchar() != EOF) {
      printf("End of File has been reached.\n");
    } else {
      printf("End of File has not been reached.\n");
    }
    putchar(c);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e98(%rip),%rcx
cmp    (%rcx),%eax
je     1198 <main+0x68>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    0x2e82(%rip),%rcx
cmp    (%rcx),%eax
je     117f <main+0x4f>
lea    0xe8b(%rip),%rdi
call   1040 <printf@plt>
jmp    118b <main+0x5b>
lea    0xe99(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
jmp    113f <main+0xf>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2ea2(%rip),%r14
cmp    (%r14),%eax
jne    1159 <main+0x29>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    %eax,%ebx
lea    0xe9e(%rip),%r15
lea    0xeb9(%rip),%r12
jmp    118a <main+0x5a>
nopl   0x0(%rax,%rax,1)
call   1040 <puts@plt>
mov    %ebx,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebx
cmp    (%r14),%eax
je     114b <main+0x1b>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %r15,%rdi
cmp    (%r14),%eax
je     1170 <main+0x40>
mov    %r12,%rdi
jmp    1170 <main+0x40>

LLVM IR (-O0):
@EOF = global i32 0
@.str = [31 x i8] c"End of File has been reached.\0A\00"
@.str.1 = [35 x i8] c"End of File has not been reached.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
br label %3
3: ; preds = %15, %0
%4 = call i32 (...) @getchar()
store i32 %4, i32* %2
%5 = load i32, i32* @EOF
%6 = icmp ne i32 %4, %5
br i1 %6, label %7, label %18
7: ; preds = %3
%8 = call i32 (...) @getchar()
%9 = load i32, i32* @EOF
%10 = icmp ne i32 %8, %9
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %15
13: ; preds = %7
%14 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %13, %11
%16 = load i32, i32* %2
%17 = call i32 @putchar(i32 %16)
br label %3
18: ; preds = %3
%19 = load i32, i32* %1
ret i32 %19
}

LLVM IR (-O2):
@EOF = global i32 0
@str = [34 x i8] c"End of File has not been reached.\00"
@str.2 = [30 x i8] c"End of File has been reached.\00"
define i32 @main() {
%1 = tail call i32 (...) @getchar()
%2 = load i32, i32* @EOF
%3 = icmp eq i32 %1, %2
br i1 %3, label %15, label %4
4: ; preds = %0, %4
%5 = phi i32 [ %12, %4 ], [ %1, %0 ]
%6 = tail call i32 (...) @getchar()
%7 = load i32, i32* @EOF
%8 = icmp eq i32 %6, %7
%9 = select i1 %8, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @str.2, i64 0, i64 0)
%10 = tail call i32 @puts(i8* dereferenceable(1) %9)
%11 = tail call i32 @putchar(i32 %5)
%12 = tail call i32 (...) @getchar()
%13 = load i32, i32* @EOF
%14 = icmp eq i32 %12, %13
br i1 %14, label %15, label %4
15: ; preds = %4, %0
ret i32 0
}