#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 */
struct map_session_data {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ clif_send_petstatus(struct map_session_data *);
int /*<<< orphan*/ pet_food(struct map_session_data *);
int /*<<< orphan*/ pet_performance(struct map_session_data *);
int /*<<< orphan*/ pet_return_egg(struct map_session_data *);
int /*<<< orphan*/ pet_unequipitem(struct map_session_data *);
int pet_menu(struct map_session_data *sd, int menunum) {
  switch (menunum) {
  case 0:
    clif_send_petstatus(sd);
    break;
  case 1:
    pet_food(sd);
    break;
  case 2:
    pet_performance(sd);
    break;
  case 3:
    pet_return_egg(sd);
    break;
  case 4:
    pet_unequipitem(sd);
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<pet_menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x4,%rax
ja     11c5 <pet_menu+0x75>
mov    -0x18(%rbp),%rax
lea    0xe85(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%rdi
call   1060 <clif_send_petstatus@plt>
jmp    11c5 <pet_menu+0x75>
mov    -0x8(%rbp),%rdi
call   1030 <pet_food@plt>
jmp    11c5 <pet_menu+0x75>
mov    -0x8(%rbp),%rdi
call   1070 <pet_performance@plt>
jmp    11c5 <pet_menu+0x75>
mov    -0x8(%rbp),%rdi
call   1050 <pet_return_egg@plt>
jmp    11c5 <pet_menu+0x75>
mov    -0x8(%rbp),%rdi
call   1040 <pet_unequipitem@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pet_menu>:
push   %rax
cmp    $0x4,%esi
ja     1189 <pet_menu+0x39>
mov    %esi,%eax
lea    0xea1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
call   1060 <clif_send_petstatus@plt>
jmp    1189 <pet_menu+0x39>
call   1030 <pet_food@plt>
jmp    1189 <pet_menu+0x39>
call   1070 <pet_performance@plt>
jmp    1189 <pet_menu+0x39>
call   1050 <pet_return_egg@plt>
jmp    1189 <pet_menu+0x39>
call   1040 <pet_unequipitem@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.map_session_data = type { i32 }
define i32 @pet_menu(%struct.map_session_data* %0, i32 %1) {
%3 = alloca %struct.map_session_data*
%4 = alloca i32
store %struct.map_session_data* %0, %struct.map_session_data** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
switch i32 %5, label %21 [
i32 0, label %6
i32 1, label %9
i32 2, label %12
i32 3, label %15
i32 4, label %18
]
6: ; preds = %2
%7 = load %struct.map_session_data*, %struct.map_session_data** %3
%8 = call i32 @clif_send_petstatus(%struct.map_session_data* %7)
br label %21
9: ; preds = %2
%10 = load %struct.map_session_data*, %struct.map_session_data** %3
%11 = call i32 @pet_food(%struct.map_session_data* %10)
br label %21
12: ; preds = %2
%13 = load %struct.map_session_data*, %struct.map_session_data** %3
%14 = call i32 @pet_performance(%struct.map_session_data* %13)
br label %21
15: ; preds = %2
%16 = load %struct.map_session_data*, %struct.map_session_data** %3
%17 = call i32 @pet_return_egg(%struct.map_session_data* %16)
br label %21
18: ; preds = %2
%19 = load %struct.map_session_data*, %struct.map_session_data** %3
%20 = call i32 @pet_unequipitem(%struct.map_session_data* %19)
br label %21
21: ; preds = %2, %18, %15, %12, %9, %6
ret i32 0
}

LLVM IR (-O2):
%struct.map_session_data = type { i32 }
define i32 @pet_menu(%struct.map_session_data* %0, i32 %1) {
switch i32 %1, label %13 [
i32 0, label %3
i32 1, label %5
i32 2, label %7
i32 3, label %9
i32 4, label %11
]
3: ; preds = %2
%4 = tail call i32 @clif_send_petstatus(%struct.map_session_data* %0)
br label %13
5: ; preds = %2
%6 = tail call i32 @pet_food(%struct.map_session_data* %0)
br label %13
7: ; preds = %2
%8 = tail call i32 @pet_performance(%struct.map_session_data* %0)
br label %13
9: ; preds = %2
%10 = tail call i32 @pet_return_egg(%struct.map_session_data* %0)
br label %13
11: ; preds = %2
%12 = tail call i32 @pet_unequipitem(%struct.map_session_data* %0)
br label %13
13: ; preds = %2, %11, %9, %7, %5, %3
ret i32 0
}