#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 getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ read_chat_history();
int /*<<< orphan*/ sleep(int);
int menu() {
  sleep(1);
  printf("----------help----menu---------\n");
  printf("\t r--report to user\n");
  printf("\t c--chat history\n");
  printf("\t h--help menu\n");
  printf("\t e--exit the system\n");
  printf("----------help_menu---------\n");
  int command = 0;
  printf("input command>");
  command = getchar();
  switch (command) {
  case 'c':
    read_chat_history();
    break;
  case 'e':
    exit_sys();
    break;
  case 'r':
  default:
    menu();
    break;
  }
  getchar();
  return (0);
}


x86 assembly (clang, -O0):
<menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x1,%edi
call   1080 <sleep@plt>
lea    0xe87(%rip),%rdi
call   1050 <printf@plt>
lea    0xe9c(%rip),%rdi
call   1050 <printf@plt>
lea    0xea5(%rip),%rdi
call   1050 <printf@plt>
lea    0xeac(%rip),%rdi
call   1050 <printf@plt>
lea    0xeb0(%rip),%rdi
call   1050 <printf@plt>
lea    0xeba(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
lea    0xec5(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
sub    $0x63,%eax
je     120d <menu+0xad>
jmp    11eb <menu+0x8b>
mov    -0x8(%rbp),%eax
sub    $0x65,%eax
je     1219 <menu+0xb9>
jmp    11fc <menu+0x9c>
mov    -0x8(%rbp),%eax
sub    $0x72,%eax
je     1225 <menu+0xc5>
jmp    122a <menu+0xca>
mov    $0x0,%al
call   1030 <read_chat_history@plt>
jmp    122f <menu+0xcf>
mov    $0x0,%al
call   1070 <exit_sys@plt>
jmp    122f <menu+0xcf>
jmp    122a <menu+0xca>
call   1040 <menu@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<menu>:
push   %rax
mov    $0x1,%edi
call   1090 <sleep@plt>
lea    0xe8d(%rip),%rdi
call   1030 <puts@plt>
lea    0xea1(%rip),%rdi
call   1030 <puts@plt>
lea    0xea9(%rip),%rdi
call   1030 <puts@plt>
lea    0xeaf(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb2(%rip),%rdi
call   1030 <puts@plt>
lea    0xebb(%rip),%rdi
call   1030 <puts@plt>
lea    0xe36(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
cmp    $0x65,%eax
je     11e9 <menu+0x79>
cmp    $0x63,%eax
jne    11f2 <menu+0x82>
xor    %eax,%eax
call   1040 <read_chat_history@plt>
jmp    11f7 <menu+0x87>
xor    %eax,%eax
call   1080 <exit_sys@plt>
jmp    11f7 <menu+0x87>
call   1050 <menu@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [33 x i8] c"----------help----menu---------\0A\00"
@.str.1 = [21 x i8] c"\09 r--report to user\0A\00"
@.str.2 = [19 x i8] c"\09 c--chat history\0A\00"
@.str.3 = [16 x i8] c"\09 h--help menu\0A\00"
@.str.4 = [22 x i8] c"\09 e--exit the system\0A\00"
@.str.5 = [30 x i8] c"----------help_menu---------\0A\00"
@.str.6 = [15 x i8] c"input command>\00"
define i32 @menu() {
%1 = alloca i32
%2 = call i32 @sleep(i32 1)
%3 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %1
%9 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
%10 = call i32 (...) @getchar()
store i32 %10, i32* %1
%11 = load i32, i32* %1
switch i32 %11, label %17 [
i32 99, label %12
i32 101, label %14
i32 114, label %16
]
12: ; preds = %0
%13 = call i32 (...) @read_chat_history()
br label %19
14: ; preds = %0
%15 = call i32 (...) @exit_sys()
br label %19
16: ; preds = %0
br label %17
17: ; preds = %0, %16
%18 = call i32 @menu()
br label %19
19: ; preds = %17, %14, %12
%20 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@.str.6 = [15 x i8] c"input command>\00"
@str = [32 x i8] c"----------help----menu---------\00"
@str.7 = [20 x i8] c"\09 r--report to user\00"
@str.8 = [18 x i8] c"\09 c--chat history\00"
@str.9 = [15 x i8] c"\09 h--help menu\00"
@str.10 = [21 x i8] c"\09 e--exit the system\00"
@str.11 = [29 x i8] c"----------help_menu---------\00"
define i32 @menu() {
%1 = tail call i32 @sleep(i32 1)
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.7, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.8, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.9, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.10, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.11, i64 0, i64 0))
%8 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
%9 = tail call i32 (...) @getchar()
switch i32 %9, label %14 [
i32 99, label %10
i32 101, label %12
]
10: ; preds = %0
%11 = tail call i32 (...) @read_chat_history()
br label %16
12: ; preds = %0
%13 = tail call i32 (...) @exit_sys()
br label %16
14: ; preds = %0
%15 = tail call i32 @menu()
br label %16
16: ; preds = %14, %12, %10
%17 = tail call i32 (...) @getchar()
ret i32 0
}