#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 uint32_t;

/* Variables and functions */
char EOF;
char getchar();
scalar_t__ realloc(char *, int);
char *io_line() {
  bool end = false;
  char c, *prod = NULL;
  uint32_t len = 0, prod_s = 0;
  while (!end) {
    prod = (char *)realloc(prod, prod_s += 80);
    while (len < prod_s - 1) {
      if ((c = getchar()) == EOF || c == '\n') {
        end = true;
        break;
      } else
        prod[len++] = c;
    }
  }
  prod = (char *)realloc(prod, len + 1);
  prod[len] = '\0';
  return prod;
}


x86 assembly (clang, -O0):
<io_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x0,-0x4(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    115b <io_line+0x3b>
jmp    11dc <io_line+0xbc>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
add    $0x50,%esi
mov    %esi,-0x18(%rbp)
call   1040 <realloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11d7 <io_line+0xb7>
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
mov    0x2e52(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11ae <io_line+0x8e>
movsbl -0x5(%rbp),%eax
cmp    $0xa,%eax
jne    11ba <io_line+0x9a>
movl   $0x1,-0x4(%rbp)
jmp    11d7 <io_line+0xb7>
mov    -0x5(%rbp),%dl
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x14(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
jmp    1171 <io_line+0x51>
jmp    1145 <io_line+0x25>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    $0x1,%esi
call   1040 <realloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<io_line>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    $0x4f,%ebp
mov    0x2eae(%rip),%r12
xor    %r14d,%r14d
xor    %r13d,%r13d
xor    %ebx,%ebx
jmp    1158 <io_line+0x38>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x50,%ebp
mov    0x10(%rsp),%r14
lea    0x50(%r14),%rsi
mov    %rbx,%rdi
mov    %rsi,0x10(%rsp)
call   1040 <realloc@plt>
mov    %rax,%rbx
add    $0x4f,%r14
movslq %r13d,%r15
cmp    %r15,%r14
jle    1150 <io_line+0x30>
mov    %ebp,0xc(%rsp)
mov    %r15,%r13
shl    $0x20,%r13
lea    0x1(%r15),%ebp
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <getchar@plt>
cmp    $0xa,%al
je     11c7 <io_line+0xa7>
cmp    (%r12),%al
je     11c7 <io_line+0xa7>
mov    %al,(%rbx,%r15,1)
add    $0x1,%r15
movabs $0x100000000,%rax
add    %rax,%r13
add    $0x1,%ebp
cmp    %r14,%r15
jl     1190 <io_line+0x70>
mov    0xc(%rsp),%ebp
mov    %ebp,%r13d
jmp    1150 <io_line+0x30>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <realloc@plt>
sar    $0x20,%r13
movb   $0x0,(%rax,%r13,1)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@EOF = global i8 0
define i8* @io_line() {
br label %1
1: ; preds = %24, %0
%2 = phi i64 [ 0, %0 ], [ %6, %24 ]
%3 = phi i32 [ 79, %0 ], [ %26, %24 ]
%4 = phi i32 [ 0, %0 ], [ %25, %24 ]
%5 = phi i8* [ null, %0 ], [ %9, %24 ]
%6 = add nuw i64 %2, 80
%7 = trunc i64 %6 to i32
%8 = tail call i64 @realloc(i8* %5, i32 %7)
%9 = inttoptr i64 %8 to i8*
%10 = add nuw nsw i64 %2, 79
%11 = sext i32 %4 to i64
%12 = icmp sgt i64 %10, %11
br i1 %12, label %13, label %24
13: ; preds = %1, %20
%14 = phi i64 [ %21, %20 ], [ %11, %1 ]
%15 = tail call signext i8 (...) @getchar()
%16 = load i8, i8* @EOF
%17 = icmp eq i8 %15, %16
%18 = icmp eq i8 %15, 10
%19 = or i1 %18, %17
br i1 %19, label %27, label %20
20: ; preds = %13
%21 = add nsw i64 %14, 1
%22 = getelementptr inbounds i8, i8* %9, i64 %14
store i8 %15, i8* %22
%23 = icmp slt i64 %21, %10
br i1 %23, label %13, label %24
24: ; preds = %20, %1
%25 = phi i32 [ %4, %1 ], [ %3, %20 ]
%26 = add i32 %3, 80
br label %1
27: ; preds = %13
%28 = inttoptr i64 %8 to i8*
%29 = trunc i64 %14 to i32
%30 = add nsw i32 %29, 1
%31 = tail call i64 @realloc(i8* %28, i32 %30)
%32 = inttoptr i64 %31 to i8*
%33 = shl i64 %14, 32
%34 = ashr exact i64 %33, 32
%35 = getelementptr inbounds i8, i8* %32, i64 %34
store i8 0, i8* %35
ret i8* %32
}