#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_PAIR(int);
int INT_MIN;
#define KEY_DOWN 129
#define KEY_UP 128
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*/ derwin(int /*<<< orphan*/ *, int, int, int, double);
int /*<<< orphan*/ getmaxyx(int /*<<< orphan*/ *, int, int);
int /*<<< orphan*/ keypad(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ menu_driver(int /*<<< orphan*/ *, int /*<<< orphan*/);
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 /*<<< orphan*/ *new_item(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ *new_menu(int /*<<< orphan*/ **);
int /*<<< orphan*/ *newwin(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/, int /*<<< orphan*/);
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*/ remove_menu(int /*<<< orphan*/ *, int /*<<< orphan*/ **,
                               int);
int /*<<< orphan*/ set_menu_format(int /*<<< orphan*/ *, int, int);
int /*<<< orphan*/ set_menu_mark(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ set_menu_spacing(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                    int, int /*<<< orphan*/);
int /*<<< orphan*/ set_menu_sub(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ set_menu_win(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ start_color();
int /*<<< orphan*/ *stdscr;
int wgetch(int /*<<< orphan*/ *);
int /*<<< orphan*/ wrefresh(int /*<<< orphan*/ *);
int show_database_menu(char *database) {
  int i, c;
  int n = 6;
  ITEM **items;
  MENU *menu;
  WINDOW *win;
  char *choices[] = {
      "Teachers", "Subjects", "Batches", "Rooms", "Slots", "Timetable",
  };
  int x, y;
  start_color();
  cbreak();
  noecho();
  keypad(stdscr, TRUE);
  items = (ITEM **)calloc(n + 2, sizeof(ITEM *));
  for (i = 0; i < n; ++i) {
    items[i] = new_item(choices[i], NULL);
  }
  menu = new_menu((ITEM **)items);
  win = newwin(0, 0, 0, 0);
  getmaxyx(win, y, x);
  keypad(win, TRUE);
  set_menu_win(menu, win);
  set_menu_sub(menu, derwin(win, y - 5, 38, 5, 0.4 * x));
  set_menu_format(menu, y / 2, 1);
  set_menu_mark(menu, " * ");
  set_menu_spacing(menu, 0, 2, 0);
  box(win, 0, 0);
  print_in_middle(win, 1, 0, x, database, COLOR_PAIR(1));
  mvwaddch(win, 2, 0, ACS_LTEE);
  mvwhline(win, 2, 1, ACS_HLINE, x);
  mvwaddch(win, 2, x - 1, ACS_RTEE);
  mvwaddch(win, y - 3, 0, ACS_LTEE);
  mvwhline(win, y - 3, 1, ACS_HLINE, x - 2);
  mvwaddch(win, y - 3, x - 1, ACS_RTEE);
  mvwprintw(win, y - 2, 2, "B:Back\t\tQ:Quit");
  refresh();
  post_menu(menu);
  wrefresh(win);
  int choice = 0;
  while ((c = wgetch(win))) {
    switch (c) {
    case KEY_DOWN:
      menu_driver(menu, REQ_DOWN_ITEM);
      if (choice != n - 1)
        choice++;
      break;
    case KEY_UP:
      menu_driver(menu, REQ_UP_ITEM);
      if (choice != 0)
        choice--;
      break;
    case 10:
      remove_menu(menu, items, n);
      return choice;
      break;
    case 'B':
    case 'b':
      remove_menu(menu, items, n);
      return n + 1;
    case 'q':
    case 'Q':
      remove_menu(menu, items, n);
      return INT_MIN;
    default:
      break;
    }
    if (c == 10)
      break;
    wrefresh(win);
  }
  return -1;
}


x86 assembly (clang, -O0):
<show_database_menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x6,-0x1c(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   10b0 <memset@plt>
lea    0xd1b(%rip),%rax
mov    %rax,-0x70(%rbp)
lea    0xd19(%rip),%rax
mov    %rax,-0x68(%rbp)
lea    0xd17(%rip),%rax
mov    %rax,-0x60(%rbp)
lea    0xd14(%rip),%rax
mov    %rax,-0x58(%rbp)
lea    0xd0f(%rip),%rax
mov    %rax,-0x50(%rbp)
lea    0xd0a(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    $0x0,%al
call   1090 <start_color@plt>
mov    $0x0,%al
call   1040 <cbreak@plt>
mov    $0x0,%al
call   11a0 <noecho@plt>
mov    0x2c94(%rip),%rax
mov    (%rax),%rdi
mov    0x2c82(%rip),%rax
mov    (%rax),%esi
call   1080 <keypad@plt>
mov    -0x1c(%rbp),%edi
add    $0x2,%edi
mov    $0x8,%esi
call   10e0 <calloc@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    13ab <show_database_menu+0xeb>
movslq -0x14(%rbp),%rax
mov    -0x70(%rbp,%rax,8),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1140 <new_item@plt>
mov    %rax,%rdx
mov    -0x28(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1370 <show_database_menu+0xb0>
mov    -0x28(%rbp),%rdi
call   1110 <new_menu@plt>
mov    %rax,-0x30(%rbp)
xor    %ecx,%ecx
mov    %ecx,%edi
mov    %ecx,%esi
mov    %ecx,%edx
call   10a0 <newwin@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x78(%rbp),%esi
mov    -0x74(%rbp),%edx
call   10d0 <getmaxyx@plt>
mov    -0x38(%rbp),%rdi
mov    0x2bed(%rip),%rax
mov    (%rax),%esi
call   1080 <keypad@plt>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1030 <set_menu_win@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x78(%rbp),%esi
sub    $0x5,%esi
cvtsi2sdl -0x74(%rbp),%xmm1
movsd  0xbe7(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    $0x26,%edx
mov    $0x5,%ecx
call   11e0 <derwin@plt>
mov    -0xa0(%rbp),%rdi
mov    %eax,%esi
call   10c0 <set_menu_sub@plt>
mov    -0x30(%rbp),%rdi
mov    -0x78(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    $0x1,%edx
call   1190 <set_menu_format@plt>
mov    -0x30(%rbp),%rdi
lea    0xbd8(%rip),%rsi
call   10f0 <set_menu_mark@plt>
mov    -0x30(%rbp),%rdi
xor    %ecx,%ecx
mov    $0x2,%edx
mov    %ecx,%esi
call   11c0 <set_menu_spacing@plt>
mov    -0x38(%rbp),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   1100 <box@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x74(%rbp),%eax
mov    %eax,-0x8c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    $0x1,%edi
call   1120 <COLOR_PAIR@plt>
mov    -0x98(%rbp),%rdi
mov    -0x8c(%rbp),%ecx
mov    -0x88(%rbp),%r8
mov    %eax,%r9d
mov    $0x1,%esi
xor    %edx,%edx
call   11d0 <print_in_middle@plt>
mov    -0x38(%rbp),%rdi
mov    0x2b0d(%rip),%rax
mov    (%rax),%ecx
mov    $0x2,%esi
xor    %edx,%edx
call   11b0 <mvwaddch@plt>
mov    -0x38(%rbp),%rdi
mov    0x2ac4(%rip),%rax
mov    (%rax),%ecx
mov    -0x74(%rbp),%r8d
mov    $0x2,%esi
mov    $0x1,%edx
call   1150 <mvwhline@plt>
mov    -0x38(%rbp),%rdi
mov    -0x74(%rbp),%edx
sub    $0x1,%edx
mov    0x2a8e(%rip),%rax
mov    (%rax),%ecx
mov    $0x2,%esi
call   11b0 <mvwaddch@plt>
mov    -0x38(%rbp),%rdi
mov    -0x78(%rbp),%esi
sub    $0x3,%esi
mov    0x2ab1(%rip),%rax
mov    (%rax),%ecx
xor    %edx,%edx
call   11b0 <mvwaddch@plt>
mov    -0x38(%rbp),%rdi
mov    -0x78(%rbp),%esi
sub    $0x3,%esi
mov    0x2a67(%rip),%rax
mov    (%rax),%ecx
mov    -0x74(%rbp),%r8d
sub    $0x2,%r8d
mov    $0x1,%edx
call   1150 <mvwhline@plt>
mov    -0x38(%rbp),%rdi
mov    -0x78(%rbp),%esi
sub    $0x3,%esi
mov    -0x74(%rbp),%edx
sub    $0x1,%edx
mov    0x2a2c(%rip),%rax
mov    (%rax),%ecx
call   11b0 <mvwaddch@plt>
mov    -0x38(%rbp),%rdi
mov    -0x78(%rbp),%esi
sub    $0x2,%esi
mov    $0x2,%edx
lea    0xaa3(%rip),%rcx
call   1180 <mvwprintw@plt>
mov    $0x0,%al
call   1160 <refresh@plt>
mov    -0x30(%rbp),%rdi
call   1060 <post_menu@plt>
mov    -0x38(%rbp),%rdi
call   1070 <wrefresh@plt>
movl   $0x0,-0x7c(%rbp)
mov    -0x38(%rbp),%rdi
call   1170 <wgetch@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
je     173d <show_database_menu+0x47d>
mov    -0x18(%rbp),%eax
mov    %eax,-0xa4(%rbp)
sub    $0xa,%eax
je     16c1 <show_database_menu+0x401>
jmp    15ea <show_database_menu+0x32a>
mov    -0xa4(%rbp),%eax
sub    $0x42,%eax
je     16dc <show_database_menu+0x41c>
jmp    15fe <show_database_menu+0x33e>
mov    -0xa4(%rbp),%eax
sub    $0x51,%eax
je     16fa <show_database_menu+0x43a>
jmp    1612 <show_database_menu+0x352>
mov    -0xa4(%rbp),%eax
sub    $0x62,%eax
je     16dc <show_database_menu+0x41c>
jmp    1626 <show_database_menu+0x366>
mov    -0xa4(%rbp),%eax
sub    $0x71,%eax
je     16fa <show_database_menu+0x43a>
jmp    163a <show_database_menu+0x37a>
mov    -0xa4(%rbp),%eax
sub    $0x80,%eax
je     1697 <show_database_menu+0x3d7>
jmp    1650 <show_database_menu+0x390>
mov    -0xa4(%rbp),%eax
sub    $0x81,%eax
jne    171b <show_database_menu+0x45b>
jmp    1666 <show_database_menu+0x3a6>
mov    -0x30(%rbp),%rdi
mov    0x293f(%rip),%rax
mov    (%rax),%esi
call   1050 <menu_driver@plt>
mov    -0x7c(%rbp),%eax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
je     1692 <show_database_menu+0x3d2>
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    1720 <show_database_menu+0x460>
mov    -0x30(%rbp),%rdi
mov    0x291e(%rip),%rax
mov    (%rax),%esi
call   1050 <menu_driver@plt>
cmpl   $0x0,-0x7c(%rbp)
je     16bc <show_database_menu+0x3fc>
mov    -0x7c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x7c(%rbp)
jmp    1720 <show_database_menu+0x460>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1130 <remove_menu@plt>
mov    -0x7c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1744 <show_database_menu+0x484>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1130 <remove_menu@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1744 <show_database_menu+0x484>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1130 <remove_menu@plt>
mov    0x28cf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1744 <show_database_menu+0x484>
jmp    1720 <show_database_menu+0x460>
cmpl   $0xa,-0x18(%rbp)
jne    172f <show_database_menu+0x46f>
jmp    173d <show_database_menu+0x47d>
mov    -0x38(%rbp),%rdi
call   1070 <wrefresh@plt>
jmp    15be <show_database_menu+0x2fe>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_database_menu>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r13
xor    %eax,%eax
mov    %rax,(%rsp)
xor    %eax,%eax
call   1090 <start_color@plt>
xor    %eax,%eax
call   1040 <cbreak@plt>
xor    %eax,%eax
call   1190 <noecho@plt>
mov    0x2cf8(%rip),%rax
mov    (%rax),%rdi
mov    0x2ce6(%rip),%rbp
mov    0x0(%rbp),%esi
call   1080 <keypad@plt>
mov    $0x8,%edi
mov    $0x8,%esi
call   10d0 <calloc@plt>
mov    %rax,%r15
lea    0xdb9(%rip),%rdi
xor    %esi,%esi
call   1130 <new_item@plt>
mov    %rax,(%r15)
lea    0xdb1(%rip),%rdi
xor    %esi,%esi
call   1130 <new_item@plt>
mov    %rax,0x8(%r15)
lea    0xda8(%rip),%rdi
xor    %esi,%esi
call   1130 <new_item@plt>
mov    %rax,0x10(%r15)
lea    0xd9e(%rip),%rdi
xor    %esi,%esi
call   1130 <new_item@plt>
mov    %rax,0x18(%r15)
lea    0xd92(%rip),%rdi
xor    %esi,%esi
call   1130 <new_item@plt>
mov    %rax,0x20(%r15)
lea    0xd86(%rip),%rdi
xor    %esi,%esi
call   1130 <new_item@plt>
mov    %rax,0x28(%r15)
mov    %r15,%rdi
call   1100 <new_menu@plt>
mov    %rax,%r12
xor    %edi,%edi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   10a0 <newwin@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   10c0 <getmaxyx@plt>
mov    0x0(%rbp),%esi
mov    %rbx,%rdi
call   1080 <keypad@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <set_menu_win@plt>
xorps  %xmm0,%xmm0
mov    %rbx,%rdi
mov    $0x26,%edx
mov    $0x5,%ecx
call   11d0 <derwin@plt>
mov    %r12,%rdi
mov    %eax,%esi
call   10b0 <set_menu_sub@plt>
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1180 <set_menu_format@plt>
lea    0xd17(%rip),%rsi
mov    %r12,%rdi
call   10e0 <set_menu_mark@plt>
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
call   11b0 <set_menu_spacing@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   10f0 <box@plt>
mov    $0x1,%edi
call   1110 <COLOR_PAIR@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %edx,%edx
mov    %r13,%r8
mov    %eax,%r9d
call   11c0 <print_in_middle@plt>
mov    0x2bc0(%rip),%r14
mov    (%r14),%ecx
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %edx,%edx
call   11a0 <mvwaddch@plt>
mov    0x2b77(%rip),%r13
mov    0x0(%r13),%ecx
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x1,%edx
call   1140 <mvwhline@plt>
mov    0x2b4a(%rip),%rbp
mov    0x0(%rbp),%ecx
mov    %rbx,%rdi
mov    $0x2,%esi
call   11a0 <mvwaddch@plt>
mov    (%r14),%ecx
mov    %rbx,%rdi
xor    %edx,%edx
call   11a0 <mvwaddch@plt>
mov    0x0(%r13),%ecx
mov    %rbx,%rdi
mov    $0x1,%edx
call   1140 <mvwhline@plt>
mov    0x0(%rbp),%ecx
mov    %rbx,%rdi
call   11a0 <mvwaddch@plt>
lea    0xc5a(%rip),%rcx
mov    %rbx,%rdi
mov    $0x2,%edx
call   1170 <mvwprintw@plt>
xor    %eax,%eax
call   1150 <refresh@plt>
mov    %r12,%rdi
call   1060 <post_menu@plt>
lea    0xb3f(%rip),%rbp
mov    0x2af8(%rip),%r14
mov    0x2ae1(%rip),%r13
mov    %rbx,%rdi
call   1070 <wrefresh@plt>
mov    %rbx,%rdi
call   1160 <wgetch@plt>
cmp    $0x50,%eax
jle    1500 <show_database_menu+0x250>
add    $0xffffffaf,%eax
cmp    $0x30,%eax
ja     14cf <show_database_menu+0x21f>
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
jmp    *%rax
cs nopw 0x0(%rax,%rax,1)
test   %eax,%eax
je     158b <show_database_menu+0x2db>
cmp    $0xa,%eax
je     1592 <show_database_menu+0x2e2>
cmp    $0x42,%eax
jne    14cf <show_database_menu+0x21f>
jmp    1574 <show_database_menu+0x2c4>
mov    $0xffffffff,%r13d
mov    %r14,%rax
xor    %r14d,%r14d
jmp    1535 <show_database_menu+0x285>
mov    %r13,%rax
mov    $0x1,%r13d
mov    $0x5,%r14d
mov    (%rax),%esi
mov    %r12,%rdi
call   1050 <menu_driver@plt>
mov    (%rsp),%rax
add    %eax,%r13d
cmp    %r14d,%eax
cmove  %r14d,%r13d
mov    %r13d,%eax
mov    %rax,(%rsp)
jmp    14c1 <show_database_menu+0x211>
mov    %r12,%rdi
mov    %r15,%rsi
mov    $0x6,%edx
call   1120 <remove_menu@plt>
mov    0x2a70(%rip),%rax
mov    (%rax),%eax
jmp    15a6 <show_database_menu+0x2f6>
mov    %r12,%rdi
mov    %r15,%rsi
mov    $0x6,%edx
call   1120 <remove_menu@plt>
mov    $0x7,%eax
jmp    15a6 <show_database_menu+0x2f6>
mov    $0xffffffff,%eax
jmp    15a6 <show_database_menu+0x2f6>
mov    %r12,%rdi
mov    %r15,%rsi
mov    $0x6,%edx
call   1120 <remove_menu@plt>
mov    (%rsp),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"Teachers\00"
@.str.1 = [9 x i8] c"Subjects\00"
@.str.2 = [8 x i8] c"Batches\00"
@.str.3 = [6 x i8] c"Rooms\00"
@.str.4 = [6 x i8] c"Slots\00"
@.str.5 = [10 x i8] c"Timetable\00"
@stdscr = global i32* null
@TRUE = global i32 0
@.str.6 = [4 x i8] c" * \00"
@ACS_LTEE = global i32 0
@ACS_HLINE = global i32 0
@ACS_RTEE = global i32 0
@.str.7 = [15 x i8] c"B:Back\09\09Q:Quit\00"
@REQ_DOWN_ITEM = global i32 0
@REQ_UP_ITEM = global i32 0
@INT_MIN = global i32 0
define i32 @show_database_menu(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32**
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca [6 x i8*]
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i8* %0, i8** %3
store i32 6, i32* %6
%14 = bitcast [6 x i8*]* %10 to i8*
%15 = bitcast i8* %14 to [6 x i8*]*
%16 = getelementptr inbounds [6 x i8*], [6 x i8*]* %15, i32 0, i32 0
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i32 0, i32 0), i8** %16
%17 = getelementptr inbounds [6 x i8*], [6 x i8*]* %15, i32 0, i32 1
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i32 0, i32 0), i8** %17
%18 = getelementptr inbounds [6 x i8*], [6 x i8*]* %15, i32 0, i32 2
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i32 0, i32 0), i8** %18
%19 = getelementptr inbounds [6 x i8*], [6 x i8*]* %15, i32 0, i32 3
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i8** %19
%20 = getelementptr inbounds [6 x i8*], [6 x i8*]* %15, i32 0, i32 4
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i32 0, i32 0), i8** %20
%21 = getelementptr inbounds [6 x i8*], [6 x i8*]* %15, i32 0, i32 5
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i32 0, i32 0), i8** %21
%22 = call i32 (...) @start_color()
%23 = call i32 (...) @cbreak()
%24 = call i32 (...) @noecho()
%25 = load i32*, i32** @stdscr
%26 = load i32, i32* @TRUE
%27 = call i32 @keypad(i32* %25, i32 %26)
%28 = load i32, i32* %6
%29 = add nsw i32 %28, 2
%30 = call i64 @calloc(i32 %29, i32 8)
%31 = inttoptr i64 %30 to i32**
store i32** %31, i32*** %7
store i32 0, i32* %4
br label %32
32: ; preds = %46, %1
%33 = load i32, i32* %4
%34 = load i32, i32* %6
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %49
36: ; preds = %32
%37 = load i32, i32* %4
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [6 x i8*], [6 x i8*]* %10, i64 0, i64 %38
%40 = load i8*, i8** %39
%41 = call i32* @new_item(i8* %40, i32* null)
%42 = load i32**, i32*** %7
%43 = load i32, i32* %4
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i32*, i32** %42, i64 %44
store i32* %41, i32** %45
br label %46
46: ; preds = %36
%47 = load i32, i32* %4
%48 = add nsw i32 %47, 1
store i32 %48, i32* %4
br label %32
49: ; preds = %32
%50 = load i32**, i32*** %7
%51 = call i32* @new_menu(i32** %50)
store i32* %51, i32** %8
%52 = call i32* @newwin(i32 0, i32 0, i32 0, i32 0)
store i32* %52, i32** %9
%53 = load i32*, i32** %9
%54 = load i32, i32* %12
%55 = load i32, i32* %11
%56 = call i32 @getmaxyx(i32* %53, i32 %54, i32 %55)
%57 = load i32*, i32** %9
%58 = load i32, i32* @TRUE
%59 = call i32 @keypad(i32* %57, i32 %58)
%60 = load i32*, i32** %8
%61 = load i32*, i32** %9
%62 = call i32 @set_menu_win(i32* %60, i32* %61)
%63 = load i32*, i32** %8
%64 = load i32*, i32** %9
%65 = load i32, i32* %12
%66 = sub nsw i32 %65, 5
%67 = load i32, i32* %11
%68 = sitofp i32 %67 to double
%69 = fmul double 4.000000e-01, %68
%70 = call i32 @derwin(i32* %64, i32 %66, i32 38, i32 5, double %69)
%71 = call i32 @set_menu_sub(i32* %63, i32 %70)
%72 = load i32*, i32** %8
%73 = load i32, i32* %12
%74 = sdiv i32 %73, 2
%75 = call i32 @set_menu_format(i32* %72, i32 %74, i32 1)
%76 = load i32*, i32** %8
%77 = call i32 @set_menu_mark(i32* %76, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%78 = load i32*, i32** %8
%79 = call i32 @set_menu_spacing(i32* %78, i32 0, i32 2, i32 0)
%80 = load i32*, i32** %9
%81 = call i32 @box(i32* %80, i32 0, i32 0)
%82 = load i32*, i32** %9
%83 = load i32, i32* %11
%84 = load i8*, i8** %3
%85 = call i32 @COLOR_PAIR(i32 1)
%86 = call i32 @print_in_middle(i32* %82, i32 1, i32 0, i32 %83, i8* %84, i32 %85)
%87 = load i32*, i32** %9
%88 = load i32, i32* @ACS_LTEE
%89 = call i32 @mvwaddch(i32* %87, i32 2, i32 0, i32 %88)
%90 = load i32*, i32** %9
%91 = load i32, i32* @ACS_HLINE
%92 = load i32, i32* %11
%93 = call i32 @mvwhline(i32* %90, i32 2, i32 1, i32 %91, i32 %92)
%94 = load i32*, i32** %9
%95 = load i32, i32* %11
%96 = sub nsw i32 %95, 1
%97 = load i32, i32* @ACS_RTEE
%98 = call i32 @mvwaddch(i32* %94, i32 2, i32 %96, i32 %97)
%99 = load i32*, i32** %9
%100 = load i32, i32* %12
%101 = sub nsw i32 %100, 3
%102 = load i32, i32* @ACS_LTEE
%103 = call i32 @mvwaddch(i32* %99, i32 %101, i32 0, i32 %102)
%104 = load i32*, i32** %9
%105 = load i32, i32* %12
%106 = sub nsw i32 %105, 3
%107 = load i32, i32* @ACS_HLINE
%108 = load i32, i32* %11
%109 = sub nsw i32 %108, 2
%110 = call i32 @mvwhline(i32* %104, i32 %106, i32 1, i32 %107, i32 %109)
%111 = load i32*, i32** %9
%112 = load i32, i32* %12
%113 = sub nsw i32 %112, 3
%114 = load i32, i32* %11
%115 = sub nsw i32 %114, 1
%116 = load i32, i32* @ACS_RTEE
%117 = call i32 @mvwaddch(i32* %111, i32 %113, i32 %115, i32 %116)
%118 = load i32*, i32** %9
%119 = load i32, i32* %12
%120 = sub nsw i32 %119, 2
%121 = call i32 @mvwprintw(i32* %118, i32 %120, i32 2, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
%122 = call i32 (...) @refresh()
%123 = load i32*, i32** %8
%124 = call i32 @post_menu(i32* %123)
%125 = load i32*, i32** %9
%126 = call i32 @wrefresh(i32* %125)
store i32 0, i32* %13
br label %127
127: ; preds = %179, %49
%128 = load i32*, i32** %9
%129 = call i32 @wgetch(i32* %128)
store i32 %129, i32* %5
%130 = icmp ne i32 %129, 0
br i1 %130, label %131, label %182
131: ; preds = %127
%132 = load i32, i32* %5
switch i32 %132, label %174 [
i32 129, label %133
i32 128, label %145
i32 10, label %155
i32 66, label %161
i32 98, label %161
i32 113, label %168
i32 81, label %168
]
133: ; preds = %131
%134 = load i32*, i32** %8
%135 = load i32, i32* @REQ_DOWN_ITEM
%136 = call i32 @menu_driver(i32* %134, i32 %135)
%137 = load i32, i32* %13
%138 = load i32, i32* %6
%139 = sub nsw i32 %138, 1
%140 = icmp ne i32 %137, %139
br i1 %140, label %141, label %144
141: ; preds = %133
%142 = load i32, i32* %13
%143 = add nsw i32 %142, 1
store i32 %143, i32* %13
br label %144
144: ; preds = %141, %133
br label %175
145: ; preds = %131
%146 = load i32*, i32** %8
%147 = load i32, i32* @REQ_UP_ITEM
%148 = call i32 @menu_driver(i32* %146, i32 %147)
%149 = load i32, i32* %13
%150 = icmp ne i32 %149, 0
br i1 %150, label %151, label %154
151: ; preds = %145
%152 = load i32, i32* %13
%153 = add nsw i32 %152, -1
store i32 %153, i32* %13
br label %154
154: ; preds = %151, %145
br label %175
155: ; preds = %131
%156 = load i32*, i32** %8
%157 = load i32**, i32*** %7
%158 = load i32, i32* %6
%159 = call i32 @remove_menu(i32* %156, i32** %157, i32 %158)
%160 = load i32, i32* %13
store i32 %160, i32* %2
br label %183
161: ; preds = %131, %131
%162 = load i32*, i32** %8
%163 = load i32**, i32*** %7
%164 = load i32, i32* %6
%165 = call i32 @remove_menu(i32* %162, i32** %163, i32 %164)
%166 = load i32, i32* %6
%167 = add nsw i32 %166, 1
store i32 %167, i32* %2
br label %183
168: ; preds = %131, %131
%169 = load i32*, i32** %8
%170 = load i32**, i32*** %7
%171 = load i32, i32* %6
%172 = call i32 @remove_menu(i32* %169, i32** %170, i32 %171)
%173 = load i32, i32* @INT_MIN
store i32 %173, i32* %2
br label %183
174: ; preds = %131
br label %175
175: ; preds = %174, %154, %144
%176 = load i32, i32* %5
%177 = icmp eq i32 %176, 10
br i1 %177, label %178, label %179
178: ; preds = %175
br label %182
179: ; preds = %175
%180 = load i32*, i32** %9
%181 = call i32 @wrefresh(i32* %180)
br label %127
182: ; preds = %178, %127
store i32 -1, i32* %2
br label %183
183: ; preds = %182, %168, %161, %155
%184 = load i32, i32* %2
ret i32 %184
}

LLVM IR (-O2):
@.str = [9 x i8] c"Teachers\00"
@.str.1 = [9 x i8] c"Subjects\00"
@.str.2 = [8 x i8] c"Batches\00"
@.str.3 = [6 x i8] c"Rooms\00"
@.str.4 = [6 x i8] c"Slots\00"
@.str.5 = [10 x i8] c"Timetable\00"
@stdscr = global i32* null
@TRUE = global i32 0
@.str.6 = [4 x i8] c" * \00"
@ACS_LTEE = global i32 0
@ACS_HLINE = global i32 0
@ACS_RTEE = global i32 0
@.str.7 = [15 x i8] c"B:Back\09\09Q:Quit\00"
@REQ_DOWN_ITEM = global i32 0
@REQ_UP_ITEM = global i32 0
@INT_MIN = global i32 0
define i32 @show_database_menu(i8* %0) {
%2 = tail call i32 (...) @start_color()
%3 = tail call i32 (...) @cbreak()
%4 = tail call i32 (...) @noecho()
%5 = load i32*, i32** @stdscr
%6 = load i32, i32* @TRUE
%7 = tail call i32 @keypad(i32* %5, i32 %6)
%8 = tail call i64 @calloc(i32 8, i32 8)
%9 = inttoptr i64 %8 to i32**
%10 = tail call i32* @new_item(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* null)
store i32* %10, i32** %9
%11 = tail call i32* @new_item(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* null)
%12 = getelementptr inbounds i32*, i32** %9, i64 1
store i32* %11, i32** %12
%13 = tail call i32* @new_item(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32* null)
%14 = getelementptr inbounds i32*, i32** %9, i64 2
store i32* %13, i32** %14
%15 = tail call i32* @new_item(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* null)
%16 = getelementptr inbounds i32*, i32** %9, i64 3
store i32* %15, i32** %16
%17 = tail call i32* @new_item(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* null)
%18 = getelementptr inbounds i32*, i32** %9, i64 4
store i32* %17, i32** %18
%19 = tail call i32* @new_item(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32* null)
%20 = getelementptr inbounds i32*, i32** %9, i64 5
store i32* %19, i32** %20
%21 = tail call i32* @new_menu(i32** %9)
%22 = tail call i32* @newwin(i32 0, i32 0, i32 0, i32 0)
%23 = tail call i32 @getmaxyx(i32* %22, i32 undef, i32 undef)
%24 = load i32, i32* @TRUE
%25 = tail call i32 @keypad(i32* %22, i32 %24)
%26 = tail call i32 @set_menu_win(i32* %21, i32* %22)
%27 = tail call i32 @derwin(i32* %22, i32 undef, i32 38, i32 5, double 0.000000e+00)
%28 = tail call i32 @set_menu_sub(i32* %21, i32 %27)
%29 = tail call i32 @set_menu_format(i32* %21, i32 0, i32 1)
%30 = tail call i32 @set_menu_mark(i32* %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%31 = tail call i32 @set_menu_spacing(i32* %21, i32 0, i32 2, i32 0)
%32 = tail call i32 @box(i32* %22, i32 0, i32 0)
%33 = tail call i32 @COLOR_PAIR(i32 1)
%34 = tail call i32 @print_in_middle(i32* %22, i32 1, i32 0, i32 undef, i8* %0, i32 %33)
%35 = load i32, i32* @ACS_LTEE
%36 = tail call i32 @mvwaddch(i32* %22, i32 2, i32 0, i32 %35)
%37 = load i32, i32* @ACS_HLINE
%38 = tail call i32 @mvwhline(i32* %22, i32 2, i32 1, i32 %37, i32 undef)
%39 = load i32, i32* @ACS_RTEE
%40 = tail call i32 @mvwaddch(i32* %22, i32 2, i32 undef, i32 %39)
%41 = load i32, i32* @ACS_LTEE
%42 = tail call i32 @mvwaddch(i32* %22, i32 undef, i32 0, i32 %41)
%43 = load i32, i32* @ACS_HLINE
%44 = tail call i32 @mvwhline(i32* %22, i32 undef, i32 1, i32 %43, i32 undef)
%45 = load i32, i32* @ACS_RTEE
%46 = tail call i32 @mvwaddch(i32* %22, i32 undef, i32 undef, i32 %45)
%47 = tail call i32 @mvwprintw(i32* %22, i32 undef, i32 2, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
%48 = tail call i32 (...) @refresh()
%49 = tail call i32 @post_menu(i32* %21)
br label %50
50: ; preds = %63, %1
%51 = phi i32 [ %71, %63 ], [ 0, %1 ]
br label %52
52: ; preds = %50, %52
%53 = tail call i32 @wrefresh(i32* %22)
%54 = tail call i32 @wgetch(i32* %22)
switch i32 %54, label %52 [
i32 0, label %72
i32 129, label %62
i32 128, label %63
i32 10, label %55
i32 66, label %57
i32 98, label %57
i32 113, label %59
i32 81, label %59
]
55: ; preds = %52
%56 = tail call i32 @remove_menu(i32* %21, i32** %9, i32 6)
br label %72
57: ; preds = %52, %52
%58 = tail call i32 @remove_menu(i32* %21, i32** %9, i32 6)
br label %72
59: ; preds = %52, %52
%60 = tail call i32 @remove_menu(i32* %21, i32** %9, i32 6)
%61 = load i32, i32* @INT_MIN
br label %72
62: ; preds = %52
br label %63
63: ; preds = %52, %62
%64 = phi i32* [ @REQ_DOWN_ITEM, %62 ], [ @REQ_UP_ITEM, %52 ]
%65 = phi i32 [ 5, %62 ], [ 0, %52 ]
%66 = phi i32 [ 1, %62 ], [ -1, %52 ]
%67 = load i32, i32* %64
%68 = tail call i32 @menu_driver(i32* %21, i32 %67)
%69 = icmp eq i32 %51, %65
%70 = add nsw i32 %51, %66
%71 = select i1 %69, i32 %65, i32 %70
br label %50
72: ; preds = %52, %59, %57, %55
%73 = phi i32 [ %61, %59 ], [ 7, %57 ], [ %51, %55 ], [ -1, %52 ]
ret i32 %73
}