#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_LTEE;
int /*<<< orphan*/ ACS_RTEE;
int /*<<< orphan*/ COLOR_BLACK;
int /*<<< orphan*/ COLOR_MAGENTA;
int /*<<< orphan*/ COLOR_PAIR(int);
int COLS;
#define KEY_DOWN 130
#define KEY_LEFT 129
#define KEY_UP 128
int LINES;
int /*<<< orphan*/ REQ_DOWN_ITEM;
int /*<<< orphan*/ REQ_UP_ITEM;
int /*<<< orphan*/ TRUE;
int /*<<< orphan*/ box(int /*<<< orphan*/ *, int /*<<< orphan*/,
                       int /*<<< orphan*/);
scalar_t__ calloc(int, int);
int /*<<< orphan*/ cbreak();
int /*<<< orphan*/ curs_set(int /*<<< orphan*/);
int /*<<< orphan*/ derwin(int /*<<< orphan*/ *, int, int, int, int);
int /*<<< orphan*/ free_item(int /*<<< orphan*/ *);
int /*<<< orphan*/ free_menu(int /*<<< orphan*/ *);
int get_max_elem(char **, int);
int /*<<< orphan*/ init_pair(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ keypad(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ menu_driver(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ mvprintw(int, int, char *);
int /*<<< orphan*/ mvwaddch(int /*<<< orphan*/ *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ mvwhline(int /*<<< orphan*/ *, int, int, int /*<<< orphan*/,
                            int);
int /*<<< orphan*/ mvwprintw(int /*<<< orphan*/, int, int, char *, int);
int /*<<< orphan*/ *new_item(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ *new_menu(int /*<<< orphan*/ **);
int /*<<< orphan*/ *newwin(int, int, int, int);
int /*<<< orphan*/ noecho();
int /*<<< orphan*/ post_menu(int /*<<< orphan*/ *);
int /*<<< orphan*/ print_in_middle(int /*<<< orphan*/ *, int,
                                   int /*<<< orphan*/, int, char *,
                                   int /*<<< orphan*/);
int /*<<< orphan*/ refresh();
int /*<<< orphan*/ set_menu_mark(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ set_menu_sub(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ set_menu_win(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ stdscr;
int /*<<< orphan*/ unpost_menu(int /*<<< orphan*/ *);
int /*<<< orphan*/ wclear(int /*<<< orphan*/ *);
int wgetch(int /*<<< orphan*/ *);
int /*<<< orphan*/ wrefresh(int /*<<< orphan*/ *);
int get_choice(char *choices[], int choices_count, char *title) {
  ITEM **my_items;
  MENU *my_menu;
  WINDOW *my_menu_win;
  int c;
  int n_choices, i, width;
  int ch = 1;
  cbreak();
  noecho();
  curs_set(0);
  init_pair(1, COLOR_MAGENTA, COLOR_BLACK);
  n_choices = choices_count;
  width = get_max_elem(choices, n_choices);
  my_items = (ITEM **)calloc(n_choices, sizeof(ITEM *));
  for (i = 0; i < n_choices; ++i)
    my_items[i] = new_item(choices[i], NULL);
  my_menu = new_menu((ITEM **)my_items);
  my_menu_win = newwin(n_choices + 4, width + 4, 10, (COLS - width) / 2);
  keypad(my_menu_win, TRUE);
  set_menu_win(my_menu, my_menu_win);
  set_menu_sub(my_menu, derwin(my_menu_win, n_choices, width, 3, 2));
  set_menu_mark(my_menu, NULL);
  box(my_menu_win, 0, 0);
  print_in_middle(my_menu_win, 1, 0, width + 4, title, COLOR_PAIR(1));
  mvwaddch(my_menu_win, 2, 0, ACS_LTEE);
  mvwhline(my_menu_win, 2, 1, ACS_HLINE, width + 2);
  mvwaddch(my_menu_win, 2, width + 3, ACS_RTEE);
  mvprintw(LINES - 2, 3, "press ENTER for choice action");
  refresh();
  post_menu(my_menu);
  wrefresh(my_menu_win);
  while ((c = wgetch(my_menu_win)) != 10) {
    switch (c) {
    case KEY_DOWN:
      if (ch < choices_count) {
        menu_driver(my_menu, REQ_DOWN_ITEM);
        mvprintw(3, 10, "                            ");
        ++ch;
      }
      break;
    case KEY_UP:
      if (ch > 1) {
        menu_driver(my_menu, REQ_UP_ITEM);
        mvprintw(3, 10, "                            ");
        --ch;
      }
      break;
    case KEY_LEFT:
      mvwprintw(stdscr, 3, 10, "select = %d", ch);
      refresh();
      break;
    }
    wrefresh(my_menu_win);
  }
  unpost_menu(my_menu);
  free_menu(my_menu);
  for (i = 0; i < n_choices; ++i)
    free_item(my_items[i]);
  wclear(my_menu_win);
  refresh();
  return ch;
}


x86 assembly (clang, -O0):
<get_choice>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x1,-0x44(%rbp)
mov    $0x0,%al
call   1050 <cbreak@plt>
mov    $0x0,%al
call   11b0 <noecho@plt>
xor    %edi,%edi
call   11e0 <curs_set@plt>
mov    0x2c9a(%rip),%rax
mov    (%rax),%esi
mov    0x2ca9(%rip),%rax
mov    (%rax),%edx
mov    $0x1,%edi
call   1090 <init_pair@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x38(%rbp),%esi
call   1040 <get_max_elem@plt>
mov    %eax,-0x40(%rbp)
mov    -0x38(%rbp),%edi
mov    $0x8,%esi
call   1100 <calloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x38(%rbp),%eax
jge    1396 <get_choice+0xb6>
mov    -0x8(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1150 <new_item@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1358 <get_choice+0x78>
mov    -0x20(%rbp),%rdi
call   1130 <new_menu@plt>
mov    %rax,-0x28(%rbp)
mov    -0x38(%rbp),%edi
add    $0x4,%edi
mov    -0x40(%rbp),%esi
add    $0x4,%esi
mov    0x2c0a(%rip),%rax
mov    (%rax),%eax
sub    -0x40(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    $0xa,%edx
call   10c0 <newwin@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    0x2bf2(%rip),%rax
mov    (%rax),%esi
call   10b0 <keypad@plt>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1030 <set_menu_win@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%esi
mov    -0x40(%rbp),%edx
mov    $0x3,%ecx
mov    $0x2,%r8d
call   1200 <derwin@plt>
mov    -0x68(%rbp),%rdi
mov    %eax,%esi
call   10f0 <set_menu_sub@plt>
mov    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1110 <set_menu_mark@plt>
mov    -0x30(%rbp),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   1120 <box@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x40(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x54(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    $0x1,%edi
call   1140 <COLOR_PAIR@plt>
mov    -0x60(%rbp),%rdi
mov    -0x54(%rbp),%ecx
mov    -0x50(%rbp),%r8
mov    %eax,%r9d
mov    $0x1,%esi
xor    %edx,%edx
call   11d0 <print_in_middle@plt>
mov    -0x30(%rbp),%rdi
mov    0x2b67(%rip),%rax
mov    (%rax),%ecx
mov    $0x2,%esi
xor    %edx,%edx
call   11c0 <mvwaddch@plt>
mov    -0x30(%rbp),%rdi
mov    0x2b06(%rip),%rax
mov    (%rax),%ecx
mov    -0x40(%rbp),%r8d
add    $0x2,%r8d
mov    $0x2,%esi
mov    $0x1,%edx
call   1160 <mvwhline@plt>
mov    -0x30(%rbp),%rdi
mov    -0x40(%rbp),%edx
add    $0x3,%edx
mov    0x2acc(%rip),%rax
mov    (%rax),%ecx
mov    $0x2,%esi
call   11c0 <mvwaddch@plt>
mov    0x2b09(%rip),%rax
mov    (%rax),%edi
sub    $0x2,%edi
mov    $0x3,%esi
lea    0xb18(%rip),%rdx
call   11f0 <mvprintw@plt>
mov    $0x0,%al
call   1170 <refresh@plt>
mov    -0x28(%rbp),%rdi
call   1080 <post_menu@plt>
mov    -0x30(%rbp),%rdi
call   10a0 <wrefresh@plt>
mov    -0x30(%rbp),%rdi
call   1180 <wgetch@plt>
mov    %eax,-0x34(%rbp)
cmp    $0xa,%eax
je     1611 <get_choice+0x331>
mov    -0x34(%rbp),%eax
mov    %eax,-0x6c(%rbp)
sub    $0x80,%eax
je     1599 <get_choice+0x2b9>
jmp    1531 <get_choice+0x251>
mov    -0x6c(%rbp),%eax
sub    $0x81,%eax
je     15d9 <get_choice+0x2f9>
jmp    1544 <get_choice+0x264>
mov    -0x6c(%rbp),%eax
sub    $0x82,%eax
jne    1603 <get_choice+0x323>
jmp    1557 <get_choice+0x277>
mov    -0x44(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1594 <get_choice+0x2b4>
mov    -0x28(%rbp),%rdi
mov    0x2a2a(%rip),%rax
mov    (%rax),%esi
call   1070 <menu_driver@plt>
mov    $0x3,%edi
mov    $0xa,%esi
lea    0xa98(%rip),%rdx
call   11f0 <mvprintw@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1603 <get_choice+0x323>
cmpl   $0x1,-0x44(%rbp)
jle    15d4 <get_choice+0x2f4>
mov    -0x28(%rbp),%rdi
mov    0x29fa(%rip),%rax
mov    (%rax),%esi
call   1070 <menu_driver@plt>
mov    $0x3,%edi
mov    $0xa,%esi
lea    0xa58(%rip),%rdx
call   11f0 <mvprintw@plt>
mov    -0x44(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x44(%rbp)
jmp    1603 <get_choice+0x323>
mov    0x29f8(%rip),%rax
mov    (%rax),%edi
mov    -0x44(%rbp),%r8d
mov    $0x3,%esi
mov    $0xa,%edx
lea    0xa44(%rip),%rcx
call   11a0 <mvwprintw@plt>
mov    $0x0,%al
call   1170 <refresh@plt>
mov    -0x30(%rbp),%rdi
call   10a0 <wrefresh@plt>
jmp    1506 <get_choice+0x226>
mov    -0x28(%rbp),%rdi
call   1060 <unpost_menu@plt>
mov    -0x28(%rbp),%rdi
call   10e0 <free_menu@plt>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x38(%rbp),%eax
jge    1655 <get_choice+0x375>
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   10d0 <free_item@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    162a <get_choice+0x34a>
mov    -0x30(%rbp),%rdi
call   1190 <wclear@plt>
mov    $0x0,%al
call   1170 <refresh@plt>
mov    -0x44(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_choice>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,0x8(%rsp)
mov    %esi,%ebp
mov    %rdi,%r14
xor    %eax,%eax
call   1050 <cbreak@plt>
xor    %eax,%eax
call   11b0 <noecho@plt>
xor    %edi,%edi
call   11e0 <curs_set@plt>
mov    0x2c9c(%rip),%rax
mov    (%rax),%esi
mov    0x2cab(%rip),%rax
mov    (%rax),%edx
mov    $0x1,%r12d
mov    $0x1,%edi
call   1090 <init_pair@plt>
mov    %r14,%rdi
mov    %ebp,%esi
call   1040 <get_max_elem@plt>
mov    %rax,0x18(%rsp)
mov    %ebp,%edi
mov    $0x8,%esi
call   1100 <calloc@plt>
mov    %rax,%r15
mov    %ebp,%r13d
test   %ebp,%ebp
jle    1378 <get_choice+0x98>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    (%r14,%rbx,8),%rdi
xor    %esi,%esi
call   1150 <new_item@plt>
mov    %rax,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1360 <get_choice+0x80>
mov    %r13,0x20(%rsp)
mov    %r15,%rdi
call   1130 <new_menu@plt>
mov    %rax,%r14
lea    0x4(%rbp),%edi
mov    0x18(%rsp),%r13
lea    0x4(%r13),%esi
mov    %esi,0x14(%rsp)
mov    0x2c21(%rip),%rax
mov    (%rax),%eax
sub    %r13d,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
mov    $0xa,%edx
call   10c0 <newwin@plt>
mov    %rax,%rbx
mov    0x2c0f(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   10b0 <keypad@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <set_menu_win@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r13d,%edx
mov    $0x3,%ecx
mov    $0x2,%r8d
call   1200 <derwin@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   10f0 <set_menu_sub@plt>
mov    %r14,%rdi
xor    %esi,%esi
call   1110 <set_menu_mark@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1120 <box@plt>
mov    $0x1,%edi
call   1140 <COLOR_PAIR@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %edx,%edx
mov    0x14(%rsp),%ecx
mov    0x8(%rsp),%r8
mov    %eax,%r9d
call   11d0 <print_in_middle@plt>
mov    0x2bae(%rip),%rax
mov    (%rax),%ecx
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %edx,%edx
call   11c0 <mvwaddch@plt>
mov    0x2b4e(%rip),%rax
mov    (%rax),%ecx
lea    0x2(%r13),%r8d
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x1,%edx
call   1160 <mvwhline@plt>
add    $0x3,%r13d
mov    0x2b1b(%rip),%rax
mov    (%rax),%ecx
mov    %rbx,%rdi
mov    $0x2,%esi
mov    %r13d,%edx
call   11c0 <mvwaddch@plt>
mov    0x2b52(%rip),%rax
mov    (%rax),%edi
add    $0xfffffffe,%edi
lea    0xb66(%rip),%rdx
mov    $0x3,%esi
call   11f0 <mvprintw@plt>
xor    %eax,%eax
call   1170 <refresh@plt>
mov    %r14,0x8(%rsp)
mov    %r14,%rdi
call   1080 <post_menu@plt>
mov    0x2b19(%rip),%r14
lea    0xb75(%rip),%r13
jmp    14ef <get_choice+0x20f>
nopl   0x0(%rax,%rax,1)
mov    (%r14),%edi
mov    $0x3,%esi
mov    $0xa,%edx
mov    %r13,%rcx
mov    %r12d,%r8d
call   11a0 <mvwprintw@plt>
xor    %eax,%eax
call   1170 <refresh@plt>
mov    %rbx,%rdi
call   10a0 <wrefresh@plt>
mov    %rbx,%rdi
call   1180 <wgetch@plt>
cmp    $0x80,%eax
jle    1550 <get_choice+0x270>
cmp    $0x81,%eax
je     14d0 <get_choice+0x1f0>
cmp    $0x82,%eax
jne    14ef <get_choice+0x20f>
cmp    %ebp,%r12d
jge    14ef <get_choice+0x20f>
mov    0x2a78(%rip),%rax
mov    (%rax),%esi
mov    0x8(%rsp),%rdi
call   1070 <menu_driver@plt>
mov    $0x3,%edi
mov    $0xa,%esi
lea    0xae1(%rip),%rdx
call   11f0 <mvprintw@plt>
add    $0x1,%r12d
jmp    14ef <get_choice+0x20f>
nopl   0x0(%rax,%rax,1)
jne    158a <get_choice+0x2aa>
cmp    $0x2,%r12d
jl     14ef <get_choice+0x20f>
mov    0x2a49(%rip),%rax
mov    (%rax),%esi
mov    0x8(%rsp),%rdi
call   1070 <menu_driver@plt>
mov    $0x3,%edi
mov    $0xa,%esi
lea    0xaa2(%rip),%rdx
call   11f0 <mvprintw@plt>
add    $0xffffffff,%r12d
jmp    14ef <get_choice+0x20f>
cmp    $0xa,%eax
jne    14ef <get_choice+0x20f>
mov    0x8(%rsp),%r14
mov    %r14,%rdi
call   1060 <unpost_menu@plt>
mov    %r14,%rdi
call   10e0 <free_menu@plt>
test   %ebp,%ebp
mov    0x20(%rsp),%r14
jle    15d2 <get_choice+0x2f2>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r15,%rbp,8),%rdi
call   10d0 <free_item@plt>
add    $0x1,%rbp
cmp    %rbp,%r14
jne    15c0 <get_choice+0x2e0>
mov    %rbx,%rdi
call   1190 <wclear@plt>
xor    %eax,%eax
call   1170 <refresh@plt>
mov    %r12d,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@COLOR_MAGENTA = global i32 0
@COLOR_BLACK = global i32 0
@COLS = global i32 0
@TRUE = global i32 0
@ACS_LTEE = global i32 0
@ACS_HLINE = global i32 0
@ACS_RTEE = global i32 0
@LINES = global i32 0
@.str = [30 x i8] c"press ENTER for choice action\00"
@REQ_DOWN_ITEM = global i32 0
@.str.1 = [29 x i8] c" \00"
@REQ_UP_ITEM = global i32 0
@stdscr = global i32 0
@.str.2 = [12 x i8] c"select = %d\00"
define i32 @get_choice(i8** %0, i32 %1, i8* %2) {
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32**
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i8** %0, i8*** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
store i32 1, i32* %14
%15 = call i32 (...) @cbreak()
%16 = call i32 (...) @noecho()
%17 = call i32 @curs_set(i32 0)
%18 = load i32, i32* @COLOR_MAGENTA
%19 = load i32, i32* @COLOR_BLACK
%20 = call i32 @init_pair(i32 1, i32 %18, i32 %19)
%21 = load i32, i32* %5
store i32 %21, i32* %11
%22 = load i8**, i8*** %4
%23 = load i32, i32* %11
%24 = call i32 @get_max_elem(i8** %22, i32 %23)
store i32 %24, i32* %13
%25 = load i32, i32* %11
%26 = call i64 @calloc(i32 %25, i32 8)
%27 = inttoptr i64 %26 to i32**
store i32** %27, i32*** %7
store i32 0, i32* %12
br label %28
28: ; preds = %43, %3
%29 = load i32, i32* %12
%30 = load i32, i32* %11
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %46
32: ; preds = %28
%33 = load i8**, i8*** %4
%34 = load i32, i32* %12
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8*, i8** %33, i64 %35
%37 = load i8*, i8** %36
%38 = call i32* @new_item(i8* %37, i32* null)
%39 = load i32**, i32*** %7
%40 = load i32, i32* %12
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i32*, i32** %39, i64 %41
store i32* %38, i32** %42
br label %43
43: ; preds = %32
%44 = load i32, i32* %12
%45 = add nsw i32 %44, 1
store i32 %45, i32* %12
br label %28
46: ; preds = %28
%47 = load i32**, i32*** %7
%48 = call i32* @new_menu(i32** %47)
store i32* %48, i32** %8
%49 = load i32, i32* %11
%50 = add nsw i32 %49, 4
%51 = load i32, i32* %13
%52 = add nsw i32 %51, 4
%53 = load i32, i32* @COLS
%54 = load i32, i32* %13
%55 = sub nsw i32 %53, %54
%56 = sdiv i32 %55, 2
%57 = call i32* @newwin(i32 %50, i32 %52, i32 10, i32 %56)
store i32* %57, i32** %9
%58 = load i32*, i32** %9
%59 = load i32, i32* @TRUE
%60 = call i32 @keypad(i32* %58, i32 %59)
%61 = load i32*, i32** %8
%62 = load i32*, i32** %9
%63 = call i32 @set_menu_win(i32* %61, i32* %62)
%64 = load i32*, i32** %8
%65 = load i32*, i32** %9
%66 = load i32, i32* %11
%67 = load i32, i32* %13
%68 = call i32 @derwin(i32* %65, i32 %66, i32 %67, i32 3, i32 2)
%69 = call i32 @set_menu_sub(i32* %64, i32 %68)
%70 = load i32*, i32** %8
%71 = call i32 @set_menu_mark(i32* %70, i32* null)
%72 = load i32*, i32** %9
%73 = call i32 @box(i32* %72, i32 0, i32 0)
%74 = load i32*, i32** %9
%75 = load i32, i32* %13
%76 = add nsw i32 %75, 4
%77 = load i8*, i8** %6
%78 = call i32 @COLOR_PAIR(i32 1)
%79 = call i32 @print_in_middle(i32* %74, i32 1, i32 0, i32 %76, i8* %77, i32 %78)
%80 = load i32*, i32** %9
%81 = load i32, i32* @ACS_LTEE
%82 = call i32 @mvwaddch(i32* %80, i32 2, i32 0, i32 %81)
%83 = load i32*, i32** %9
%84 = load i32, i32* @ACS_HLINE
%85 = load i32, i32* %13
%86 = add nsw i32 %85, 2
%87 = call i32 @mvwhline(i32* %83, i32 2, i32 1, i32 %84, i32 %86)
%88 = load i32*, i32** %9
%89 = load i32, i32* %13
%90 = add nsw i32 %89, 3
%91 = load i32, i32* @ACS_RTEE
%92 = call i32 @mvwaddch(i32* %88, i32 2, i32 %90, i32 %91)
%93 = load i32, i32* @LINES
%94 = sub nsw i32 %93, 2
%95 = call i32 @mvprintw(i32 %94, i32 3, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%96 = call i32 (...) @refresh()
%97 = load i32*, i32** %8
%98 = call i32 @post_menu(i32* %97)
%99 = load i32*, i32** %9
%100 = call i32 @wrefresh(i32* %99)
br label %101
101: ; preds = %135, %46
%102 = load i32*, i32** %9
%103 = call i32 @wgetch(i32* %102)
store i32 %103, i32* %10
%104 = icmp ne i32 %103, 10
br i1 %104, label %105, label %138
105: ; preds = %101
%106 = load i32, i32* %10
switch i32 %106, label %135 [
i32 130, label %107
i32 128, label %119
i32 129, label %130
]
107: ; preds = %105
%108 = load i32, i32* %14
%109 = load i32, i32* %5
%110 = icmp slt i32 %108, %109
br i1 %110, label %111, label %118
111: ; preds = %107
%112 = load i32*, i32** %8
%113 = load i32, i32* @REQ_DOWN_ITEM
%114 = call i32 @menu_driver(i32* %112, i32 %113)
%115 = call i32 @mvprintw(i32 3, i32 10, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%116 = load i32, i32* %14
%117 = add nsw i32 %116, 1
store i32 %117, i32* %14
br label %118
118: ; preds = %111, %107
br label %135
119: ; preds = %105
%120 = load i32, i32* %14
%121 = icmp sgt i32 %120, 1
br i1 %121, label %122, label %129
122: ; preds = %119
%123 = load i32*, i32** %8
%124 = load i32, i32* @REQ_UP_ITEM
%125 = call i32 @menu_driver(i32* %123, i32 %124)
%126 = call i32 @mvprintw(i32 3, i32 10, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%127 = load i32, i32* %14
%128 = add nsw i32 %127, -1
store i32 %128, i32* %14
br label %129
129: ; preds = %122, %119
br label %135
130: ; preds = %105
%131 = load i32, i32* @stdscr
%132 = load i32, i32* %14
%133 = call i32 @mvwprintw(i32 %131, i32 3, i32 10, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %132)
%134 = call i32 (...) @refresh()
br label %135
135: ; preds = %105, %130, %129, %118
%136 = load i32*, i32** %9
%137 = call i32 @wrefresh(i32* %136)
br label %101
138: ; preds = %101
%139 = load i32*, i32** %8
%140 = call i32 @unpost_menu(i32* %139)
%141 = load i32*, i32** %8
%142 = call i32 @free_menu(i32* %141)
store i32 0, i32* %12
br label %143
143: ; preds = %154, %138
%144 = load i32, i32* %12
%145 = load i32, i32* %11
%146 = icmp slt i32 %144, %145
br i1 %146, label %147, label %157
147: ; preds = %143
%148 = load i32**, i32*** %7
%149 = load i32, i32* %12
%150 = sext i32 %149 to i64
%151 = getelementptr inbounds i32*, i32** %148, i64 %150
%152 = load i32*, i32** %151
%153 = call i32 @free_item(i32* %152)
br label %154
154: ; preds = %147
%155 = load i32, i32* %12
%156 = add nsw i32 %155, 1
store i32 %156, i32* %12
br label %143
157: ; preds = %143
%158 = load i32*, i32** %9
%159 = call i32 @wclear(i32* %158)
%160 = call i32 (...) @refresh()
%161 = load i32, i32* %14
ret i32 %161
}

LLVM IR (-O2):
@COLOR_MAGENTA = global i32 0
@COLOR_BLACK = global i32 0
@COLS = global i32 0
@TRUE = global i32 0
@ACS_LTEE = global i32 0
@ACS_HLINE = global i32 0
@ACS_RTEE = global i32 0
@LINES = global i32 0
@.str = [30 x i8] c"press ENTER for choice action\00"
@REQ_DOWN_ITEM = global i32 0
@.str.1 = [29 x i8] c" \00"
@REQ_UP_ITEM = global i32 0
@stdscr = global i32 0
@.str.2 = [12 x i8] c"select = %d\00"
define i32 @get_choice(i8** %0, i32 %1, i8* %2) {
%4 = tail call i32 (...) @cbreak()
%5 = tail call i32 (...) @noecho()
%6 = tail call i32 @curs_set(i32 0)
%7 = load i32, i32* @COLOR_MAGENTA
%8 = load i32, i32* @COLOR_BLACK
%9 = tail call i32 @init_pair(i32 1, i32 %7, i32 %8)
%10 = tail call i32 @get_max_elem(i8** %0, i32 %1)
%11 = tail call i64 @calloc(i32 %1, i32 8)
%12 = inttoptr i64 %11 to i32**
%13 = icmp sgt i32 %1, 0
br i1 %13, label %14, label %24
14: ; preds = %3
%15 = zext i32 %1 to i64
br label %16
16: ; preds = %14, %16
%17 = phi i64 [ 0, %14 ], [ %22, %16 ]
%18 = getelementptr inbounds i8*, i8** %0, i64 %17
%19 = load i8*, i8** %18
%20 = tail call i32* @new_item(i8* %19, i32* null)
%21 = getelementptr inbounds i32*, i32** %12, i64 %17
store i32* %20, i32** %21
%22 = add nuw nsw i64 %17, 1
%23 = icmp eq i64 %22, %15
br i1 %23, label %24, label %16
24: ; preds = %16, %3
%25 = tail call i32* @new_menu(i32** %12)
%26 = add nsw i32 %1, 4
%27 = add nsw i32 %10, 4
%28 = load i32, i32* @COLS
%29 = sub nsw i32 %28, %10
%30 = sdiv i32 %29, 2
%31 = tail call i32* @newwin(i32 %26, i32 %27, i32 10, i32 %30)
%32 = load i32, i32* @TRUE
%33 = tail call i32 @keypad(i32* %31, i32 %32)
%34 = tail call i32 @set_menu_win(i32* %25, i32* %31)
%35 = tail call i32 @derwin(i32* %31, i32 %1, i32 %10, i32 3, i32 2)
%36 = tail call i32 @set_menu_sub(i32* %25, i32 %35)
%37 = tail call i32 @set_menu_mark(i32* %25, i32* null)
%38 = tail call i32 @box(i32* %31, i32 0, i32 0)
%39 = tail call i32 @COLOR_PAIR(i32 1)
%40 = tail call i32 @print_in_middle(i32* %31, i32 1, i32 0, i32 %27, i8* %2, i32 %39)
%41 = load i32, i32* @ACS_LTEE
%42 = tail call i32 @mvwaddch(i32* %31, i32 2, i32 0, i32 %41)
%43 = load i32, i32* @ACS_HLINE
%44 = add nsw i32 %10, 2
%45 = tail call i32 @mvwhline(i32* %31, i32 2, i32 1, i32 %43, i32 %44)
%46 = add nsw i32 %10, 3
%47 = load i32, i32* @ACS_RTEE
%48 = tail call i32 @mvwaddch(i32* %31, i32 2, i32 %46, i32 %47)
%49 = load i32, i32* @LINES
%50 = add nsw i32 %49, -2
%51 = tail call i32 @mvprintw(i32 %50, i32 3, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%52 = tail call i32 (...) @refresh()
%53 = tail call i32 @post_menu(i32* %25)
br label %54
54: ; preds = %74, %24
%55 = phi i32 [ 1, %24 ], [ %75, %74 ]
%56 = icmp sgt i32 %55, 1
%57 = icmp slt i32 %55, %1
br label %58
58: ; preds = %61, %54
%59 = tail call i32 @wrefresh(i32* %31)
%60 = tail call i32 @wgetch(i32* %31)
switch i32 %60, label %61 [
i32 10, label %80
i32 130, label %62
i32 128, label %68
i32 129, label %76
]
61: ; preds = %58, %68, %62, %76
br label %58
62: ; preds = %58
br i1 %57, label %63, label %61
63: ; preds = %62
%64 = load i32, i32* @REQ_DOWN_ITEM
%65 = tail call i32 @menu_driver(i32* %25, i32 %64)
%66 = tail call i32 @mvprintw(i32 3, i32 10, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%67 = add nsw i32 %55, 1
br label %74
68: ; preds = %58
br i1 %56, label %69, label %61
69: ; preds = %68
%70 = load i32, i32* @REQ_UP_ITEM
%71 = tail call i32 @menu_driver(i32* %25, i32 %70)
%72 = tail call i32 @mvprintw(i32 3, i32 10, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%73 = add nsw i32 %55, -1
br label %74
74: ; preds = %69, %63
%75 = phi i32 [ %67, %63 ], [ %73, %69 ]
br label %54
76: ; preds = %58
%77 = load i32, i32* @stdscr
%78 = tail call i32 @mvwprintw(i32 %77, i32 3, i32 10, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %55)
%79 = tail call i32 (...) @refresh()
br label %61
80: ; preds = %58
%81 = tail call i32 @unpost_menu(i32* %25)
%82 = tail call i32 @free_menu(i32* %25)
br i1 %13, label %83, label %92
83: ; preds = %80
%84 = zext i32 %1 to i64
br label %85
85: ; preds = %83, %85
%86 = phi i64 [ 0, %83 ], [ %90, %85 ]
%87 = getelementptr inbounds i32*, i32** %12, i64 %86
%88 = load i32*, i32** %87
%89 = tail call i32 @free_item(i32* %88)
%90 = add nuw nsw i64 %86, 1
%91 = icmp eq i64 %90, %84
br i1 %91, label %92, label %85
92: ; preds = %85, %80
%93 = tail call i32 @wclear(i32* %31)
%94 = tail call i32 (...) @refresh()
ret i32 %55
}