#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 getchar();
int /*<<< orphan*/ printf(char *, char);
int /*<<< orphan*/ putchar(int);
int main() {
  printf("EOF != 'a': %d\n", 'a' != EOF);
  printf("EOF != EOF: %d\n", EOF != EOF);
  printf("EOF: %d\n", EOF);
  int c;
  while ((c = getchar()) != EOF) {
    putchar(c);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2ea2(%rip),%rax
movsbl (%rax),%ecx
mov    $0x61,%eax
cmp    %ecx,%eax
setne  %al
and    $0x1,%al
movzbl %al,%eax
lea    0xea1(%rip),%rdi
movsbl %al,%esi
call   1040 <printf@plt>
mov    0x2e7a(%rip),%rax
movsbl (%rax),%eax
mov    0x2e70(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
setne  %al
and    $0x1,%al
movzbl %al,%eax
lea    0xe84(%rip),%rdi
movsbl %al,%esi
call   1040 <printf@plt>
lea    0xe7c(%rip),%rdi
mov    0x2e46(%rip),%rax
movsbl (%rax),%esi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e2d(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11d3 <main+0xa3>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
jmp    11aa <main+0x7a>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    0x2eb0(%rip),%rbx
xor    %esi,%esi
cmpb   $0x61,(%rbx)
setne  %sil
lea    0xeb8(%rip),%rdi
call   1040 <printf@plt>
lea    0xebc(%rip),%rdi
xor    %esi,%esi
call   1040 <printf@plt>
movsbl (%rbx),%esi
lea    0xeb2(%rip),%rdi
call   1040 <printf@plt>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <getchar@plt>
movsbl (%rbx),%ecx
cmp    %ecx,%eax
je     1187 <main+0x57>
mov    %eax,%edi
call   1030 <putchar@plt>
jmp    1170 <main+0x40>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"EOF != 'a': %d\0A\00"
@EOF = global i8 0
@.str.1 = [16 x i8] c"EOF != EOF: %d\0A\00"
@.str.2 = [9 x i8] c"EOF: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = load i8, i8* @EOF
%4 = sext i8 %3 to i32
%5 = icmp ne i32 97, %4
%6 = zext i1 %5 to i32
%7 = trunc i32 %6 to i8
%8 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8 signext %7)
%9 = load i8, i8* @EOF
%10 = sext i8 %9 to i32
%11 = load i8, i8* @EOF
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %10, %12
%14 = zext i1 %13 to i32
%15 = trunc i32 %14 to i8
%16 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8 signext %15)
%17 = load i8, i8* @EOF
%18 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8 signext %17)
br label %19
19: ; preds = %24, %0
%20 = call i32 (...) @getchar()
store i32 %20, i32* %2
%21 = load i8, i8* @EOF
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %20, %22
br i1 %23, label %24, label %27
24: ; preds = %19
%25 = load i32, i32* %2
%26 = call i32 @putchar(i32 %25)
br label %19
27: ; preds = %19
%28 = load i32, i32* %1
ret i32 %28
}

LLVM IR (-O2):
@.str = [16 x i8] c"EOF != 'a': %d\0A\00"
@EOF = global i8 0
@.str.1 = [16 x i8] c"EOF != EOF: %d\0A\00"
@.str.2 = [9 x i8] c"EOF: %d\0A\00"
define i32 @main() {
%1 = load i8, i8* @EOF
%2 = icmp ne i8 %1, 97
%3 = zext i1 %2 to i8
%4 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8 signext %3)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8 signext 0)
%6 = load i8, i8* @EOF
%7 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8 signext %6)
%8 = tail call i32 (...) @getchar()
%9 = load i8, i8* @EOF
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %8, %10
br i1 %11, label %19, label %12
12: ; preds = %0, %12
%13 = phi i32 [ %15, %12 ], [ %8, %0 ]
%14 = tail call i32 @putchar(i32 %13)
%15 = tail call i32 (...) @getchar()
%16 = load i8, i8* @EOF
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %15, %17
br i1 %18, label %19, label %12
19: ; preds = %12, %0
ret i32 0
}