#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 /*<<< orphan*/ addch(char);
int /*<<< orphan*/ clear_area(int, int, int /*<<< orphan*/, int);
int /*<<< orphan*/ echo();
int /*<<< orphan*/ getmaxyx(int /*<<< orphan*/, int, int);
int /*<<< orphan*/ getstr(char *);
char *malloc(int);
int /*<<< orphan*/ move(int, int /*<<< orphan*/);
int /*<<< orphan*/ noecho();
int /*<<< orphan*/ stdscr;
char *get_input(char key) {
  int row, col;
  echo();
  getmaxyx(stdscr, row, col);
  move(row - 1, 0);
  addch(key);
  char *strint = malloc(sizeof(char) * 64);
  getstr(strint);
  noecho();
  clear_area(row - 1, row, 0, col);
  return strint;
}


x86 assembly (clang, -O0):
<get_input>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    $0x0,%al
call   1030 <echo@plt>
mov    0x2e4c(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1060 <getmaxyx@plt>
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
xor    %esi,%esi
call   10a0 <move@plt>
movsbl -0x1(%rbp),%edi
call   1080 <addch@plt>
mov    $0x40,%edi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <getstr@plt>
mov    $0x0,%al
call   1090 <noecho@plt>
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%ecx
xor    %edx,%edx
call   1040 <clear_area@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_input>:
push   %rbx
mov    %edi,%ebx
xor    %eax,%eax
call   1030 <echo@plt>
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
call   1060 <getmaxyx@plt>
xor    %esi,%esi
call   10a0 <move@plt>
mov    %ebx,%edi
call   1080 <addch@plt>
mov    $0x40,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <getstr@plt>
xor    %eax,%eax
call   1090 <noecho@plt>
xor    %edx,%edx
call   1040 <clear_area@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@stdscr = global i32 0
define i8* @get_input(i8 signext %0) {
%2 = alloca i8
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
store i8 %0, i8* %2
%6 = call i32 (...) @echo()
%7 = load i32, i32* @stdscr
%8 = load i32, i32* %3
%9 = load i32, i32* %4
%10 = call i32 @getmaxyx(i32 %7, i32 %8, i32 %9)
%11 = load i32, i32* %3
%12 = sub nsw i32 %11, 1
%13 = call i32 @move(i32 %12, i32 0)
%14 = load i8, i8* %2
%15 = call i32 @addch(i8 signext %14)
%16 = call i8* @malloc(i32 64)
store i8* %16, i8** %5
%17 = load i8*, i8** %5
%18 = call i32 @getstr(i8* %17)
%19 = call i32 (...) @noecho()
%20 = load i32, i32* %3
%21 = sub nsw i32 %20, 1
%22 = load i32, i32* %3
%23 = load i32, i32* %4
%24 = call i32 @clear_area(i32 %21, i32 %22, i32 0, i32 %23)
%25 = load i8*, i8** %5
ret i8* %25
}

LLVM IR (-O2):
@stdscr = global i32 0
define i8* @get_input(i8 signext %0) {
%2 = tail call i32 (...) @echo()
%3 = load i32, i32* @stdscr
%4 = tail call i32 @getmaxyx(i32 %3, i32 undef, i32 undef)
%5 = tail call i32 @move(i32 undef, i32 0)
%6 = tail call i32 @addch(i8 signext %0)
%7 = tail call dereferenceable_or_null(64) i8* @malloc(i32 64)
%8 = tail call i32 @getstr(i8* %7)
%9 = tail call i32 (...) @noecho()
%10 = tail call i32 @clear_area(i32 undef, i32 undef, i32 0, i32 undef)
ret i8* %7
}