#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 */

/* Variables and functions */
int EOF;
int /*<<< orphan*/ asprintf(char **, char *, char *, ...);
int getc(int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
char *dynreadline() {
  char *line = NULL;
  static const int bufsz = 100;
  char buf[bufsz];
  bool done = false;
  while (!done) {
    int c, i = 0;
    while ((i < bufsz - 1) && ((c = getc(stdin)) != EOF)) {
      if (c == '\n') {
        buf[i] = 0;
        done = true;
        break;
      }
      buf[i] = c;
      ++i;
    }
    buf[i] = 0;
    if (line == NULL) {
      asprintf(&line, "%s", buf);
    } else {
      asprintf(&line, "%s%s", line, buf);
    }
  }
  return line;
}


x86 assembly (clang, -O0):
<dynreadline>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movq   $0x0,-0x8(%rbp)
mov    %rsp,%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1157 <dynreadline+0x37>
jmp    122e <dynreadline+0x10e>
movl   $0x0,-0x1c(%rbp)
xor    %eax,%eax
cmpl   $0x63,-0x1c(%rbp)
mov    %al,-0x81(%rbp)
jge    1193 <dynreadline+0x73>
mov    0x2e71(%rip),%rax
mov    (%rax),%edi
call   1040 <getc@plt>
mov    %eax,-0x18(%rbp)
mov    0x2e58(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
mov    %al,-0x81(%rbp)
mov    -0x81(%rbp),%al
test   $0x1,%al
jne    11a6 <dynreadline+0x86>
jmp    11e0 <dynreadline+0xc0>
cmpl   $0xa,-0x18(%rbp)
jne    11c5 <dynreadline+0xa5>
movslq -0x1c(%rbp),%rax
movb   $0x0,-0x80(%rbp,%rax,1)
movl   $0x1,-0x14(%rbp)
jmp    11e0 <dynreadline+0xc0>
mov    -0x18(%rbp),%eax
mov    %al,%cl
movslq -0x1c(%rbp),%rax
mov    %cl,-0x80(%rbp,%rax,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    115e <dynreadline+0x3e>
movslq -0x1c(%rbp),%rax
movb   $0x0,-0x80(%rbp,%rax,1)
cmpq   $0x0,-0x8(%rbp)
jne    120f <dynreadline+0xef>
lea    -0x8(%rbp),%rdi
lea    0xe07(%rip),%rsi
lea    -0x80(%rbp),%rdx
mov    $0x0,%al
call   1030 <asprintf@plt>
jmp    1229 <dynreadline+0x109>
mov    -0x8(%rbp),%rdx
lea    -0x8(%rbp),%rdi
lea    0xde6(%rip),%rsi
lea    -0x80(%rbp),%rcx
mov    $0x0,%al
call   1030 <asprintf@plt>
jmp    1141 <dynreadline+0x21>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    %rcx,%rsp
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dynreadline>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %rsp,0x8(%rsp)
movq   $0x0,(%rsp)
mov    0x2ea6(%rip),%rbp
mov    0x2e97(%rip),%r13
mov    %rsp,%r15
lea    0x10(%rsp),%rbx
xor    %r12d,%r12d
jmp    117c <dynreadline+0x5c>
cs nopw 0x0(%rax,%rax,1)
lea    0xe99(%rip),%rsi
mov    %rbx,%rcx
xor    %eax,%eax
call   1030 <asprintf@plt>
mov    $0x0,%r12d
test   %r14b,%r14b
je     11f6 <dynreadline+0xd6>
mov    0x0(%rbp),%edi
call   1040 <getc@plt>
cmp    0x0(%r13),%eax
jne    11a0 <dynreadline+0x80>
mov    %r12,%rax
mov    %eax,%eax
mov    $0x1,%r14b
jmp    11b0 <dynreadline+0x90>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    $0xa,%eax
jne    11e0 <dynreadline+0xc0>
mov    %r12d,%eax
movb   $0x0,0x10(%rsp,%rax,1)
xor    %r14d,%r14d
movb   $0x0,0x10(%rsp,%rax,1)
mov    (%rsp),%rdx
mov    %r15,%rdi
test   %rdx,%rdx
jne    1160 <dynreadline+0x40>
lea    0xe3a(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <asprintf@plt>
jmp    1171 <dynreadline+0x51>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %al,0x10(%rsp,%r12,1)
add    $0x1,%r12
mov    $0x63,%eax
cmp    $0x63,%r12
jne    117c <dynreadline+0x5c>
jmp    118d <dynreadline+0x6d>
mov    (%rsp),%rax
mov    0x8(%rsp),%rsp
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@dynreadline.bufsz = internal constant i32 100
@stdin = global i32 0
@EOF = global i32 0
@.str = [3 x i8] c"%s\00"
@.str.1 = [5 x i8] c"%s%s\00"
define i8* @dynreadline() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i8* null, i8** %1
%6 = call i8* @llvm.stacksave()
store i8* %6, i8** %2
%7 = alloca i8, i64 100
store i32 0, i32* %3
br label %8
8: ; preds = %49, %0
%9 = load i32, i32* %3
%10 = icmp ne i32 %9, 0
%11 = xor i1 %10, true
br i1 %11, label %12, label %50
12: ; preds = %8
store i32 0, i32* %5
br label %13
13: ; preds = %30, %12
%14 = load i32, i32* %5
%15 = icmp slt i32 %14, 99
br i1 %15, label %16, label %21
16: ; preds = %13
%17 = load i32, i32* @stdin
%18 = call i32 @getc(i32 %17)
store i32 %18, i32* %4
%19 = load i32, i32* @EOF
%20 = icmp ne i32 %18, %19
br label %21
21: ; preds = %16, %13
%22 = phi i1 [ false, %13 ], [ %20, %16 ]
br i1 %22, label %23, label %38
23: ; preds = %21
%24 = load i32, i32* %4
%25 = icmp eq i32 %24, 10
br i1 %25, label %26, label %30
26: ; preds = %23
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %7, i64 %28
store i8 0, i8* %29
store i32 1, i32* %3
br label %38
30: ; preds = %23
%31 = load i32, i32* %4
%32 = trunc i32 %31 to i8
%33 = load i32, i32* %5
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %7, i64 %34
store i8 %32, i8* %35
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 1
store i32 %37, i32* %5
br label %13
38: ; preds = %26, %21
%39 = load i32, i32* %5
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %7, i64 %40
store i8 0, i8* %41
%42 = load i8*, i8** %1
%43 = icmp eq i8* %42, null
br i1 %43, label %44, label %46
44: ; preds = %38
%45 = call i32 (i8**, i8*, i8*, ...) @asprintf(i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %7)
br label %49
46: ; preds = %38
%47 = load i8*, i8** %1
%48 = call i32 (i8**, i8*, i8*, ...) @asprintf(i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %47, i8* %7)
br label %49
49: ; preds = %46, %44
br label %8
50: ; preds = %8
%51 = load i8*, i8** %1
%52 = load i8*, i8** %2
ret i8* %51
}

LLVM IR (-O2):
@stdin = global i32 0
@EOF = global i32 0
@.str = [3 x i8] c"%s\00"
@.str.1 = [5 x i8] c"%s%s\00"
define i8* @dynreadline() {
%1 = alloca i8*
%2 = bitcast i8** %1 to i8*
store i8* null, i8** %1
%3 = tail call i8* @llvm.stacksave()
%4 = alloca [100 x i8]
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
br label %6
6: ; preds = %22, %0
%7 = phi i64 [ 0, %0 ], [ %23, %22 ]
%8 = load i32, i32* @stdin
%9 = call i32 @getc(i32 %8)
%10 = load i32, i32* @EOF
%11 = icmp eq i32 %9, %10
br i1 %11, label %24, label %12
12: ; preds = %6
%13 = icmp eq i32 %9, 10
br i1 %13, label %14, label %17
14: ; preds = %12
%15 = and i64 %7, 4294967295
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %15
store i8 0, i8* %16
br label %27
17: ; preds = %12
%18 = trunc i32 %9 to i8
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %7
store i8 %18, i8* %19
%20 = add nuw nsw i64 %7, 1
%21 = icmp eq i64 %20, 99
br i1 %21, label %24, label %22
22: ; preds = %17, %37
%23 = phi i64 [ %20, %17 ], [ 0, %37 ]
br label %6
24: ; preds = %6, %17
%25 = phi i64 [ 99, %17 ], [ %7, %6 ]
%26 = and i64 %25, 4294967295
br label %27
27: ; preds = %24, %14
%28 = phi i64 [ %26, %24 ], [ %15, %14 ]
%29 = phi i1 [ true, %24 ], [ false, %14 ]
%30 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %28
store i8 0, i8* %30
%31 = load i8*, i8** %1
%32 = icmp eq i8* %31, null
br i1 %32, label %33, label %35
33: ; preds = %27
%34 = call i32 (i8**, i8*, i8*, ...) @asprintf(i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %37
35: ; preds = %27
%36 = call i32 (i8**, i8*, i8*, ...) @asprintf(i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %31, i8* %5)
br label %37
37: ; preds = %35, %33
br i1 %29, label %22, label %38
38: ; preds = %37
%39 = load i8*, i8** %1
ret i8* %39
}