#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(char);
int main(int argc, char *argv[]) {
  int ch = getchar();
  while (ch != EOF) {
    if (ch == '0')
      putchar('0');
    if (ch == '1')
      putchar('1');
    ch = getchar();
  }
}


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    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e9e(%rip),%rcx
cmp    (%rcx),%eax
je     1189 <main+0x69>
cmpl   $0x30,-0x14(%rbp)
jne    1166 <main+0x46>
mov    $0x30,%edi
call   1030 <putchar@plt>
cmpl   $0x31,-0x14(%rbp)
jne    117a <main+0x5a>
mov    $0x31,%edi
call   1030 <putchar@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x14(%rbp)
jmp    1140 <main+0x20>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2eb9(%rip),%rbx
jmp    1151 <main+0x31>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x30,%al
movzbl %al,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%rbx),%eax
je     1163 <main+0x43>
cmp    $0x30,%eax
je     1140 <main+0x20>
cmp    $0x31,%eax
jne    114a <main+0x2a>
mov    $0x31,%al
jmp    1142 <main+0x22>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@EOF = global i32 0
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
%7 = call i32 (...) @getchar()
store i32 %7, i32* %6
br label %8
8: ; preds = %22, %2
%9 = load i32, i32* %6
%10 = load i32, i32* @EOF
%11 = icmp ne i32 %9, %10
br i1 %11, label %12, label %24
12: ; preds = %8
%13 = load i32, i32* %6
%14 = icmp eq i32 %13, 48
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = call i32 @putchar(i8 signext 48)
br label %17
17: ; preds = %15, %12
%18 = load i32, i32* %6
%19 = icmp eq i32 %18, 49
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 @putchar(i8 signext 49)
br label %22
22: ; preds = %20, %17
%23 = call i32 (...) @getchar()
store i32 %23, i32* %6
br label %8
24: ; preds = %8
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
@EOF = global i32 0
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 %16, label %6
6: ; preds = %2, %12
%7 = phi i32 [ %13, %12 ], [ %3, %2 ]
switch i32 %7, label %12 [
i32 48, label %9
i32 49, label %8
]
8: ; preds = %6
br label %9
9: ; preds = %6, %8
%10 = phi i8 [ 49, %8 ], [ 48, %6 ]
%11 = tail call i32 @putchar(i8 signext %10)
br label %12
12: ; preds = %9, %6
%13 = tail call i32 (...) @getchar()
%14 = load i32, i32* @EOF
%15 = icmp eq i32 %13, %14
br i1 %15, label %16, label %6
16: ; preds = %12, %2
ret i32 0
}