#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 */
#define KEY_BACKSPACE 137
#define KEY_BTAB 136
#define KEY_CTAB 135
#define KEY_DOWN 134
#define KEY_ENTER 133
#define KEY_LEFT 132
#define KEY_RESIZE 131
#define KEY_RIGHT 130
#define KEY_STAB 129
#define KEY_UP 128
scalar_t__ TRUE;
int /*<<< orphan*/ endwin();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int getch();
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ keypad(int /*<<< orphan*/, scalar_t__);
int /*<<< orphan*/ mvprintw(int, int /*<<< orphan*/, char *, int, ...);
int /*<<< orphan*/ noecho();
int /*<<< orphan*/ stdscr;
int main(int argc, char *argv[]) {
  initscr();
  noecho();
  keypad(stdscr, TRUE);
  int c;
  while (TRUE) {
    c = getch();
    mvprintw(1, 0, "Key number: '%3d' / Char: '%c'", c, c);
    switch (c) {
    case KEY_BACKSPACE:
    case KEY_LEFT:
    case KEY_RIGHT:
    case KEY_UP:
    case KEY_DOWN:
      mvprintw(5, 0, "CATCHED! %3d", c);
      break;
    case KEY_STAB:
    case KEY_BTAB:
    case KEY_CTAB:
      mvprintw(5, 0, "TAB! %3d", c);
      break;
    case KEY_RESIZE:
      mvprintw(5, 0, "RESIZE! %3d", c);
      break;
    case KEY_ENTER:
      endwin();
      exit(0);
    default:
      break;
    }
  }
  endwin();
}


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   1040 <initscr@plt>
mov    $0x0,%al
call   1070 <noecho@plt>
mov    0x2e4d(%rip),%rax
mov    (%rax),%edi
mov    0x2e3c(%rip),%rax
mov    (%rax),%rsi
call   1030 <keypad@plt>
mov    0x2e2d(%rip),%rax
cmpq   $0x0,(%rax)
je     1285 <main+0x115>
xor    %eax,%eax
mov    %eax,-0x28(%rbp)
mov    %al,-0x21(%rbp)
call   1050 <getch@plt>
mov    -0x28(%rbp),%esi
mov    %eax,%ecx
mov    -0x21(%rbp),%al
mov    %ecx,-0x14(%rbp)
mov    -0x14(%rbp),%r8d
lea    0xe48(%rip),%rdx
mov    $0x1,%edi
mov    %r8d,%ecx
call   1090 <mvprintw@plt>
mov    -0x14(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x9,%eax
ja     127b <main+0x10b>
mov    -0x20(%rbp),%rax
lea    0xdf3(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x14(%rbp),%ecx
mov    $0x5,%edi
xor    %esi,%esi
lea    0xe20(%rip),%rdx
mov    $0x0,%al
call   1090 <mvprintw@plt>
jmp    1280 <main+0x110>
mov    -0x14(%rbp),%ecx
mov    $0x5,%edi
xor    %esi,%esi
lea    0xe10(%rip),%rdx
mov    $0x0,%al
call   1090 <mvprintw@plt>
jmp    1280 <main+0x110>
mov    -0x14(%rbp),%ecx
mov    $0x5,%edi
xor    %esi,%esi
lea    0xdfc(%rip),%rdx
mov    $0x0,%al
call   1090 <mvprintw@plt>
jmp    1280 <main+0x110>
mov    $0x0,%al
call   1060 <endwin@plt>
xor    %edi,%edi
call   1080 <exit@plt>
jmp    1280 <main+0x110>
jmp    11ac <main+0x3c>
mov    $0x0,%al
call   1060 <endwin@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <initscr@plt>
xor    %eax,%eax
call   1070 <noecho@plt>
mov    0x2e58(%rip),%rax
mov    (%rax),%edi
mov    0x2e47(%rip),%rbp
mov    0x0(%rbp),%rsi
call   1030 <keypad@plt>
cmpq   $0x0,0x0(%rbp)
je     123b <main+0xcb>
lea    0xe74(%rip),%r13
lea    0xe45(%rip),%r12
lea    0xe85(%rip),%r14
lea    0xe8b(%rip),%r15
jmp    11ea <main+0x7a>
nopl   0x0(%rax,%rax,1)
mov    $0x5,%edi
xor    %esi,%esi
mov    %r14,%rdx
mov    %ebx,%ecx
xor    %eax,%eax
call   1090 <mvprintw@plt>
cmpq   $0x0,0x0(%rbp)
je     123b <main+0xcb>
xor    %eax,%eax
call   1050 <getch@plt>
mov    %eax,%ebx
mov    $0x1,%edi
xor    %esi,%esi
mov    %r13,%rdx
mov    %eax,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1090 <mvprintw@plt>
lea    -0x80(%rbx),%eax
cmp    $0x9,%eax
ja     11e3 <main+0x73>
movslq (%r12,%rax,4),%rax
add    %r12,%rax
jmp    *%rax
mov    $0x5,%edi
xor    %esi,%esi
mov    %r15,%rdx
jmp    11da <main+0x6a>
mov    $0x5,%edi
xor    %esi,%esi
lea    0xe29(%rip),%rdx
mov    $0x83,%ecx
jmp    11dc <main+0x6c>
xor    %eax,%eax
call   1060 <endwin@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   1060 <endwin@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stdscr = global i32 0
@TRUE = global i64 0
@.str = [31 x i8] c"Key number: '%3d' / Char: '%c'\00"
@.str.1 = [13 x i8] c"CATCHED! %3d\00"
@.str.2 = [9 x i8] c"TAB! %3d\00"
@.str.3 = [12 x i8] c"RESIZE! %3d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 (...) @initscr()
%8 = call i32 (...) @noecho()
%9 = load i32, i32* @stdscr
%10 = load i64, i64* @TRUE
%11 = call i32 @keypad(i32 %9, i64 %10)
br label %12
12: ; preds = %34, %2
%13 = load i64, i64* @TRUE
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %35
15: ; preds = %12
%16 = call i32 (...) @getch()
store i32 %16, i32* %6
%17 = load i32, i32* %6
%18 = load i32, i32* %6
%19 = call i32 (i32, i32, i8*, i32, ...) @mvprintw(i32 1, i32 0, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %18)
%20 = load i32, i32* %6
switch i32 %20, label %33 [
i32 137, label %21
i32 132, label %21
i32 130, label %21
i32 128, label %21
i32 134, label %21
i32 129, label %24
i32 136, label %24
i32 135, label %24
i32 131, label %27
i32 133, label %30
]
21: ; preds = %15, %15, %15, %15, %15
%22 = load i32, i32* %6
%23 = call i32 (i32, i32, i8*, i32, ...) @mvprintw(i32 5, i32 0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %22)
br label %34
24: ; preds = %15, %15, %15
%25 = load i32, i32* %6
%26 = call i32 (i32, i32, i8*, i32, ...) @mvprintw(i32 5, i32 0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %25)
br label %34
27: ; preds = %15
%28 = load i32, i32* %6
%29 = call i32 (i32, i32, i8*, i32, ...) @mvprintw(i32 5, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %28)
br label %34
30: ; preds = %15
%31 = call i32 (...) @endwin()
%32 = call i32 @exit(i32 0)
unreachable
33: ; preds = %15
br label %34
34: ; preds = %33, %27, %24, %21
br label %12
35: ; preds = %12
%36 = call i32 (...) @endwin()
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
@stdscr = global i32 0
@TRUE = global i64 0
@.str = [31 x i8] c"Key number: '%3d' / Char: '%c'\00"
@.str.1 = [13 x i8] c"CATCHED! %3d\00"
@.str.2 = [9 x i8] c"TAB! %3d\00"
@.str.3 = [12 x i8] c"RESIZE! %3d\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @initscr()
%4 = tail call i32 (...) @noecho()
%5 = load i32, i32* @stdscr
%6 = load i64, i64* @TRUE
%7 = tail call i32 @keypad(i32 %5, i64 %6)
%8 = load i64, i64* @TRUE
%9 = icmp eq i64 %8, 0
br i1 %9, label %25, label %10
10: ; preds = %2, %22
%11 = tail call i32 (...) @getch()
%12 = tail call i32 (i32, i32, i8*, i32, ...) @mvprintw(i32 1, i32 0, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %11, i32 %11)
switch i32 %11, label %22 [
i32 137, label %13
i32 132, label %13
i32 130, label %13
i32 128, label %13
i32 134, label %13
i32 129, label %15
i32 136, label %15
i32 135, label %15
i32 131, label %17
i32 133, label %19
]
13: ; preds = %10, %10, %10, %10, %10
%14 = tail call i32 (i32, i32, i8*, i32, ...) @mvprintw(i32 5, i32 0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %11)
br label %22
15: ; preds = %10, %10, %10
%16 = tail call i32 (i32, i32, i8*, i32, ...) @mvprintw(i32 5, i32 0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %11)
br label %22
17: ; preds = %10
%18 = tail call i32 (i32, i32, i8*, i32, ...) @mvprintw(i32 5, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 131)
br label %22
19: ; preds = %10
%20 = tail call i32 (...) @endwin()
%21 = tail call i32 @exit(i32 0)
unreachable
22: ; preds = %10, %17, %15, %13
%23 = load i64, i64* @TRUE
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %10
25: ; preds = %22, %2
%26 = tail call i32 (...) @endwin()
ret i32 0
}