#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*/ echo();
int /*<<< orphan*/ endwin();
int /*<<< orphan*/ getch();
int /*<<< orphan*/ getmaxyx(int /*<<< orphan*/, int, int);
int /*<<< orphan*/ getstr(char *);
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ mvprintw(int, int, char *, char *, char *, char *);
int /*<<< orphan*/ stdscr;
int strlen(char *);
int curse_init() {
  char mesg[] = "Enter a command-line app: ";
  char str[4];
  int row, col;
  initscr();
  echo();
  getmaxyx(stdscr, row, col);
  mvprintw(row / 2, (col - strlen(mesg)) / 2, "%s", "%s", mesg, str);
  getstr(str);
  getch();
  endwin();
  return 0;
}


x86 assembly (clang, -O0):
<curse_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0xe71(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe6e(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xe6b(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xe68(%rip),%ax
mov    %ax,-0x8(%rbp)
mov    0xe60(%rip),%al
mov    %al,-0x6(%rbp)
mov    $0x0,%al
call   1050 <initscr@plt>
mov    $0x0,%al
call   1030 <echo@plt>
mov    0x2e16(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%esi
mov    -0x2c(%rbp),%edx
call   1070 <getmaxyx@plt>
mov    -0x28(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x34(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x30(%rbp)
lea    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x34(%rbp),%edi
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
sub    %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    -0x20(%rbp),%r8
lea    -0x24(%rbp),%r9
lea    0xdfc(%rip),%rcx
mov    %rcx,%rdx
call   10a0 <mvprintw@plt>
lea    -0x24(%rbp),%rdi
call   1060 <getstr@plt>
mov    $0x0,%al
call   1080 <getch@plt>
mov    $0x0,%al
call   1090 <endwin@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<curse_init>:
push   %r14
push   %rbx
sub    $0x38,%rsp
movups 0xe7d(%rip),%xmm0
movups %xmm0,0x1b(%rsp)
movaps 0xe66(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1050 <initscr@plt>
xor    %eax,%eax
call   1030 <echo@plt>
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
call   1070 <getmaxyx@plt>
lea    0x10(%rsp),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    0xe4c(%rip),%rcx
lea    0xc(%rsp),%rbx
xor    %edi,%edi
xor    %esi,%esi
mov    %rcx,%rdx
mov    %r14,%r8
mov    %rbx,%r9
call   10a0 <mvprintw@plt>
mov    %rbx,%rdi
call   1060 <getstr@plt>
xor    %eax,%eax
call   1080 <getch@plt>
xor    %eax,%eax
call   1090 <endwin@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.curse_init.mesg = [27 x i8] c"Enter a command-line app: \00"
@stdscr = global i32 0
@.str = [3 x i8] c"%s\00"
define i32 @curse_init() {
%1 = alloca [27 x i8]
%2 = alloca [4 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = bitcast [27 x i8]* %1 to i8*
%6 = call i32 (...) @initscr()
%7 = call i32 (...) @echo()
%8 = load i32, i32* @stdscr
%9 = load i32, i32* %3
%10 = load i32, i32* %4
%11 = call i32 @getmaxyx(i32 %8, i32 %9, i32 %10)
%12 = load i32, i32* %3
%13 = sdiv i32 %12, 2
%14 = load i32, i32* %4
%15 = getelementptr inbounds [27 x i8], [27 x i8]* %1, i64 0, i64 0
%16 = call i32 @strlen(i8* %15)
%17 = sub nsw i32 %14, %16
%18 = sdiv i32 %17, 2
%19 = getelementptr inbounds [27 x i8], [27 x i8]* %1, i64 0, i64 0
%20 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%21 = call i32 @mvprintw(i32 %13, i32 %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %19, i8* %20)
%22 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%23 = call i32 @getstr(i8* %22)
%24 = call i32 (...) @getch()
%25 = call i32 (...) @endwin()
ret i32 0
}

LLVM IR (-O2):
@__const.curse_init.mesg = [27 x i8] c"Enter a command-line app: \00"
@stdscr = global i32 0
@.str = [3 x i8] c"%s\00"
define i32 @curse_init() {
%1 = alloca [27 x i8]
%2 = alloca [4 x i8]
%3 = getelementptr inbounds [27 x i8], [27 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (...) @initscr()
%6 = tail call i32 (...) @echo()
%7 = load i32, i32* @stdscr
%8 = tail call i32 @getmaxyx(i32 %7, i32 undef, i32 undef)
%9 = call i32 @strlen(i8* %3)
%10 = call i32 @mvprintw(i32 0, i32 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3, i8* %4)
%11 = call i32 @getstr(i8* %4)
%12 = call i32 (...) @getch()
%13 = call i32 (...) @endwin()
ret i32 0
}