#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 */
char fgetc(int /*<<< orphan*/ *);
char *realloc(char *, int);
scalar_t__ test_eof(char);
int /*<<< orphan*/ test_eol(char);
char *returnLine(FILE *fp) {
  char c;
  char *line;
  int size = 0;
  line = NULL;
  line = realloc(line, sizeof(char));
  c = fgetc(fp);
  if (test_eof(c)) {
    return NULL;
  } else {
    while (!test_eol(c)) {
      *(line + size) = c;
      size++;
      line = realloc(line, sizeof(char) * (size + 1));
      c = fgetc(fp);
    }
  }
  *(line + size) = '\0';
  return line;
}


x86 assembly (clang, -O0):
<returnLine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x1,%esi
call   1060 <realloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%edi
call   1050 <test_eof@plt>
cmp    $0x0,%rax
je     1199 <returnLine+0x59>
movq   $0x0,-0x8(%rbp)
jmp    1218 <returnLine+0xd8>
jmp    119e <returnLine+0x5e>
movsbl -0x11(%rbp),%edi
call   1040 <test_eol@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11bc <returnLine+0x7c>
jmp    11ff <returnLine+0xbf>
mov    -0x11(%rbp),%dl
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%esi
call   1060 <realloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0x11(%rbp)
jmp    119e <returnLine+0x5e>
jmp    1204 <returnLine+0xc4>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<returnLine>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r14
xor    %r12d,%r12d
xor    %edi,%edi
mov    $0x1,%esi
call   1060 <realloc@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1030 <fgetc@plt>
mov    %eax,%ebx
movsbl %al,%ebp
mov    %ebp,%edi
call   1050 <test_eof@plt>
test   %rax,%rax
jne    11c9 <returnLine+0x89>
mov    %ebp,%edi
call   1040 <test_eol@plt>
test   %eax,%eax
je     1185 <returnLine+0x45>
xor    %eax,%eax
jmp    11c1 <returnLine+0x81>
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rsi
mov    %bl,(%r15,%rbp,1)
add    $0x1,%rbp
add    $0x2,%esi
mov    %r15,%rdi
call   1060 <realloc@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1030 <fgetc@plt>
mov    %eax,%ebx
movsbl %al,%edi
call   1040 <test_eol@plt>
test   %eax,%eax
je     1190 <returnLine+0x50>
mov    %ebp,%eax
movb   $0x0,(%r15,%rax,1)
mov    %r15,%r12
mov    %r12,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i8* @returnLine(i32* nocapture %0) {
%2 = tail call i8* @realloc(i8* null, i32 1)
%3 = tail call signext i8 @fgetc(i32* %0)
%4 = tail call i64 @test_eof(i8 signext %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %27
6: ; preds = %1
%7 = tail call i32 @test_eol(i8 signext %3)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %23
9: ; preds = %6, %9
%10 = phi i64 [ %14, %9 ], [ 0, %6 ]
%11 = phi i8* [ %17, %9 ], [ %2, %6 ]
%12 = phi i8 [ %18, %9 ], [ %3, %6 ]
%13 = getelementptr inbounds i8, i8* %11, i64 %10
store i8 %12, i8* %13
%14 = add nuw i64 %10, 1
%15 = trunc i64 %10 to i32
%16 = add i32 %15, 2
%17 = tail call i8* @realloc(i8* %11, i32 %16)
%18 = tail call signext i8 @fgetc(i32* %0)
%19 = tail call i32 @test_eol(i8 signext %18)
%20 = icmp eq i32 %19, 0
br i1 %20, label %9, label %21
21: ; preds = %9
%22 = and i64 %14, 4294967295
br label %23
23: ; preds = %21, %6
%24 = phi i8* [ %2, %6 ], [ %17, %21 ]
%25 = phi i64 [ 0, %6 ], [ %22, %21 ]
%26 = getelementptr inbounds i8, i8* %24, i64 %25
store i8 0, i8* %26
br label %27
27: ; preds = %1, %23
%28 = phi i8* [ %24, %23 ], [ null, %1 ]
ret i8* %28
}