#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 /*<<< orphan*/ WINDOW;

/* Variables and functions */
int /*<<< orphan*/ ACS_HLINE;
int /*<<< orphan*/ ACS_LTEE;
int /*<<< orphan*/ ACS_RTEE;
int /*<<< orphan*/ COLOR_PAIR(int);
int COLS;
int /*<<< orphan*/ TRUE;
int /*<<< orphan*/ box(int /*<<< orphan*/ *, int /*<<< orphan*/,
                       int /*<<< orphan*/);
int /*<<< orphan*/ curs_set(int);
int /*<<< orphan*/ echo();
int /*<<< orphan*/ getstr(char *);
int /*<<< orphan*/ keypad(int /*<<< orphan*/ *, int /*<<< orphan*/);
char *malloc(int);
int /*<<< orphan*/ move(int, int);
int /*<<< orphan*/ mvwaddch(int /*<<< orphan*/ *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ mvwhline(int /*<<< orphan*/ *, int, int, int /*<<< orphan*/,
                            int);
int /*<<< orphan*/ *newwin(int, int, int, int);
int /*<<< orphan*/ print_in_middle(int /*<<< orphan*/ *, int,
                                   int /*<<< orphan*/, int, char *,
                                   int /*<<< orphan*/);
int /*<<< orphan*/ wrefresh(int /*<<< orphan*/ *);
char *get_string(char *title) {
  WINDOW *win;
  echo();
  curs_set(1);
  int w = 35;
  int h = 5;
  win = newwin(h, w, 10, (COLS - w) / 2);
  keypad(win, TRUE);
  box(win, 0, 0);
  print_in_middle(win, 1, 0, w, title, COLOR_PAIR(1));
  mvwaddch(win, 2, 0, ACS_LTEE);
  mvwhline(win, 2, 1, ACS_HLINE, w - 2);
  mvwaddch(win, 2, w - 1, ACS_RTEE);
  wrefresh(win);
  char *name = malloc(64);
  move(13, COLS / 2 - w / 2 + 2);
  getstr(name);
  return name;
}


x86 assembly (clang, -O0):
<get_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1030 <echo@plt>
mov    $0x1,%edi
call   10e0 <curs_set@plt>
movl   $0x23,-0x14(%rbp)
movl   $0x5,-0x18(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    0x2dd0(%rip),%rax
mov    (%rax),%eax
sub    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    $0xa,%edx
call   1060 <newwin@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2db0(%rip),%rax
mov    (%rax),%esi
call   1050 <keypad@plt>
mov    -0x10(%rbp),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   1080 <box@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    $0x1,%edi
call   1090 <COLOR_PAIR@plt>
mov    -0x38(%rbp),%rdi
mov    -0x2c(%rbp),%ecx
mov    -0x28(%rbp),%r8
mov    %eax,%r9d
mov    $0x1,%esi
xor    %edx,%edx
call   10d0 <print_in_middle@plt>
mov    -0x10(%rbp),%rdi
mov    0x2d5f(%rip),%rax
mov    (%rax),%ecx
mov    $0x2,%esi
xor    %edx,%edx
call   10c0 <mvwaddch@plt>
mov    -0x10(%rbp),%rdi
mov    0x2d26(%rip),%rax
mov    (%rax),%ecx
mov    -0x14(%rbp),%r8d
sub    $0x2,%r8d
mov    $0x2,%esi
mov    $0x1,%edx
call   10b0 <mvwhline@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
sub    $0x1,%edx
mov    0x2cf4(%rip),%rax
mov    (%rax),%ecx
mov    $0x2,%esi
call   10c0 <mvwaddch@plt>
mov    -0x10(%rbp),%rdi
call   1040 <wrefresh@plt>
mov    $0x40,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    0x2ce2(%rip),%rax
mov    (%rax),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
sub    %eax,%esi
add    $0x2,%esi
mov    $0xd,%edi
call   10f0 <move@plt>
mov    -0x20(%rbp),%rdi
call   1070 <getstr@plt>
mov    -0x20(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_string>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
xor    %eax,%eax
call   1030 <echo@plt>
mov    $0x1,%edi
call   10e0 <curs_set@plt>
mov    0x2de8(%rip),%r15
mov    (%r15),%eax
mov    %eax,%ecx
add    $0xffffffdd,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
add    $0xffffffdd,%ecx
sar    %ecx
mov    $0x5,%edi
mov    $0x23,%esi
mov    $0xa,%edx
call   1060 <newwin@plt>
mov    %rax,%rbx
mov    0x2dc0(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1050 <keypad@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1080 <box@plt>
mov    $0x1,%edi
call   1090 <COLOR_PAIR@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %edx,%edx
mov    $0x23,%ecx
mov    %r14,%r8
mov    %eax,%r9d
call   10d0 <print_in_middle@plt>
mov    0x2d87(%rip),%rax
mov    (%rax),%ecx
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %edx,%edx
call   10c0 <mvwaddch@plt>
mov    0x2d4f(%rip),%rax
mov    (%rax),%ecx
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    $0x21,%r8d
call   10b0 <mvwhline@plt>
mov    0x2d26(%rip),%rax
mov    (%rax),%ecx
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x22,%edx
call   10c0 <mvwaddch@plt>
mov    %rbx,%rdi
call   1040 <wrefresh@plt>
mov    $0x40,%edi
call   10a0 <malloc@plt>
mov    %rax,%rbx
mov    (%r15),%eax
mov    %eax,%esi
shr    $0x1f,%esi
add    %eax,%esi
sar    %esi
add    $0xfffffff1,%esi
mov    $0xd,%edi
call   10f0 <move@plt>
mov    %rbx,%rdi
call   1070 <getstr@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@COLS = global i32 0
@TRUE = global i32 0
@ACS_LTEE = global i32 0
@ACS_HLINE = global i32 0
@ACS_RTEE = global i32 0
define i8* @get_string(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
store i8* %0, i8** %2
%7 = call i32 (...) @echo()
%8 = call i32 @curs_set(i32 1)
store i32 35, i32* %4
store i32 5, i32* %5
%9 = load i32, i32* %5
%10 = load i32, i32* %4
%11 = load i32, i32* @COLS
%12 = load i32, i32* %4
%13 = sub nsw i32 %11, %12
%14 = sdiv i32 %13, 2
%15 = call i32* @newwin(i32 %9, i32 %10, i32 10, i32 %14)
store i32* %15, i32** %3
%16 = load i32*, i32** %3
%17 = load i32, i32* @TRUE
%18 = call i32 @keypad(i32* %16, i32 %17)
%19 = load i32*, i32** %3
%20 = call i32 @box(i32* %19, i32 0, i32 0)
%21 = load i32*, i32** %3
%22 = load i32, i32* %4
%23 = load i8*, i8** %2
%24 = call i32 @COLOR_PAIR(i32 1)
%25 = call i32 @print_in_middle(i32* %21, i32 1, i32 0, i32 %22, i8* %23, i32 %24)
%26 = load i32*, i32** %3
%27 = load i32, i32* @ACS_LTEE
%28 = call i32 @mvwaddch(i32* %26, i32 2, i32 0, i32 %27)
%29 = load i32*, i32** %3
%30 = load i32, i32* @ACS_HLINE
%31 = load i32, i32* %4
%32 = sub nsw i32 %31, 2
%33 = call i32 @mvwhline(i32* %29, i32 2, i32 1, i32 %30, i32 %32)
%34 = load i32*, i32** %3
%35 = load i32, i32* %4
%36 = sub nsw i32 %35, 1
%37 = load i32, i32* @ACS_RTEE
%38 = call i32 @mvwaddch(i32* %34, i32 2, i32 %36, i32 %37)
%39 = load i32*, i32** %3
%40 = call i32 @wrefresh(i32* %39)
%41 = call i8* @malloc(i32 64)
store i8* %41, i8** %6
%42 = load i32, i32* @COLS
%43 = sdiv i32 %42, 2
%44 = load i32, i32* %4
%45 = sdiv i32 %44, 2
%46 = sub nsw i32 %43, %45
%47 = add nsw i32 %46, 2
%48 = call i32 @move(i32 13, i32 %47)
%49 = load i8*, i8** %6
%50 = call i32 @getstr(i8* %49)
%51 = load i8*, i8** %6
ret i8* %51
}

LLVM IR (-O2):
@COLS = global i32 0
@TRUE = global i32 0
@ACS_LTEE = global i32 0
@ACS_HLINE = global i32 0
@ACS_RTEE = global i32 0
define i8* @get_string(i8* %0) {
%2 = tail call i32 (...) @echo()
%3 = tail call i32 @curs_set(i32 1)
%4 = load i32, i32* @COLS
%5 = add nsw i32 %4, -35
%6 = sdiv i32 %5, 2
%7 = tail call i32* @newwin(i32 5, i32 35, i32 10, i32 %6)
%8 = load i32, i32* @TRUE
%9 = tail call i32 @keypad(i32* %7, i32 %8)
%10 = tail call i32 @box(i32* %7, i32 0, i32 0)
%11 = tail call i32 @COLOR_PAIR(i32 1)
%12 = tail call i32 @print_in_middle(i32* %7, i32 1, i32 0, i32 35, i8* %0, i32 %11)
%13 = load i32, i32* @ACS_LTEE
%14 = tail call i32 @mvwaddch(i32* %7, i32 2, i32 0, i32 %13)
%15 = load i32, i32* @ACS_HLINE
%16 = tail call i32 @mvwhline(i32* %7, i32 2, i32 1, i32 %15, i32 33)
%17 = load i32, i32* @ACS_RTEE
%18 = tail call i32 @mvwaddch(i32* %7, i32 2, i32 34, i32 %17)
%19 = tail call i32 @wrefresh(i32* %7)
%20 = tail call dereferenceable_or_null(64) i8* @malloc(i32 64)
%21 = load i32, i32* @COLS
%22 = sdiv i32 %21, 2
%23 = add nsw i32 %22, -15
%24 = tail call i32 @move(i32 13, i32 %23)
%25 = tail call i32 @getstr(i8* %20)
ret i8* %20
}