#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*/ snprintf(char *, int, char *, int);
const char *target2str(int n) {
  static char unknown[24];
  switch (n) {
  case 0:
    return "X Screen";
  case 1:
    return "GPU";
  case 8:
    return "Display";
  case 2:
    return "Frame Lock";
  case 5:
    return "Cooler";
  case 6:
    return "Thermal Sensor";
  case 7:
    return "3D Vision Pro Transceiver";
  default:
    snprintf(unknown, 24, "Unknown (%d)", n);
    return unknown;
  }
}


x86 assembly (clang, -O0):
<target2str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x8,%rax
ja     11b0 <target2str+0xa0>
mov    -0x18(%rbp),%rax
lea    0xec9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xedd(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d6 <target2str+0xc6>
lea    0xed6(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d6 <target2str+0xc6>
lea    0xeca(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d6 <target2str+0xc6>
lea    0xec2(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d6 <target2str+0xc6>
lea    0xebd(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d6 <target2str+0xc6>
lea    0xeb4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d6 <target2str+0xc6>
lea    0xeb3(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d6 <target2str+0xc6>
mov    -0xc(%rbp),%ecx
lea    0x2e86(%rip),%rdi
mov    $0x18,%esi
lea    0xeae(%rip),%rdx
call   1030 <snprintf@plt>
lea    0x2e6e(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<target2str>:
push   %rbx
mov    %edi,%ecx
cmp    $0x9,%edi
jae    1122 <target2str+0x12>
mov    $0x1e7,%eax
bt     %ecx,%eax
jb     113f <target2str+0x2f>
lea    0x2f17(%rip),%rbx
lea    0xf20(%rip),%rdx
mov    %rbx,%rdi
mov    $0x18,%esi
call   1030 <snprintf@plt>
jmp    1150 <target2str+0x40>
movslq %ecx,%rax
lea    0xf17(%rip),%rcx
movslq (%rcx,%rax,4),%rbx
add    %rcx,%rbx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@target2str.unknown = internal global [24 x i8] zeroinitializer
@.str = [9 x i8] c"X Screen\00"
@.str.1 = [4 x i8] c"GPU\00"
@.str.2 = [8 x i8] c"Display\00"
@.str.3 = [11 x i8] c"Frame Lock\00"
@.str.4 = [7 x i8] c"Cooler\00"
@.str.5 = [15 x i8] c"Thermal Sensor\00"
@.str.6 = [26 x i8] c"3D Vision Pro Transceiver\00"
@.str.7 = [13 x i8] c"Unknown (%d)\00"
define i8* @target2str(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %12 [
i32 0, label %5
i32 1, label %6
i32 8, label %7
i32 2, label %8
i32 5, label %9
i32 6, label %10
i32 7, label %11
]
5: ; preds = %1
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8** %2
br label %15
6: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %15
7: ; preds = %1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %15
8: ; preds = %1
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %15
9: ; preds = %1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %15
10: ; preds = %1
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %15
11: ; preds = %1
store i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %15
12: ; preds = %1
%13 = load i32, i32* %3
%14 = call i32 @snprintf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @target2str.unknown, i64 0, i64 0), i32 24, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i32 %13)
store i8* getelementptr inbounds ([24 x i8], [24 x i8]* @target2str.unknown, i64 0, i64 0), i8** %2
br label %15
15: ; preds = %12, %11, %10, %9, %8, %7, %6, %5
%16 = load i8*, i8** %2
ret i8* %16
}

LLVM IR (-O2):
@target2str.unknown = internal global [24 x i8] zeroinitializer
@.str = [9 x i8] c"X Screen\00"
@.str.1 = [4 x i8] c"GPU\00"
@.str.2 = [8 x i8] c"Display\00"
@.str.3 = [11 x i8] c"Frame Lock\00"
@.str.4 = [7 x i8] c"Cooler\00"
@.str.5 = [15 x i8] c"Thermal Sensor\00"
@.str.6 = [26 x i8] c"3D Vision Pro Transceiver\00"
@.str.7 = [13 x i8] c"Unknown (%d)\00"
@reltable.target2str = [9 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str to i64), i64 ptrtoint ([9 x i32]* @reltable.target2str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.1 to i64), i64 ptrtoint ([9 x i32]* @reltable.target2str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.3 to i64), i64 ptrtoint ([9 x i32]* @reltable.target2str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str to i64), i64 ptrtoint ([9 x i32]* @reltable.target2str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str to i64), i64 ptrtoint ([9 x i32]* @reltable.target2str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.4 to i64), i64 ptrtoint ([9 x i32]* @reltable.target2str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @.str.5 to i64), i64 ptrtoint ([9 x i32]* @reltable.target2str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([26 x i8]* @.str.6 to i64), i64 ptrtoint ([9 x i32]* @reltable.target2str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.2 to i64), i64 ptrtoint ([9 x i32]* @reltable.target2str to i64)) to i32)]
define i8* @target2str(i32 %0) {
%2 = icmp ult i32 %0, 9
br i1 %2, label %5, label %3
3: ; preds = %5, %1
%4 = tail call i32 @snprintf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @target2str.unknown, i64 0, i64 0), i32 24, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i32 %0)
br label %14
5: ; preds = %1
%6 = trunc i32 %0 to i16
%7 = lshr i16 487, %6
%8 = and i16 %7, 1
%9 = icmp eq i16 %8, 0
br i1 %9, label %3, label %10
10: ; preds = %5
%11 = sext i32 %0 to i64
%12 = shl i64 %11, 2
%13 = call i8* @llvm.load.relative.i64(i8* bitcast ([9 x i32]* @reltable.target2str to i8*), i64 %12)
br label %14
14: ; preds = %10, %3
%15 = phi i8* [ getelementptr inbounds ([24 x i8], [24 x i8]* @target2str.unknown, i64 0, i64 0), %3 ], [ %13, %10 ]
ret i8* %15
}