#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 ReadLine(char *Buffer, FILE *InputFile) {
  int i = 0, j;
  while (1) {
    j = fgetc(InputFile);
    if (j == '\r')
      continue;
    Buffer[i++] = j;
    if (j == '\n' || j == EOF) {
      Buffer[i - 1] = 0;
      if (j == EOF)
        return 1;
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<ReadLine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0xd,-0x20(%rbp)
jne    1142 <ReadLine+0x32>
jmp    1127 <ReadLine+0x17>
mov    -0x20(%rbp),%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x1c(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
cmpl   $0xa,-0x20(%rbp)
je     1178 <ReadLine+0x68>
mov    -0x20(%rbp),%eax
mov    0x2e78(%rip),%rcx
cmp    (%rcx),%eax
jne    11ac <ReadLine+0x9c>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%eax
mov    0x2e55(%rip),%rcx
cmp    (%rcx),%eax
jne    11a7 <ReadLine+0x97>
movl   $0x1,-0x4(%rbp)
jmp    11b8 <ReadLine+0xa8>
jmp    11b1 <ReadLine+0xa1>
jmp    1127 <ReadLine+0x17>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReadLine>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
xor    %ecx,%ecx
mov    0x2ec1(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    %rcx,%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
call   1030 <fgetc@plt>
cmp    $0xd,%eax
je     1140 <ReadLine+0x30>
mov    %al,(%r14,%r12,1)
cmp    $0xa,%eax
je     1160 <ReadLine+0x50>
lea    0x1(%r12),%rcx
cmp    (%r15),%eax
jne    1130 <ReadLine+0x20>
movb   $0x0,(%r14,%r12,1)
xor    %ecx,%ecx
cmp    (%r15),%eax
sete   %cl
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@EOF = global i32 0
define i32 @ReadLine(i8* nocapture writeonly %0, i32* nocapture %1) {
br label %3
3: ; preds = %12, %2
%4 = phi i64 [ %13, %12 ], [ 0, %2 ]
br label %5
5: ; preds = %3, %5
%6 = tail call i32 @fgetc(i32* %1)
%7 = icmp eq i32 %6, 13
br i1 %7, label %5, label %8
8: ; preds = %5
%9 = trunc i32 %6 to i8
%10 = getelementptr inbounds i8, i8* %0, i64 %4
store i8 %9, i8* %10
%11 = icmp eq i32 %6, 10
br i1 %11, label %16, label %12
12: ; preds = %8
%13 = add nuw i64 %4, 1
%14 = load i32, i32* @EOF
%15 = icmp eq i32 %6, %14
br i1 %15, label %16, label %3
16: ; preds = %12, %8
%17 = getelementptr inbounds i8, i8* %0, i64 %4
store i8 0, i8* %17
%18 = load i32, i32* @EOF
%19 = icmp eq i32 %6, %18
%20 = zext i1 %19 to i32
ret i32 %20
}