#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 ERR;
int /*<<< orphan*/ TRUE;
int /*<<< orphan*/ addstr(char *);
int /*<<< orphan*/ cbreak();
int getch();
int getch_nodelay();
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ keypad(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ noecho();
int /*<<< orphan*/ nonl();
int /*<<< orphan*/ snprintf(char *, int, char *, int, ...);
int /*<<< orphan*/ stdscr;
int main(void) {
  cbreak();
  initscr();
  noecho();
  nonl();
  keypad(stdscr, TRUE);
  while (1) {
    char number[32];
    int c[5] = {getch(), getch_nodelay(), getch_nodelay(), getch_nodelay(),
                getch_nodelay()};
    if (c[1] == ERR)
      snprintf(number, 32, "%d ", c[0]);
    else if (c[2] == ERR)
      snprintf(number, 32, "%d-%d ", c[0], c[1]);
    else if (c[3] == ERR)
      snprintf(number, 32, "%d-%d-%d ", c[0], c[1], c[2]);
    else if (c[4] == ERR)
      snprintf(number, 32, "%d-%d-%d-%d ", c[0], c[1], c[2], c[3]);
    else if (c[5] == ERR)
      snprintf(number, 32, "%d-%d-%d-%d-%d ", c[0], c[1], c[2], c[3], c[4]);
    addstr(number);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <cbreak@plt>
mov    $0x0,%al
call   1050 <initscr@plt>
mov    $0x0,%al
call   10a0 <noecho@plt>
mov    $0x0,%al
call   1070 <nonl@plt>
mov    0x2e1e(%rip),%rax
mov    (%rax),%edi
mov    0x2e0d(%rip),%rax
mov    (%rax),%esi
call   1040 <keypad@plt>
mov    $0x0,%al
call   1080 <getch@plt>
mov    %eax,-0x50(%rbp)
mov    $0x0,%al
call   1090 <getch_nodelay@plt>
mov    %eax,-0x4c(%rbp)
mov    $0x0,%al
call   1090 <getch_nodelay@plt>
mov    %eax,-0x48(%rbp)
mov    $0x0,%al
call   1090 <getch_nodelay@plt>
mov    %eax,-0x44(%rbp)
mov    $0x0,%al
call   1090 <getch_nodelay@plt>
mov    %eax,-0x40(%rbp)
mov    -0x4c(%rbp),%eax
mov    0x2dda(%rip),%rcx
cmp    (%rcx),%eax
jne    1235 <main+0xa5>
lea    -0x30(%rbp),%rdi
mov    -0x50(%rbp),%ecx
mov    $0x20,%esi
lea    0xde3(%rip),%rdx
mov    $0x0,%al
call   1060 <snprintf@plt>
jmp    1339 <main+0x1a9>
mov    -0x48(%rbp),%eax
mov    0x2da9(%rip),%rcx
cmp    (%rcx),%eax
jne    126a <main+0xda>
lea    -0x30(%rbp),%rdi
mov    -0x50(%rbp),%ecx
mov    -0x4c(%rbp),%r8d
mov    $0x20,%esi
lea    0xdab(%rip),%rdx
mov    $0x0,%al
call   1060 <snprintf@plt>
jmp    1334 <main+0x1a4>
mov    -0x44(%rbp),%eax
mov    0x2d74(%rip),%rcx
cmp    (%rcx),%eax
jne    12a3 <main+0x113>
lea    -0x30(%rbp),%rdi
mov    -0x50(%rbp),%ecx
mov    -0x4c(%rbp),%r8d
mov    -0x48(%rbp),%r9d
mov    $0x20,%esi
lea    0xd6f(%rip),%rdx
mov    $0x0,%al
call   1060 <snprintf@plt>
jmp    132f <main+0x19f>
mov    -0x40(%rbp),%eax
mov    0x2d3b(%rip),%rcx
cmp    (%rcx),%eax
jne    12e2 <main+0x152>
lea    -0x30(%rbp),%rdi
mov    -0x50(%rbp),%ecx
mov    -0x4c(%rbp),%r8d
mov    -0x48(%rbp),%r9d
mov    -0x44(%rbp),%eax
mov    $0x20,%esi
lea    0xd30(%rip),%rdx
mov    %eax,(%rsp)
mov    $0x0,%al
call   1060 <snprintf@plt>
jmp    132a <main+0x19a>
mov    -0x3c(%rbp),%eax
mov    0x2cfc(%rip),%rcx
cmp    (%rcx),%eax
jne    1325 <main+0x195>
lea    -0x30(%rbp),%rdi
mov    -0x50(%rbp),%ecx
mov    -0x4c(%rbp),%r8d
mov    -0x48(%rbp),%r9d
mov    -0x44(%rbp),%r10d
mov    -0x40(%rbp),%eax
mov    $0x20,%esi
lea    0xcea(%rip),%rdx
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
mov    $0x0,%al
call   1060 <snprintf@plt>
jmp    132a <main+0x19a>
jmp    132f <main+0x19f>
jmp    1334 <main+0x1a4>
jmp    1339 <main+0x1a9>
lea    -0x30(%rbp),%rdi
call   10b0 <addstr@plt>
jmp    11d2 <main+0x42>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
xor    %eax,%eax
call   1030 <cbreak@plt>
xor    %eax,%eax
call   1050 <initscr@plt>
xor    %eax,%eax
call   10a0 <noecho@plt>
xor    %eax,%eax
call   1070 <nonl@plt>
mov    0x2e1f(%rip),%rax
mov    (%rax),%edi
mov    0x2e0e(%rip),%rax
mov    (%rax),%esi
call   1040 <keypad@plt>
mov    0x2e10(%rip),%r14
lea    0x10(%rsp),%rbx
jmp    1200 <main+0x70>
nop
mov    %rbx,%rdi
mov    $0x20,%esi
lea    0xe1a(%rip),%rdx
mov    %ebp,%ecx
xor    %eax,%eax
call   1060 <snprintf@plt>
mov    %rbx,%rdi
call   10b0 <addstr@plt>
xor    %eax,%eax
call   1080 <getch@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1090 <getch_nodelay@plt>
mov    %eax,%r13d
xor    %eax,%eax
call   1090 <getch_nodelay@plt>
mov    %eax,%r12d
xor    %eax,%eax
call   1090 <getch_nodelay@plt>
mov    %eax,%r15d
xor    %eax,%eax
call   1090 <getch_nodelay@plt>
mov    (%r14),%ecx
cmp    %ecx,%r13d
je     11e0 <main+0x50>
cmp    %ecx,%r12d
jne    1260 <main+0xd0>
mov    %rbx,%rdi
mov    $0x20,%esi
lea    0xdbc(%rip),%rdx
mov    %ebp,%ecx
mov    %r13d,%r8d
xor    %eax,%eax
call   1060 <snprintf@plt>
jmp    11f8 <main+0x68>
nopl   0x0(%rax,%rax,1)
cmp    %ecx,%r15d
jne    1276 <main+0xe6>
mov    %rbx,%rdi
mov    $0x20,%esi
lea    0xd8f(%rip),%rdx
jmp    1291 <main+0x101>
cmp    %ecx,%eax
jne    11f8 <main+0x68>
mov    %r15d,(%rsp)
mov    %rbx,%rdi
mov    $0x20,%esi
lea    0xd6f(%rip),%rdx
mov    %ebp,%ecx
mov    %r13d,%r8d
mov    %r12d,%r9d
xor    %eax,%eax
call   1060 <snprintf@plt>
jmp    11f8 <main+0x68>

LLVM IR (-O0):
@stdscr = global i32 0
@TRUE = global i32 0
@ERR = global i32 0
@.str = [4 x i8] c"%d \00"
@.str.1 = [7 x i8] c"%d-%d \00"
@.str.2 = [10 x i8] c"%d-%d-%d \00"
@.str.3 = [13 x i8] c"%d-%d-%d-%d \00"
@.str.4 = [16 x i8] c"%d-%d-%d-%d-%d \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [32 x i8]
%3 = alloca [5 x i32]
store i32 0, i32* %1
%4 = call i32 (...) @cbreak()
%5 = call i32 (...) @initscr()
%6 = call i32 (...) @noecho()
%7 = call i32 (...) @nonl()
%8 = load i32, i32* @stdscr
%9 = load i32, i32* @TRUE
%10 = call i32 @keypad(i32 %8, i32 %9)
br label %11
11: ; preds = %0, %95
%12 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 0
%13 = call i32 (...) @getch()
store i32 %13, i32* %12
%14 = getelementptr inbounds i32, i32* %12, i64 1
%15 = call i32 (...) @getch_nodelay()
store i32 %15, i32* %14
%16 = getelementptr inbounds i32, i32* %14, i64 1
%17 = call i32 (...) @getch_nodelay()
store i32 %17, i32* %16
%18 = getelementptr inbounds i32, i32* %16, i64 1
%19 = call i32 (...) @getch_nodelay()
store i32 %19, i32* %18
%20 = getelementptr inbounds i32, i32* %18, i64 1
%21 = call i32 (...) @getch_nodelay()
store i32 %21, i32* %20
%22 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 1
%23 = load i32, i32* %22
%24 = load i32, i32* @ERR
%25 = icmp eq i32 %23, %24
br i1 %25, label %26, label %31
26: ; preds = %11
%27 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%28 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 0
%29 = load i32, i32* %28
%30 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %27, i32 32, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %29)
br label %95
31: ; preds = %11
%32 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 2
%33 = load i32, i32* %32
%34 = load i32, i32* @ERR
%35 = icmp eq i32 %33, %34
br i1 %35, label %36, label %43
36: ; preds = %31
%37 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%38 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 0
%39 = load i32, i32* %38
%40 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 1
%41 = load i32, i32* %40
%42 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %37, i32 32, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %39, i32 %41)
br label %94
43: ; preds = %31
%44 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 3
%45 = load i32, i32* %44
%46 = load i32, i32* @ERR
%47 = icmp eq i32 %45, %46
br i1 %47, label %48, label %57
48: ; preds = %43
%49 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%50 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 0
%51 = load i32, i32* %50
%52 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 1
%53 = load i32, i32* %52
%54 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 2
%55 = load i32, i32* %54
%56 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %49, i32 32, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %51, i32 %53, i32 %55)
br label %93
57: ; preds = %43
%58 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 4
%59 = load i32, i32* %58
%60 = load i32, i32* @ERR
%61 = icmp eq i32 %59, %60
br i1 %61, label %62, label %73
62: ; preds = %57
%63 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%64 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 0
%65 = load i32, i32* %64
%66 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 1
%67 = load i32, i32* %66
%68 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 2
%69 = load i32, i32* %68
%70 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 3
%71 = load i32, i32* %70
%72 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %63, i32 32, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %65, i32 %67, i32 %69, i32 %71)
br label %92
73: ; preds = %57
%74 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 5
%75 = load i32, i32* %74
%76 = load i32, i32* @ERR
%77 = icmp eq i32 %75, %76
br i1 %77, label %78, label %91
78: ; preds = %73
%79 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%80 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 0
%81 = load i32, i32* %80
%82 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 1
%83 = load i32, i32* %82
%84 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 2
%85 = load i32, i32* %84
%86 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 3
%87 = load i32, i32* %86
%88 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 4
%89 = load i32, i32* %88
%90 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %79, i32 32, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %81, i32 %83, i32 %85, i32 %87, i32 %89)
br label %91
91: ; preds = %78, %73
br label %92
92: ; preds = %91, %62
br label %93
93: ; preds = %92, %48
br label %94
94: ; preds = %93, %36
br label %95
95: ; preds = %94, %26
%96 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%97 = call i32 @addstr(i8* %96)
br label %11
}

LLVM IR (-O2):
@stdscr = global i32 0
@TRUE = global i32 0
@ERR = global i32 0
@.str = [4 x i8] c"%d \00"
@.str.1 = [7 x i8] c"%d-%d \00"
@.str.2 = [10 x i8] c"%d-%d-%d \00"
@.str.3 = [13 x i8] c"%d-%d-%d-%d \00"
define i32 @main() {
%1 = alloca [32 x i8]
%2 = tail call i32 (...) @cbreak()
%3 = tail call i32 (...) @initscr()
%4 = tail call i32 (...) @noecho()
%5 = tail call i32 (...) @nonl()
%6 = load i32, i32* @stdscr
%7 = load i32, i32* @TRUE
%8 = tail call i32 @keypad(i32 %6, i32 %7)
%9 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
br label %10
10: ; preds = %0, %32
%11 = call i32 (...) @getch()
%12 = call i32 (...) @getch_nodelay()
%13 = call i32 (...) @getch_nodelay()
%14 = call i32 (...) @getch_nodelay()
%15 = call i32 (...) @getch_nodelay()
%16 = load i32, i32* @ERR
%17 = icmp eq i32 %12, %16
br i1 %17, label %18, label %20
18: ; preds = %10
%19 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %9, i32 32, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %11)
br label %32
20: ; preds = %10
%21 = icmp eq i32 %13, %16
br i1 %21, label %22, label %24
22: ; preds = %20
%23 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %9, i32 32, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 %12)
br label %32
24: ; preds = %20
%25 = icmp eq i32 %14, %16
br i1 %25, label %26, label %28
26: ; preds = %24
%27 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %9, i32 32, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %11, i32 %12, i32 %13)
br label %32
28: ; preds = %24
%29 = icmp eq i32 %15, %16
br i1 %29, label %30, label %32
30: ; preds = %28
%31 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %9, i32 32, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %11, i32 %12, i32 %13, i32 %14)
br label %32
32: ; preds = %28, %22, %30, %26, %18
%33 = call i32 @addstr(i8* %9)
br label %10
}