#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 getchar();
char *readln_aux(int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ ungetc(int, int /*<<< orphan*/);
char *read_line() {
  int c;
  if ((c = getchar()) == '#') {
    while ((c = getchar()) != '\n' && c != EOF)
      ;
    return c != EOF ? read_line() : NULL;
  } else {
    ungetc(c, stdin);
    return readln_aux(0);
  }
}


x86 assembly (clang, -O0):
<read_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x23,%eax
jne    11d9 <read_line+0x99>
jmp    1160 <read_line+0x20>
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %eax,%ecx
mov    %ecx,-0xc(%rbp)
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0xd(%rbp)
je     118c <read_line+0x4c>
mov    -0xc(%rbp),%eax
mov    0x2e5c(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    119c <read_line+0x5c>
jmp    11a1 <read_line+0x61>
jmp    1160 <read_line+0x20>
mov    -0xc(%rbp),%eax
mov    0x2e35(%rip),%rcx
cmp    (%rcx),%eax
je     11c1 <read_line+0x81>
call   1050 <read_line@plt>
mov    %rax,-0x18(%rbp)
jmp    11cc <read_line+0x8c>
xor    %eax,%eax
mov    %rax,-0x18(%rbp)
jmp    11cc <read_line+0x8c>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11f5 <read_line+0xb5>
mov    -0xc(%rbp),%edi
mov    0x2e05(%rip),%rax
mov    (%rax),%esi
call   1040 <ungetc@plt>
xor    %edi,%edi
call   1060 <readln_aux@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_line>:
push   %rbx
mov    0x2ea8(%rip),%rbx
jmp    1144 <read_line+0x14>
nopw   0x0(%rax,%rax,1)
cmp    %ecx,%eax
je     1164 <read_line+0x34>
xor    %eax,%eax
call   1030 <getchar@plt>
cmp    $0x23,%eax
jne    1168 <read_line+0x38>
xor    %eax,%eax
call   1030 <getchar@plt>
mov    (%rbx),%ecx
cmp    $0xa,%eax
je     1140 <read_line+0x10>
cmp    %ecx,%eax
jne    1150 <read_line+0x20>
jmp    1140 <read_line+0x10>
xor    %eax,%eax
pop    %rbx
ret
mov    0x2e79(%rip),%rcx
mov    (%rcx),%esi
mov    %eax,%edi
call   1040 <ungetc@plt>
xor    %edi,%edi
pop    %rbx
jmp    1050 <readln_aux@plt>

LLVM IR (-O0):
@EOF = global i32 0
@stdin = global i32 0
define i8* @read_line() {
%1 = alloca i8*
%2 = alloca i32
%3 = call i32 (...) @getchar()
store i32 %3, i32* %2
%4 = icmp eq i32 %3, 35
br i1 %4, label %5, label %25
5: ; preds = %0
br label %6
6: ; preds = %15, %5
%7 = call i32 (...) @getchar()
store i32 %7, i32* %2
%8 = icmp ne i32 %7, 10
br i1 %8, label %9, label %13
9: ; preds = %6
%10 = load i32, i32* %2
%11 = load i32, i32* @EOF
%12 = icmp ne i32 %10, %11
br label %13
13: ; preds = %9, %6
%14 = phi i1 [ false, %6 ], [ %12, %9 ]
br i1 %14, label %15, label %16
15: ; preds = %13
br label %6
16: ; preds = %13
%17 = load i32, i32* %2
%18 = load i32, i32* @EOF
%19 = icmp ne i32 %17, %18
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i8* @read_line()
br label %23
22: ; preds = %16
br label %23
23: ; preds = %22, %20
%24 = phi i8* [ %21, %20 ], [ null, %22 ]
store i8* %24, i8** %1
br label %30
25: ; preds = %0
%26 = load i32, i32* %2
%27 = load i32, i32* @stdin
%28 = call i32 @ungetc(i32 %26, i32 %27)
%29 = call i8* @readln_aux(i32 0)
store i8* %29, i8** %1
br label %30
30: ; preds = %25, %23
%31 = load i8*, i8** %1
ret i8* %31
}

LLVM IR (-O2):
@EOF = global i32 0
@stdin = global i32 0
define i8* @read_line() {
br label %1
1: ; preds = %10, %0
%2 = tail call i32 (...) @getchar()
%3 = icmp eq i32 %2, 35
br i1 %3, label %4, label %11
4: ; preds = %1, %4
%5 = tail call i32 (...) @getchar()
%6 = icmp ne i32 %5, 10
%7 = load i32, i32* @EOF
%8 = icmp ne i32 %5, %7
%9 = select i1 %6, i1 %8, i1 false
br i1 %9, label %4, label %10
10: ; preds = %4
br i1 %8, label %1, label %15
11: ; preds = %1
%12 = load i32, i32* @stdin
%13 = tail call i32 @ungetc(i32 %2, i32 %12)
%14 = tail call i8* @readln_aux(i32 0)
br label %15
15: ; preds = %10, %11
%16 = phi i8* [ %14, %11 ], [ null, %10 ]
ret i8* %16
}