#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*/ assert(int);
int /*<<< orphan*/ free(void *);
int /*<<< orphan*/ meeting_free(void *);
int /*<<< orphan*/ opponent_free(void *);
int /*<<< orphan*/ pool_free(void *);
int /*<<< orphan*/ tournament_free(void *);
void *any_free(void *any) {
  assert(!((any) == NULL));
  switch (*(unsigned short *)any) {
  case 0xA000:
    tournament_free(any);
    break;
  case 0xA002:
    opponent_free(any);
    break;
  case 0xA001:
    pool_free(any);
    break;
  case 0xA003:
    meeting_free(any);
    break;
  default:
    free(any);
    (any) = NULL;
    ;
    break;
  }
  return NULL;
}


x86 assembly (clang, -O0):
<any_free>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
test   %rax,%rax
setne  %al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x8(%rbp),%rax
movzwl (%rax),%eax
add    $0xffff6000,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x3,%eax
ja     11e5 <any_free+0x85>
mov    -0x10(%rbp),%rax
lea    0xe5c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%rdi
call   1040 <tournament_free@plt>
jmp    11f6 <any_free+0x96>
mov    -0x8(%rbp),%rdi
call   1060 <opponent_free@plt>
jmp    11f6 <any_free+0x96>
mov    -0x8(%rbp),%rdi
call   1080 <pool_free@plt>
jmp    11f6 <any_free+0x96>
mov    -0x8(%rbp),%rdi
call   1050 <meeting_free@plt>
jmp    11f6 <any_free+0x96>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<any_free>:
push   %rbx
mov    %rdi,%rbx
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1070 <assert@plt>
movzwl (%rbx),%eax
add    $0x6000,%eax
cmp    $0x3,%ax
ja     119d <any_free+0x3d>
movzwl %ax,%eax
lea    0xe76(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    %rbx,%rdi
call   1040 <tournament_free@plt>
jmp    11c3 <any_free+0x63>
mov    %rbx,%rdi
call   1030 <free@plt>
jmp    11c3 <any_free+0x63>
mov    %rbx,%rdi
call   1080 <pool_free@plt>
jmp    11c3 <any_free+0x63>
mov    %rbx,%rdi
call   1060 <opponent_free@plt>
jmp    11c3 <any_free+0x63>
mov    %rbx,%rdi
call   1050 <meeting_free@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i8* @any_free(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = icmp eq i8* %3, null
%5 = xor i1 %4, true
%6 = zext i1 %5 to i32
%7 = call i32 @assert(i32 %6)
%8 = load i8*, i8** %2
%9 = bitcast i8* %8 to i16*
%10 = load i16, i16* %9
%11 = zext i16 %10 to i32
switch i32 %11, label %24 [
i32 40960, label %12
i32 40962, label %15
i32 40961, label %18
i32 40963, label %21
]
12: ; preds = %1
%13 = load i8*, i8** %2
%14 = call i32 @tournament_free(i8* %13)
br label %27
15: ; preds = %1
%16 = load i8*, i8** %2
%17 = call i32 @opponent_free(i8* %16)
br label %27
18: ; preds = %1
%19 = load i8*, i8** %2
%20 = call i32 @pool_free(i8* %19)
br label %27
21: ; preds = %1
%22 = load i8*, i8** %2
%23 = call i32 @meeting_free(i8* %22)
br label %27
24: ; preds = %1
%25 = load i8*, i8** %2
%26 = call i32 @free(i8* %25)
store i8* null, i8** %2
br label %27
27: ; preds = %24, %21, %18, %15, %12
ret i8* null
}

LLVM IR (-O2):
define noalias i8* @any_free(i8* %0) {
%2 = icmp ne i8* %0, null
%3 = zext i1 %2 to i32
%4 = tail call i32 @assert(i32 %3)
%5 = bitcast i8* %0 to i16*
%6 = load i16, i16* %5
switch i16 %6, label %15 [
i16 -24576, label %7
i16 -24574, label %9
i16 -24575, label %11
i16 -24573, label %13
]
7: ; preds = %1
%8 = tail call i32 @tournament_free(i8* %0)
br label %17
9: ; preds = %1
%10 = tail call i32 @opponent_free(i8* %0)
br label %17
11: ; preds = %1
%12 = tail call i32 @pool_free(i8* %0)
br label %17
13: ; preds = %1
%14 = tail call i32 @meeting_free(i8* %0)
br label %17
15: ; preds = %1
%16 = tail call i32 @free(i8* %0)
br label %17
17: ; preds = %15, %13, %11, %9, %7
ret i8* null
}