#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(void) {
  int cdbl[2] = {'\0', '\0'};
  while ((cdbl[1] = getchar()) != EOF) {
    putchar(cdbl[1]);
    cdbl[0] = cdbl[1];
  }
  if (cdbl[0] != '\n') {
    putchar('\n');
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xc(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e88(%rip),%rcx
cmp    (%rcx),%eax
je     117e <main+0x4e>
mov    -0x8(%rbp),%eax
movsbl %al,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    114f <main+0x1f>
cmpl   $0xa,-0xc(%rbp)
je     1192 <main+0x62>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2eb7(%rip),%rbx
cmp    (%rbx),%eax
je     115b <main+0x3b>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %eax,%ebp
movsbl %bpl,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%rbx),%eax
jne    1140 <main+0x20>
cmp    $0xa,%ebp
je     1165 <main+0x45>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [2 x i32]
store i32 0, i32* %1
%3 = bitcast [2 x i32]* %2 to i8*
br label %4
4: ; preds = %9, %0
%5 = call i32 (...) @getchar()
%6 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
store i32 %5, i32* %6
%7 = load i32, i32* @EOF
%8 = icmp ne i32 %5, %7
br i1 %8, label %9, label %17
9: ; preds = %4
%10 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%11 = load i32, i32* %10
%12 = trunc i32 %11 to i8
%13 = call i32 @putchar(i8 signext %12)
%14 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%15 = load i32, i32* %14
%16 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
store i32 %15, i32* %16
br label %4
17: ; preds = %4
%18 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%19 = load i32, i32* %18
%20 = icmp ne i32 %19, 10
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = call i32 @putchar(i8 signext 10)
br label %23
23: ; preds = %21, %17
ret i32 0
}

LLVM IR (-O2):
@EOF = global i32 0
define i32 @main() {
%1 = tail call i32 (...) @getchar()
%2 = load i32, i32* @EOF
%3 = icmp eq i32 %1, %2
br i1 %3, label %13, label %4
4: ; preds = %0, %4
%5 = phi i32 [ %8, %4 ], [ %1, %0 ]
%6 = trunc i32 %5 to i8
%7 = tail call i32 @putchar(i8 signext %6)
%8 = tail call i32 (...) @getchar()
%9 = load i32, i32* @EOF
%10 = icmp eq i32 %8, %9
br i1 %10, label %11, label %4
11: ; preds = %4
%12 = icmp eq i32 %5, 10
br i1 %12, label %15, label %13
13: ; preds = %0, %11
%14 = tail call i32 @putchar(i8 signext 10)
br label %15
15: ; preds = %13, %11
ret i32 0
}