#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*/ cow_echo();
int /*<<< orphan*/ cow_exit();
int /*<<< orphan*/ cow_fortune();
int /*<<< orphan*/ cow_time();
int /*<<< orphan*/ puts(char *);
int select_menu();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/);
int main(void) {
  srand(time(0));
  while (1) {
    switch (select_menu()) {
    case 1:
      cow_fortune();
      break;
    case 2:
      cow_time();
      break;
    case 3:
      cow_echo();
      break;
    case 4:
      cow_exit();
      break;
    default:
      puts("Available menu is 1~4! Please select again.");
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
xor    %eax,%eax
call   1050 <select_menu@plt>
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x3,%eax
ja     11fa <main+0x7a>
mov    -0x10(%rbp),%rax
lea    0xe3f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1090 <cow_fortune@plt>
jmp    1206 <main+0x86>
mov    $0x0,%al
call   10a0 <cow_time@plt>
jmp    1206 <main+0x86>
mov    $0x0,%al
call   1030 <cow_echo@plt>
jmp    1206 <main+0x86>
mov    $0x0,%al
call   1070 <cow_exit@plt>
jmp    1206 <main+0x86>
lea    0xe0f(%rip),%rdi
call   1040 <puts@plt>
jmp    119d <main+0x1d>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
lea    0xe77(%rip),%r14
lea    0xe60(%rip),%rbx
jmp    11c0 <main+0x40>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1070 <cow_exit@plt>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <select_menu@plt>
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     11f0 <main+0x70>
movslq (%rbx,%rax,4),%rax
add    %rbx,%rax
jmp    *%rax
xor    %eax,%eax
call   1090 <cow_fortune@plt>
jmp    11c0 <main+0x40>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <puts@plt>
jmp    11c0 <main+0x40>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   10a0 <cow_time@plt>
jmp    11c0 <main+0x40>
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <cow_echo@plt>
jmp    11c0 <main+0x40>

LLVM IR (-O0):
@.str = [44 x i8] c"Available menu is 1~4! Please select again.\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @time(i32 0)
%3 = call i32 @srand(i32 %2)
br label %4
4: ; preds = %0, %16
%5 = call i32 (...) @select_menu()
switch i32 %5, label %14 [
i32 1, label %6
i32 2, label %8
i32 3, label %10
i32 4, label %12
]
6: ; preds = %4
%7 = call i32 (...) @cow_fortune()
br label %16
8: ; preds = %4
%9 = call i32 (...) @cow_time()
br label %16
10: ; preds = %4
%11 = call i32 (...) @cow_echo()
br label %16
12: ; preds = %4
%13 = call i32 (...) @cow_exit()
br label %16
14: ; preds = %4
%15 = call i32 @puts(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %14, %12, %10, %8, %6
br label %4
}

LLVM IR (-O2):
@.str = [44 x i8] c"Available menu is 1~4! Please select again.\00"
define i32 @main() {
%1 = tail call i32 @time(i32 0)
%2 = tail call i32 @srand(i32 %1)
br label %3
3: ; preds = %15, %0
%4 = tail call i32 (...) @select_menu()
switch i32 %4, label %13 [
i32 1, label %5
i32 2, label %7
i32 3, label %9
i32 4, label %11
]
5: ; preds = %3
%6 = tail call i32 (...) @cow_fortune()
br label %15
7: ; preds = %3
%8 = tail call i32 (...) @cow_time()
br label %15
9: ; preds = %3
%10 = tail call i32 (...) @cow_echo()
br label %15
11: ; preds = %3
%12 = tail call i32 (...) @cow_exit()
br label %15
13: ; preds = %3
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %13, %11, %9, %7, %5
br label %3
}