#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, ...);
int main(int argc, char *argv[]) {
  int res;
  while (res = (getchar() != EOF)) {
    printf("res is %i\n", res);
  }
  printf("Last response is: %i, (getchar() != EOF) is: %s\n", EOF,
         (res ? "YES" : "NO"));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    0x2ea4(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
mov    %al,%cl
and    $0x1,%cl
movzbl %cl,%ecx
mov    %ecx,-0x14(%rbp)
test   $0x1,%al
jne    1161 <main+0x41>
jmp    1177 <main+0x57>
mov    -0x14(%rbp),%esi
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1136 <main+0x16>
mov    0x2e6a(%rip),%rax
mov    (%rax),%esi
mov    -0x14(%rbp),%ecx
lea    0xeb6(%rip),%rdx
lea    0xeab(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdx
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2eb6(%rip),%r14
cmp    (%r14),%eax
je     115b <main+0x3b>
lea    0xec2(%rip),%rbx
xchg   %ax,%ax
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%r14),%eax
jne    1140 <main+0x20>
lea    0xea9(%rip),%rdi
lea    0xed3(%rip),%rdx
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@EOF = global i32 0
@.str = [11 x i8] c"res is %i\0A\00"
@.str.1 = [49 x i8] c"Last response is: %i, (getchar() != EOF) is: %s\0A\00"
@.str.2 = [4 x i8] c"YES\00"
@.str.3 = [3 x i8] c"NO\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %7
7: ; preds = %12, %2
%8 = call i32 (...) @getchar()
%9 = load i32, i32* @EOF
%10 = icmp ne i32 %8, %9
%11 = zext i1 %10 to i32
store i32 %11, i32* %6
br i1 %10, label %12, label %15
12: ; preds = %7
%13 = load i32, i32* %6
%14 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %13)
br label %7
15: ; preds = %7
%16 = load i32, i32* @EOF
%17 = load i32, i32* %6
%18 = icmp ne i32 %17, 0
%19 = zext i1 %18 to i64
%20 = select i1 %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0)
%21 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i32 %16, i8* %20)
ret i32 0
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [11 x i8] c"res is %i\0A\00"
@.str.1 = [49 x i8] c"Last response is: %i, (getchar() != EOF) is: %s\0A\00"
@.str.3 = [3 x i8] c"NO\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @getchar()
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
br i1 %5, label %11, label %6
6: ; preds = %2, %6
%7 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 1)
%8 = tail call i32 (...) @getchar()
%9 = load i32, i32* @EOF
%10 = icmp eq i32 %8, %9
br i1 %10, label %11, label %6
11: ; preds = %6, %2
%12 = phi i32 [ %3, %2 ], [ %8, %6 ]
%13 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i32 %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}