#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;
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ ungetc(int, int /*<<< orphan*/ *);
void copyLine(FILE *fin, FILE *fout) {
  int c;
  while ((c = fgetc(fin)) != EOF && c != '\r' && c != '\n')
    fputc(c, fout);
  if (c == '\r' && (c = fgetc(fin)) != EOF && c != '\n')
    ungetc(c, fin);
  fputc('\n', fout);
}


x86 assembly (clang, -O0):
<copyLine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,%ecx
mov    %ecx,-0x14(%rbp)
xor    %eax,%eax
mov    0x2e91(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x15(%rbp)
je     117b <copyLine+0x4b>
xor    %eax,%eax
cmpl   $0xd,-0x14(%rbp)
mov    %al,-0x15(%rbp)
je     117b <copyLine+0x4b>
cmpl   $0xa,-0x14(%rbp)
setne  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    118b <copyLine+0x5b>
jmp    119f <copyLine+0x6f>
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%rsi
movsbl %al,%edi
call   1040 <fputc@plt>
jmp    1140 <copyLine+0x10>
cmpl   $0xd,-0x14(%rbp)
jne    11da <copyLine+0xaa>
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e2c(%rip),%rcx
cmp    (%rcx),%eax
je     11da <copyLine+0xaa>
cmpl   $0xa,-0x14(%rbp)
je     11da <copyLine+0xaa>
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1050 <ungetc@plt>
mov    -0x10(%rbp),%rsi
mov    $0xa,%edi
call   1040 <fputc@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<copyLine>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <fgetc@plt>
mov    0x2ea1(%rip),%r15
cmp    (%r15),%eax
je     1172 <copyLine+0x42>
nopl   0x0(%rax)
cmp    $0xa,%eax
je     1193 <copyLine+0x63>
cmp    $0xd,%eax
je     1177 <copyLine+0x47>
movsbl %al,%edi
mov    %r14,%rsi
call   1040 <fputc@plt>
mov    %rbx,%rdi
call   1030 <fgetc@plt>
cmp    (%r15),%eax
jne    1150 <copyLine+0x20>
cmp    $0xd,%eax
jne    1193 <copyLine+0x63>
mov    %rbx,%rdi
call   1030 <fgetc@plt>
cmp    $0xa,%eax
je     1193 <copyLine+0x63>
cmp    (%r15),%eax
je     1193 <copyLine+0x63>
mov    %eax,%edi
mov    %rbx,%rsi
call   1050 <ungetc@plt>
mov    $0xa,%edi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <fputc@plt>

LLVM IR (-O0):
@EOF = global i32 0
define void @copyLine(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
br label %6
6: ; preds = %19, %2
%7 = load i32*, i32** %3
%8 = call i32 @fgetc(i32* %7)
store i32 %8, i32* %5
%9 = load i32, i32* @EOF
%10 = icmp ne i32 %8, %9
br i1 %10, label %11, label %17
11: ; preds = %6
%12 = load i32, i32* %5
%13 = icmp ne i32 %12, 13
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = load i32, i32* %5
%16 = icmp ne i32 %15, 10
br label %17
17: ; preds = %14, %11, %6
%18 = phi i1 [ false, %11 ], [ false, %6 ], [ %16, %14 ]
br i1 %18, label %19, label %24
19: ; preds = %17
%20 = load i32, i32* %5
%21 = trunc i32 %20 to i8
%22 = load i32*, i32** %4
%23 = call i32 @fputc(i8 signext %21, i32* %22)
br label %6
24: ; preds = %17
%25 = load i32, i32* %5
%26 = icmp eq i32 %25, 13
br i1 %26, label %27, label %39
27: ; preds = %24
%28 = load i32*, i32** %3
%29 = call i32 @fgetc(i32* %28)
store i32 %29, i32* %5
%30 = load i32, i32* @EOF
%31 = icmp ne i32 %29, %30
br i1 %31, label %32, label %39
32: ; preds = %27
%33 = load i32, i32* %5
%34 = icmp ne i32 %33, 10
br i1 %34, label %35, label %39
35: ; preds = %32
%36 = load i32, i32* %5
%37 = load i32*, i32** %3
%38 = call i32 @ungetc(i32 %36, i32* %37)
br label %39
39: ; preds = %35, %32, %27, %24
%40 = load i32*, i32** %4
%41 = call i32 @fputc(i8 signext 10, i32* %40)
ret void
}

LLVM IR (-O2):
@EOF = global i32 0
define void @copyLine(i32* nocapture %0, i32* nocapture %1) {
%3 = tail call i32 @fgetc(i32* %0)
%4 = load i32, i32* @EOF
%5 = freeze i32 %4
%6 = icmp eq i32 %3, %5
br i1 %6, label %16, label %7
7: ; preds = %2, %9
%8 = phi i32 [ %12, %9 ], [ %3, %2 ]
switch i32 %8, label %9 [
i32 13, label %19
i32 10, label %27
]
9: ; preds = %7
%10 = trunc i32 %8 to i8
%11 = tail call i32 @fputc(i8 signext %10, i32* %1)
%12 = tail call i32 @fgetc(i32* %0)
%13 = load i32, i32* @EOF
%14 = freeze i32 %13
%15 = icmp eq i32 %12, %14
br i1 %15, label %16, label %7
16: ; preds = %9, %2
%17 = phi i32 [ %3, %2 ], [ %12, %9 ]
%18 = icmp eq i32 %17, 13
br i1 %18, label %19, label %27
19: ; preds = %7, %16
%20 = tail call i32 @fgetc(i32* %0)
%21 = load i32, i32* @EOF
%22 = icmp ne i32 %20, %21
%23 = icmp ne i32 %20, 10
%24 = and i1 %23, %22
br i1 %24, label %25, label %27
25: ; preds = %19
%26 = tail call i32 @ungetc(i32 %20, i32* %0)
br label %27
27: ; preds = %7, %25, %19, %16
%28 = tail call i32 @fputc(i8 signext 10, i32* %1)
ret void
}