int pet_menu(struct map_session_data *sd, int menunum) {
  if (nullpo_chk("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                 "outputs/2022-01-22/02-19-57/repos/MishimaHaruna/jathena/refs/"
                 "heads/master/src/map/pet.c",
                 873, __func__, (void *)(sd))) {
    return (0);
  };
  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,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rcx
lea    0xe9a(%rip),%rdi
mov    $0x369,%esi
lea    0xf1e(%rip),%rdx
mov    $0x0,%al
call   1050 <nullpo_chk@plt>
cmp    $0x0,%eax
je     11a2 <pet_menu+0x42>
movl   $0x0,-0x4(%rbp)
jmp    1219 <pet_menu+0xb9>
mov    -0x14(%rbp),%eax
mov    %rax,-0x20(%rbp)
sub    $0x4,%rax
ja     1212 <pet_menu+0xb2>
mov    -0x20(%rbp),%rax
lea    0xe42(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1070 <clif_send_petstatus@plt>
jmp    1212 <pet_menu+0xb2>
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1030 <pet_food@plt>
jmp    1212 <pet_menu+0xb2>
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1080 <pet_performance@plt>
jmp    1212 <pet_menu+0xb2>
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1060 <pet_return_egg@plt>
jmp    1212 <pet_menu+0xb2>
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1040 <pet_unequipitem@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pet_menu>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xea5(%rip),%rdi
lea    0xf2e(%rip),%rdx
mov    $0x369,%esi
mov    %rbx,%rcx
xor    %eax,%eax
call   1050 <nullpo_chk@plt>
test   %eax,%eax
je     1192 <pet_menu+0x32>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
cmp    $0x4,%ebp
ja     1189 <pet_menu+0x29>
mov    %ebp,%eax
lea    0xe60(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <clif_send_petstatus@plt>
jmp    1189 <pet_menu+0x29>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <pet_food@plt>
jmp    1189 <pet_menu+0x29>
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <pet_performance@plt>
jmp    1189 <pet_menu+0x29>
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <pet_return_egg@plt>
jmp    1189 <pet_menu+0x29>
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <pet_unequipitem@plt>
jmp    1189 <pet_menu+0x29>

LLVM IR (-O0):
%struct.map_session_data = type opaque
@.str = [144 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/MishimaHaruna/jathena/refs/heads/master/src/map/pet.c\00"
@__func__.pet_menu = [9 x i8] c"pet_menu\00"
define i32 @pet_menu(%struct.map_session_data* %0, i32 %1) {
%3 = alloca i32
%4 = alloca %struct.map_session_data*
%5 = alloca i32
store %struct.map_session_data* %0, %struct.map_session_data** %4
store i32 %1, i32* %5
%6 = load %struct.map_session_data*, %struct.map_session_data** %4
%7 = bitcast %struct.map_session_data* %6 to i8*
%8 = call i32 (i8*, i32, i8*, i8*, ...) bitcast (i32 (...)* @nullpo_chk to i32 (i8*, i32, i8*, i8*, ...)*)(i8* getelementptr inbounds ([144 x i8], [144 x i8]* @.str, i64 0, i64 0), i32 873, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @__func__.pet_menu, i64 0, i64 0), i8* %7)
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 0, i32* %3
br label %29
11: ; preds = %2
%12 = load i32, i32* %5
switch i32 %12, label %28 [
i32 0, label %13
i32 1, label %16
i32 2, label %19
i32 3, label %22
i32 4, label %25
]
13: ; preds = %11
%14 = load %struct.map_session_data*, %struct.map_session_data** %4
%15 = call i32 (%struct.map_session_data*, ...) bitcast (i32 (...)* @clif_send_petstatus to i32 (%struct.map_session_data*, ...)*)(%struct.map_session_data* %14)
br label %28
16: ; preds = %11
%17 = load %struct.map_session_data*, %struct.map_session_data** %4
%18 = call i32 (%struct.map_session_data*, ...) bitcast (i32 (...)* @pet_food to i32 (%struct.map_session_data*, ...)*)(%struct.map_session_data* %17)
br label %28
19: ; preds = %11
%20 = load %struct.map_session_data*, %struct.map_session_data** %4
%21 = call i32 (%struct.map_session_data*, ...) bitcast (i32 (...)* @pet_performance to i32 (%struct.map_session_data*, ...)*)(%struct.map_session_data* %20)
br label %28
22: ; preds = %11
%23 = load %struct.map_session_data*, %struct.map_session_data** %4
%24 = call i32 (%struct.map_session_data*, ...) bitcast (i32 (...)* @pet_return_egg to i32 (%struct.map_session_data*, ...)*)(%struct.map_session_data* %23)
br label %28
25: ; preds = %11
%26 = load %struct.map_session_data*, %struct.map_session_data** %4
%27 = call i32 (%struct.map_session_data*, ...) bitcast (i32 (...)* @pet_unequipitem to i32 (%struct.map_session_data*, ...)*)(%struct.map_session_data* %26)
br label %28
28: ; preds = %11, %25, %22, %19, %16, %13
store i32 0, i32* %3
br label %29
29: ; preds = %28, %10
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
%struct.map_session_data = type opaque
@.str = [144 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/MishimaHaruna/jathena/refs/heads/master/src/map/pet.c\00"
@__func__.pet_menu = [9 x i8] c"pet_menu\00"
define i32 @pet_menu(%struct.map_session_data* %0, i32 %1) {
%3 = bitcast %struct.map_session_data* %0 to i8*
%4 = tail call i32 (i8*, i32, i8*, i8*, ...) bitcast (i32 (...)* @nullpo_chk to i32 (i8*, i32, i8*, i8*, ...)*)(i8* getelementptr inbounds ([144 x i8], [144 x i8]* @.str, i64 0, i64 0), i32 873, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @__func__.pet_menu, i64 0, i64 0), i8* %3)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %17
6: ; preds = %2
switch i32 %1, label %17 [
i32 0, label %7
i32 1, label %9
i32 2, label %11
i32 3, label %13
i32 4, label %15
]
7: ; preds = %6
%8 = tail call i32 (%struct.map_session_data*, ...) bitcast (i32 (...)* @clif_send_petstatus to i32 (%struct.map_session_data*, ...)*)(%struct.map_session_data* %0)
br label %17
9: ; preds = %6
%10 = tail call i32 (%struct.map_session_data*, ...) bitcast (i32 (...)* @pet_food to i32 (%struct.map_session_data*, ...)*)(%struct.map_session_data* %0)
br label %17
11: ; preds = %6
%12 = tail call i32 (%struct.map_session_data*, ...) bitcast (i32 (...)* @pet_performance to i32 (%struct.map_session_data*, ...)*)(%struct.map_session_data* %0)
br label %17
13: ; preds = %6
%14 = tail call i32 (%struct.map_session_data*, ...) bitcast (i32 (...)* @pet_return_egg to i32 (%struct.map_session_data*, ...)*)(%struct.map_session_data* %0)
br label %17
15: ; preds = %6
%16 = tail call i32 (%struct.map_session_data*, ...) bitcast (i32 (...)* @pet_unequipitem to i32 (%struct.map_session_data*, ...)*)(%struct.map_session_data* %0)
br label %17
17: ; preds = %7, %9, %11, %13, %15, %6, %2
ret i32 0
}