#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*/ A_BOLD;
int /*<<< orphan*/ assert(char *);
int /*<<< orphan*/ attroff(int /*<<< orphan*/);
int /*<<< orphan*/ attron(int /*<<< orphan*/);
char *calloc(int const, int);
int /*<<< orphan*/ deleteln();
int /*<<< orphan*/ echo();
int /*<<< orphan*/ getnstr(char *, int const);
int /*<<< orphan*/ insertln();
int /*<<< orphan*/ move(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mvprintw(int /*<<< orphan*/, int /*<<< orphan*/,
                            char const *);
int /*<<< orphan*/ noecho();
char *editor_dialog(const char *prompt) {
  const int n = 1024;
  char *str;
  str = calloc(n, 1);
  assert(str);
  move(0, 0);
  deleteln();
  insertln();
  echo();
  attron(A_BOLD);
  mvprintw(0, 0, prompt);
  attroff(A_BOLD);
  getnstr(str, n - 1);
  noecho();
  return str;
}


x86 assembly (clang, -O0):
<editor_dialog>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x400,-0xc(%rbp)
mov    $0x400,%edi
mov    $0x1,%esi
call   1070 <calloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1080 <assert@plt>
xor    %esi,%esi
mov    %esi,%edi
call   10d0 <move@plt>
mov    $0x0,%al
call   1090 <deleteln@plt>
mov    $0x0,%al
call   10a0 <insertln@plt>
mov    $0x0,%al
call   1040 <echo@plt>
mov    0x2ddc(%rip),%rax
mov    (%rax),%edi
call   1060 <attron@plt>
mov    -0x8(%rbp),%rdx
xor    %esi,%esi
mov    %esi,%edi
call   10c0 <mvprintw@plt>
mov    0x2dc1(%rip),%rax
mov    (%rax),%edi
call   1030 <attroff@plt>
mov    -0x18(%rbp),%rdi
mov    $0x3ff,%esi
call   1050 <getnstr@plt>
mov    $0x0,%al
call   10b0 <noecho@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<editor_dialog>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    $0x400,%edi
mov    $0x1,%esi
call   1070 <calloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1080 <assert@plt>
xor    %edi,%edi
xor    %esi,%esi
call   10d0 <move@plt>
xor    %eax,%eax
call   1090 <deleteln@plt>
xor    %eax,%eax
call   10a0 <insertln@plt>
xor    %eax,%eax
call   1040 <echo@plt>
mov    0x2de9(%rip),%r15
mov    (%r15),%edi
call   1060 <attron@plt>
xor    %edi,%edi
xor    %esi,%esi
mov    %r14,%rdx
call   10c0 <mvprintw@plt>
mov    (%r15),%edi
call   1030 <attroff@plt>
mov    %rbx,%rdi
mov    $0x3ff,%esi
call   1050 <getnstr@plt>
xor    %eax,%eax
call   10b0 <noecho@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@A_BOLD = global i32 0
define i8* @editor_dialog(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
store i8* %0, i8** %2
store i32 1024, i32* %3
%5 = call i8* @calloc(i32 1024, i32 1)
store i8* %5, i8** %4
%6 = load i8*, i8** %4
%7 = call i32 @assert(i8* %6)
%8 = call i32 @move(i32 0, i32 0)
%9 = call i32 (...) @deleteln()
%10 = call i32 (...) @insertln()
%11 = call i32 (...) @echo()
%12 = load i32, i32* @A_BOLD
%13 = call i32 @attron(i32 %12)
%14 = load i8*, i8** %2
%15 = call i32 @mvprintw(i32 0, i32 0, i8* %14)
%16 = load i32, i32* @A_BOLD
%17 = call i32 @attroff(i32 %16)
%18 = load i8*, i8** %4
%19 = call i32 @getnstr(i8* %18, i32 1023)
%20 = call i32 (...) @noecho()
%21 = load i8*, i8** %4
ret i8* %21
}

LLVM IR (-O2):
@A_BOLD = global i32 0
define i8* @editor_dialog(i8* %0) {
%2 = tail call dereferenceable_or_null(1024) i8* @calloc(i32 1024, i32 1)
%3 = tail call i32 @assert(i8* %2)
%4 = tail call i32 @move(i32 0, i32 0)
%5 = tail call i32 (...) @deleteln()
%6 = tail call i32 (...) @insertln()
%7 = tail call i32 (...) @echo()
%8 = load i32, i32* @A_BOLD
%9 = tail call i32 @attron(i32 %8)
%10 = tail call i32 @mvprintw(i32 0, i32 0, i8* %0)
%11 = load i32, i32* @A_BOLD
%12 = tail call i32 @attroff(i32 %11)
%13 = tail call i32 @getnstr(i8* %2, i32 1023)
%14 = tail call i32 (...) @noecho()
ret i8* %2
}