#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 int /*<<< orphan*/ typenames;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
const char *spn_typetag_name(int ttag) {
  static const char *const typenames[] = {
      "nil", "bool", "number", "pointer", "object",
  };
  assert(ttag < (sizeof(typenames) / sizeof(typenames[0])));
  return typenames[ttag];
}


x86 assembly (clang, -O0):
<spn_typetag_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movslq -0x4(%rbp),%rax
cmp    $0x5,%rax
setb   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movslq -0x4(%rbp),%rcx
lea    0x2cb5(%rip),%rax
mov    (%rax,%rcx,8),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<spn_typetag_name>:
push   %rbx
movslq %edi,%rbx
xor    %edi,%edi
cmp    $0x5,%ebx
setb   %dil
call   1030 <assert@plt>
lea    0xed7(%rip),%rcx
movslq (%rcx,%rbx,4),%rax
add    %rcx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@spn_typetag_name.typenames = internal constant [5 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i32 0, i32 0)]
@.str = [4 x i8] c"nil\00"
@.str.1 = [5 x i8] c"bool\00"
@.str.2 = [7 x i8] c"number\00"
@.str.3 = [8 x i8] c"pointer\00"
@.str.4 = [7 x i8] c"object\00"
define i8* @spn_typetag_name(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = sext i32 %3 to i64
%5 = icmp ult i64 %4, 5
%6 = zext i1 %5 to i32
%7 = call i32 @assert(i32 %6)
%8 = load i32, i32* %2
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds [5 x i8*], [5 x i8*]* @spn_typetag_name.typenames, i64 0, i64 %9
%11 = load i8*, i8** %10
ret i8* %11
}

LLVM IR (-O2):
@reltable.spn_typetag_name = internal unnamed_addr constant [5 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str to i64), i64 ptrtoint ([5 x i32]* @reltable.spn_typetag_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.1 to i64), i64 ptrtoint ([5 x i32]* @reltable.spn_typetag_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.2 to i64), i64 ptrtoint ([5 x i32]* @reltable.spn_typetag_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.3 to i64), i64 ptrtoint ([5 x i32]* @reltable.spn_typetag_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.4 to i64), i64 ptrtoint ([5 x i32]* @reltable.spn_typetag_name to i64)) to i32)]
@.str = [4 x i8] c"nil\00"
@.str.1 = [5 x i8] c"bool\00"
@.str.2 = [7 x i8] c"number\00"
@.str.3 = [8 x i8] c"pointer\00"
@.str.4 = [7 x i8] c"object\00"
define i8* @spn_typetag_name(i32 %0) {
%2 = sext i32 %0 to i64
%3 = icmp ult i32 %0, 5
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = shl i64 %2, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([5 x i32]* @reltable.spn_typetag_name to i8*), i64 %6)
ret i8* %7
}