#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*/ sprintf(char *, char *, int);
char *asn1id2text(int id) {
  static char data[32];
  static char *strings[] = {
      "none",
      "Boolean",
      "Integer",
      "Bit String",
      "Octet String",
      "NULL",
      "Object Identifier",
      "Object Descriptor",
      "External Reference",
      "Real Number",
      "Enumerated",
      "Embedded PDV",
      "UTF-8 String",
      "Relative Object ID",
      "Reserved (0e)",
      "Reserved (0f)",
      "Sequence",
      "Set",
      "Numeric String",
      "Printable String",
      "Tele-Text String",
      "IA-5 String",
      "UTC Time",
      "Generalized Time",
  };
  if (id > 0 && id <= 0x18) {
    return strings[id];
  } else {
    sprintf(data, "Unknown (%02x)", id);
    return data;
  }
}


x86 assembly (clang, -O0):
<asn1id2text>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    1147 <asn1id2text+0x37>
cmpl   $0x18,-0xc(%rbp)
jg     1147 <asn1id2text+0x37>
movslq -0xc(%rbp),%rcx
lea    0x2ef6(%rip),%rax
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x8(%rbp)
jmp    1168 <asn1id2text+0x58>
mov    -0xc(%rbp),%edx
lea    0x2faf(%rip),%rdi
lea    0xfd5(%rip),%rsi
call   1030 <sprintf@plt>
lea    0x2f9c(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<asn1id2text>:
push   %rbx
mov    %edi,%edx
lea    -0x1(%rdx),%eax
cmp    $0x17,%eax
ja     112d <asn1id2text+0x1d>
mov    %edx,%eax
lea    0xedc(%rip),%rcx
movslq (%rcx,%rax,4),%rbx
add    %rcx,%rbx
jmp    1143 <asn1id2text+0x33>
lea    0x2f0c(%rip),%rbx
lea    0x1052(%rip),%rsi
mov    %rbx,%rdi
call   1030 <sprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@asn1id2text.data = internal global [32 x i8] zeroinitializer
@asn1id2text.strings = internal global [24 x i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.16, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.17, i32 0, i32 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.18, i32 0, i32 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.19, i32 0, i32 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.20, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.21, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.22, i32 0, i32 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.23, i32 0, i32 0)]
@.str = [5 x i8] c"none\00"
@.str.1 = [8 x i8] c"Boolean\00"
@.str.2 = [8 x i8] c"Integer\00"
@.str.3 = [11 x i8] c"Bit String\00"
@.str.4 = [13 x i8] c"Octet String\00"
@.str.5 = [5 x i8] c"NULL\00"
@.str.6 = [18 x i8] c"Object Identifier\00"
@.str.7 = [18 x i8] c"Object Descriptor\00"
@.str.8 = [19 x i8] c"External Reference\00"
@.str.9 = [12 x i8] c"Real Number\00"
@.str.10 = [11 x i8] c"Enumerated\00"
@.str.11 = [13 x i8] c"Embedded PDV\00"
@.str.12 = [13 x i8] c"UTF-8 String\00"
@.str.13 = [19 x i8] c"Relative Object ID\00"
@.str.14 = [14 x i8] c"Reserved (0e)\00"
@.str.15 = [14 x i8] c"Reserved (0f)\00"
@.str.16 = [9 x i8] c"Sequence\00"
@.str.17 = [4 x i8] c"Set\00"
@.str.18 = [15 x i8] c"Numeric String\00"
@.str.19 = [17 x i8] c"Printable String\00"
@.str.20 = [17 x i8] c"Tele-Text String\00"
@.str.21 = [12 x i8] c"IA-5 String\00"
@.str.22 = [9 x i8] c"UTC Time\00"
@.str.23 = [17 x i8] c"Generalized Time\00"
@.str.24 = [15 x i8] c"Unknown (%02x)\00"
define i8* @asn1id2text(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %14
6: ; preds = %1
%7 = load i32, i32* %3
%8 = icmp sle i32 %7, 24
br i1 %8, label %9, label %14
9: ; preds = %6
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [24 x i8*], [24 x i8*]* @asn1id2text.strings, i64 0, i64 %11
%13 = load i8*, i8** %12
store i8* %13, i8** %2
br label %17
14: ; preds = %6, %1
%15 = load i32, i32* %3
%16 = call i32 @sprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @asn1id2text.data, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.24, i64 0, i64 0), i32 %15)
store i8* getelementptr inbounds ([32 x i8], [32 x i8]* @asn1id2text.data, i64 0, i64 0), i8** %2
br label %17
17: ; preds = %14, %9
%18 = load i8*, i8** %2
ret i8* %18
}

LLVM IR (-O2):
@asn1id2text.data = internal global [32 x i8] zeroinitializer
@reltable.asn1id2text = internal unnamed_addr constant [24 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([24 x i32]* @reltable.asn1id2text to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.1 to i64), i64 ptrtoint ([24 x i32]* @reltable.asn1id2text to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.2 to i64), i64 ptrtoint ([24 x i32]* @reltable.asn1id2text to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.3 to i64), i64 ptrtoint ([24 x i32]* @reltable.asn1id2text to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str.4 to i64), i64 ptrtoint ([24 x i32]* @reltable.asn1id2text to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.5 to i64), i64 ptrtoint ([24 x i32]* @reltable.asn1id2text to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.6 to i64), i64 ptrtoint ([24 x i32]* @reltable.asn1id2text to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.7 to i64), i64 ptrtoint ([24 x i32]* @reltable.asn1id2text to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @.str.8 to i64), i64 ptrtoint ([24 x i32]* @reltable.asn1id2text to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.9 to i64), i64 ptrtoint ([24 x i32]* @reltable.asn1id2text to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.10 to i64), i64 ptrtoint ([24 x i32]* @reltable.asn1id2text to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str.11 to i64), i64 ptrtoint ([24 x i32]* @reltable.asn1id2text to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str.12 to i64), i64 ptrtoint ([24 x i32]* @reltable.asn1id2text to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @.str.13 to i64), i64 ptrtoint ([24 x i32]* @reltable.asn1id2text to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.14 to i64), i64 ptrtoint ([24 x i32]* @reltable.asn1id2text to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.15 to i64), i64 ptrtoint ([24 x i32]* @reltable.asn1id2text to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.16 to i64), i64 ptrtoint ([24 x i32]* @reltable.asn1id2text to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.17 to i64), i64 ptrtoint ([24 x i32]* @reltable.asn1id2text to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @.str.18 to i64), i64 ptrtoint ([24 x i32]* @reltable.asn1id2text to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @.str.19 to i64), i64 ptrtoint ([24 x i32]* @reltable.asn1id2text to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @.str.20 to i64), i64 ptrtoint ([24 x i32]* @reltable.asn1id2text to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.21 to i64), i64 ptrtoint ([24 x i32]* @reltable.asn1id2text to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.22 to i64), i64 ptrtoint ([24 x i32]* @reltable.asn1id2text to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @.str.23 to i64), i64 ptrtoint ([24 x i32]* @reltable.asn1id2text to i64)) to i32)]
@.str = [5 x i8] c"none\00"
@.str.1 = [8 x i8] c"Boolean\00"
@.str.2 = [8 x i8] c"Integer\00"
@.str.3 = [11 x i8] c"Bit String\00"
@.str.4 = [13 x i8] c"Octet String\00"
@.str.5 = [5 x i8] c"NULL\00"
@.str.6 = [18 x i8] c"Object Identifier\00"
@.str.7 = [18 x i8] c"Object Descriptor\00"
@.str.8 = [19 x i8] c"External Reference\00"
@.str.9 = [12 x i8] c"Real Number\00"
@.str.10 = [11 x i8] c"Enumerated\00"
@.str.11 = [13 x i8] c"Embedded PDV\00"
@.str.12 = [13 x i8] c"UTF-8 String\00"
@.str.13 = [19 x i8] c"Relative Object ID\00"
@.str.14 = [14 x i8] c"Reserved (0e)\00"
@.str.15 = [14 x i8] c"Reserved (0f)\00"
@.str.16 = [9 x i8] c"Sequence\00"
@.str.17 = [4 x i8] c"Set\00"
@.str.18 = [15 x i8] c"Numeric String\00"
@.str.19 = [17 x i8] c"Printable String\00"
@.str.20 = [17 x i8] c"Tele-Text String\00"
@.str.21 = [12 x i8] c"IA-5 String\00"
@.str.22 = [9 x i8] c"UTC Time\00"
@.str.23 = [17 x i8] c"Generalized Time\00"
@.str.24 = [15 x i8] c"Unknown (%02x)\00"
define i8* @asn1id2text(i32 %0) {
%2 = add i32 %0, -1
%3 = icmp ult i32 %2, 24
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = zext i32 %0 to i64
%6 = shl i64 %5, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([24 x i32]* @reltable.asn1id2text to i8*), i64 %6)
br label %10
8: ; preds = %1
%9 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @asn1id2text.data, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.24, i64 0, i64 0), i32 %0)
br label %10
10: ; preds = %8, %4
%11 = phi i8* [ %7, %4 ], [ getelementptr inbounds ([32 x i8], [32 x i8]* @asn1id2text.data, i64 0, i64 0), %8 ]
ret i8* %11
}