#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 */
short COLS;
short FALSE;
int LINES;
int /*<<< orphan*/ SIGINT;
short TRUE;
int /*<<< orphan*/ box(int /*<<< orphan*/ *, char, char);
int /*<<< orphan*/ cbreak();
int /*<<< orphan*/ endwin();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int getch();
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ *newwin(short, short, short, short);
int /*<<< orphan*/ noecho();
int /*<<< orphan*/ scrollok(int /*<<< orphan*/ *, short);
int /*<<< orphan*/ signal(int /*<<< orphan*/, void (*)());
int /*<<< orphan*/ touchwin(int /*<<< orphan*/ *);
int /*<<< orphan*/ waddch(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ wmove(int /*<<< orphan*/ *, int, int);
int /*<<< orphan*/ wrefresh(int /*<<< orphan*/ *);
main() {
  WINDOW *uwin, *lwin;
  short unl, unc, ubr, ubc;
  short lnl, lnc, lbr, lbc;
  char inbuf[100];
  short finished;
  int c;
  void done();
  initscr();
  cbreak();
  noecho();
  signal(SIGINT, done);
  ubr = 0;
  ubc = 0;
  unc = COLS;
  unl = (LINES - 4);
  lbr = LINES - 4;
  lbc = 0;
  lnc = COLS;
  lnl = 4;
  uwin = newwin(unl, unc, ubr, ubc);
  lwin = newwin(lnl, lnc, lbr, lbc);
  box(uwin, '*', '*');
  box(lwin, '+', '+');
  touchwin(uwin);
  wrefresh(uwin);
  touchwin(lwin);
  wrefresh(lwin);
  scrollok(lwin, TRUE);
  finished = FALSE;
  wmove(lwin, 1, 1);
  touchwin(lwin);
  wrefresh(lwin);
  while (!finished) {
    c = getch();
    switch (c) {
    case ('c' & 037):
      finished = TRUE;
      break;
    default:
      waddch(lwin, c);
      break;
    }
    touchwin(lwin);
    wrefresh(lwin);
  }
  endwin();
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1070 <initscr@plt>
mov    $0x0,%al
call   1040 <cbreak@plt>
mov    $0x0,%al
call   10e0 <noecho@plt>
mov    0x2dda(%rip),%rax
mov    (%rax),%edi
mov    0x2da9(%rip),%rsi
call   1090 <signal@plt>
movw   $0x0,-0x1e(%rbp)
movw   $0x0,-0x20(%rbp)
mov    0x2da1(%rip),%rax
mov    (%rax),%ax
mov    %ax,-0x1c(%rbp)
mov    0x2da3(%rip),%rax
mov    (%rax),%eax
sub    $0x4,%eax
mov    %ax,-0x1a(%rbp)
mov    0x2d93(%rip),%rax
mov    (%rax),%eax
sub    $0x4,%eax
mov    %ax,-0x26(%rbp)
movw   $0x0,-0x28(%rbp)
mov    0x2d6d(%rip),%rax
mov    (%rax),%ax
mov    %ax,-0x24(%rbp)
movw   $0x4,-0x22(%rbp)
mov    -0x1a(%rbp),%dx
mov    -0x1c(%rbp),%cx
mov    -0x1e(%rbp),%ax
movswl %dx,%edi
movswl %cx,%esi
movswl %ax,%edx
movswl -0x20(%rbp),%ecx
call   1080 <newwin@plt>
mov    %rax,-0x10(%rbp)
mov    -0x22(%rbp),%dx
mov    -0x24(%rbp),%cx
mov    -0x26(%rbp),%ax
movswl %dx,%edi
movswl %cx,%esi
movswl %ax,%edx
movswl -0x28(%rbp),%ecx
call   1080 <newwin@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2a,%edx
mov    %edx,%esi
call   10a0 <box@plt>
mov    -0x18(%rbp),%rdi
mov    $0x2b,%edx
mov    %edx,%esi
call   10a0 <box@plt>
mov    -0x10(%rbp),%rdi
call   1050 <touchwin@plt>
mov    -0x10(%rbp),%rdi
call   1060 <wrefresh@plt>
mov    -0x18(%rbp),%rdi
call   1050 <touchwin@plt>
mov    -0x18(%rbp),%rdi
call   1060 <wrefresh@plt>
mov    -0x18(%rbp),%rdi
mov    0x2cd5(%rip),%rax
movswl (%rax),%esi
call   10c0 <scrollok@plt>
mov    0x2ca6(%rip),%rax
mov    (%rax),%ax
mov    %ax,-0x92(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1100 <wmove@plt>
mov    -0x18(%rbp),%rdi
call   1050 <touchwin@plt>
mov    -0x18(%rbp),%rdi
call   1060 <wrefresh@plt>
cmpw   $0x0,-0x92(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1358 <main+0x178>
jmp    13b5 <main+0x1d5>
xor    %eax,%eax
call   10b0 <getch@plt>
mov    %eax,-0x98(%rbp)
mov    -0x98(%rbp),%eax
sub    $0x3,%eax
jne    138f <main+0x1af>
jmp    1379 <main+0x199>
mov    0x2c58(%rip),%rax
mov    (%rax),%ax
mov    %ax,-0x92(%rbp)
jmp    139e <main+0x1be>
mov    -0x18(%rbp),%rdi
mov    -0x98(%rbp),%esi
call   1030 <waddch@plt>
mov    -0x18(%rbp),%rdi
call   1050 <touchwin@plt>
mov    -0x18(%rbp),%rdi
call   1060 <wrefresh@plt>
jmp    133e <main+0x15e>
mov    $0x0,%al
call   10d0 <endwin@plt>
xor    %edi,%edi
call   10f0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
xor    %eax,%eax
call   1070 <initscr@plt>
xor    %eax,%eax
call   1040 <cbreak@plt>
xor    %eax,%eax
call   10e0 <noecho@plt>
mov    0x2de8(%rip),%rax
mov    (%rax),%edi
mov    0x2db7(%rip),%rsi
call   1090 <signal@plt>
mov    0x2dbb(%rip),%rax
movswl (%rax),%ebx
mov    0x2dc1(%rip),%rax
mov    (%rax),%eax
add    $0xfffffffc,%eax
movswl %ax,%ebp
mov    %ebp,%edi
mov    %ebx,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1080 <newwin@plt>
mov    %rax,%r14
mov    $0x4,%edi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %ecx,%ecx
call   1080 <newwin@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    $0x2a,%esi
mov    $0x2a,%edx
call   10a0 <box@plt>
mov    %rbx,%rdi
mov    $0x2b,%esi
mov    $0x2b,%edx
call   10a0 <box@plt>
mov    %r14,%rdi
call   1050 <touchwin@plt>
mov    %r14,%rdi
call   1060 <wrefresh@plt>
mov    %rbx,%rdi
call   1050 <touchwin@plt>
mov    %rbx,%rdi
call   1060 <wrefresh@plt>
mov    0x2d43(%rip),%r14
movswl (%r14),%esi
mov    %rbx,%rdi
call   10c0 <scrollok@plt>
mov    0x2d10(%rip),%rax
movzwl (%rax),%ebp
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
call   1100 <wmove@plt>
mov    %rbx,%rdi
call   1050 <touchwin@plt>
mov    %rbx,%rdi
call   1060 <wrefresh@plt>
test   %bp,%bp
je     1301 <main+0x121>
xor    %eax,%eax
call   10d0 <endwin@plt>
xor    %edi,%edi
call   10f0 <exit@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <waddch@plt>
xor    %ebp,%ebp
mov    %rbx,%rdi
call   1050 <touchwin@plt>
mov    %rbx,%rdi
call   1060 <wrefresh@plt>
test   %bp,%bp
jne    12d2 <main+0xf2>
xor    %eax,%eax
call   10b0 <getch@plt>
cmp    $0x3,%eax
jne    12e0 <main+0x100>
movzwl (%r14),%ebp
jmp    12ec <main+0x10c>

LLVM IR (-O0):
@SIGINT = global i32 0
@COLS = global i16 0
@LINES = global i32 0
@TRUE = global i16 0
@FALSE = global i16 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i16
%5 = alloca i16
%6 = alloca i16
%7 = alloca i16
%8 = alloca i16
%9 = alloca i16
%10 = alloca i16
%11 = alloca i16
%12 = alloca [100 x i8]
%13 = alloca i16
%14 = alloca i32
store i32 0, i32* %1
%15 = call i32 (...) @initscr()
%16 = call i32 (...) @cbreak()
%17 = call i32 (...) @noecho()
%18 = load i32, i32* @SIGINT
%19 = call i32 @signal(i32 %18, void (...)* @done)
store i16 0, i16* %6
store i16 0, i16* %7
%20 = load i16, i16* @COLS
store i16 %20, i16* %5
%21 = load i32, i32* @LINES
%22 = sub nsw i32 %21, 4
%23 = trunc i32 %22 to i16
store i16 %23, i16* %4
%24 = load i32, i32* @LINES
%25 = sub nsw i32 %24, 4
%26 = trunc i32 %25 to i16
store i16 %26, i16* %10
store i16 0, i16* %11
%27 = load i16, i16* @COLS
store i16 %27, i16* %9
store i16 4, i16* %8
%28 = load i16, i16* %4
%29 = load i16, i16* %5
%30 = load i16, i16* %6
%31 = load i16, i16* %7
%32 = call i32* @newwin(i16 signext %28, i16 signext %29, i16 signext %30, i16 signext %31)
store i32* %32, i32** %2
%33 = load i16, i16* %8
%34 = load i16, i16* %9
%35 = load i16, i16* %10
%36 = load i16, i16* %11
%37 = call i32* @newwin(i16 signext %33, i16 signext %34, i16 signext %35, i16 signext %36)
store i32* %37, i32** %3
%38 = load i32*, i32** %2
%39 = call i32 @box(i32* %38, i8 signext 42, i8 signext 42)
%40 = load i32*, i32** %3
%41 = call i32 @box(i32* %40, i8 signext 43, i8 signext 43)
%42 = load i32*, i32** %2
%43 = call i32 @touchwin(i32* %42)
%44 = load i32*, i32** %2
%45 = call i32 @wrefresh(i32* %44)
%46 = load i32*, i32** %3
%47 = call i32 @touchwin(i32* %46)
%48 = load i32*, i32** %3
%49 = call i32 @wrefresh(i32* %48)
%50 = load i32*, i32** %3
%51 = load i16, i16* @TRUE
%52 = call i32 @scrollok(i32* %50, i16 signext %51)
%53 = load i16, i16* @FALSE
store i16 %53, i16* %13
%54 = load i32*, i32** %3
%55 = call i32 @wmove(i32* %54, i32 1, i32 1)
%56 = load i32*, i32** %3
%57 = call i32 @touchwin(i32* %56)
%58 = load i32*, i32** %3
%59 = call i32 @wrefresh(i32* %58)
br label %60
60: ; preds = %73, %0
%61 = load i16, i16* %13
%62 = icmp ne i16 %61, 0
%63 = xor i1 %62, true
br i1 %63, label %64, label %78
64: ; preds = %60
%65 = call i32 (...) @getch()
store i32 %65, i32* %14
%66 = load i32, i32* %14
switch i32 %66, label %69 [
i32 3, label %67
]
67: ; preds = %64
%68 = load i16, i16* @TRUE
store i16 %68, i16* %13
br label %73
69: ; preds = %64
%70 = load i32*, i32** %3
%71 = load i32, i32* %14
%72 = call i32 @waddch(i32* %70, i32 %71)
br label %73
73: ; preds = %69, %67
%74 = load i32*, i32** %3
%75 = call i32 @touchwin(i32* %74)
%76 = load i32*, i32** %3
%77 = call i32 @wrefresh(i32* %76)
br label %60
78: ; preds = %60
%79 = call i32 (...) @endwin()
%80 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@SIGINT = global i32 0
@COLS = global i16 0
@LINES = global i32 0
@TRUE = global i16 0
@FALSE = global i16 0
define i32 @main() {
%1 = tail call i32 (...) @initscr()
%2 = tail call i32 (...) @cbreak()
%3 = tail call i32 (...) @noecho()
%4 = load i32, i32* @SIGINT
%5 = tail call i32 @signal(i32 %4, void (...)* @done)
%6 = load i16, i16* @COLS
%7 = load i32, i32* @LINES
%8 = trunc i32 %7 to i16
%9 = add i16 %8, -4
%10 = tail call i32* @newwin(i16 signext %9, i16 signext %6, i16 signext 0, i16 signext 0)
%11 = tail call i32* @newwin(i16 signext 4, i16 signext %6, i16 signext %9, i16 signext 0)
%12 = tail call i32 @box(i32* %10, i8 signext 42, i8 signext 42)
%13 = tail call i32 @box(i32* %11, i8 signext 43, i8 signext 43)
%14 = tail call i32 @touchwin(i32* %10)
%15 = tail call i32 @wrefresh(i32* %10)
%16 = tail call i32 @touchwin(i32* %11)
%17 = tail call i32 @wrefresh(i32* %11)
%18 = load i16, i16* @TRUE
%19 = tail call i32 @scrollok(i32* %11, i16 signext %18)
%20 = load i16, i16* @FALSE
%21 = tail call i32 @wmove(i32* %11, i32 1, i32 1)
%22 = tail call i32 @touchwin(i32* %11)
%23 = tail call i32 @wrefresh(i32* %11)
%24 = icmp eq i16 %20, 0
br i1 %24, label %25, label %37
25: ; preds = %0, %32
%26 = tail call i32 (...) @getch()
%27 = icmp eq i32 %26, 3
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = load i16, i16* @TRUE
br label %32
30: ; preds = %25
%31 = tail call i32 @waddch(i32* %11, i32 %26)
br label %32
32: ; preds = %30, %28
%33 = phi i16 [ %29, %28 ], [ 0, %30 ]
%34 = tail call i32 @touchwin(i32* %11)
%35 = tail call i32 @wrefresh(i32* %11)
%36 = icmp eq i16 %33, 0
br i1 %36, label %25, label %37
37: ; preds = %32, %0
%38 = tail call i32 (...) @endwin()
%39 = tail call i32 @exit(i32 0)
unreachable
}