#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 */
int /*<<< orphan*/ FALSE;
int /*<<< orphan*/ TRUE;
int /*<<< orphan*/ cbreak();
int /*<<< orphan*/ endwin();
int getch();
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ intrflush(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ keypad(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ noecho();
int /*<<< orphan*/ nonl();
int /*<<< orphan*/ printw(char *, ...);
int /*<<< orphan*/ stdscr;
int main(int argc, char **argv) {
  int key;
  initscr();
  cbreak();
  noecho();
  nonl();
  intrflush(stdscr, FALSE);
  keypad(stdscr, TRUE);
  printw("getch() should produce only one value when hitting an arrow.\n");
  while ((key = getch()) != 'q') {
    printw("%c:%d:0%o\n", key, key, key);
  }
  endwin();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1050 <initscr@plt>
mov    $0x0,%al
call   1030 <cbreak@plt>
mov    $0x0,%al
call   10b0 <noecho@plt>
mov    $0x0,%al
call   1070 <nonl@plt>
mov    0x2e1f(%rip),%rax
mov    (%rax),%edi
mov    0x2dfe(%rip),%rax
mov    (%rax),%esi
call   1060 <intrflush@plt>
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
mov    0x2df7(%rip),%rax
mov    (%rax),%esi
call   1040 <keypad@plt>
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1080 <printw@plt>
mov    $0x0,%al
call   1090 <getch@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x71,%eax
je     122d <main+0x9d>
mov    -0x14(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1080 <printw@plt>
jmp    11fe <main+0x6e>
mov    $0x0,%al
call   10a0 <endwin@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1050 <initscr@plt>
xor    %eax,%eax
call   1030 <cbreak@plt>
xor    %eax,%eax
call   10b0 <noecho@plt>
xor    %eax,%eax
call   1070 <nonl@plt>
mov    0x2e34(%rip),%rbx
mov    (%rbx),%edi
mov    0x2e13(%rip),%rax
mov    (%rax),%esi
call   1060 <intrflush@plt>
mov    (%rbx),%edi
mov    0x2e13(%rip),%rax
mov    (%rax),%esi
call   1040 <keypad@plt>
lea    0xe25(%rip),%rdi
xor    %eax,%eax
call   1080 <printw@plt>
xor    %eax,%eax
call   1090 <getch@plt>
cmp    $0x71,%eax
je     121c <main+0x8c>
lea    0xe49(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
mov    %eax,%esi
mov    %eax,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1080 <printw@plt>
xor    %eax,%eax
call   1090 <getch@plt>
cmp    $0x71,%eax
jne    1200 <main+0x70>
xor    %eax,%eax
call   10a0 <endwin@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@stdscr = global i32 0
@FALSE = global i32 0
@TRUE = global i32 0
@.str = [62 x i8] c"getch() should produce only one value when hitting an arrow.\0A\00"
@.str.1 = [11 x i8] c"%c:%d:0%o\0A\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 (...) @cbreak()
%9 = call i32 (...) @noecho()
%10 = call i32 (...) @nonl()
%11 = load i32, i32* @stdscr
%12 = load i32, i32* @FALSE
%13 = call i32 @intrflush(i32 %11, i32 %12)
%14 = load i32, i32* @stdscr
%15 = load i32, i32* @TRUE
%16 = call i32 @keypad(i32 %14, i32 %15)
%17 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %21, %2
%19 = call i32 (...) @getch()
store i32 %19, i32* %6
%20 = icmp ne i32 %19, 113
br i1 %20, label %21, label %26
21: ; preds = %18
%22 = load i32, i32* %6
%23 = load i32, i32* %6
%24 = load i32, i32* %6
%25 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %22, i32 %23, i32 %24)
br label %18
26: ; preds = %18
%27 = call i32 (...) @endwin()
ret i32 0
}

LLVM IR (-O2):
@stdscr = global i32 0
@FALSE = global i32 0
@TRUE = global i32 0
@.str = [62 x i8] c"getch() should produce only one value when hitting an arrow.\0A\00"
@.str.1 = [11 x i8] c"%c:%d:0%o\0A\00"
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* @stdscr
%8 = load i32, i32* @FALSE
%9 = tail call i32 @intrflush(i32 %7, i32 %8)
%10 = load i32, i32* @stdscr
%11 = load i32, i32* @TRUE
%12 = tail call i32 @keypad(i32 %10, i32 %11)
%13 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0))
%14 = tail call i32 (...) @getch()
%15 = icmp eq i32 %14, 113
br i1 %15, label %21, label %16
16: ; preds = %2, %16
%17 = phi i32 [ %19, %16 ], [ %14, %2 ]
%18 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %17, i32 %17, i32 %17)
%19 = tail call i32 (...) @getch()
%20 = icmp eq i32 %19, 113
br i1 %20, label %21, label %16
21: ; preds = %16, %2
%22 = tail call i32 (...) @endwin()
ret i32 0
}