#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 */
char EOF;
char getchar();
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ puts(char *);
scalar_t__ realloc(char *, int);
char *ask_for_parameter(char *question, char EndChar) {
  puts(question);
  char *value = NULL;
  char temp;
  int i = 0;
  while (1) {
    temp = getchar();
    if (temp == EndChar || temp == EOF)
      break;
    value = (char *)realloc(value, i + 1);
    value[i] = temp;
    i++;
  }
  value[i] = '\0';
  if (temp != '\n')
    putchar('\n');
  return value;
}


x86 assembly (clang, -O0):
<ask_for_parameter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <puts@plt>
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
movsbl -0x9(%rbp),%ecx
cmp    %ecx,%eax
je     119a <ask_for_parameter+0x5a>
movsbl -0x19(%rbp),%eax
mov    0x2e59(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    119f <ask_for_parameter+0x5f>
jmp    11ce <ask_for_parameter+0x8e>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%esi
add    $0x1,%esi
call   1060 <realloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x19(%rbp),%dl
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    116a <ask_for_parameter+0x2a>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
movsbl -0x19(%rbp),%eax
cmp    $0xa,%eax
je     11f1 <ask_for_parameter+0xb1>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ask_for_parameter>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
call   1040 <puts@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebx
mov    0x2e85(%rip),%r12
xor    %r13d,%r13d
xor    %r15d,%r15d
nopl   0x0(%rax)
mov    %r13,%rbp
add    $0x1,%r13
mov    %r15,%rdi
mov    %r13d,%esi
call   1060 <realloc@plt>
mov    %rax,%r15
mov    %bl,(%rax,%rbp,1)
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebx
cmp    %r14b,%al
je     119c <ask_for_parameter+0x5c>
cmp    (%r12),%bl
jne    1170 <ask_for_parameter+0x30>
mov    %r13d,%eax
movb   $0x0,(%r15,%rax,1)
cmp    $0xa,%bl
je     11b3 <ask_for_parameter+0x73>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@EOF = global i8 0
define i8* @ask_for_parameter(i8* nocapture %0, i8 signext %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) %0)
%4 = tail call signext i8 (...) @getchar()
%5 = icmp ne i8 %4, %1
%6 = load i8, i8* @EOF
%7 = icmp ne i8 %4, %6
br label %8
8: ; preds = %2, %8
%9 = phi i64 [ 0, %2 ], [ %12, %8 ]
%10 = phi i8 [ %4, %2 ], [ %17, %8 ]
%11 = phi i8* [ null, %2 ], [ %15, %8 ]
%12 = add nuw i64 %9, 1
%13 = trunc i64 %12 to i32
%14 = tail call i64 @realloc(i8* %11, i32 %13)
%15 = inttoptr i64 %14 to i8*
%16 = getelementptr inbounds i8, i8* %15, i64 %9
store i8 %10, i8* %16
%17 = tail call signext i8 (...) @getchar()
%18 = icmp eq i8 %17, %1
%19 = load i8, i8* @EOF
%20 = icmp eq i8 %17, %19
%21 = select i1 %18, i1 true, i1 %20
br i1 %21, label %22, label %8
22: ; preds = %8
%23 = inttoptr i64 %14 to i8*
%24 = and i64 %12, 4294967295
%25 = getelementptr inbounds i8, i8* %23, i64 %24
store i8 0, i8* %25
%26 = icmp eq i8 %17, 10
br i1 %26, label %29, label %27
27: ; preds = %22
%28 = tail call i32 @putchar(i8 signext 10)
br label %29
29: ; preds = %27, %22
ret i8* %23
}