#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;
typedef int /*<<< orphan*/ MENU;
typedef int /*<<< orphan*/ ITEM;

/* Variables and functions */
int /*<<< orphan*/ ACS_HLINE;
int /*<<< orphan*/ ACS_VLINE;
int KEY_DOWN;
int KEY_ENTER;
int KEY_F(int);
int KEY_UP;
int /*<<< orphan*/ REQ_DOWN_ITEM;
int /*<<< orphan*/ REQ_UP_ITEM;
int /*<<< orphan*/ box(int /*<<< orphan*/ *, int /*<<< orphan*/,
                       int /*<<< orphan*/);
int /*<<< orphan*/ *current_item(int /*<<< orphan*/ *);
int /*<<< orphan*/ delwin(int /*<<< orphan*/ *);
int /*<<< orphan*/ doupdate();
int /*<<< orphan*/ free_menu(int /*<<< orphan*/ *);
int getch();
int /*<<< orphan*/ getmaxyx(int /*<<< orphan*/, int, int);
int item_index(int /*<<< orphan*/ *);
int *item_userptr(int /*<<< orphan*/ *);
int /*<<< orphan*/ menu_driver(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ mvwaddstr(int /*<<< orphan*/ *, int, int, char *);
int /*<<< orphan*/ *new_menu(int /*<<< orphan*/ **);
int /*<<< orphan*/ *newwin(int, int, int, int);
int /*<<< orphan*/ post_menu(int /*<<< orphan*/ *);
int /*<<< orphan*/ scale_menu(int /*<<< orphan*/ *, int *, int *);
int /*<<< orphan*/ set_menu_format(int /*<<< orphan*/ *, int, int);
int /*<<< orphan*/ set_menu_mark(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ set_menu_win(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ stdscr;
int /*<<< orphan*/ unpost_menu(int /*<<< orphan*/ *);
int /*<<< orphan*/ wclear(int /*<<< orphan*/ *);
int /*<<< orphan*/ wnoutrefresh(int /*<<< orphan*/ *);
int /*<<< orphan*/ wrefresh(int /*<<< orphan*/ *);
int display_menu(ITEM **menu_item, int menu_start_row, int menu_index_max,
                 int **userptrptr) {
  ITEM *cur_item;
  MENU *menu;
  WINDOW *box1_win, *box2_win, *field_win;
  int menu_rows, menu_cols, menu_rows_disp;
  int menu_index;
  int use_box2 = 0;
  int cur_item_index;
  int ch, i;
  int rc = 0;
  int max_y, max_x;
  getmaxyx(stdscr, max_y, max_x);
  menu = new_menu(menu_item);
  scale_menu(menu, &menu_rows, &menu_cols);
  menu_rows_disp = menu_rows;
  if ((menu_start_row + menu_rows + 1 + 1) > max_y) {
    menu_start_row = max_y - (menu_rows + 1 + 1);
    if (menu_start_row < (8 + 1)) {
      menu_rows_disp = max_y - (8 + 2 + 1);
      menu_start_row = (8 + 1);
    }
  }
  if (menu_rows > menu_rows_disp) {
    set_menu_format(menu, menu_rows_disp, 1);
    use_box2 = 1;
  }
  set_menu_mark(menu, "*");
  scale_menu(menu, &menu_rows, &menu_cols);
  box1_win = newwin(menu_rows + 2, menu_cols + 2, menu_start_row - 1, 54);
  field_win = newwin(menu_rows, menu_cols, menu_start_row, 55);
  set_menu_win(menu, field_win);
  post_menu(menu);
  box(box1_win, ACS_VLINE, ACS_HLINE);
  if (use_box2) {
    box2_win = newwin(menu_rows + 2, 3, menu_start_row - 1, 54 + menu_cols + 1);
    box(box2_win, ACS_VLINE, ACS_HLINE);
    for (i = 0; i < menu_rows_disp / 2; i++)
      mvwaddstr(box2_win, i + 1, 1, "#");
    for (i = menu_rows_disp; i > (menu_rows_disp - menu_rows_disp / 2); i--)
      mvwaddstr(box2_win, i, 1, "v");
  }
  wnoutrefresh(box1_win);
  menu_index = 0;
  while (1) {
    if (use_box2)
      wnoutrefresh(box2_win);
    wnoutrefresh(field_win);
    doupdate();
    ch = getch();
    if (((ch == KEY_ENTER) || (ch == '\n'))) {
      cur_item = current_item(menu);
      cur_item_index = item_index(cur_item);
      *userptrptr = item_userptr(menu_item[cur_item_index]);
      break;
    } else if ((ch == KEY_DOWN) || (ch == '\t')) {
      if (use_box2 && (menu_index < (menu_index_max - 1))) {
        menu_index++;
        if (menu_index == menu_rows_disp) {
          for (i = 0; i < menu_rows_disp / 2; i++)
            mvwaddstr(box2_win, i + 1, 1, "^");
        }
        if (menu_index == (menu_index_max - 1)) {
          for (i = menu_rows_disp; i > (menu_rows_disp - menu_rows_disp / 2);
               i--)
            mvwaddstr(box2_win, i, 1, "#");
        }
      }
      menu_driver(menu, REQ_DOWN_ITEM);
    } else if (ch == KEY_UP) {
      if (use_box2 && menu_index != 0) {
        menu_index--;
        if (menu_index == (menu_index_max - menu_rows_disp - 1)) {
          for (i = menu_rows_disp; i > (menu_rows_disp - menu_rows_disp / 2);
               i--)
            mvwaddstr(box2_win, i, 1, "v");
        }
        if (menu_index == 0) {
          for (i = 0; i < menu_rows_disp / 2; i++)
            mvwaddstr(box2_win, i + 1, 1, "#");
        }
      }
      menu_driver(menu, REQ_UP_ITEM);
    } else if (((ch == KEY_F(3)) || (ch == 'e') || (ch == 'E'))) {
      rc = 0x8000;
      break;
    } else if (((ch == KEY_F(12)) || (ch == 'q') || (ch == 'Q'))) {
      rc = 0x4000;
      break;
    }
  }
  unpost_menu(menu);
  free_menu(menu);
  wclear(field_win);
  wrefresh(field_win);
  delwin(field_win);
  wclear(box1_win);
  wrefresh(box1_win);
  delwin(box1_win);
  if (use_box2) {
    wclear(box2_win);
    wrefresh(box2_win);
    delwin(box2_win);
  }
  return rc;
}


x86 assembly (clang, -O0):
<display_menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
movl   $0x0,-0x54(%rbp)
movl   $0x0,-0x64(%rbp)
mov    0x2d3a(%rip),%rax
mov    (%rax),%edi
mov    -0x68(%rbp),%esi
mov    -0x6c(%rbp),%edx
call   10d0 <getmaxyx@plt>
mov    -0x8(%rbp),%rdi
call   1110 <new_menu@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    -0x44(%rbp),%rsi
lea    -0x48(%rbp),%rdx
call   1170 <scale_menu@plt>
mov    -0x44(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0xc(%rbp),%eax
add    -0x44(%rbp),%eax
add    $0x1,%eax
add    $0x1,%eax
cmp    -0x68(%rbp),%eax
jle    1314 <display_menu+0xa4>
mov    -0x68(%rbp),%eax
mov    -0x44(%rbp),%ecx
add    $0x1,%ecx
add    $0x1,%ecx
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x9,-0xc(%rbp)
jge    130f <display_menu+0x9f>
mov    -0x68(%rbp),%eax
sub    $0xb,%eax
mov    %eax,-0x4c(%rbp)
movl   $0x9,-0xc(%rbp)
jmp    1314 <display_menu+0xa4>
mov    -0x44(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jle    1338 <display_menu+0xc8>
mov    -0x28(%rbp),%rdi
mov    -0x4c(%rbp),%esi
mov    $0x1,%edx
call   1160 <set_menu_format@plt>
movl   $0x1,-0x54(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xcbd(%rip),%rsi
call   10e0 <set_menu_mark@plt>
mov    -0x28(%rbp),%rdi
lea    -0x44(%rbp),%rsi
lea    -0x48(%rbp),%rdx
call   1170 <scale_menu@plt>
mov    -0x44(%rbp),%edi
add    $0x2,%edi
mov    -0x48(%rbp),%esi
add    $0x2,%esi
mov    -0xc(%rbp),%edx
sub    $0x1,%edx
mov    $0x36,%ecx
call   10a0 <newwin@plt>
mov    %rax,-0x30(%rbp)
mov    -0x44(%rbp),%edi
mov    -0x48(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    $0x37,%ecx
call   10a0 <newwin@plt>
mov    %rax,-0x40(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1030 <set_menu_win@plt>
mov    -0x28(%rbp),%rdi
call   1080 <post_menu@plt>
mov    -0x30(%rbp),%rdi
mov    0x2bff(%rip),%rax
mov    (%rax),%esi
mov    0x2c06(%rip),%rax
mov    (%rax),%edx
call   10f0 <box@plt>
cmpl   $0x0,-0x54(%rbp)
je     14ab <display_menu+0x23b>
mov    -0x44(%rbp),%edi
add    $0x2,%edi
mov    -0xc(%rbp),%edx
sub    $0x1,%edx
mov    -0x48(%rbp),%ecx
add    $0x36,%ecx
add    $0x1,%ecx
mov    $0x3,%esi
call   10a0 <newwin@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    0x2bb7(%rip),%rax
mov    (%rax),%esi
mov    0x2bbe(%rip),%rax
mov    (%rax),%edx
call   10f0 <box@plt>
movl   $0x0,-0x60(%rbp)
mov    -0x60(%rbp),%eax
mov    %eax,-0x70(%rbp)
mov    -0x4c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x70(%rbp),%eax
cmp    %ecx,%eax
jge    1457 <display_menu+0x1e7>
mov    -0x38(%rbp),%rdi
mov    -0x60(%rbp),%esi
add    $0x1,%esi
mov    $0x1,%edx
lea    0xbbe(%rip),%rcx
call   1190 <mvwaddstr@plt>
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    1410 <display_menu+0x1a0>
mov    -0x4c(%rbp),%eax
mov    %eax,-0x60(%rbp)
mov    -0x60(%rbp),%eax
mov    %eax,-0x74(%rbp)
mov    -0x4c(%rbp),%ecx
mov    -0x4c(%rbp),%eax
mov    $0x2,%esi
cltd
idiv   %esi
mov    %eax,%edx
mov    -0x74(%rbp),%eax
sub    %edx,%ecx
cmp    %ecx,%eax
jle    14a6 <display_menu+0x236>
mov    -0x38(%rbp),%rdi
mov    -0x60(%rbp),%esi
mov    $0x1,%edx
lea    0xb71(%rip),%rcx
call   1190 <mvwaddstr@plt>
mov    -0x60(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x60(%rbp)
jmp    145d <display_menu+0x1ed>
jmp    14ab <display_menu+0x23b>
mov    -0x30(%rbp),%rdi
call   1120 <wnoutrefresh@plt>
movl   $0x0,-0x50(%rbp)
cmpl   $0x0,-0x54(%rbp)
je     14ce <display_menu+0x25e>
mov    -0x38(%rbp),%rdi
call   1120 <wnoutrefresh@plt>
mov    -0x40(%rbp),%rdi
call   1120 <wnoutrefresh@plt>
mov    $0x0,%al
call   1180 <doupdate@plt>
mov    $0x0,%al
call   1130 <getch@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
mov    0x2aae(%rip),%rcx
cmp    (%rcx),%eax
je     1504 <display_menu+0x294>
cmpl   $0xa,-0x5c(%rbp)
jne    153d <display_menu+0x2cd>
mov    -0x28(%rbp),%rdi
call   1040 <current_item@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1070 <item_index@plt>
mov    %eax,-0x58(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x58(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1150 <item_userptr@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    1812 <display_menu+0x5a2>
mov    -0x5c(%rbp),%eax
mov    0x2aa1(%rip),%rcx
cmp    (%rcx),%eax
je     1559 <display_menu+0x2e9>
cmpl   $0x9,-0x5c(%rbp)
jne    165d <display_menu+0x3ed>
cmpl   $0x0,-0x54(%rbp)
je     1646 <display_menu+0x3d6>
mov    -0x50(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1646 <display_menu+0x3d6>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jne    15dc <display_menu+0x36c>
movl   $0x0,-0x60(%rbp)
mov    -0x60(%rbp),%eax
mov    %eax,-0x78(%rbp)
mov    -0x4c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x78(%rbp),%eax
cmp    %ecx,%eax
jge    15d7 <display_menu+0x367>
mov    -0x38(%rbp),%rdi
mov    -0x60(%rbp),%esi
add    $0x1,%esi
mov    $0x1,%edx
lea    0xa42(%rip),%rcx
call   1190 <mvwaddstr@plt>
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    1590 <display_menu+0x320>
jmp    15dc <display_menu+0x36c>
mov    -0x50(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    1641 <display_menu+0x3d1>
mov    -0x4c(%rbp),%eax
mov    %eax,-0x60(%rbp)
mov    -0x60(%rbp),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x4c(%rbp),%ecx
mov    -0x4c(%rbp),%eax
mov    $0x2,%esi
cltd
idiv   %esi
mov    %eax,%edx
mov    -0x7c(%rbp),%eax
sub    %edx,%ecx
cmp    %ecx,%eax
jle    163c <display_menu+0x3cc>
mov    -0x38(%rbp),%rdi
mov    -0x60(%rbp),%esi
mov    $0x1,%edx
lea    0x9d9(%rip),%rcx
call   1190 <mvwaddstr@plt>
mov    -0x60(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x60(%rbp)
jmp    15f3 <display_menu+0x383>
jmp    1641 <display_menu+0x3d1>
jmp    1646 <display_menu+0x3d6>
mov    -0x28(%rbp),%rdi
mov    0x2967(%rip),%rax
mov    (%rax),%esi
call   1060 <menu_driver@plt>
jmp    1808 <display_menu+0x598>
mov    -0x5c(%rbp),%eax
mov    0x2979(%rip),%rcx
cmp    (%rcx),%eax
jne    1773 <display_menu+0x503>
cmpl   $0x0,-0x54(%rbp)
je     175c <display_menu+0x4ec>
cmpl   $0x0,-0x50(%rbp)
je     175c <display_menu+0x4ec>
mov    -0x50(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x50(%rbp)
mov    -0x50(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    -0x4c(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    16f4 <display_menu+0x484>
mov    -0x4c(%rbp),%eax
mov    %eax,-0x60(%rbp)
mov    -0x60(%rbp),%eax
mov    %eax,-0x80(%rbp)
mov    -0x4c(%rbp),%ecx
mov    -0x4c(%rbp),%eax
mov    $0x2,%esi
cltd
idiv   %esi
mov    %eax,%edx
mov    -0x80(%rbp),%eax
sub    %edx,%ecx
cmp    %ecx,%eax
jle    16ef <display_menu+0x47f>
mov    -0x38(%rbp),%rdi
mov    -0x60(%rbp),%esi
mov    $0x1,%edx
lea    0x928(%rip),%rcx
call   1190 <mvwaddstr@plt>
mov    -0x60(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x60(%rbp)
jmp    16a6 <display_menu+0x436>
jmp    16f4 <display_menu+0x484>
cmpl   $0x0,-0x50(%rbp)
jne    1757 <display_menu+0x4e7>
movl   $0x0,-0x60(%rbp)
mov    -0x60(%rbp),%eax
mov    %eax,-0x84(%rbp)
mov    -0x4c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x84(%rbp),%eax
cmp    %ecx,%eax
jge    1752 <display_menu+0x4e2>
mov    -0x38(%rbp),%rdi
mov    -0x60(%rbp),%esi
add    $0x1,%esi
mov    $0x1,%edx
lea    0x8c3(%rip),%rcx
call   1190 <mvwaddstr@plt>
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    1705 <display_menu+0x495>
jmp    1757 <display_menu+0x4e7>
jmp    175c <display_menu+0x4ec>
mov    -0x28(%rbp),%rdi
mov    0x2861(%rip),%rax
mov    (%rax),%esi
call   1060 <menu_driver@plt>
jmp    1803 <display_menu+0x593>
mov    -0x5c(%rbp),%eax
mov    %eax,-0x88(%rbp)
mov    $0x3,%edi
call   10c0 <KEY_F@plt>
mov    %eax,%ecx
mov    -0x88(%rbp),%eax
cmp    %ecx,%eax
je     17aa <display_menu+0x53a>
cmpl   $0x65,-0x5c(%rbp)
je     17aa <display_menu+0x53a>
cmpl   $0x45,-0x5c(%rbp)
jne    17b6 <display_menu+0x546>
movl   $0x8000,-0x64(%rbp)
jmp    1812 <display_menu+0x5a2>
mov    -0x5c(%rbp),%eax
mov    %eax,-0x8c(%rbp)
mov    $0xc,%edi
call   10c0 <KEY_F@plt>
mov    %eax,%ecx
mov    -0x8c(%rbp),%eax
cmp    %ecx,%eax
je     17ed <display_menu+0x57d>
cmpl   $0x71,-0x5c(%rbp)
je     17ed <display_menu+0x57d>
cmpl   $0x51,-0x5c(%rbp)
jne    17f9 <display_menu+0x589>
movl   $0x4000,-0x64(%rbp)
jmp    1812 <display_menu+0x5a2>
jmp    17fe <display_menu+0x58e>
jmp    1803 <display_menu+0x593>
jmp    1808 <display_menu+0x598>
jmp    180d <display_menu+0x59d>
jmp    14bb <display_menu+0x24b>
mov    -0x28(%rbp),%rdi
call   1050 <unpost_menu@plt>
mov    -0x28(%rbp),%rdi
call   10b0 <free_menu@plt>
mov    -0x40(%rbp),%rdi
call   1140 <wclear@plt>
mov    -0x40(%rbp),%rdi
call   1090 <wrefresh@plt>
mov    -0x40(%rbp),%rdi
call   1100 <delwin@plt>
mov    -0x30(%rbp),%rdi
call   1140 <wclear@plt>
mov    -0x30(%rbp),%rdi
call   1090 <wrefresh@plt>
mov    -0x30(%rbp),%rdi
call   1100 <delwin@plt>
cmpl   $0x0,-0x54(%rbp)
je     187f <display_menu+0x60f>
mov    -0x38(%rbp),%rdi
call   1140 <wclear@plt>
mov    -0x38(%rbp),%rdi
call   1090 <wrefresh@plt>
mov    -0x38(%rbp),%rdi
call   1100 <delwin@plt>
mov    -0x64(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display_menu>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rcx,0x18(%rsp)
mov    %esi,%r14d
mov    %rdi,%rbx
mov    0x2d68(%rip),%rax
mov    (%rax),%edi
call   10d0 <getmaxyx@plt>
mov    %rbx,0x10(%rsp)
mov    %rbx,%rdi
call   1110 <new_menu@plt>
mov    %rax,%r13
lea    0xc(%rsp),%rbp
lea    0x8(%rsp),%rbx
mov    %rax,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
call   1160 <scale_menu@plt>
lea    0xd5a(%rip),%rsi
mov    %r13,%rdi
call   10e0 <set_menu_mark@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
call   1160 <scale_menu@plt>
mov    0xc(%rsp),%edi
add    $0x2,%edi
mov    0x8(%rsp),%esi
add    $0x2,%esi
lea    -0x1(%r14),%edx
mov    $0x36,%ecx
call   10a0 <newwin@plt>
mov    %rax,%rbp
mov    0xc(%rsp),%edi
mov    0x8(%rsp),%esi
mov    %r14d,%edx
mov    $0x37,%ecx
call   10a0 <newwin@plt>
mov    %rax,%rbx
mov    %r13,%rdi
mov    %rax,%rsi
call   1030 <set_menu_win@plt>
mov    %r13,%rdi
call   1080 <post_menu@plt>
mov    0x2ca3(%rip),%rax
mov    (%rax),%esi
mov    0x2caa(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
call   10f0 <box@plt>
mov    %rbp,0x20(%rsp)
mov    %rbp,%rdi
call   1120 <wnoutrefresh@plt>
mov    %rbx,%rdi
call   1120 <wnoutrefresh@plt>
xor    %eax,%eax
call   1170 <doupdate@plt>
xor    %eax,%eax
call   1130 <getch@plt>
cmp    $0xa,%eax
je     1417 <display_menu+0x1c7>
mov    %eax,%ebp
mov    0x2c4b(%rip),%rax
cmp    (%rax),%ebp
je     1417 <display_menu+0x1c7>
mov    0x2c54(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r12,%rax
cmp    $0x9,%ebp
je     1398 <display_menu+0x148>
mov    %r12,%rax
mov    0x2c66(%rip),%rcx
cmp    (%rcx),%ebp
je     1398 <display_menu+0x148>
mov    0x2c3b(%rip),%rax
mov    0x2c4c(%rip),%rcx
cmp    (%rcx),%ebp
jne    13b0 <display_menu+0x160>
mov    (%rax),%esi
mov    %r13,%rdi
call   1060 <menu_driver@plt>
jmp    13eb <display_menu+0x19b>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x3,%edi
call   10c0 <KEY_F@plt>
mov    %ebp,%r15d
and    $0xffffffdf,%r15d
mov    $0x8000,%r14d
cmp    $0x45,%r15d
je     1442 <display_menu+0x1f2>
cmp    %eax,%ebp
je     1442 <display_menu+0x1f2>
mov    $0xc,%edi
call   10c0 <KEY_F@plt>
mov    $0x4000,%r14d
cmp    $0x51,%r15d
je     1442 <display_menu+0x1f2>
cmp    %eax,%ebp
je     1442 <display_menu+0x1f2>
mov    %rbx,%rdi
call   1120 <wnoutrefresh@plt>
xor    %eax,%eax
call   1170 <doupdate@plt>
xor    %eax,%eax
call   1130 <getch@plt>
cmp    $0xa,%eax
je     1417 <display_menu+0x1c7>
mov    %eax,%ebp
mov    0x2b91(%rip),%rax
cmp    (%rax),%ebp
jne    1370 <display_menu+0x120>
mov    %r13,%rdi
call   1040 <current_item@plt>
mov    %rax,%rdi
call   1070 <item_index@plt>
cltq
mov    0x10(%rsp),%rcx
mov    (%rcx,%rax,8),%rdi
call   1150 <item_userptr@plt>
mov    0x18(%rsp),%rcx
mov    %rax,(%rcx)
xor    %r14d,%r14d
mov    %r13,%rdi
call   1050 <unpost_menu@plt>
mov    %r13,%rdi
call   10b0 <free_menu@plt>
mov    %rbx,%rdi
call   1140 <wclear@plt>
mov    %rbx,%rdi
call   1090 <wrefresh@plt>
mov    %rbx,%rdi
call   1100 <delwin@plt>
mov    0x20(%rsp),%rbx
mov    %rbx,%rdi
call   1140 <wclear@plt>
mov    %rbx,%rdi
call   1090 <wrefresh@plt>
mov    %rbx,%rdi
call   1100 <delwin@plt>
mov    %r14d,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdscr = global i32 0
@.str = [2 x i8] c"*\00"
@ACS_VLINE = global i32 0
@ACS_HLINE = global i32 0
@.str.1 = [2 x i8] c"#\00"
@.str.2 = [2 x i8] c"v\00"
@KEY_ENTER = global i32 0
@KEY_DOWN = global i32 0
@.str.3 = [2 x i8] c"^\00"
@REQ_DOWN_ITEM = global i32 0
@KEY_UP = global i32 0
@REQ_UP_ITEM = global i32 0
define i32 @display_menu(i32** %0, i32 %1, i32 %2, i32** %3) {
%5 = alloca i32**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32**
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
store i32** %0, i32*** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32** %3, i32*** %8
store i32 0, i32* %18
store i32 0, i32* %22
%25 = load i32, i32* @stdscr
%26 = load i32, i32* %23
%27 = load i32, i32* %24
%28 = call i32 @getmaxyx(i32 %25, i32 %26, i32 %27)
%29 = load i32**, i32*** %5
%30 = call i32* @new_menu(i32** %29)
store i32* %30, i32** %10
%31 = load i32*, i32** %10
%32 = call i32 @scale_menu(i32* %31, i32* %14, i32* %15)
%33 = load i32, i32* %14
store i32 %33, i32* %16
%34 = load i32, i32* %6
%35 = load i32, i32* %14
%36 = add nsw i32 %34, %35
%37 = add nsw i32 %36, 1
%38 = add nsw i32 %37, 1
%39 = load i32, i32* %23
%40 = icmp sgt i32 %38, %39
br i1 %40, label %41, label %53
41: ; preds = %4
%42 = load i32, i32* %23
%43 = load i32, i32* %14
%44 = add nsw i32 %43, 1
%45 = add nsw i32 %44, 1
%46 = sub nsw i32 %42, %45
store i32 %46, i32* %6
%47 = load i32, i32* %6
%48 = icmp slt i32 %47, 9
br i1 %48, label %49, label %52
49: ; preds = %41
%50 = load i32, i32* %23
%51 = sub nsw i32 %50, 11
store i32 %51, i32* %16
store i32 9, i32* %6
br label %52
52: ; preds = %49, %41
br label %53
53: ; preds = %52, %4
%54 = load i32, i32* %14
%55 = load i32, i32* %16
%56 = icmp sgt i32 %54, %55
br i1 %56, label %57, label %61
57: ; preds = %53
%58 = load i32*, i32** %10
%59 = load i32, i32* %16
%60 = call i32 @set_menu_format(i32* %58, i32 %59, i32 1)
store i32 1, i32* %18
br label %61
61: ; preds = %57, %53
%62 = load i32*, i32** %10
%63 = call i32 @set_menu_mark(i32* %62, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%64 = load i32*, i32** %10
%65 = call i32 @scale_menu(i32* %64, i32* %14, i32* %15)
%66 = load i32, i32* %14
%67 = add nsw i32 %66, 2
%68 = load i32, i32* %15
%69 = add nsw i32 %68, 2
%70 = load i32, i32* %6
%71 = sub nsw i32 %70, 1
%72 = call i32* @newwin(i32 %67, i32 %69, i32 %71, i32 54)
store i32* %72, i32** %11
%73 = load i32, i32* %14
%74 = load i32, i32* %15
%75 = load i32, i32* %6
%76 = call i32* @newwin(i32 %73, i32 %74, i32 %75, i32 55)
store i32* %76, i32** %13
%77 = load i32*, i32** %10
%78 = load i32*, i32** %13
%79 = call i32 @set_menu_win(i32* %77, i32* %78)
%80 = load i32*, i32** %10
%81 = call i32 @post_menu(i32* %80)
%82 = load i32*, i32** %11
%83 = load i32, i32* @ACS_VLINE
%84 = load i32, i32* @ACS_HLINE
%85 = call i32 @box(i32* %82, i32 %83, i32 %84)
%86 = load i32, i32* %18
%87 = icmp ne i32 %86, 0
br i1 %87, label %88, label %131
88: ; preds = %61
%89 = load i32, i32* %14
%90 = add nsw i32 %89, 2
%91 = load i32, i32* %6
%92 = sub nsw i32 %91, 1
%93 = load i32, i32* %15
%94 = add nsw i32 54, %93
%95 = add nsw i32 %94, 1
%96 = call i32* @newwin(i32 %90, i32 3, i32 %92, i32 %95)
store i32* %96, i32** %12
%97 = load i32*, i32** %12
%98 = load i32, i32* @ACS_VLINE
%99 = load i32, i32* @ACS_HLINE
%100 = call i32 @box(i32* %97, i32 %98, i32 %99)
store i32 0, i32* %21
br label %101
101: ; preds = %111, %88
%102 = load i32, i32* %21
%103 = load i32, i32* %16
%104 = sdiv i32 %103, 2
%105 = icmp slt i32 %102, %104
br i1 %105, label %106, label %114
106: ; preds = %101
%107 = load i32*, i32** %12
%108 = load i32, i32* %21
%109 = add nsw i32 %108, 1
%110 = call i32 @mvwaddstr(i32* %107, i32 %109, i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %111
111: ; preds = %106
%112 = load i32, i32* %21
%113 = add nsw i32 %112, 1
store i32 %113, i32* %21
br label %101
114: ; preds = %101
%115 = load i32, i32* %16
store i32 %115, i32* %21
br label %116
116: ; preds = %127, %114
%117 = load i32, i32* %21
%118 = load i32, i32* %16
%119 = load i32, i32* %16
%120 = sdiv i32 %119, 2
%121 = sub nsw i32 %118, %120
%122 = icmp sgt i32 %117, %121
br i1 %122, label %123, label %130
123: ; preds = %116
%124 = load i32*, i32** %12
%125 = load i32, i32* %21
%126 = call i32 @mvwaddstr(i32* %124, i32 %125, i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %127
127: ; preds = %123
%128 = load i32, i32* %21
%129 = add nsw i32 %128, -1
store i32 %129, i32* %21
br label %116
130: ; preds = %116
br label %131
131: ; preds = %130, %61
%132 = load i32*, i32** %11
%133 = call i32 @wnoutrefresh(i32* %132)
store i32 0, i32* %17
br label %134
134: ; preds = %131, %311
%135 = load i32, i32* %18
%136 = icmp ne i32 %135, 0
br i1 %136, label %137, label %140
137: ; preds = %134
%138 = load i32*, i32** %12
%139 = call i32 @wnoutrefresh(i32* %138)
br label %140
140: ; preds = %137, %134
%141 = load i32*, i32** %13
%142 = call i32 @wnoutrefresh(i32* %141)
%143 = call i32 (...) @doupdate()
%144 = call i32 (...) @getch()
store i32 %144, i32* %20
%145 = load i32, i32* %20
%146 = load i32, i32* @KEY_ENTER
%147 = icmp eq i32 %145, %146
br i1 %147, label %151, label %148
148: ; preds = %140
%149 = load i32, i32* %20
%150 = icmp eq i32 %149, 10
br i1 %150, label %151, label %163
151: ; preds = %148, %140
%152 = load i32*, i32** %10
%153 = call i32* @current_item(i32* %152)
store i32* %153, i32** %9
%154 = load i32*, i32** %9
%155 = call i32 @item_index(i32* %154)
store i32 %155, i32* %19
%156 = load i32**, i32*** %5
%157 = load i32, i32* %19
%158 = sext i32 %157 to i64
%159 = getelementptr inbounds i32*, i32** %156, i64 %158
%160 = load i32*, i32** %159
%161 = call i32* @item_userptr(i32* %160)
%162 = load i32**, i32*** %8
store i32* %161, i32** %162
br label %312
163: ; preds = %148
%164 = load i32, i32* %20
%165 = load i32, i32* @KEY_DOWN
%166 = icmp eq i32 %164, %165
br i1 %166, label %170, label %167
167: ; preds = %163
%168 = load i32, i32* %20
%169 = icmp eq i32 %168, 9
br i1 %169, label %170, label %226
170: ; preds = %167, %163
%171 = load i32, i32* %18
%172 = icmp ne i32 %171, 0
br i1 %172, label %173, label %222
173: ; preds = %170
%174 = load i32, i32* %17
%175 = load i32, i32* %7
%176 = sub nsw i32 %175, 1
%177 = icmp slt i32 %174, %176
br i1 %177, label %178, label %222
178: ; preds = %173
%179 = load i32, i32* %17
%180 = add nsw i32 %179, 1
store i32 %180, i32* %17
%181 = load i32, i32* %17
%182 = load i32, i32* %16
%183 = icmp eq i32 %181, %182
br i1 %183, label %184, label %199
184: ; preds = %178
store i32 0, i32* %21
br label %185
185: ; preds = %195, %184
%186 = load i32, i32* %21
%187 = load i32, i32* %16
%188 = sdiv i32 %187, 2
%189 = icmp slt i32 %186, %188
br i1 %189, label %190, label %198
190: ; preds = %185
%191 = load i32*, i32** %12
%192 = load i32, i32* %21
%193 = add nsw i32 %192, 1
%194 = call i32 @mvwaddstr(i32* %191, i32 %193, i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %195
195: ; preds = %190
%196 = load i32, i32* %21
%197 = add nsw i32 %196, 1
store i32 %197, i32* %21
br label %185
198: ; preds = %185
br label %199
199: ; preds = %198, %178
%200 = load i32, i32* %17
%201 = load i32, i32* %7
%202 = sub nsw i32 %201, 1
%203 = icmp eq i32 %200, %202
br i1 %203, label %204, label %221
204: ; preds = %199
%205 = load i32, i32* %16
store i32 %205, i32* %21
br label %206
206: ; preds = %217, %204
%207 = load i32, i32* %21
%208 = load i32, i32* %16
%209 = load i32, i32* %16
%210 = sdiv i32 %209, 2
%211 = sub nsw i32 %208, %210
%212 = icmp sgt i32 %207, %211
br i1 %212, label %213, label %220
213: ; preds = %206
%214 = load i32*, i32** %12
%215 = load i32, i32* %21
%216 = call i32 @mvwaddstr(i32* %214, i32 %215, i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %217
217: ; preds = %213
%218 = load i32, i32* %21
%219 = add nsw i32 %218, -1
store i32 %219, i32* %21
br label %206
220: ; preds = %206
br label %221
221: ; preds = %220, %199
br label %222
222: ; preds = %221, %173, %170
%223 = load i32*, i32** %10
%224 = load i32, i32* @REQ_DOWN_ITEM
%225 = call i32 @menu_driver(i32* %223, i32 %224)
br label %310
226: ; preds = %167
%227 = load i32, i32* %20
%228 = load i32, i32* @KEY_UP
%229 = icmp eq i32 %227, %228
br i1 %229, label %230, label %285
230: ; preds = %226
%231 = load i32, i32* %18
%232 = icmp ne i32 %231, 0
br i1 %232, label %233, label %281
233: ; preds = %230
%234 = load i32, i32* %17
%235 = icmp ne i32 %234, 0
br i1 %235, label %236, label %281
236: ; preds = %233
%237 = load i32, i32* %17
%238 = add nsw i32 %237, -1
store i32 %238, i32* %17
%239 = load i32, i32* %17
%240 = load i32, i32* %7
%241 = load i32, i32* %16
%242 = sub nsw i32 %240, %241
%243 = sub nsw i32 %242, 1
%244 = icmp eq i32 %239, %243
br i1 %244, label %245, label %262
245: ; preds = %236
%246 = load i32, i32* %16
store i32 %246, i32* %21
br label %247
247: ; preds = %258, %245
%248 = load i32, i32* %21
%249 = load i32, i32* %16
%250 = load i32, i32* %16
%251 = sdiv i32 %250, 2
%252 = sub nsw i32 %249, %251
%253 = icmp sgt i32 %248, %252
br i1 %253, label %254, label %261
254: ; preds = %247
%255 = load i32*, i32** %12
%256 = load i32, i32* %21
%257 = call i32 @mvwaddstr(i32* %255, i32 %256, i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %258
258: ; preds = %254
%259 = load i32, i32* %21
%260 = add nsw i32 %259, -1
store i32 %260, i32* %21
br label %247
261: ; preds = %247
br label %262
262: ; preds = %261, %236
%263 = load i32, i32* %17
%264 = icmp eq i32 %263, 0
br i1 %264, label %265, label %280
265: ; preds = %262
store i32 0, i32* %21
br label %266
266: ; preds = %276, %265
%267 = load i32, i32* %21
%268 = load i32, i32* %16
%269 = sdiv i32 %268, 2
%270 = icmp slt i32 %267, %269
br i1 %270, label %271, label %279
271: ; preds = %266
%272 = load i32*, i32** %12
%273 = load i32, i32* %21
%274 = add nsw i32 %273, 1
%275 = call i32 @mvwaddstr(i32* %272, i32 %274, i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %276
276: ; preds = %271
%277 = load i32, i32* %21
%278 = add nsw i32 %277, 1
store i32 %278, i32* %21
br label %266
279: ; preds = %266
br label %280
280: ; preds = %279, %262
br label %281
281: ; preds = %280, %233, %230
%282 = load i32*, i32** %10
%283 = load i32, i32* @REQ_UP_ITEM
%284 = call i32 @menu_driver(i32* %282, i32 %283)
br label %309
285: ; preds = %226
%286 = load i32, i32* %20
%287 = call i32 @KEY_F(i32 3)
%288 = icmp eq i32 %286, %287
br i1 %288, label %295, label %289
289: ; preds = %285
%290 = load i32, i32* %20
%291 = icmp eq i32 %290, 101
br i1 %291, label %295, label %292
292: ; preds = %289
%293 = load i32, i32* %20
%294 = icmp eq i32 %293, 69
br i1 %294, label %295, label %296
295: ; preds = %292, %289, %285
store i32 32768, i32* %22
br label %312
296: ; preds = %292
%297 = load i32, i32* %20
%298 = call i32 @KEY_F(i32 12)
%299 = icmp eq i32 %297, %298
br i1 %299, label %306, label %300
300: ; preds = %296
%301 = load i32, i32* %20
%302 = icmp eq i32 %301, 113
br i1 %302, label %306, label %303
303: ; preds = %300
%304 = load i32, i32* %20
%305 = icmp eq i32 %304, 81
br i1 %305, label %306, label %307
306: ; preds = %303, %300, %296
store i32 16384, i32* %22
br label %312
307: ; preds = %303
br label %308
308: ; preds = %307
br label %309
309: ; preds = %308, %281
br label %310
310: ; preds = %309, %222
br label %311
311: ; preds = %310
br label %134
312: ; preds = %306, %295, %151
%313 = load i32*, i32** %10
%314 = call i32 @unpost_menu(i32* %313)
%315 = load i32*, i32** %10
%316 = call i32 @free_menu(i32* %315)
%317 = load i32*, i32** %13
%318 = call i32 @wclear(i32* %317)
%319 = load i32*, i32** %13
%320 = call i32 @wrefresh(i32* %319)
%321 = load i32*, i32** %13
%322 = call i32 @delwin(i32* %321)
%323 = load i32*, i32** %11
%324 = call i32 @wclear(i32* %323)
%325 = load i32*, i32** %11
%326 = call i32 @wrefresh(i32* %325)
%327 = load i32*, i32** %11
%328 = call i32 @delwin(i32* %327)
%329 = load i32, i32* %18
%330 = icmp ne i32 %329, 0
br i1 %330, label %331, label %338
331: ; preds = %312
%332 = load i32*, i32** %12
%333 = call i32 @wclear(i32* %332)
%334 = load i32*, i32** %12
%335 = call i32 @wrefresh(i32* %334)
%336 = load i32*, i32** %12
%337 = call i32 @delwin(i32* %336)
br label %338
338: ; preds = %331, %312
%339 = load i32, i32* %22
ret i32 %339
}

LLVM IR (-O2):
@stdscr = global i32 0
@.str = [2 x i8] c"*\00"
@ACS_VLINE = global i32 0
@ACS_HLINE = global i32 0
@KEY_ENTER = global i32 0
@KEY_DOWN = global i32 0
@REQ_DOWN_ITEM = global i32 0
@KEY_UP = global i32 0
@REQ_UP_ITEM = global i32 0
define i32 @display_menu(i32** %0, i32 %1, i32 %2, i32** nocapture writeonly %3) {
%5 = alloca i32
%6 = alloca i32
%7 = bitcast i32* %5 to i8*
%8 = bitcast i32* %6 to i8*
%9 = load i32, i32* @stdscr
%10 = tail call i32 @getmaxyx(i32 %9, i32 undef, i32 undef)
%11 = tail call i32* @new_menu(i32** %0)
%12 = call i32 @scale_menu(i32* %11, i32* %5, i32* %6)
%13 = call i32 @set_menu_mark(i32* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @scale_menu(i32* %11, i32* %5, i32* %6)
%15 = load i32, i32* %5
%16 = add nsw i32 %15, 2
%17 = load i32, i32* %6
%18 = add nsw i32 %17, 2
%19 = add nsw i32 %1, -1
%20 = call i32* @newwin(i32 %16, i32 %18, i32 %19, i32 54)
%21 = load i32, i32* %5
%22 = load i32, i32* %6
%23 = call i32* @newwin(i32 %21, i32 %22, i32 %1, i32 55)
%24 = call i32 @set_menu_win(i32* %11, i32* %23)
%25 = call i32 @post_menu(i32* %11)
%26 = load i32, i32* @ACS_VLINE
%27 = load i32, i32* @ACS_HLINE
%28 = call i32 @box(i32* %20, i32 %26, i32 %27)
%29 = call i32 @wnoutrefresh(i32* %20)
%30 = call i32 @wnoutrefresh(i32* %23)
%31 = call i32 (...) @doupdate()
%32 = call i32 (...) @getch()
%33 = load i32, i32* @KEY_ENTER
%34 = icmp eq i32 %32, %33
%35 = icmp eq i32 %32, 10
%36 = or i1 %35, %34
br i1 %36, label %37, label %44
37: ; preds = %68, %4
%38 = call i32* @current_item(i32* %11)
%39 = call i32 @item_index(i32* %38)
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i32*, i32** %0, i64 %40
%42 = load i32*, i32** %41
%43 = call i32* @item_userptr(i32* %42)
store i32* %43, i32** %3
br label %76
44: ; preds = %4, %68
%45 = phi i32 [ %71, %68 ], [ %32, %4 ]
%46 = load i32, i32* @KEY_DOWN
%47 = icmp eq i32 %45, %46
%48 = icmp eq i32 %45, 9
%49 = or i1 %48, %47
br i1 %49, label %64, label %50
50: ; preds = %44
%51 = load i32, i32* @KEY_UP
%52 = icmp eq i32 %45, %51
br i1 %52, label %64, label %53
53: ; preds = %50
%54 = call i32 @KEY_F(i32 3)
%55 = icmp eq i32 %45, %54
%56 = and i32 %45, -33
%57 = icmp eq i32 %56, 69
%58 = or i1 %57, %55
br i1 %58, label %76, label %59
59: ; preds = %53
%60 = call i32 @KEY_F(i32 12)
%61 = icmp eq i32 %45, %60
%62 = icmp eq i32 %56, 81
%63 = or i1 %62, %61
br i1 %63, label %76, label %68
64: ; preds = %50, %44
%65 = phi i32* [ @REQ_DOWN_ITEM, %44 ], [ @REQ_UP_ITEM, %50 ]
%66 = load i32, i32* %65
%67 = call i32 @menu_driver(i32* %11, i32 %66)
br label %68
68: ; preds = %64, %59
%69 = call i32 @wnoutrefresh(i32* %23)
%70 = call i32 (...) @doupdate()
%71 = call i32 (...) @getch()
%72 = load i32, i32* @KEY_ENTER
%73 = icmp eq i32 %71, %72
%74 = icmp eq i32 %71, 10
%75 = or i1 %74, %73
br i1 %75, label %37, label %44
76: ; preds = %53, %59, %37
%77 = phi i32 [ 0, %37 ], [ 16384, %59 ], [ 32768, %53 ]
%78 = call i32 @unpost_menu(i32* %11)
%79 = call i32 @free_menu(i32* %11)
%80 = call i32 @wclear(i32* %23)
%81 = call i32 @wrefresh(i32* %23)
%82 = call i32 @delwin(i32* %23)
%83 = call i32 @wclear(i32* %20)
%84 = call i32 @wrefresh(i32* %20)
%85 = call i32 @delwin(i32* %20)
ret i32 %77
}