#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 COLS;
int LINES;
int /*<<< orphan*/ TRUE;
int /*<<< orphan*/ box(int /*<<< orphan*/ *, int /*<<< orphan*/,
                       int /*<<< orphan*/);
int /*<<< orphan*/ cbreak();
int /*<<< orphan*/ destory_win(int /*<<< orphan*/ *);
int /*<<< orphan*/ endwin();
int /*<<< orphan*/ getch();
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ keypad(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ *newwin(int, int, int, int);
int /*<<< orphan*/ printw(char *);
int /*<<< orphan*/ refresh();
int /*<<< orphan*/ stdscr;
int /*<<< orphan*/ wrefresh(int /*<<< orphan*/ *);
int main(int argc, const char *argv[]) {
  WINDOW *box_win;
  int startx, starty, width, height;
  int ch;
  initscr();
  cbreak();
  keypad(stdscr, TRUE);
  height = 3;
  width = 10;
  starty = (LINES - height) / 2;
  startx = (COLS - width) / 2;
  printw("Press F1 to exit");
  refresh();
  box_win = newwin(height, width, starty, startx);
  box(box_win, 0, 0);
  wrefresh(box_win);
  getch();
  destory_win(box_win);
  endwin();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1060 <initscr@plt>
mov    $0x0,%al
call   1030 <cbreak@plt>
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
mov    0x2df4(%rip),%rax
mov    (%rax),%esi
call   1050 <keypad@plt>
movl   $0x3,-0x28(%rbp)
movl   $0xa,-0x24(%rbp)
mov    0x2de8(%rip),%rax
mov    (%rax),%eax
sub    -0x28(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x20(%rbp)
mov    0x2db9(%rip),%rax
mov    (%rax),%eax
sub    -0x24(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
lea    0xdd2(%rip),%rdi
call   1090 <printw@plt>
mov    $0x0,%al
call   10a0 <refresh@plt>
mov    -0x28(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x1c(%rbp),%ecx
call   1070 <newwin@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   1080 <box@plt>
mov    -0x18(%rbp),%rdi
call   1040 <wrefresh@plt>
mov    $0x0,%al
call   10c0 <getch@plt>
mov    -0x18(%rbp),%rdi
call   10b0 <destory_win@plt>
mov    $0x0,%al
call   10d0 <endwin@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1060 <initscr@plt>
xor    %eax,%eax
call   1030 <cbreak@plt>
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
mov    0x2e07(%rip),%rax
mov    (%rax),%esi
call   1050 <keypad@plt>
mov    0x2e09(%rip),%rax
mov    (%rax),%eax
mov    %eax,%ecx
add    $0xfffffffd,%ecx
shr    $0x1f,%ecx
lea    (%rax,%rcx,1),%ebx
add    $0xfffffffd,%ebx
sar    %ebx
mov    0x2dd8(%rip),%rax
mov    (%rax),%eax
mov    %eax,%ecx
add    $0xfffffff6,%ecx
shr    $0x1f,%ecx
lea    (%rax,%rcx,1),%ebp
add    $0xfffffff6,%ebp
sar    %ebp
lea    0xdef(%rip),%rdi
call   1090 <printw@plt>
xor    %eax,%eax
call   10a0 <refresh@plt>
mov    $0x3,%edi
mov    $0xa,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
call   1070 <newwin@plt>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1080 <box@plt>
mov    %rbx,%rdi
call   1040 <wrefresh@plt>
xor    %eax,%eax
call   10c0 <getch@plt>
mov    %rbx,%rdi
call   10b0 <destory_win@plt>
xor    %eax,%eax
call   10d0 <endwin@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stdscr = global i32 0
@TRUE = global i32 0
@LINES = global i32 0
@COLS = global i32 0
@.str = [17 x i8] c"Press F1 to exit\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = call i32 (...) @initscr()
%13 = call i32 (...) @cbreak()
%14 = load i32, i32* @stdscr
%15 = load i32, i32* @TRUE
%16 = call i32 @keypad(i32 %14, i32 %15)
store i32 3, i32* %10
store i32 10, i32* %9
%17 = load i32, i32* @LINES
%18 = load i32, i32* %10
%19 = sub nsw i32 %17, %18
%20 = sdiv i32 %19, 2
store i32 %20, i32* %8
%21 = load i32, i32* @COLS
%22 = load i32, i32* %9
%23 = sub nsw i32 %21, %22
%24 = sdiv i32 %23, 2
store i32 %24, i32* %7
%25 = call i32 @printw(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%26 = call i32 (...) @refresh()
%27 = load i32, i32* %10
%28 = load i32, i32* %9
%29 = load i32, i32* %8
%30 = load i32, i32* %7
%31 = call i32* @newwin(i32 %27, i32 %28, i32 %29, i32 %30)
store i32* %31, i32** %6
%32 = load i32*, i32** %6
%33 = call i32 @box(i32* %32, i32 0, i32 0)
%34 = load i32*, i32** %6
%35 = call i32 @wrefresh(i32* %34)
%36 = call i32 (...) @getch()
%37 = load i32*, i32** %6
%38 = call i32 @destory_win(i32* %37)
%39 = call i32 (...) @endwin()
ret i32 0
}

LLVM IR (-O2):
@stdscr = global i32 0
@TRUE = global i32 0
@LINES = global i32 0
@COLS = global i32 0
@.str = [17 x i8] c"Press F1 to exit\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @initscr()
%4 = tail call i32 (...) @cbreak()
%5 = load i32, i32* @stdscr
%6 = load i32, i32* @TRUE
%7 = tail call i32 @keypad(i32 %5, i32 %6)
%8 = load i32, i32* @LINES
%9 = add nsw i32 %8, -3
%10 = sdiv i32 %9, 2
%11 = load i32, i32* @COLS
%12 = add nsw i32 %11, -10
%13 = sdiv i32 %12, 2
%14 = tail call i32 @printw(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%15 = tail call i32 (...) @refresh()
%16 = tail call i32* @newwin(i32 3, i32 10, i32 %10, i32 %13)
%17 = tail call i32 @box(i32* %16, i32 0, i32 0)
%18 = tail call i32 @wrefresh(i32* %16)
%19 = tail call i32 (...) @getch()
%20 = tail call i32 @destory_win(i32* %16)
%21 = tail call i32 (...) @endwin()
ret i32 0
}