#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 */
typedef void castable;

/* Variables and functions */
scalar_t__ strcmp(char const *, char *);
void *try_cast_player(struct castable *castable, const char *type_name) {
  if (strcmp(type_name, "equatable") == 0)
    return castable;
  if (strcmp(type_name, "castable") == 0)
    return castable;
  if (strcmp(type_name, "simulant") == 0)
    return castable;
  if (strcmp(type_name, "entity") == 0)
    return castable;
  if (strcmp(type_name, "player") == 0)
    return castable;
  return NULL;
}


x86 assembly (clang, -O0):
<try_cast_player>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xed5(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1147 <try_cast_player+0x37>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11eb <try_cast_player+0xdb>
mov    -0x18(%rbp),%rdi
lea    0xeb8(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    116e <try_cast_player+0x5e>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11eb <try_cast_player+0xdb>
mov    -0x18(%rbp),%rdi
lea    0xe9a(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1195 <try_cast_player+0x85>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11eb <try_cast_player+0xdb>
mov    -0x18(%rbp),%rdi
lea    0xe7c(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11bc <try_cast_player+0xac>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11eb <try_cast_player+0xdb>
mov    -0x18(%rbp),%rdi
lea    0xe5c(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11e3 <try_cast_player+0xd3>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11eb <try_cast_player+0xdb>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<try_cast_player>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xedf(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1182 <try_cast_player+0x72>
lea    0xed5(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1182 <try_cast_player+0x72>
lea    0xeca(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1182 <try_cast_player+0x72>
lea    0xebf(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1182 <try_cast_player+0x72>
lea    0xeb2(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
cmovne %rcx,%r14
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.castable = type opaque
@.str = [10 x i8] c"equatable\00"
@.str.1 = [9 x i8] c"castable\00"
@.str.2 = [9 x i8] c"simulant\00"
@.str.3 = [7 x i8] c"entity\00"
@.str.4 = [7 x i8] c"player\00"
define i8* @try_cast_player(%struct.castable* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca %struct.castable*
%5 = alloca i8*
store %struct.castable* %0, %struct.castable** %4
store i8* %1, i8** %5
%6 = load i8*, i8** %5
%7 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load %struct.castable*, %struct.castable** %4
%11 = bitcast %struct.castable* %10 to i8*
store i8* %11, i8** %3
br label %41
12: ; preds = %2
%13 = load i8*, i8** %5
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = load %struct.castable*, %struct.castable** %4
%18 = bitcast %struct.castable* %17 to i8*
store i8* %18, i8** %3
br label %41
19: ; preds = %12
%20 = load i8*, i8** %5
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %19
%24 = load %struct.castable*, %struct.castable** %4
%25 = bitcast %struct.castable* %24 to i8*
store i8* %25, i8** %3
br label %41
26: ; preds = %19
%27 = load i8*, i8** %5
%28 = call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %26
%31 = load %struct.castable*, %struct.castable** %4
%32 = bitcast %struct.castable* %31 to i8*
store i8* %32, i8** %3
br label %41
33: ; preds = %26
%34 = load i8*, i8** %5
%35 = call i64 @strcmp(i8* %34, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %33
%38 = load %struct.castable*, %struct.castable** %4
%39 = bitcast %struct.castable* %38 to i8*
store i8* %39, i8** %3
br label %41
40: ; preds = %33
store i8* null, i8** %3
br label %41
41: ; preds = %40, %37, %30, %23, %16, %9
%42 = load i8*, i8** %3
ret i8* %42
}

LLVM IR (-O2):
%struct.castable = type opaque
@.str = [10 x i8] c"equatable\00"
@.str.1 = [9 x i8] c"castable\00"
@.str.2 = [9 x i8] c"simulant\00"
@.str.3 = [7 x i8] c"entity\00"
@.str.4 = [7 x i8] c"player\00"
define i8* @try_cast_player(%struct.castable* readnone %0, i8* %1) {
%3 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = bitcast %struct.castable* %0 to i8*
br label %27
7: ; preds = %2
%8 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = bitcast %struct.castable* %0 to i8*
br label %27
12: ; preds = %7
%13 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = bitcast %struct.castable* %0 to i8*
br label %27
17: ; preds = %12
%18 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = bitcast %struct.castable* %0 to i8*
br label %27
22: ; preds = %17
%23 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
%25 = bitcast %struct.castable* %0 to i8*
%26 = select i1 %24, i8* %25, i8* null
br label %27
27: ; preds = %22, %20, %15, %10, %5
%28 = phi i8* [ %6, %5 ], [ %11, %10 ], [ %16, %15 ], [ %21, %20 ], [ %26, %22 ]
ret i8* %28
}