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


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   1050 <getchar@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e91(%rip),%rcx
cmp    (%rcx),%eax
je     118c <main+0x5c>
mov    -0x14(%rbp),%eax
mov    0x2e7f(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
and    $0x1,%al
movzbl %al,%esi
lea    0xe86(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%edi
call   1030 <putchar@plt>
jmp    1146 <main+0x16>
mov    -0x14(%rbp),%eax
mov    0x2e52(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
and    $0x1,%al
movzbl %al,%esi
lea    0xe5d(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2ea6(%rip),%r14
cmp    (%r14),%eax
je     1172 <main+0x42>
mov    %eax,%ebp
lea    0xeb0(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
call   1040 <printf@plt>
mov    %ebp,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebp
cmp    (%r14),%eax
jne    1150 <main+0x20>
lea    0xe8b(%rip),%rdi
xor    %esi,%esi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
@.str = [4 x i8] c"%d \00"
@.str.1 = [5 x i8] c"\0A%d\0A\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 = %11, %2
%8 = call i32 (...) @getchar()
store i32 %8, i32* %6
%9 = load i32, i32* @EOF
%10 = icmp ne i32 %8, %9
br i1 %10, label %11, label %19
11: ; preds = %7
%12 = load i32, i32* %6
%13 = load i32, i32* @EOF
%14 = icmp ne i32 %12, %13
%15 = zext i1 %14 to i32
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = load i32, i32* %6
%18 = call i32 @putchar(i32 %17)
br label %7
19: ; preds = %7
%20 = load i32, i32* %6
%21 = load i32, i32* @EOF
%22 = icmp ne i32 %20, %21
%23 = zext i1 %22 to i32
%24 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %23)
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [4 x i8] c"%d \00"
@.str.1 = [5 x i8] c"\0A%d\0A\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 %13, label %6
6: ; preds = %2, %6
%7 = phi i32 [ %10, %6 ], [ %3, %2 ]
%8 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 1)
%9 = tail call i32 @putchar(i32 %7)
%10 = tail call i32 (...) @getchar()
%11 = load i32, i32* @EOF
%12 = icmp eq i32 %10, %11
br i1 %12, label %13, label %6
13: ; preds = %6, %2
%14 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 0)
ret i32 0
}