#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 /*<<< orphan*/ box(int /*<<< orphan*/ *, int /*<<< orphan*/,
                       int /*<<< orphan*/);
int /*<<< orphan*/ cbreak();
int /*<<< orphan*/ doupdate();
int /*<<< orphan*/ endwin();
int getch();
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ *newpad(int, int);
int /*<<< orphan*/ noecho();
int /*<<< orphan*/ prefresh(int /*<<< orphan*/ *, int /*<<< orphan*/,
                            int /*<<< orphan*/, int /*<<< orphan*/,
                            int /*<<< orphan*/, int, int);
int /*<<< orphan*/ printw(char *, int);
int /*<<< orphan*/ refresh();
int main() {
  int ch;
  initscr();
  noecho();
  cbreak();
  refresh();
  WINDOW *win = newpad(20, 30);
  box(win, 0, 0);
  prefresh(win, 0, 0, 0, 0, 19, 29);
  doupdate();
  while ((ch = getch())) {
    printw("%d ", ch);
    refresh();
  }
  endwin();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <initscr@plt>
mov    $0x0,%al
call   10c0 <noecho@plt>
mov    $0x0,%al
call   1030 <cbreak@plt>
mov    $0x0,%al
call   1080 <refresh@plt>
mov    $0x14,%edi
mov    $0x1e,%esi
call   10a0 <newpad@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   1050 <box@plt>
mov    -0x10(%rbp),%rdi
xor    %r8d,%r8d
mov    $0x13,%r9d
mov    %r8d,%esi
mov    %r8d,%edx
mov    %r8d,%ecx
movl   $0x1d,(%rsp)
call   1070 <prefresh@plt>
mov    $0x0,%al
call   10d0 <doupdate@plt>
mov    $0x0,%al
call   1090 <getch@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
je     1252 <main+0xa2>
mov    -0x8(%rbp),%esi
lea    0xdbf(%rip),%rdi
call   1060 <printw@plt>
mov    $0x0,%al
call   1080 <refresh@plt>
jmp    1224 <main+0x74>
mov    $0x0,%al
call   10b0 <endwin@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1040 <initscr@plt>
xor    %eax,%eax
call   10c0 <noecho@plt>
xor    %eax,%eax
call   1030 <cbreak@plt>
xor    %eax,%eax
call   1080 <refresh@plt>
mov    $0x14,%edi
mov    $0x1e,%esi
call   10a0 <newpad@plt>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <box@plt>
movl   $0x1d,(%rsp)
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
mov    $0x13,%r9d
call   1070 <prefresh@plt>
xor    %eax,%eax
call   10d0 <doupdate@plt>
xor    %eax,%eax
call   1090 <getch@plt>
test   %eax,%eax
je     124c <main+0x9c>
lea    0xdda(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %eax,%esi
call   1060 <printw@plt>
xor    %eax,%eax
call   1080 <refresh@plt>
xor    %eax,%eax
call   1090 <getch@plt>
test   %eax,%eax
jne    1230 <main+0x80>
xor    %eax,%eax
call   10b0 <endwin@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
store i32 0, i32* %1
%4 = call i32 (...) @initscr()
%5 = call i32 (...) @noecho()
%6 = call i32 (...) @cbreak()
%7 = call i32 (...) @refresh()
%8 = call i32* @newpad(i32 20, i32 30)
store i32* %8, i32** %3
%9 = load i32*, i32** %3
%10 = call i32 @box(i32* %9, i32 0, i32 0)
%11 = load i32*, i32** %3
%12 = call i32 @prefresh(i32* %11, i32 0, i32 0, i32 0, i32 0, i32 19, i32 29)
%13 = call i32 (...) @doupdate()
br label %14
14: ; preds = %17, %0
%15 = call i32 (...) @getch()
store i32 %15, i32* %2
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %14
%18 = load i32, i32* %2
%19 = call i32 @printw(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = call i32 (...) @refresh()
br label %14
21: ; preds = %14
%22 = call i32 (...) @endwin()
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
define i32 @main() {
%1 = tail call i32 (...) @initscr()
%2 = tail call i32 (...) @noecho()
%3 = tail call i32 (...) @cbreak()
%4 = tail call i32 (...) @refresh()
%5 = tail call i32* @newpad(i32 20, i32 30)
%6 = tail call i32 @box(i32* %5, i32 0, i32 0)
%7 = tail call i32 @prefresh(i32* %5, i32 0, i32 0, i32 0, i32 0, i32 19, i32 29)
%8 = tail call i32 (...) @doupdate()
%9 = tail call i32 (...) @getch()
%10 = icmp eq i32 %9, 0
br i1 %10, label %17, label %11
11: ; preds = %0, %11
%12 = phi i32 [ %15, %11 ], [ %9, %0 ]
%13 = tail call i32 @printw(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = tail call i32 (...) @refresh()
%15 = tail call i32 (...) @getch()
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %11
17: ; preds = %11, %0
%18 = tail call i32 (...) @endwin()
ret i32 0
}