#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*/ exit_sys();
int get_input(char *);
int /*<<< orphan*/ i_send_msg();
int /*<<< orphan*/ print_menu();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ read_chat_history();
int /*<<< orphan*/ reply();
int /*<<< orphan*/ send_file();
int /*<<< orphan*/ sleep(int);
int menu() {
  sleep(1);
  print_menu();
  char command;
  while (1 == get_input(&command)) {
    switch (command) {
    case 'h':
      print_menu();
      break;
    case 's':
      i_send_msg();
      break;
    case 'r':
      reply();
      break;
    case 'f':
      send_file();
      break;
    case 'c':
      read_chat_history();
      break;
    case 'e':
      exit_sys();
      break;
    default:
      printf(">");
      break;
    }
  }
  return (0);
}


x86 assembly (clang, -O0):
<menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x1,%edi
call   10a0 <sleep@plt>
mov    $0x0,%al
call   1080 <print_menu@plt>
lea    -0x1(%rbp),%rdi
call   10b0 <get_input@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
jne    1244 <menu+0xb4>
movsbl -0x1(%rbp),%eax
add    $0xffffff9d,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x10,%eax
ja     1233 <menu+0xa3>
mov    -0x10(%rbp),%rax
lea    0xe1e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1080 <print_menu@plt>
jmp    123f <menu+0xaf>
mov    $0x0,%al
call   1030 <i_send_msg@plt>
jmp    123f <menu+0xaf>
mov    $0x0,%al
call   1060 <reply@plt>
jmp    123f <menu+0xaf>
mov    $0x0,%al
call   1090 <send_file@plt>
jmp    123f <menu+0xaf>
mov    $0x0,%al
call   1040 <read_chat_history@plt>
jmp    123f <menu+0xaf>
mov    $0x0,%al
call   1070 <exit_sys@plt>
jmp    123f <menu+0xaf>
lea    0xe0a(%rip),%rdi
call   1050 <printf@plt>
jmp    11a9 <menu+0x19>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<menu>:
push   %r14
push   %rbx
push   %rax
mov    $0x1,%edi
call   10a0 <sleep@plt>
xor    %eax,%eax
call   1080 <print_menu@plt>
lea    0x7(%rsp),%rdi
call   10b0 <get_input@plt>
cmp    $0x1,%eax
jne    1229 <menu+0x99>
lea    0x7(%rsp),%r14
lea    0xe40(%rip),%rbx
jmp    11dd <menu+0x4d>
mov    $0x3e,%edi
call   1030 <putchar@plt>
nopl   0x0(%rax)
mov    %r14,%rdi
call   10b0 <get_input@plt>
cmp    $0x1,%eax
jne    1229 <menu+0x99>
movsbl 0x7(%rsp),%eax
add    $0xffffff9d,%eax
cmp    $0x10,%eax
ja     11c2 <menu+0x32>
movslq (%rbx,%rax,4),%rax
add    %rbx,%rax
jmp    *%rax
xor    %eax,%eax
call   1050 <read_chat_history@plt>
jmp    11d0 <menu+0x40>
xor    %eax,%eax
call   1070 <exit_sys@plt>
jmp    11d0 <menu+0x40>
xor    %eax,%eax
call   1090 <send_file@plt>
jmp    11d0 <menu+0x40>
xor    %eax,%eax
call   1080 <print_menu@plt>
jmp    11d0 <menu+0x40>
xor    %eax,%eax
call   1060 <reply@plt>
jmp    11d0 <menu+0x40>
xor    %eax,%eax
call   1040 <i_send_msg@plt>
jmp    11d0 <menu+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c">\00"
define i32 @menu() {
%1 = alloca i8
%2 = call i32 @sleep(i32 1)
%3 = call i32 (...) @print_menu()
br label %4
4: ; preds = %24, %0
%5 = call i32 @get_input(i8* %1)
%6 = icmp eq i32 1, %5
br i1 %6, label %7, label %25
7: ; preds = %4
%8 = load i8, i8* %1
%9 = sext i8 %8 to i32
switch i32 %9, label %22 [
i32 104, label %10
i32 115, label %12
i32 114, label %14
i32 102, label %16
i32 99, label %18
i32 101, label %20
]
10: ; preds = %7
%11 = call i32 (...) @print_menu()
br label %24
12: ; preds = %7
%13 = call i32 (...) @i_send_msg()
br label %24
14: ; preds = %7
%15 = call i32 (...) @reply()
br label %24
16: ; preds = %7
%17 = call i32 (...) @send_file()
br label %24
18: ; preds = %7
%19 = call i32 (...) @read_chat_history()
br label %24
20: ; preds = %7
%21 = call i32 (...) @exit_sys()
br label %24
22: ; preds = %7
%23 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %24
24: ; preds = %22, %20, %18, %16, %14, %12, %10
br label %4
25: ; preds = %4
ret i32 0
}

LLVM IR (-O2):
define i32 @menu() {
%1 = alloca i8
%2 = tail call i32 @sleep(i32 1)
%3 = tail call i32 (...) @print_menu()
%4 = call i32 @get_input(i8* %1)
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %26
6: ; preds = %0, %23
%7 = load i8, i8* %1
%8 = sext i8 %7 to i32
switch i32 %8, label %21 [
i32 104, label %9
i32 115, label %11
i32 114, label %13
i32 102, label %15
i32 99, label %17
i32 101, label %19
]
9: ; preds = %6
%10 = call i32 (...) @print_menu()
br label %23
11: ; preds = %6
%12 = call i32 (...) @i_send_msg()
br label %23
13: ; preds = %6
%14 = call i32 (...) @reply()
br label %23
15: ; preds = %6
%16 = call i32 (...) @send_file()
br label %23
17: ; preds = %6
%18 = call i32 (...) @read_chat_history()
br label %23
19: ; preds = %6
%20 = call i32 (...) @exit_sys()
br label %23
21: ; preds = %6
%22 = call i32 @putchar(i32 62)
br label %23
23: ; preds = %21, %19, %17, %15, %13, %11, %9
%24 = call i32 @get_input(i8* %1)
%25 = icmp eq i32 %24, 1
br i1 %25, label %6, label %26
26: ; preds = %23, %0
ret i32 0
}