#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 /*<<< orphan*/ exit(int);
scalar_t__ ferror(int /*<<< orphan*/);
int getchar();
int /*<<< orphan*/ putchar(int);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
main() {
  int c;
loop:
  c = getchar();
  if (c == EOF)
    goto eof;
  if (c == 13) {
    c = getchar();
    if (c == EOF) {
      putchar(13);
      goto eof;
    }
    if (!(c == 10)) {
      putchar(13);
      putchar(c);
    } else {
      putchar(10);
    }
  } else {
    putchar(c);
  }
  goto loop;
eof:;
  if (ferror(stdin) || ferror(stdout)) {
    exit(1);
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2e7d(%rip),%rcx
cmp    (%rcx),%eax
jne    1170 <main+0x30>
jmp    11e2 <main+0xa2>
cmpl   $0xd,-0x8(%rbp)
jne    11d5 <main+0x95>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2e52(%rip),%rcx
cmp    (%rcx),%eax
jne    11a5 <main+0x65>
mov    $0xd,%edi
call   1030 <putchar@plt>
jmp    11e2 <main+0xa2>
cmpl   $0xa,-0x8(%rbp)
je     11c6 <main+0x86>
mov    $0xd,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
jmp    11d0 <main+0x90>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11dd <main+0x9d>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
jmp    114f <main+0xf>
mov    0x2dff(%rip),%rax
mov    (%rax),%edi
call   1040 <ferror@plt>
cmp    $0x0,%rax
jne    1212 <main+0xd2>
mov    0x2dcf(%rip),%rax
mov    (%rax),%edi
call   1040 <ferror@plt>
cmp    $0x0,%rax
je     121c <main+0xdc>
mov    $0x1,%edi
call   1060 <exit@plt>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e8e(%rip),%r14
jmp    116e <main+0x2e>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %eax,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    (%r14),%eax
je     11a8 <main+0x68>
cmp    $0xd,%eax
jne    1160 <main+0x20>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    (%r14),%eax
je     119e <main+0x5e>
mov    %eax,%ebx
mov    $0xa,%eax
cmp    $0xa,%ebx
je     1160 <main+0x20>
mov    $0xd,%edi
call   1030 <putchar@plt>
mov    %ebx,%eax
jmp    1160 <main+0x20>
mov    $0xd,%edi
call   1030 <putchar@plt>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
call   1040 <ferror@plt>
test   %rax,%rax
jne    11d5 <main+0x95>
mov    0x2e0e(%rip),%rax
mov    (%rax),%edi
call   1040 <ferror@plt>
test   %rax,%rax
jne    11d5 <main+0x95>
xor    %edi,%edi
call   1060 <exit@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@EOF = global i32 0
@stdin = global i32 0
@stdout = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
br label %3
3: ; preds = %32, %0
%4 = call i32 (...) @getchar()
store i32 %4, i32* %2
%5 = load i32, i32* %2
%6 = load i32, i32* @EOF
%7 = icmp eq i32 %5, %6
br i1 %7, label %8, label %9
8: ; preds = %3
br label %33
9: ; preds = %3
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, 13
br i1 %11, label %12, label %29
12: ; preds = %9
%13 = call i32 (...) @getchar()
store i32 %13, i32* %2
%14 = load i32, i32* %2
%15 = load i32, i32* @EOF
%16 = icmp eq i32 %14, %15
br i1 %16, label %17, label %19
17: ; preds = %12
%18 = call i32 @putchar(i32 13)
br label %33
19: ; preds = %12
%20 = load i32, i32* %2
%21 = icmp eq i32 %20, 10
br i1 %21, label %26, label %22
22: ; preds = %19
%23 = call i32 @putchar(i32 13)
%24 = load i32, i32* %2
%25 = call i32 @putchar(i32 %24)
br label %28
26: ; preds = %19
%27 = call i32 @putchar(i32 10)
br label %28
28: ; preds = %26, %22
br label %32
29: ; preds = %9
%30 = load i32, i32* %2
%31 = call i32 @putchar(i32 %30)
br label %32
32: ; preds = %29, %28
br label %3
33: ; preds = %17, %8
%34 = load i32, i32* @stdin
%35 = call i64 @ferror(i32 %34)
%36 = icmp ne i64 %35, 0
br i1 %36, label %41, label %37
37: ; preds = %33
%38 = load i32, i32* @stdout
%39 = call i64 @ferror(i32 %38)
%40 = icmp ne i64 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %37, %33
%42 = call i32 @exit(i32 1)
unreachable
43: ; preds = %37
%44 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@EOF = global i32 0
@stdin = global i32 0
@stdout = 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 %23, label %4
4: ; preds = %0, %17
%5 = phi i32 [ %20, %17 ], [ %1, %0 ]
%6 = icmp eq i32 %5, 13
br i1 %6, label %7, label %17
7: ; preds = %4
%8 = tail call i32 (...) @getchar()
%9 = load i32, i32* @EOF
%10 = icmp eq i32 %8, %9
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = tail call i32 @putchar(i32 13)
br label %23
13: ; preds = %7
%14 = icmp eq i32 %8, 10
br i1 %14, label %17, label %15
15: ; preds = %13
%16 = tail call i32 @putchar(i32 13)
br label %17
17: ; preds = %4, %13, %15
%18 = phi i32 [ %8, %15 ], [ 10, %13 ], [ %5, %4 ]
%19 = tail call i32 @putchar(i32 %18)
%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 = %17, %0, %11
%24 = load i32, i32* @stdin
%25 = tail call i64 @ferror(i32 %24)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %31
27: ; preds = %23
%28 = load i32, i32* @stdout
%29 = tail call i64 @ferror(i32 %28)
%30 = icmp eq i64 %29, 0
br i1 %30, label %33, label %31
31: ; preds = %27, %23
%32 = tail call i32 @exit(i32 1)
unreachable
33: ; preds = %27
%34 = tail call i32 @exit(i32 0)
unreachable
}