#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ add_bold(char);
int /*<<< orphan*/ add_entry();
int /*<<< orphan*/ cbreak();
int /*<<< orphan*/ change_entry();
int /*<<< orphan*/ config_options();
int /*<<< orphan*/ delete_entry();
int getch();
int /*<<< orphan*/ help();
int /*<<< orphan*/ move(int, int);
int /*<<< orphan*/ printw(char *, ...);
int /*<<< orphan*/ quit_prog();
int /*<<< orphan*/ refresh();
int /*<<< orphan*/ search_menu();
int /*<<< orphan*/ setup_screen();
int tolower(int);
void menu() {
  int ch, lch;
  setup_screen();
  move(4, 5);
  add_bold('S');
  printw("%s", "earch and query");
  move(5, 5);
  add_bold('A');
  printw("%s", "dd a new entry");
  move(6, 5);
  add_bold('D');
  printw("%s", "elete an entry");
  move(7, 5);
  printw("%s", "View or ");
  add_bold('C');
  printw("%s", "hange an existing entry");
  move(11, 5);
  add_bold('H');
  printw("%s", "elp");
  move(12, 5);
  add_bold('Q');
  printw("%s", "uit");
  move(15, 5);
  printw("What do you want to do? ");
  refresh();
  cbreak();
  ch = getch();
  lch = tolower(ch);
  switch (lch) {
  case 's':
    search_menu();
    break;
  case 'a':
    add_entry();
    break;
  case 'd':
    delete_entry();
    break;
  case 'c':
    change_entry();
    break;
  case 'o':
    config_options();
    break;
  case 'h':
    help();
    break;
  case 'q':
    quit_prog();
    break;
  default:
    break;
  }
}


x86 assembly (clang, -O0):
<menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
xor    %eax,%eax
mov    %al,-0x11(%rbp)
call   1060 <setup_screen@plt>
mov    $0x4,%edi
mov    $0x5,%esi
mov    %esi,-0x18(%rbp)
call   1110 <move@plt>
mov    $0x53,%edi
call   10e0 <add_bold@plt>
mov    -0x11(%rbp),%al
lea    0xe24(%rip),%rdi
mov    %rdi,-0x20(%rbp)
lea    0xe1c(%rip),%rsi
call   1080 <printw@plt>
mov    -0x18(%rbp),%esi
mov    %esi,%edi
call   1110 <move@plt>
mov    $0x41,%edi
call   10e0 <add_bold@plt>
mov    -0x20(%rbp),%rdi
mov    -0x11(%rbp),%al
lea    0xe05(%rip),%rsi
call   1080 <printw@plt>
mov    -0x18(%rbp),%esi
mov    $0x6,%edi
call   1110 <move@plt>
mov    $0x44,%edi
call   10e0 <add_bold@plt>
mov    -0x20(%rbp),%rdi
mov    -0x11(%rbp),%al
lea    0xdea(%rip),%rsi
call   1080 <printw@plt>
mov    -0x18(%rbp),%esi
mov    $0x7,%edi
call   1110 <move@plt>
mov    -0x20(%rbp),%rdi
mov    -0x11(%rbp),%al
lea    0xdd9(%rip),%rsi
call   1080 <printw@plt>
mov    $0x43,%edi
call   10e0 <add_bold@plt>
mov    -0x20(%rbp),%rdi
mov    -0x11(%rbp),%al
lea    0xdc5(%rip),%rsi
call   1080 <printw@plt>
mov    -0x18(%rbp),%esi
mov    $0xb,%edi
call   1110 <move@plt>
mov    $0x48,%edi
call   10e0 <add_bold@plt>
mov    -0x20(%rbp),%rdi
mov    -0x11(%rbp),%al
lea    0xdb3(%rip),%rsi
call   1080 <printw@plt>
mov    -0x18(%rbp),%esi
mov    $0xc,%edi
call   1110 <move@plt>
mov    $0x51,%edi
call   10e0 <add_bold@plt>
mov    -0x20(%rbp),%rdi
mov    -0x11(%rbp),%al
lea    0xd8d(%rip),%rsi
call   1080 <printw@plt>
mov    -0x18(%rbp),%esi
mov    $0xf,%edi
call   1110 <move@plt>
mov    -0x11(%rbp),%al
lea    0xd75(%rip),%rdi
call   1080 <printw@plt>
mov    -0x11(%rbp),%al
call   10c0 <refresh@plt>
mov    -0x11(%rbp),%al
call   1040 <cbreak@plt>
mov    -0x11(%rbp),%al
call   10d0 <getch@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1090 <tolower@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffff9f,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x12,%eax
ja     13d9 <menu+0x1e9>
mov    -0x10(%rbp),%rax
lea    0xc84(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1030 <search_menu@plt>
jmp    13de <menu+0x1ee>
mov    $0x0,%al
call   1070 <add_entry@plt>
jmp    13de <menu+0x1ee>
mov    $0x0,%al
call   10a0 <delete_entry@plt>
jmp    13de <menu+0x1ee>
mov    $0x0,%al
call   1050 <change_entry@plt>
jmp    13de <menu+0x1ee>
mov    $0x0,%al
call   1100 <config_options@plt>
jmp    13de <menu+0x1ee>
mov    $0x0,%al
call   10f0 <help@plt>
jmp    13de <menu+0x1ee>
mov    $0x0,%al
call   10b0 <quit_prog@plt>
jmp    13de <menu+0x1ee>
jmp    13de <menu+0x1ee>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<menu>:
push   %rbx
xor    %eax,%eax
call   1060 <setup_screen@plt>
mov    $0x4,%edi
mov    $0x5,%esi
call   1110 <move@plt>
mov    $0x53,%edi
call   10e0 <add_bold@plt>
lea    0xe34(%rip),%rbx
lea    0xe30(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <printw@plt>
mov    $0x5,%edi
mov    $0x5,%esi
call   1110 <move@plt>
mov    $0x41,%edi
call   10e0 <add_bold@plt>
lea    0xe16(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <printw@plt>
mov    $0x6,%edi
mov    $0x5,%esi
call   1110 <move@plt>
mov    $0x44,%edi
call   10e0 <add_bold@plt>
lea    0xdfb(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <printw@plt>
mov    $0x7,%edi
mov    $0x5,%esi
call   1110 <move@plt>
lea    0xdea(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <printw@plt>
mov    $0x43,%edi
call   10e0 <add_bold@plt>
lea    0xdd8(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <printw@plt>
mov    $0xb,%edi
mov    $0x5,%esi
call   1110 <move@plt>
mov    $0x48,%edi
call   10e0 <add_bold@plt>
lea    0xdc6(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <printw@plt>
mov    $0xc,%edi
mov    $0x5,%esi
call   1110 <move@plt>
mov    $0x51,%edi
call   10e0 <add_bold@plt>
lea    0xda0(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <printw@plt>
mov    $0xf,%edi
mov    $0x5,%esi
call   1110 <move@plt>
lea    0xd84(%rip),%rdi
xor    %eax,%eax
call   1080 <printw@plt>
xor    %eax,%eax
call   10c0 <refresh@plt>
xor    %eax,%eax
call   1040 <cbreak@plt>
xor    %eax,%eax
call   10d0 <getch@plt>
mov    %eax,%edi
call   1090 <tolower@plt>
add    $0xffffff9f,%eax
cmp    $0x12,%eax
ja     1365 <menu+0x175>
lea    0xcac(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
xor    %eax,%eax
pop    %rbx
jmp    1070 <add_entry@plt>
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
jmp    1050 <change_entry@plt>
xor    %eax,%eax
pop    %rbx
jmp    10a0 <delete_entry@plt>
xor    %eax,%eax
pop    %rbx
jmp    10f0 <help@plt>
xor    %eax,%eax
pop    %rbx
jmp    10b0 <quit_prog@plt>
xor    %eax,%eax
pop    %rbx
jmp    1030 <search_menu@plt>
xor    %eax,%eax
pop    %rbx
jmp    1100 <config_options@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [16 x i8] c"earch and query\00"
@.str.2 = [15 x i8] c"dd a new entry\00"
@.str.3 = [15 x i8] c"elete an entry\00"
@.str.4 = [9 x i8] c"View or \00"
@.str.5 = [24 x i8] c"hange an existing entry\00"
@.str.6 = [4 x i8] c"elp\00"
@.str.7 = [4 x i8] c"uit\00"
@.str.8 = [25 x i8] c"What do you want to do? \00"
define void @menu() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 (...) @setup_screen()
%4 = call i32 @move(i32 4, i32 5)
%5 = call i32 @add_bold(i8 signext 83)
%6 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @move(i32 5, i32 5)
%8 = call i32 @add_bold(i8 signext 65)
%9 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @move(i32 6, i32 5)
%11 = call i32 @add_bold(i8 signext 68)
%12 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 @move(i32 7, i32 5)
%14 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%15 = call i32 @add_bold(i8 signext 67)
%16 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%17 = call i32 @move(i32 11, i32 5)
%18 = call i32 @add_bold(i8 signext 72)
%19 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%20 = call i32 @move(i32 12, i32 5)
%21 = call i32 @add_bold(i8 signext 81)
%22 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%23 = call i32 @move(i32 15, i32 5)
%24 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0))
%25 = call i32 (...) @refresh()
%26 = call i32 (...) @cbreak()
%27 = call i32 (...) @getch()
store i32 %27, i32* %1
%28 = load i32, i32* %1
%29 = call i32 @tolower(i32 %28)
store i32 %29, i32* %2
%30 = load i32, i32* %2
switch i32 %30, label %45 [
i32 115, label %31
i32 97, label %33
i32 100, label %35
i32 99, label %37
i32 111, label %39
i32 104, label %41
i32 113, label %43
]
31: ; preds = %0
%32 = call i32 (...) @search_menu()
br label %46
33: ; preds = %0
%34 = call i32 (...) @add_entry()
br label %46
35: ; preds = %0
%36 = call i32 (...) @delete_entry()
br label %46
37: ; preds = %0
%38 = call i32 (...) @change_entry()
br label %46
39: ; preds = %0
%40 = call i32 (...) @config_options()
br label %46
41: ; preds = %0
%42 = call i32 (...) @help()
br label %46
43: ; preds = %0
%44 = call i32 (...) @quit_prog()
br label %46
45: ; preds = %0
br label %46
46: ; preds = %45, %43, %41, %39, %37, %35, %33, %31
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [16 x i8] c"earch and query\00"
@.str.2 = [15 x i8] c"dd a new entry\00"
@.str.3 = [15 x i8] c"elete an entry\00"
@.str.4 = [9 x i8] c"View or \00"
@.str.5 = [24 x i8] c"hange an existing entry\00"
@.str.6 = [4 x i8] c"elp\00"
@.str.7 = [4 x i8] c"uit\00"
@.str.8 = [25 x i8] c"What do you want to do? \00"
define void @menu() {
%1 = tail call i32 (...) @setup_screen()
%2 = tail call i32 @move(i32 4, i32 5)
%3 = tail call i32 @add_bold(i8 signext 83)
%4 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 @move(i32 5, i32 5)
%6 = tail call i32 @add_bold(i8 signext 65)
%7 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%8 = tail call i32 @move(i32 6, i32 5)
%9 = tail call i32 @add_bold(i8 signext 68)
%10 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%11 = tail call i32 @move(i32 7, i32 5)
%12 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%13 = tail call i32 @add_bold(i8 signext 67)
%14 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%15 = tail call i32 @move(i32 11, i32 5)
%16 = tail call i32 @add_bold(i8 signext 72)
%17 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%18 = tail call i32 @move(i32 12, i32 5)
%19 = tail call i32 @add_bold(i8 signext 81)
%20 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%21 = tail call i32 @move(i32 15, i32 5)
%22 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0))
%23 = tail call i32 (...) @refresh()
%24 = tail call i32 (...) @cbreak()
%25 = tail call i32 (...) @getch()
%26 = tail call i32 @tolower(i32 %25)
switch i32 %26, label %41 [
i32 115, label %27
i32 97, label %29
i32 100, label %31
i32 99, label %33
i32 111, label %35
i32 104, label %37
i32 113, label %39
]
27: ; preds = %0
%28 = tail call i32 (...) @search_menu()
br label %41
29: ; preds = %0
%30 = tail call i32 (...) @add_entry()
br label %41
31: ; preds = %0
%32 = tail call i32 (...) @delete_entry()
br label %41
33: ; preds = %0
%34 = tail call i32 (...) @change_entry()
br label %41
35: ; preds = %0
%36 = tail call i32 (...) @config_options()
br label %41
37: ; preds = %0
%38 = tail call i32 (...) @help()
br label %41
39: ; preds = %0
%40 = tail call i32 (...) @quit_prog()
br label %41
41: ; preds = %0, %39, %37, %35, %33, %31, %29, %27
ret void
}