#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*/ putchar(int);
int /*<<< orphan*/ puts(char *);
int main() {
  int c;
  puts("Copy all input chars and verify that getchar() != EOF is 01 or 1");
  while ((c = getchar()) != EOF) {
    putchar(c);
    if ((c != EOF) != 1)
      puts("That's not right.");
    else if ((c != EOF) == 0)
      puts("This is the end, my friend.");
  }
  puts("Verify getchar() != EOF is 0");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1040 <puts@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e8c(%rip),%rcx
cmp    (%rcx),%eax
je     11cd <main+0x9d>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%eax
mov    0x2e72(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
and    $0x1,%al
movzbl %al,%eax
cmp    $0x1,%eax
je     119a <main+0x6a>
lea    0xeb1(%rip),%rdi
call   1040 <puts@plt>
jmp    11c8 <main+0x98>
mov    -0x8(%rbp),%eax
mov    0x2e44(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
and    $0x1,%al
movzbl %al,%eax
cmp    $0x0,%eax
jne    11c3 <main+0x93>
lea    0xe95(%rip),%rdi
call   1040 <puts@plt>
jmp    11c8 <main+0x98>
jmp    114b <main+0x1b>
lea    0xe9b(%rip),%rdi
call   1040 <puts@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
lea    0xec5(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e9a(%rip),%rbx
cmp    (%rbx),%eax
jne    1165 <main+0x35>
lea    0xefa(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    %eax,%ebp
lea    0xed3(%rip),%r14
jmp    117d <main+0x4d>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebp
cmp    (%rbx),%eax
je     1152 <main+0x22>
mov    %ebp,%edi
call   1030 <putchar@plt>
cmp    (%rbx),%ebp
jne    1170 <main+0x40>
mov    %r14,%rdi
call   1040 <puts@plt>
jmp    1170 <main+0x40>

LLVM IR (-O0):
@.str = [65 x i8] c"Copy all input chars and verify that getchar() != EOF is 01 or 1\00"
@EOF = global i32 0
@.str.1 = [18 x i8] c"That's not right.\00"
@.str.2 = [28 x i8] c"This is the end, my friend.\00"
@.str.3 = [29 x i8] c"Verify getchar() != EOF is 0\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @puts(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %27, %0
%5 = call i32 (...) @getchar()
store i32 %5, i32* %2
%6 = load i32, i32* @EOF
%7 = icmp ne i32 %5, %6
br i1 %7, label %8, label %28
8: ; preds = %4
%9 = load i32, i32* %2
%10 = call i32 @putchar(i32 %9)
%11 = load i32, i32* %2
%12 = load i32, i32* @EOF
%13 = icmp ne i32 %11, %12
%14 = zext i1 %13 to i32
%15 = icmp ne i32 %14, 1
br i1 %15, label %16, label %18
16: ; preds = %8
%17 = call i32 @puts(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %27
18: ; preds = %8
%19 = load i32, i32* %2
%20 = load i32, i32* @EOF
%21 = icmp ne i32 %19, %20
%22 = zext i1 %21 to i32
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %18
%25 = call i32 @puts(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %26
26: ; preds = %24, %18
br label %27
27: ; preds = %26, %16
br label %4
28: ; preds = %4
%29 = call i32 @puts(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%30 = load i32, i32* %1
ret i32 %30
}

LLVM IR (-O2):
@.str = [65 x i8] c"Copy all input chars and verify that getchar() != EOF is 01 or 1\00"
@EOF = global i32 0
@.str.1 = [18 x i8] c"That's not right.\00"
@.str.3 = [29 x i8] c"Verify getchar() != EOF is 0\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 (...) @getchar()
%3 = load i32, i32* @EOF
%4 = icmp eq i32 %2, %3
br i1 %4, label %16, label %5
5: ; preds = %0, %12
%6 = phi i32 [ %13, %12 ], [ %2, %0 ]
%7 = tail call i32 @putchar(i32 %6)
%8 = load i32, i32* @EOF
%9 = icmp eq i32 %6, %8
br i1 %9, label %10, label %12
10: ; preds = %5
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %5, %10
%13 = tail call i32 (...) @getchar()
%14 = load i32, i32* @EOF
%15 = icmp eq i32 %13, %14
br i1 %15, label %16, label %5
16: ; preds = %12, %0
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}