#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*/ feof(int /*<<< orphan*/);
int fgetc(int /*<<< orphan*/);
int /*<<< orphan*/ fputc(int, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  int ch;
  (void)argc;
  (void)argv;
  while (!feof(stdin)) {
    ch = fgetc(stdin);
    if (ch == 10)
      fputc(13, stdout);
    if (ch != EOF)
      fputc(ch, stdout);
  }
  return 0;
}


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    0x2e9b(%rip),%rax
mov    (%rax),%edi
call   1050 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1169 <main+0x39>
jmp    11bf <main+0x8f>
mov    0x2e78(%rip),%rax
mov    (%rax),%edi
call   1030 <fgetc@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jne    1197 <main+0x67>
mov    0x2e45(%rip),%rax
mov    (%rax),%esi
mov    $0xd,%edi
call   1040 <fputc@plt>
mov    -0x14(%rbp),%eax
mov    0x2e3f(%rip),%rcx
cmp    (%rcx),%eax
je     11ba <main+0x8a>
mov    -0x14(%rbp),%edi
mov    0x2e1d(%rip),%rax
mov    (%rax),%esi
call   1040 <fputc@plt>
jmp    1146 <main+0x16>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    0x2ea9(%rip),%r14
mov    (%r14),%edi
call   1050 <feof@plt>
test   %eax,%eax
je     1159 <main+0x29>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    0x2e70(%rip),%r15
mov    0x2e79(%rip),%r12
jmp    117c <main+0x4c>
nopl   0x0(%rax)
mov    (%r14),%edi
call   1050 <feof@plt>
test   %eax,%eax
jne    114b <main+0x1b>
mov    (%r14),%edi
call   1030 <fgetc@plt>
mov    %eax,%ebx
cmp    $0xa,%eax
jne    1198 <main+0x68>
mov    (%r15),%esi
mov    $0xd,%edi
call   1040 <fputc@plt>
cmp    (%r12),%ebx
je     1170 <main+0x40>
mov    (%r15),%esi
mov    %ebx,%edi
call   1040 <fputc@plt>
jmp    1170 <main+0x40>

LLVM IR (-O0):
@stdin = global i32 0
@stdout = global i32 0
@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 = load i32, i32* %4
%8 = load i8**, i8*** %5
br label %9
9: ; preds = %30, %2
%10 = load i32, i32* @stdin
%11 = call i32 @feof(i32 %10)
%12 = icmp ne i32 %11, 0
%13 = xor i1 %12, true
br i1 %13, label %14, label %31
14: ; preds = %9
%15 = load i32, i32* @stdin
%16 = call i32 @fgetc(i32 %15)
store i32 %16, i32* %6
%17 = load i32, i32* %6
%18 = icmp eq i32 %17, 10
br i1 %18, label %19, label %22
19: ; preds = %14
%20 = load i32, i32* @stdout
%21 = call i32 @fputc(i32 13, i32 %20)
br label %22
22: ; preds = %19, %14
%23 = load i32, i32* %6
%24 = load i32, i32* @EOF
%25 = icmp ne i32 %23, %24
br i1 %25, label %26, label %30
26: ; preds = %22
%27 = load i32, i32* %6
%28 = load i32, i32* @stdout
%29 = call i32 @fputc(i32 %27, i32 %28)
br label %30
30: ; preds = %26, %22
br label %9
31: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@stdout = global i32 0
@EOF = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @stdin
%4 = tail call i32 @feof(i32 %3)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %23
6: ; preds = %2, %19
%7 = load i32, i32* @stdin
%8 = tail call i32 @fgetc(i32 %7)
%9 = icmp eq i32 %8, 10
br i1 %9, label %10, label %13
10: ; preds = %6
%11 = load i32, i32* @stdout
%12 = tail call i32 @fputc(i32 13, i32 %11)
br label %13
13: ; preds = %10, %6
%14 = load i32, i32* @EOF
%15 = icmp eq i32 %8, %14
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = load i32, i32* @stdout
%18 = tail call i32 @fputc(i32 %8, i32 %17)
br label %19
19: ; preds = %16, %13
%20 = load i32, i32* @stdin
%21 = tail call i32 @feof(i32 %20)
%22 = icmp eq i32 %21, 0
br i1 %22, label %6, label %23
23: ; preds = %19, %2
ret i32 0
}