#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 RfileReadRawLine(FILE *fp, int buflen, char *buffer) {
  int s;
  int j = 0;
  do {
    s = fgetc(fp);
    if (s == EOF)
      break;
    buffer[j] = s;
    j++;
  } while (s != 0);
  if (s == EOF)
    return -1;
  return 0;
}


x86 assembly (clang, -O0):
<RfileReadRawLine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    0x2ea8(%rip),%rcx
cmp    (%rcx),%eax
jne    114d <RfileReadRawLine+0x3d>
jmp    1170 <RfileReadRawLine+0x60>
mov    -0x24(%rbp),%eax
mov    %al,%dl
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    112a <RfileReadRawLine+0x1a>
mov    -0x24(%rbp),%eax
mov    0x2e6e(%rip),%rcx
cmp    (%rcx),%eax
jne    118e <RfileReadRawLine+0x7e>
movl   $0xffffffff,-0x4(%rbp)
jmp    1195 <RfileReadRawLine+0x85>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RfileReadRawLine>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %rdi,%r14
mov    0x2ec6(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
call   1030 <fgetc@plt>
cmp    (%r15),%eax
je     114c <RfileReadRawLine+0x3c>
mov    %al,(%rbx)
add    $0x1,%rbx
test   %eax,%eax
jne    1130 <RfileReadRawLine+0x20>
mov    (%r15),%edx
jmp    114e <RfileReadRawLine+0x3e>
mov    %eax,%edx
xor    %ecx,%ecx
cmp    %edx,%eax
sete   %cl
neg    %ecx
mov    %ecx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

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