#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 getc(int /*<<< orphan*/);
int /*<<< orphan*/ putc(int, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ ungetc(int, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  int ch;
  while ((ch = getc(stdin)) != EOF) {
    if (ch == 0x0A) {
      putc('\n', stdout);
    } else if (ch == 0x0D) {
      putc('\n', stdout);
      ch = getc(stdin);
      if (ch == EOF) {
        break;
      } else if (ch != 0x0A) {
        ungetc(ch, stdin);
      }
    } else {
      putc(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 <getc@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e82(%rip),%rcx
cmp    (%rcx),%eax
je     120d <main+0xdd>
cmpl   $0xa,-0x14(%rbp)
jne    1188 <main+0x58>
mov    0x2e59(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1030 <putc@plt>
jmp    1208 <main+0xd8>
cmpl   $0xd,-0x14(%rbp)
jne    11f2 <main+0xc2>
mov    0x2e37(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1030 <putc@plt>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
call   1050 <getc@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e20(%rip),%rcx
cmp    (%rcx),%eax
jne    11cd <main+0x9d>
jmp    120d <main+0xdd>
cmpl   $0xa,-0x14(%rbp)
je     11e8 <main+0xb8>
mov    -0x14(%rbp),%edi
mov    0x2e07(%rip),%rax
mov    (%rax),%esi
call   1040 <ungetc@plt>
jmp    11ed <main+0xbd>
jmp    1203 <main+0xd3>
mov    -0x14(%rbp),%edi
mov    0x2dd4(%rip),%rax
mov    (%rax),%esi
call   1030 <putc@plt>
jmp    1208 <main+0xd8>
jmp    1146 <main+0x16>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    0x2eac(%rip),%rbx
mov    (%rbx),%edi
call   1050 <getc@plt>
mov    0x2e96(%rip),%r14
cmp    (%r14),%eax
jne    1157 <main+0x27>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2e72(%rip),%r15
jmp    1176 <main+0x46>
mov    (%r15),%esi
mov    %eax,%edi
call   1030 <putc@plt>
mov    (%rbx),%edi
call   1050 <getc@plt>
cmp    (%r14),%eax
je     114f <main+0x1f>
cmp    $0xd,%eax
je     1190 <main+0x60>
cmp    $0xa,%eax
jne    1160 <main+0x30>
mov    (%r15),%esi
mov    $0xa,%edi
jmp    1165 <main+0x35>
nopw   0x0(%rax,%rax,1)
mov    (%r15),%esi
mov    $0xa,%edi
call   1030 <putc@plt>
mov    (%rbx),%edi
call   1050 <getc@plt>
cmp    (%r14),%eax
je     114f <main+0x1f>
cmp    $0xa,%eax
je     116a <main+0x3a>
mov    (%rbx),%esi
mov    %eax,%edi
call   1040 <ungetc@plt>
jmp    116a <main+0x3a>

LLVM IR (-O0):
@stdin = global i32 0
@EOF = global i32 0
@stdout = 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
br label %7
7: ; preds = %44, %2
%8 = load i32, i32* @stdin
%9 = call i32 @getc(i32 %8)
store i32 %9, i32* %6
%10 = load i32, i32* @EOF
%11 = icmp ne i32 %9, %10
br i1 %11, label %12, label %45
12: ; preds = %7
%13 = load i32, i32* %6
%14 = icmp eq i32 %13, 10
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load i32, i32* @stdout
%17 = call i32 @putc(i32 10, i32 %16)
br label %44
18: ; preds = %12
%19 = load i32, i32* %6
%20 = icmp eq i32 %19, 13
br i1 %20, label %21, label %39
21: ; preds = %18
%22 = load i32, i32* @stdout
%23 = call i32 @putc(i32 10, i32 %22)
%24 = load i32, i32* @stdin
%25 = call i32 @getc(i32 %24)
store i32 %25, i32* %6
%26 = load i32, i32* %6
%27 = load i32, i32* @EOF
%28 = icmp eq i32 %26, %27
br i1 %28, label %29, label %30
29: ; preds = %21
br label %45
30: ; preds = %21
%31 = load i32, i32* %6
%32 = icmp ne i32 %31, 10
br i1 %32, label %33, label %37
33: ; preds = %30
%34 = load i32, i32* %6
%35 = load i32, i32* @stdin
%36 = call i32 @ungetc(i32 %34, i32 %35)
br label %37
37: ; preds = %33, %30
br label %38
38: ; preds = %37
br label %43
39: ; preds = %18
%40 = load i32, i32* %6
%41 = load i32, i32* @stdout
%42 = call i32 @putc(i32 %40, i32 %41)
br label %43
43: ; preds = %39, %38
br label %44
44: ; preds = %43, %15
br label %7
45: ; preds = %29, %7
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@EOF = global i32 0
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @stdin
%4 = tail call i32 @getc(i32 %3)
%5 = load i32, i32* @EOF
%6 = icmp eq i32 %4, %5
br i1 %6, label %32, label %7
7: ; preds = %2, %27
%8 = phi i32 [ %29, %27 ], [ %4, %2 ]
switch i32 %8, label %24 [
i32 10, label %9
i32 13, label %12
]
9: ; preds = %7
%10 = load i32, i32* @stdout
%11 = tail call i32 @putc(i32 10, i32 %10)
br label %27
12: ; preds = %7
%13 = load i32, i32* @stdout
%14 = tail call i32 @putc(i32 10, i32 %13)
%15 = load i32, i32* @stdin
%16 = tail call i32 @getc(i32 %15)
%17 = load i32, i32* @EOF
%18 = icmp eq i32 %16, %17
br i1 %18, label %32, label %19
19: ; preds = %12
%20 = icmp eq i32 %16, 10
br i1 %20, label %27, label %21
21: ; preds = %19
%22 = load i32, i32* @stdin
%23 = tail call i32 @ungetc(i32 %16, i32 %22)
br label %27
24: ; preds = %7
%25 = load i32, i32* @stdout
%26 = tail call i32 @putc(i32 %8, i32 %25)
br label %27
27: ; preds = %24, %19, %21, %9
%28 = load i32, i32* @stdin
%29 = tail call i32 @getc(i32 %28)
%30 = load i32, i32* @EOF
%31 = icmp eq i32 %29, %30
br i1 %31, label %32, label %7
32: ; preds = %27, %12, %2
ret i32 0
}