#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 */
#define KEY_DOWN 129
#define KEY_UP 128
int /*<<< orphan*/ TRUE;
int /*<<< orphan*/ cbreak();
int /*<<< orphan*/ clrtoeol();
int /*<<< orphan*/ getmaxyx(int /*<<< orphan*/, int, int);
int /*<<< orphan*/ keypad(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ menu(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ noecho();
int /*<<< orphan*/ refresh();
int /*<<< orphan*/ stdscr;
int wgetch(int /*<<< orphan*/ *);
int aplayer(WINDOW *m) {
  int hl = 1, choice = 0, xx, yy, c;
  getmaxyx(stdscr, yy, xx);
  keypad(m, TRUE);
  noecho();
  cbreak();
  menu(m, hl);
  while (1) {
    c = wgetch(m);
    switch (c) {
    case KEY_UP:
      if (hl == 1)
        hl = 7;
      else
        --hl;
      break;
    case KEY_DOWN:
      if (hl == 7)
        hl = 1;
      else
        ++hl;
      break;
    case 10:
      choice = hl;
      break;
    default:
      refresh();
      break;
    }
    menu(m, hl);
    if (choice != 0)
      break;
  }
  clrtoeol();
  refresh();
  return hl;
}


x86 assembly (clang, -O0):
<aplayer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1060 <getmaxyx@plt>
mov    -0x8(%rbp),%rdi
mov    0x2e27(%rip),%rax
mov    (%rax),%esi
call   1050 <keypad@plt>
mov    $0x0,%al
call   10a0 <noecho@plt>
mov    $0x0,%al
call   1030 <cbreak@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <menu@plt>
mov    -0x8(%rbp),%rdi
call   1080 <wgetch@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
sub    $0xa,%eax
je     1268 <aplayer+0xe8>
jmp    11fa <aplayer+0x7a>
mov    -0x20(%rbp),%eax
sub    $0x80,%eax
je     1220 <aplayer+0xa0>
jmp    120d <aplayer+0x8d>
mov    -0x20(%rbp),%eax
sub    $0x81,%eax
je     1244 <aplayer+0xc4>
jmp    1273 <aplayer+0xf3>
cmpl   $0x1,-0xc(%rbp)
jne    1236 <aplayer+0xb6>
movl   $0x7,-0xc(%rbp)
jmp    123f <aplayer+0xbf>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    127a <aplayer+0xfa>
cmpl   $0x7,-0xc(%rbp)
jne    125a <aplayer+0xda>
movl   $0x1,-0xc(%rbp)
jmp    1263 <aplayer+0xe3>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    127a <aplayer+0xfa>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    127a <aplayer+0xfa>
mov    $0x0,%al
call   1070 <refresh@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <menu@plt>
cmpl   $0x0,-0x10(%rbp)
je     1295 <aplayer+0x115>
jmp    129a <aplayer+0x11a>
jmp    11da <aplayer+0x5a>
mov    $0x0,%al
call   1090 <clrtoeol@plt>
mov    $0x0,%al
call   1070 <refresh@plt>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aplayer>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r14
mov    0x2e56(%rip),%rax
mov    (%rax),%edi
call   1060 <getmaxyx@plt>
mov    0x2e40(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   1050 <keypad@plt>
xor    %eax,%eax
call   10a0 <noecho@plt>
xor    %eax,%eax
call   1030 <cbreak@plt>
mov    $0x1,%r15d
mov    %r14,%rdi
mov    $0x1,%esi
call   1040 <menu@plt>
mov    $0x7,%r12d
mov    $0x1,%ebx
jmp    11fc <aplayer+0x7c>
nopl   0x0(%rax,%rax,1)
cmp    $0x7,%ebx
lea    0x1(%rbx),%eax
cmove  %r15d,%eax
xor    %ebp,%ebp
mov    %eax,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
call   1040 <menu@plt>
test   %ebp,%ebp
jne    124b <aplayer+0xcb>
mov    %r14,%rdi
call   1080 <wgetch@plt>
cmp    $0xa,%eax
je     1230 <aplayer+0xb0>
cmp    $0x81,%eax
je     11e0 <aplayer+0x60>
cmp    $0x80,%eax
jne    1240 <aplayer+0xc0>
cmp    $0x1,%ebx
lea    -0x1(%rbx),%eax
cmove  %r12d,%eax
jmp    11ea <aplayer+0x6a>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebx,%ebp
jmp    11ee <aplayer+0x6e>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %ebp,%ebp
xor    %eax,%eax
call   1070 <refresh@plt>
jmp    11ee <aplayer+0x6e>
xor    %eax,%eax
call   1090 <clrtoeol@plt>
xor    %eax,%eax
call   1070 <refresh@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdscr = global i32 0
@TRUE = global i32 0
define i32 @aplayer(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %2
store i32 1, i32* %3
store i32 0, i32* %4
%8 = load i32, i32* @stdscr
%9 = load i32, i32* %6
%10 = load i32, i32* %5
%11 = call i32 @getmaxyx(i32 %8, i32 %9, i32 %10)
%12 = load i32*, i32** %2
%13 = load i32, i32* @TRUE
%14 = call i32 @keypad(i32* %12, i32 %13)
%15 = call i32 (...) @noecho()
%16 = call i32 (...) @cbreak()
%17 = load i32*, i32** %2
%18 = load i32, i32* %3
%19 = call i32 @menu(i32* %17, i32 %18)
br label %20
20: ; preds = %1, %51
%21 = load i32*, i32** %2
%22 = call i32 @wgetch(i32* %21)
store i32 %22, i32* %7
%23 = load i32, i32* %7
switch i32 %23, label %42 [
i32 128, label %24
i32 129, label %32
i32 10, label %40
]
24: ; preds = %20
%25 = load i32, i32* %3
%26 = icmp eq i32 %25, 1
br i1 %26, label %27, label %28
27: ; preds = %24
store i32 7, i32* %3
br label %31
28: ; preds = %24
%29 = load i32, i32* %3
%30 = add nsw i32 %29, -1
store i32 %30, i32* %3
br label %31
31: ; preds = %28, %27
br label %44
32: ; preds = %20
%33 = load i32, i32* %3
%34 = icmp eq i32 %33, 7
br i1 %34, label %35, label %36
35: ; preds = %32
store i32 1, i32* %3
br label %39
36: ; preds = %32
%37 = load i32, i32* %3
%38 = add nsw i32 %37, 1
store i32 %38, i32* %3
br label %39
39: ; preds = %36, %35
br label %44
40: ; preds = %20
%41 = load i32, i32* %3
store i32 %41, i32* %4
br label %44
42: ; preds = %20
%43 = call i32 (...) @refresh()
br label %44
44: ; preds = %42, %40, %39, %31
%45 = load i32*, i32** %2
%46 = load i32, i32* %3
%47 = call i32 @menu(i32* %45, i32 %46)
%48 = load i32, i32* %4
%49 = icmp ne i32 %48, 0
br i1 %49, label %50, label %51
50: ; preds = %44
br label %52
51: ; preds = %44
br label %20
52: ; preds = %50
%53 = call i32 (...) @clrtoeol()
%54 = call i32 (...) @refresh()
%55 = load i32, i32* %3
ret i32 %55
}

LLVM IR (-O2):
@stdscr = global i32 0
@TRUE = global i32 0
define i32 @aplayer(i32* %0) {
%2 = load i32, i32* @stdscr
%3 = tail call i32 @getmaxyx(i32 %2, i32 undef, i32 undef)
%4 = load i32, i32* @TRUE
%5 = tail call i32 @keypad(i32* %0, i32 %4)
%6 = tail call i32 (...) @noecho()
%7 = tail call i32 (...) @cbreak()
%8 = tail call i32 @menu(i32* %0, i32 1)
br label %9
9: ; preds = %22, %1
%10 = phi i32 [ 1, %1 ], [ %24, %22 ]
%11 = tail call i32 @wgetch(i32* %0)
switch i32 %11, label %20 [
i32 128, label %12
i32 129, label %16
i32 10, label %22
]
12: ; preds = %9
%13 = icmp eq i32 %10, 1
%14 = add nsw i32 %10, -1
%15 = select i1 %13, i32 7, i32 %14
br label %22
16: ; preds = %9
%17 = icmp eq i32 %10, 7
%18 = add nsw i32 %10, 1
%19 = select i1 %17, i32 1, i32 %18
br label %22
20: ; preds = %9
%21 = tail call i32 (...) @refresh()
br label %22
22: ; preds = %16, %12, %9, %20
%23 = phi i32 [ 0, %20 ], [ %10, %9 ], [ 0, %12 ], [ 0, %16 ]
%24 = phi i32 [ %10, %20 ], [ %10, %9 ], [ %15, %12 ], [ %19, %16 ]
%25 = tail call i32 @menu(i32* %0, i32 %24)
%26 = icmp eq i32 %23, 0
br i1 %26, label %9, label %27
27: ; preds = %22
%28 = tail call i32 (...) @clrtoeol()
%29 = tail call i32 (...) @refresh()
ret i32 %24
}