#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*/ box(int /*<<< orphan*/ *, char, char);
int /*<<< orphan*/ cbreak();
int /*<<< orphan*/ endwin();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int getch();
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ mvprintw(int, int, char *);
int /*<<< orphan*/ mvwaddstr(int /*<<< orphan*/ *, int, int, char *);
int /*<<< orphan*/ *newwin(int, int, int, int);
int /*<<< orphan*/ noecho();
int /*<<< orphan*/ nonl();
int /*<<< orphan*/ refresh();
int /*<<< orphan*/ *stdscr;
int /*<<< orphan*/ touchwin(int /*<<< orphan*/ *);
int /*<<< orphan*/ wrefresh(int /*<<< orphan*/ *);
int main(int argc, const char *argv[]) {
  int ch, y, x;
  WINDOW *win;
  initscr();
  cbreak();
  noecho();
  nonl();
  win = newwin(4, 30, LINES / 2 - 3, COLS / 2 - 15);
  box(win, '|', '_');
  mvwaddstr(win, 1, 4, "This is another screen");
  mvwaddstr(win, 2, 2, "Press any key to continue");
  for (y = 1; y < 4 - 1; y++) {
    for (x = 1; x < 30 - 1; x++) {
      mvprintw(y + LINES / 2 - 3, x + COLS / 2 - 15, "@");
    }
  }
  while (1) {
    refresh();
    ch = getch();
    switch (ch) {
    case 'q':
      endwin();
      exit(0);
    case '\t':
      touchwin(win);
      wrefresh(win);
      getch();
      touchwin(stdscr);
      break;
    default:
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%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    $0x0,%al
call   10d0 <noecho@plt>
mov    $0x0,%al
call   1090 <nonl@plt>
mov    0x2dcf(%rip),%rax
mov    (%rax),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
sub    $0x3,%eax
mov    %eax,-0x2c(%rbp)
mov    0x2da8(%rip),%rax
mov    (%rax),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    -0x2c(%rbp),%edx
mov    %eax,%ecx
sub    $0xf,%ecx
mov    $0x4,%edi
mov    $0x1e,%esi
call   1070 <newwin@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    $0x7c,%esi
mov    $0x5f,%edx
call   1080 <box@plt>
mov    -0x28(%rbp),%rdi
mov    $0x1,%esi
mov    $0x4,%edx
lea    0xd83(%rip),%rcx
call   10f0 <mvwaddstr@plt>
mov    -0x28(%rbp),%rdi
mov    $0x2,%edx
lea    0xd85(%rip),%rcx
mov    %edx,%esi
call   10f0 <mvwaddstr@plt>
movl   $0x1,-0x18(%rbp)
cmpl   $0x3,-0x18(%rbp)
jge    131a <main+0x13a>
movl   $0x1,-0x1c(%rbp)
cmpl   $0x1d,-0x1c(%rbp)
jge    1307 <main+0x127>
mov    -0x18(%rbp),%edi
mov    0x2d23(%rip),%rax
mov    (%rax),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
add    %eax,%edi
sub    $0x3,%edi
mov    -0x1c(%rbp),%esi
mov    0x2cfa(%rip),%rax
mov    (%rax),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
add    %eax,%esi
sub    $0xf,%esi
lea    0xd3d(%rip),%rdx
call   1100 <mvprintw@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    12b1 <main+0xd1>
jmp    130c <main+0x12c>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    12a0 <main+0xc0>
jmp    131f <main+0x13f>
xor    %eax,%eax
mov    %al,-0x31(%rbp)
call   10a0 <refresh@plt>
mov    -0x31(%rbp),%al
call   10b0 <getch@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x30(%rbp)
sub    $0x9,%eax
je     1367 <main+0x187>
jmp    1348 <main+0x168>
mov    -0x30(%rbp),%eax
sub    $0x71,%eax
jne    1394 <main+0x1b4>
jmp    1359 <main+0x179>
mov    $0x0,%al
call   10c0 <endwin@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
mov    -0x28(%rbp),%rdi
call   1040 <touchwin@plt>
mov    -0x28(%rbp),%rdi
call   1050 <wrefresh@plt>
mov    $0x0,%al
call   10b0 <getch@plt>
mov    0x2c59(%rip),%rax
mov    (%rax),%rdi
call   1040 <touchwin@plt>
jmp    1399 <main+0x1b9>
jmp    1399 <main+0x1b9>
jmp    131f <main+0x13f>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %eax,%eax
call   1060 <initscr@plt>
xor    %eax,%eax
call   1030 <cbreak@plt>
xor    %eax,%eax
call   10d0 <noecho@plt>
xor    %eax,%eax
call   1090 <nonl@plt>
mov    0x2ddd(%rip),%r15
mov    (%r15),%eax
mov    %eax,%edx
shr    $0x1f,%edx
add    %eax,%edx
sar    %edx
add    $0xfffffffd,%edx
mov    0x2db7(%rip),%r12
mov    (%r12),%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
add    $0xfffffff1,%ecx
mov    $0x4,%edi
mov    $0x1e,%esi
call   1070 <newwin@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x7c,%esi
mov    $0x5f,%edx
call   1080 <box@plt>
lea    0xda4(%rip),%rcx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
call   10f0 <mvwaddstr@plt>
lea    0xda2(%rip),%rcx
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x2,%edx
call   10f0 <mvwaddstr@plt>
mov    $0xfffffff2,%ebp
lea    0xd9e(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r15),%eax
mov    %eax,%edi
shr    $0x1f,%edi
add    %eax,%edi
sar    %edi
add    $0xfffffffe,%edi
mov    (%r12),%eax
mov    %eax,%esi
shr    $0x1f,%esi
add    %eax,%esi
sar    %esi
add    %ebp,%esi
mov    %r14,%rdx
call   1100 <mvprintw@plt>
add    $0x1,%ebp
cmp    $0xe,%ebp
jne    12a0 <main+0xc0>
mov    $0xfffffff2,%ebp
lea    0xd57(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    (%r15),%eax
mov    %eax,%edi
shr    $0x1f,%edi
add    %eax,%edi
sar    %edi
add    $0xffffffff,%edi
mov    (%r12),%eax
mov    %eax,%esi
shr    $0x1f,%esi
add    %eax,%esi
sar    %esi
add    %ebp,%esi
mov    %r14,%rdx
call   1100 <mvprintw@plt>
add    $0x1,%ebp
cmp    $0xe,%ebp
jne    12e0 <main+0x100>
mov    0x2ccb(%rip),%r14
jmp    133f <main+0x15f>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1040 <touchwin@plt>
mov    %rbx,%rdi
call   1050 <wrefresh@plt>
xor    %eax,%eax
call   10b0 <getch@plt>
mov    (%r14),%rdi
call   1040 <touchwin@plt>
xor    %eax,%eax
call   10a0 <refresh@plt>
xor    %eax,%eax
call   10b0 <getch@plt>
cmp    $0x9,%eax
je     1320 <main+0x140>
cmp    $0x71,%eax
jne    133f <main+0x15f>
xor    %eax,%eax
call   10c0 <endwin@plt>
xor    %edi,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
@LINES = global i32 0
@COLS = global i32 0
@.str = [23 x i8] c"This is another screen\00"
@.str.1 = [26 x i8] c"Press any key to continue\00"
@.str.2 = [2 x i8] c"@\00"
@stdscr = global i32* null
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*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 (...) @initscr()
%11 = call i32 (...) @cbreak()
%12 = call i32 (...) @noecho()
%13 = call i32 (...) @nonl()
%14 = load i32, i32* @LINES
%15 = sdiv i32 %14, 2
%16 = sub nsw i32 %15, 3
%17 = load i32, i32* @COLS
%18 = sdiv i32 %17, 2
%19 = sub nsw i32 %18, 15
%20 = call i32* @newwin(i32 4, i32 30, i32 %16, i32 %19)
store i32* %20, i32** %9
%21 = load i32*, i32** %9
%22 = call i32 @box(i32* %21, i8 signext 124, i8 signext 95)
%23 = load i32*, i32** %9
%24 = call i32 @mvwaddstr(i32* %23, i32 1, i32 4, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%25 = load i32*, i32** %9
%26 = call i32 @mvwaddstr(i32* %25, i32 2, i32 2, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %7
br label %27
27: ; preds = %50, %2
%28 = load i32, i32* %7
%29 = icmp slt i32 %28, 3
br i1 %29, label %30, label %53
30: ; preds = %27
store i32 1, i32* %8
br label %31
31: ; preds = %46, %30
%32 = load i32, i32* %8
%33 = icmp slt i32 %32, 29
br i1 %33, label %34, label %49
34: ; preds = %31
%35 = load i32, i32* %7
%36 = load i32, i32* @LINES
%37 = sdiv i32 %36, 2
%38 = add nsw i32 %35, %37
%39 = sub nsw i32 %38, 3
%40 = load i32, i32* %8
%41 = load i32, i32* @COLS
%42 = sdiv i32 %41, 2
%43 = add nsw i32 %40, %42
%44 = sub nsw i32 %43, 15
%45 = call i32 @mvprintw(i32 %39, i32 %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %46
46: ; preds = %34
%47 = load i32, i32* %8
%48 = add nsw i32 %47, 1
store i32 %48, i32* %8
br label %31
49: ; preds = %31
br label %50
50: ; preds = %49
%51 = load i32, i32* %7
%52 = add nsw i32 %51, 1
store i32 %52, i32* %7
br label %27
53: ; preds = %27
br label %54
54: ; preds = %53, %70
%55 = call i32 (...) @refresh()
%56 = call i32 (...) @getch()
store i32 %56, i32* %6
%57 = load i32, i32* %6
switch i32 %57, label %69 [
i32 113, label %58
i32 9, label %61
]
58: ; preds = %54
%59 = call i32 (...) @endwin()
%60 = call i32 @exit(i32 0)
unreachable
61: ; preds = %54
%62 = load i32*, i32** %9
%63 = call i32 @touchwin(i32* %62)
%64 = load i32*, i32** %9
%65 = call i32 @wrefresh(i32* %64)
%66 = call i32 (...) @getch()
%67 = load i32*, i32** @stdscr
%68 = call i32 @touchwin(i32* %67)
br label %70
69: ; preds = %54
br label %70
70: ; preds = %69, %61
br label %54
}

LLVM IR (-O2):
@LINES = global i32 0
@COLS = global i32 0
@.str = [23 x i8] c"This is another screen\00"
@.str.1 = [26 x i8] c"Press any key to continue\00"
@.str.2 = [2 x i8] c"@\00"
@stdscr = global i32* null
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @initscr()
%4 = tail call i32 (...) @cbreak()
%5 = tail call i32 (...) @noecho()
%6 = tail call i32 (...) @nonl()
%7 = load i32, i32* @LINES
%8 = sdiv i32 %7, 2
%9 = add nsw i32 %8, -3
%10 = load i32, i32* @COLS
%11 = sdiv i32 %10, 2
%12 = add nsw i32 %11, -15
%13 = tail call i32* @newwin(i32 4, i32 30, i32 %9, i32 %12)
%14 = tail call i32 @box(i32* %13, i8 signext 124, i8 signext 95)
%15 = tail call i32 @mvwaddstr(i32* %13, i32 1, i32 4, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%16 = tail call i32 @mvwaddstr(i32* %13, i32 2, i32 2, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
br label %17
17: ; preds = %2, %17
%18 = phi i32 [ 1, %2 ], [ %27, %17 ]
%19 = load i32, i32* @LINES
%20 = sdiv i32 %19, 2
%21 = add nsw i32 %20, -2
%22 = load i32, i32* @COLS
%23 = sdiv i32 %22, 2
%24 = add nsw i32 %18, -15
%25 = add i32 %24, %23
%26 = tail call i32 @mvprintw(i32 %21, i32 %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%27 = add nuw nsw i32 %18, 1
%28 = icmp eq i32 %27, 29
br i1 %28, label %29, label %17
29: ; preds = %17, %29
%30 = phi i32 [ %39, %29 ], [ 1, %17 ]
%31 = load i32, i32* @LINES
%32 = sdiv i32 %31, 2
%33 = add nsw i32 %32, -1
%34 = load i32, i32* @COLS
%35 = sdiv i32 %34, 2
%36 = add nsw i32 %30, -15
%37 = add i32 %36, %35
%38 = tail call i32 @mvprintw(i32 %33, i32 %37, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%39 = add nuw nsw i32 %30, 1
%40 = icmp eq i32 %39, 29
br i1 %40, label %41, label %29
41: ; preds = %29, %44
%42 = tail call i32 (...) @refresh()
%43 = tail call i32 (...) @getch()
switch i32 %43, label %44 [
i32 113, label %45
i32 9, label %48
]
44: ; preds = %41, %48
br label %41
45: ; preds = %41
%46 = tail call i32 (...) @endwin()
%47 = tail call i32 @exit(i32 0)
unreachable
48: ; preds = %41
%49 = tail call i32 @touchwin(i32* %13)
%50 = tail call i32 @wrefresh(i32* %13)
%51 = tail call i32 (...) @getch()
%52 = load i32*, i32** @stdscr
%53 = tail call i32 @touchwin(i32* %52)
br label %44
}