#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 3:
    return "VCS";
  case 4:
    return "GVI";
  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     11d0 <target2str+0xc0>
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    11f6 <target2str+0xe6>
lea    0xed6(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f6 <target2str+0xe6>
lea    0xeca(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f6 <target2str+0xe6>
lea    0xec2(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f6 <target2str+0xe6>
lea    0xebd(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f6 <target2str+0xe6>
lea    0xeb1(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f6 <target2str+0xe6>
lea    0xea5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f6 <target2str+0xe6>
lea    0xe9c(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f6 <target2str+0xe6>
lea    0xe9b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f6 <target2str+0xe6>
mov    -0xc(%rbp),%ecx
lea    0x2e66(%rip),%rdi
mov    $0x18,%esi
lea    0xe96(%rip),%rdx
call   1030 <snprintf@plt>
lea    0x2e4e(%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    112b <target2str+0x1b>
movslq %ecx,%rax
lea    0xf46(%rip),%rcx
movslq (%rcx,%rax,4),%rbx
add    %rcx,%rbx
jmp    1146 <target2str+0x36>
lea    0x2f0e(%rip),%rbx
lea    0xf1f(%rip),%rdx
mov    %rbx,%rdi
mov    $0x18,%esi
call   1030 <snprintf@plt>
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 = [4 x i8] c"VCS\00"
@.str.5 = [4 x i8] c"GVI\00"
@.str.6 = [7 x i8] c"Cooler\00"
@.str.7 = [15 x i8] c"Thermal Sensor\00"
@.str.8 = [26 x i8] c"3D Vision Pro Transceiver\00"
@.str.9 = [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 %14 [
i32 0, label %5
i32 1, label %6
i32 8, label %7
i32 2, label %8
i32 3, label %9
i32 4, label %10
i32 5, label %11
i32 6, label %12
i32 7, label %13
]
5: ; preds = %1
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8** %2
br label %17
6: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %17
7: ; preds = %1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %17
8: ; preds = %1
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %17
9: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %17
10: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %17
11: ; preds = %1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %17
12: ; preds = %1
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %17
13: ; preds = %1
store i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i8** %2
br label %17
14: ; preds = %1
%15 = load i32, i32* %3
%16 = 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.9, i64 0, i64 0), i32 %15)
store i8* getelementptr inbounds ([24 x i8], [24 x i8]* @target2str.unknown, i64 0, i64 0), i8** %2
br label %17
17: ; preds = %14, %13, %12, %11, %10, %9, %8, %7, %6, %5
%18 = load i8*, i8** %2
ret i8* %18
}

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 = [4 x i8] c"VCS\00"
@.str.5 = [4 x i8] c"GVI\00"
@.str.6 = [7 x i8] c"Cooler\00"
@.str.7 = [15 x i8] c"Thermal Sensor\00"
@.str.8 = [26 x i8] c"3D Vision Pro Transceiver\00"
@.str.9 = [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 ([4 x i8]* @.str.4 to i64), i64 ptrtoint ([9 x i32]* @reltable.target2str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.5 to i64), i64 ptrtoint ([9 x i32]* @reltable.target2str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.6 to i64), i64 ptrtoint ([9 x i32]* @reltable.target2str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @.str.7 to i64), i64 ptrtoint ([9 x i32]* @reltable.target2str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([26 x i8]* @.str.8 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 = %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.9, i64 0, i64 0), i32 %0)
br label %9
5: ; preds = %1
%6 = sext i32 %0 to i64
%7 = shl i64 %6, 2
%8 = call i8* @llvm.load.relative.i64(i8* bitcast ([9 x i32]* @reltable.target2str to i8*), i64 %7)
br label %9
9: ; preds = %5, %3
%10 = phi i8* [ getelementptr inbounds ([24 x i8], [24 x i8]* @target2str.unknown, i64 0, i64 0), %3 ], [ %8, %5 ]
ret i8* %10
}