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

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ free(char *);
int getline(char **, size_t *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stdin;
size_t strcspn(char *, char *);
int strlen(char *);
char *player_line_query(char *description) {
  ssize_t line_length = -1;
  size_t byte_count;
  char *line = NULL;
  if (description != NULL) {
    printf("%s", description);
  }
  line_length = getline(&line, &byte_count, stdin);
  assert(line_length != -1);
  line[strcspn(line, "\r\n")] = 0;
  line_length = strlen(line);
  if (strlen(line) == 0) {
    free(line);
    return NULL;
  }
  return line;
}


x86 assembly (clang, -O0):
<player_line_query>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0xffffffff,-0x14(%rbp)
movq   $0x0,-0x28(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1196 <player_line_query+0x36>
mov    -0x10(%rbp),%rsi
lea    0xe6f(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e4b(%rip),%rax
mov    (%rax),%edx
lea    -0x28(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1080 <getline@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xe30(%rip),%rsi
call   1060 <strcspn@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax,%rcx,1)
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%eax
jne    1217 <player_line_query+0xb7>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    121f <player_line_query+0xbf>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<player_line_query>:
push   %rbx
sub    $0x10,%rsp
movq   $0x0,(%rsp)
test   %rdi,%rdi
je     1181 <player_line_query+0x21>
mov    %rdi,%rsi
lea    0xe84(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e60(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rdi
lea    0x8(%rsp),%rsi
call   1080 <getline@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
setne  %dil
call   1070 <assert@plt>
mov    (%rsp),%rbx
lea    0xe53(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcspn@plt>
movb   $0x0,(%rbx,%rax,1)
mov    (%rsp),%rdi
call   1040 <strlen@plt>
mov    (%rsp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    (%rsp),%rax
test   %ecx,%ecx
jne    11e2 <player_line_query+0x82>
mov    %rax,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"\0D\0A\00"
define i8* @player_line_query(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i64
%6 = alloca i8*
store i8* %0, i8** %3
store i32 -1, i32* %4
store i8* null, i8** %6
%7 = load i8*, i8** %3
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %12
12: ; preds = %9, %1
%13 = load i32, i32* @stdin
%14 = call i32 @getline(i8** %6, i64* %5, i32 %13)
store i32 %14, i32* %4
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, -1
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = load i8*, i8** %6
%20 = load i8*, i8** %6
%21 = call i64 @strcspn(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%22 = getelementptr inbounds i8, i8* %19, i64 %21
store i8 0, i8* %22
%23 = load i8*, i8** %6
%24 = call i32 @strlen(i8* %23)
store i32 %24, i32* %4
%25 = load i8*, i8** %6
%26 = call i32 @strlen(i8* %25)
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %12
%29 = load i8*, i8** %6
%30 = call i32 @free(i8* %29)
store i8* null, i8** %2
br label %33
31: ; preds = %12
%32 = load i8*, i8** %6
store i8* %32, i8** %2
br label %33
33: ; preds = %31, %28
%34 = load i8*, i8** %2
ret i8* %34
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"\0D\0A\00"
define i8* @player_line_query(i8* %0) {
%2 = alloca i64
%3 = alloca i8*
%4 = bitcast i64* %2 to i8*
%5 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%6 = icmp eq i8* %0, null
br i1 %6, label %9, label %7
7: ; preds = %1
%8 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %9
9: ; preds = %7, %1
%10 = load i32, i32* @stdin
%11 = call i32 @getline(i8** %3, i64* %2, i32 %10)
%12 = icmp ne i32 %11, -1
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = load i8*, i8** %3
%16 = call i64 @strcspn(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%17 = getelementptr inbounds i8, i8* %15, i64 %16
store i8 0, i8* %17
%18 = load i8*, i8** %3
%19 = call i32 @strlen(i8* %18)
%20 = load i8*, i8** %3
%21 = call i32 @strlen(i8* %20)
%22 = icmp eq i32 %21, 0
%23 = load i8*, i8** %3
br i1 %22, label %24, label %26
24: ; preds = %9
%25 = call i32 @free(i8* %23)
br label %26
26: ; preds = %9, %24
%27 = phi i8* [ null, %24 ], [ %23, %9 ]
ret i8* %27
}