#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EOF;
scalar_t__ feof(int /*<<< orphan*/ *);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ putc(int, int /*<<< orphan*/ *);
void copy(FILE *ffp, FILE *tfp) {
  register int c, pc;
  for (pc = 0; 1; pc = c) {
    c = getc(ffp);
    if (c == EOF && feof(ffp))
      return;
    if (c == '\n' && pc != '\r')
      putc('\r', tfp);
    putc(c, tfp);
  }
}


x86 assembly (clang, -O0):
<copy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    $0x1,%al
test   $0x1,%al
jne    1156 <copy+0x26>
jmp    11c5 <copy+0x95>
mov    -0x8(%rbp),%rdi
call   1050 <getc@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e7c(%rip),%rcx
cmp    (%rcx),%eax
jne    118c <copy+0x5c>
mov    -0x8(%rbp),%rdi
call   1040 <feof@plt>
cmp    $0x0,%rax
je     118c <copy+0x5c>
jmp    11c5 <copy+0x95>
cmpl   $0xa,-0x14(%rbp)
jne    11ae <copy+0x7e>
cmpl   $0xd,-0x18(%rbp)
je     11ae <copy+0x7e>
mov    -0x10(%rbp),%rsi
mov    $0xd,%edi
call   1030 <putc@plt>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <putc@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    1147 <copy+0x17>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<copy>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r12
xor    %ebx,%ebx
mov    0x2ea1(%rip),%r15
jmp    115c <copy+0x2c>
nopl   0x0(%rax)
mov    %ebp,%edi
mov    %r14,%rsi
call   1030 <putc@plt>
mov    %ebp,%ebx
mov    %r12,%rdi
call   1050 <getc@plt>
mov    %eax,%ebp
cmp    (%r15),%eax
jne    1178 <copy+0x48>
mov    %r12,%rdi
call   1040 <feof@plt>
test   %rax,%rax
jne    1191 <copy+0x61>
cmp    $0xd,%ebx
je     1150 <copy+0x20>
cmp    $0xa,%ebp
jne    1150 <copy+0x20>
mov    $0xd,%edi
mov    %r14,%rsi
call   1030 <putc@plt>
jmp    1150 <copy+0x20>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
define void @copy(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
store i32 0, i32* %6
br label %7
7: ; preds = %32, %2
br i1 true, label %8, label %34
8: ; preds = %7
%9 = load i32*, i32** %3
%10 = call i32 @getc(i32* %9)
store i32 %10, i32* %5
%11 = load i32, i32* %5
%12 = load i32, i32* @EOF
%13 = icmp eq i32 %11, %12
br i1 %13, label %14, label %19
14: ; preds = %8
%15 = load i32*, i32** %3
%16 = call i64 @feof(i32* %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %14
br label %34
19: ; preds = %14, %8
%20 = load i32, i32* %5
%21 = icmp eq i32 %20, 10
br i1 %21, label %22, label %28
22: ; preds = %19
%23 = load i32, i32* %6
%24 = icmp ne i32 %23, 13
br i1 %24, label %25, label %28
25: ; preds = %22
%26 = load i32*, i32** %4
%27 = call i32 @putc(i32 13, i32* %26)
br label %28
28: ; preds = %25, %22, %19
%29 = load i32, i32* %5
%30 = load i32*, i32** %4
%31 = call i32 @putc(i32 %29, i32* %30)
br label %32
32: ; preds = %28
%33 = load i32, i32* %5
store i32 %33, i32* %6
br label %7
34: ; preds = %18, %7
ret void
}

LLVM IR (-O2):
@EOF = global i32 0
define void @copy(i32* nocapture %0, i32* nocapture %1) {
br label %3
3: ; preds = %18, %2
%4 = phi i32 [ 0, %2 ], [ %5, %18 ]
%5 = tail call i32 @getc(i32* %0)
%6 = load i32, i32* @EOF
%7 = icmp eq i32 %5, %6
br i1 %7, label %8, label %12
8: ; preds = %3
%9 = tail call i64 @feof(i32* %0)
%10 = icmp eq i64 %9, 0
br i1 %10, label %12, label %11
11: ; preds = %8
ret void
12: ; preds = %8, %3
%13 = icmp eq i32 %5, 10
%14 = icmp ne i32 %4, 13
%15 = and i1 %14, %13
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = tail call i32 @putc(i32 13, i32* %1)
br label %18
18: ; preds = %16, %12
%19 = tail call i32 @putc(i32 %5, i32* %1)
br label %3
}