#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*/ fprintf(int /*<<< orphan*/, char *);
int getchar();
int /*<<< orphan*/ putchar(int);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  int c, lc;
  int off = 0;
  if (argc > 1) {
    fprintf(stderr, "no arguments, please\n");
    return 1;
  }
  lc = -1;
  while ((c = getchar()) != EOF) {
    if (c == '\n' && lc == '\r')
      putchar(c);
    else if (c == '\n') {
      putchar('\r');
      putchar(c);
    } else if (c != '\n' && lc == '\r') {
      putchar('\n');
      putchar(c);
    } else
      putchar(c);
    lc = c;
    off++;
  }
  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)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1178 <main+0x48>
mov    0x2e7a(%rip),%rax
mov    (%rax),%edi
lea    0xe99(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1232 <main+0x102>
movl   $0xffffffff,-0x18(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e58(%rip),%rcx
cmp    (%rcx),%eax
je     122b <main+0xfb>
cmpl   $0xa,-0x14(%rbp)
jne    11b9 <main+0x89>
cmpl   $0xd,-0x18(%rbp)
jne    11b9 <main+0x89>
mov    -0x14(%rbp),%edi
call   1030 <putchar@plt>
jmp    1217 <main+0xe7>
cmpl   $0xa,-0x14(%rbp)
jne    11da <main+0xaa>
mov    $0xd,%edi
call   1030 <putchar@plt>
mov    -0x14(%rbp),%edi
call   1030 <putchar@plt>
jmp    1212 <main+0xe2>
cmpl   $0xa,-0x14(%rbp)
je     1205 <main+0xd5>
cmpl   $0xd,-0x18(%rbp)
jne    1205 <main+0xd5>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x14(%rbp),%edi
call   1030 <putchar@plt>
jmp    120d <main+0xdd>
mov    -0x14(%rbp),%edi
call   1030 <putchar@plt>
jmp    1212 <main+0xe2>
jmp    1217 <main+0xe7>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    117f <main+0x4f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
cmp    $0x1,%edi
jle    1155 <main+0x25>
mov    0x2e98(%rip),%rax
mov    (%rax),%edi
lea    0xeb7(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%ebx
jmp    116a <main+0x3a>
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2e83(%rip),%r14
cmp    (%r14),%eax
jne    1171 <main+0x41>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    $0xffffffff,%ebp
xor    %ebx,%ebx
jmp    11a6 <main+0x76>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
cmp    $0xa,%ebp
sete   %al
lea    (%rax,%rax,2),%edi
add    $0xa,%edi
call   1030 <putchar@plt>
mov    %ebp,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%r14),%eax
je     116a <main+0x3a>
mov    %ebp,%ecx
mov    %eax,%ebp
cmp    $0xd,%ecx
jne    11b9 <main+0x89>
mov    $0xa,%edi
cmp    $0xa,%ebp
je     1195 <main+0x65>
cmp    $0xa,%ebp
je     1180 <main+0x50>
mov    %ebp,%edi
cmp    $0xd,%ecx
jne    1195 <main+0x65>
jmp    1180 <main+0x50>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [22 x i8] c"no arguments, please\0A\00"
@EOF = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
%9 = load i32, i32* %4
%10 = icmp sgt i32 %9, 1
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %55
14: ; preds = %2
store i32 -1, i32* %7
br label %15
15: ; preds = %50, %14
%16 = call i32 (...) @getchar()
store i32 %16, i32* %6
%17 = load i32, i32* @EOF
%18 = icmp ne i32 %16, %17
br i1 %18, label %19, label %54
19: ; preds = %15
%20 = load i32, i32* %6
%21 = icmp eq i32 %20, 10
br i1 %21, label %22, label %28
22: ; preds = %19
%23 = load i32, i32* %7
%24 = icmp eq i32 %23, 13
br i1 %24, label %25, label %28
25: ; preds = %22
%26 = load i32, i32* %6
%27 = call i32 @putchar(i32 %26)
br label %50
28: ; preds = %22, %19
%29 = load i32, i32* %6
%30 = icmp eq i32 %29, 10
br i1 %30, label %31, label %35
31: ; preds = %28
%32 = call i32 @putchar(i32 13)
%33 = load i32, i32* %6
%34 = call i32 @putchar(i32 %33)
br label %49
35: ; preds = %28
%36 = load i32, i32* %6
%37 = icmp ne i32 %36, 10
br i1 %37, label %38, label %45
38: ; preds = %35
%39 = load i32, i32* %7
%40 = icmp eq i32 %39, 13
br i1 %40, label %41, label %45
41: ; preds = %38
%42 = call i32 @putchar(i32 10)
%43 = load i32, i32* %6
%44 = call i32 @putchar(i32 %43)
br label %48
45: ; preds = %38, %35
%46 = load i32, i32* %6
%47 = call i32 @putchar(i32 %46)
br label %48
48: ; preds = %45, %41
br label %49
49: ; preds = %48, %31
br label %50
50: ; preds = %49, %25
%51 = load i32, i32* %6
store i32 %51, i32* %7
%52 = load i32, i32* %8
%53 = add nsw i32 %52, 1
store i32 %53, i32* %8
br label %15
54: ; preds = %15
store i32 0, i32* %3
br label %55
55: ; preds = %54, %11
%56 = load i32, i32* %3
ret i32 %56
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [22 x i8] c"no arguments, please\0A\00"
@EOF = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = tail call i32 (...) @getchar()
%6 = load i32, i32* @EOF
%7 = icmp eq i32 %5, %6
br i1 %7, label %28, label %11
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %28
11: ; preds = %4, %22
%12 = phi i32 [ %25, %22 ], [ %5, %4 ]
%13 = phi i32 [ %12, %22 ], [ -1, %4 ]
%14 = icmp eq i32 %12, 10
%15 = icmp eq i32 %13, 13
%16 = and i1 %15, %14
br i1 %16, label %22, label %17
17: ; preds = %11
%18 = or i1 %14, %15
br i1 %18, label %19, label %22
19: ; preds = %17
%20 = select i1 %14, i32 13, i32 10
%21 = tail call i32 @putchar(i32 %20)
br label %22
22: ; preds = %17, %19, %11
%23 = phi i32 [ 10, %11 ], [ %12, %19 ], [ %12, %17 ]
%24 = tail call i32 @putchar(i32 %23)
%25 = tail call i32 (...) @getchar()
%26 = load i32, i32* @EOF
%27 = icmp eq i32 %25, %26
br i1 %27, label %28, label %11
28: ; preds = %22, %4, %8
%29 = phi i32 [ 1, %8 ], [ 0, %4 ], [ 0, %22 ]
ret i32 %29
}