#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 getline(char **, size_t *, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
scalar_t__ strcmp(char *, char *);
char *read_line(void) {
  char *line = 0;
  size_t size = 0;
  int status;
  status = getline(&line, &size, stdin);
  if (status == -1 || strcmp(line, "\n") == 0) {
    return NULL;
  }
  return line;
}


x86 assembly (clang, -O0):
<read_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    0x2ea9(%rip),%rax
mov    (%rax),%edx
lea    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <getline@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
je     1175 <read_line+0x55>
mov    -0x10(%rbp),%rdi
lea    0xe9a(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1182 <read_line+0x62>
movq   $0x0,-0x8(%rbp)
jmp    118a <read_line+0x6a>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_line>:
sub    $0x18,%rsp
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
mov    0x2eab(%rip),%rax
mov    (%rax),%edx
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1040 <getline@plt>
cmp    $0xffffffff,%eax
je     1173 <read_line+0x53>
mov    0x8(%rsp),%rdi
lea    0xea1(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     116e <read_line+0x4e>
mov    0x8(%rsp),%rax
add    $0x18,%rsp
ret
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [2 x i8] c"\0A\00"
define i8* @read_line() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i32
store i8* null, i8** %2
store i64 0, i64* %3
%5 = load i32, i32* @stdin
%6 = call i32 @getline(i8** %2, i64* %3, i32 %5)
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, -1
br i1 %8, label %13, label %9
9: ; preds = %0
%10 = load i8*, i8** %2
%11 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %9, %0
store i8* null, i8** %1
br label %16
14: ; preds = %9
%15 = load i8*, i8** %2
store i8* %15, i8** %1
br label %16
16: ; preds = %14, %13
%17 = load i8*, i8** %1
ret i8* %17
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [2 x i8] c"\0A\00"
define i8* @read_line() {
%1 = alloca i8*
%2 = alloca i64
%3 = bitcast i8** %1 to i8*
store i8* null, i8** %1
%4 = bitcast i64* %2 to i8*
store i64 0, i64* %2
%5 = load i32, i32* @stdin
%6 = call i32 @getline(i8** %1, i64* %2, i32 %5)
%7 = icmp eq i32 %6, -1
br i1 %7, label %14, label %8
8: ; preds = %0
%9 = load i8*, i8** %1
%10 = call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
%12 = load i8*, i8** %1
%13 = select i1 %11, i8* null, i8* %12
br label %14
14: ; preds = %8, %0
%15 = phi i8* [ null, %0 ], [ %13, %8 ]
ret i8* %15
}