#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 main(void) {
  int c, cc;
  while ((c = getchar()) != EOF) {
    if (c != '\n') {
      cc = c;
      printf("Before test:\n\tcc = [%c]\n", cc);
      printf("After test:");
      if ((c = getchar()) == EOF) {
        cc = c;
        printf("\n\tEOF cc = [%c]\n\n", cc);
        break;
      } else if (c != '\n') {
        cc = c;
        printf("\n\tNOT EOF cc = [%c]\n\n", cc);
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2ea8(%rip),%rcx
cmp    (%rcx),%eax
je     11dc <main+0xbc>
cmpl   $0xa,-0x8(%rbp)
je     11d7 <main+0xb7>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e60(%rip),%rcx
cmp    (%rcx),%eax
jne    11ac <main+0x8c>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11dc <main+0xbc>
cmpl   $0xa,-0x8(%rbp)
je     11cd <main+0xad>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d2 <main+0xb2>
jmp    11d7 <main+0xb7>
jmp    112f <main+0xf>
xor    %eax,%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   1040 <getchar@plt>
mov    0x2eb2(%rip),%rbx
cmp    (%rbx),%eax
je     11b4 <main+0x94>
lea    0xebf(%rip),%r14
lea    0xed1(%rip),%r12
lea    0xee8(%rip),%r15
jmp    116b <main+0x4b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%rbx),%eax
je     11b4 <main+0x94>
cmp    $0xa,%eax
je     1160 <main+0x40>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%rbx),%eax
je     11a4 <main+0x84>
cmp    $0xa,%eax
je     1160 <main+0x40>
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1160 <main+0x40>
lea    0xe7a(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@EOF = global i32 0
@.str = [25 x i8] c"Before test:\0A\09cc = [%c]\0A\00"
@.str.1 = [12 x i8] c"After test:\00"
@.str.2 = [18 x i8] c"\0A\09EOF cc = [%c]\0A\0A\00"
@.str.3 = [22 x i8] c"\0A\09NOT EOF cc = [%c]\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
br label %4
4: ; preds = %32, %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 %33
8: ; preds = %4
%9 = load i32, i32* %2
%10 = icmp ne i32 %9, 10
br i1 %10, label %11, label %32
11: ; preds = %8
%12 = load i32, i32* %2
store i32 %12, i32* %3
%13 = load i32, i32* %3
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 (...) @getchar()
store i32 %16, i32* %2
%17 = load i32, i32* @EOF
%18 = icmp eq i32 %16, %17
br i1 %18, label %19, label %23
19: ; preds = %11
%20 = load i32, i32* %2
store i32 %20, i32* %3
%21 = load i32, i32* %3
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %21)
br label %33
23: ; preds = %11
%24 = load i32, i32* %2
%25 = icmp ne i32 %24, 10
br i1 %25, label %26, label %30
26: ; preds = %23
%27 = load i32, i32* %2
store i32 %27, i32* %3
%28 = load i32, i32* %3
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %26, %23
br label %31
31: ; preds = %30
br label %32
32: ; preds = %31, %8
br label %4
33: ; preds = %19, %4
ret i32 0
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [25 x i8] c"Before test:\0A\09cc = [%c]\0A\00"
@.str.1 = [12 x i8] c"After test:\00"
@.str.2 = [18 x i8] c"\0A\09EOF cc = [%c]\0A\0A\00"
@.str.3 = [22 x i8] c"\0A\09NOT EOF cc = [%c]\0A\0A\00"
define i32 @main() {
%1 = tail call i32 (...) @getchar()
%2 = load i32, i32* @EOF
%3 = icmp eq i32 %1, %2
br i1 %3, label %23, label %4
4: ; preds = %0, %19
%5 = phi i32 [ %20, %19 ], [ %1, %0 ]
%6 = icmp eq i32 %5, 10
br i1 %6, label %19, label %7
7: ; preds = %4
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %5)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i32 (...) @getchar()
%11 = load i32, i32* @EOF
%12 = icmp eq i32 %10, %11
br i1 %12, label %13, label %15
13: ; preds = %7
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %10)
br label %23
15: ; preds = %7
%16 = icmp eq i32 %10, 10
br i1 %16, label %19, label %17
17: ; preds = %15
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %10)
br label %19
19: ; preds = %17, %15, %4
%20 = tail call i32 (...) @getchar()
%21 = load i32, i32* @EOF
%22 = icmp eq i32 %20, %21
br i1 %22, label %23, label %4
23: ; preds = %19, %0, %13
ret i32 0
}