#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_gameplay_screen(struct castable *castable,
                               const char *type_name) {
  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, "gameplay_screen") == 0)
    return castable;
  return NULL;
}


x86 assembly (clang, -O0):
<try_cast_gameplay_screen>:
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_gameplay_screen+0x37>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11c4 <try_cast_gameplay_screen+0xb4>
mov    -0x18(%rbp),%rdi
lea    0xeb7(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    116e <try_cast_gameplay_screen+0x5e>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11c4 <try_cast_gameplay_screen+0xb4>
mov    -0x18(%rbp),%rdi
lea    0xe99(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1195 <try_cast_gameplay_screen+0x85>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11c4 <try_cast_gameplay_screen+0xb4>
mov    -0x18(%rbp),%rdi
lea    0xe79(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11bc <try_cast_gameplay_screen+0xac>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11c4 <try_cast_gameplay_screen+0xb4>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<try_cast_gameplay_screen>:
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     116e <try_cast_gameplay_screen+0x5e>
lea    0xed4(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     116e <try_cast_gameplay_screen+0x5e>
lea    0xec9(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     116e <try_cast_gameplay_screen+0x5e>
lea    0xebc(%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 = [9 x i8] c"castable\00"
@.str.1 = [9 x i8] c"simulant\00"
@.str.2 = [7 x i8] c"entity\00"
@.str.3 = [16 x i8] c"gameplay_screen\00"
define i8* @try_cast_gameplay_screen(%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 ([9 x i8], [9 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 %34
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 %34
19: ; preds = %12
%20 = load i8*, i8** %5
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([7 x i8], [7 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 %34
26: ; preds = %19
%27 = load i8*, i8** %5
%28 = call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([16 x i8], [16 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 %34
33: ; preds = %26
store i8* null, i8** %3
br label %34
34: ; preds = %33, %30, %23, %16, %9
%35 = load i8*, i8** %3
ret i8* %35
}

LLVM IR (-O2):
%struct.castable = type opaque
@.str = [9 x i8] c"castable\00"
@.str.1 = [9 x i8] c"simulant\00"
@.str.2 = [7 x i8] c"entity\00"
@.str.3 = [16 x i8] c"gameplay_screen\00"
define i8* @try_cast_gameplay_screen(%struct.castable* readnone %0, i8* %1) {
%3 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([9 x i8], [9 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 %22
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 %22
12: ; preds = %7
%13 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([7 x i8], [7 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 %22
17: ; preds = %12
%18 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
%20 = bitcast %struct.castable* %0 to i8*
%21 = select i1 %19, i8* %20, i8* null
br label %22
22: ; preds = %17, %15, %10, %5
%23 = phi i8* [ %6, %5 ], [ %11, %10 ], [ %16, %15 ], [ %21, %17 ]
ret i8* %23
}