#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 uint16_t;
typedef int /*<<< orphan*/ names;

/* Variables and functions */
const char *getHardwareType(uint16_t hardwareVersion) {
  static const char *names[] = {
      "Unknown",
      "HW_LOGIC_BOARD_V2",
      "HW_LOGIC_BOARD_V3",
      "HW_LOGIC_BOARD_V4",
  };
  const char *name = "Unknown";
  if (hardwareVersion < (sizeof(names) / sizeof(names[0]))) {
    name = names[hardwareVersion];
  }
  return name;
}


x86 assembly (clang, -O0):
<getHardwareType>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
lea    0xef2(%rip),%rax
mov    %rax,-0x10(%rbp)
movslq -0x4(%rbp),%rax
cmp    $0x4,%rax
jae    1133 <getHardwareType+0x33>
movslq -0x4(%rbp),%rcx
lea    0x2f05(%rip),%rax
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<getHardwareType>:
cmp    $0x3,%edi
ja     1116 <getHardwareType+0x16>
mov    %edi,%eax
lea    0xef2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
ret
lea    0xef3(%rip),%rax
ret

LLVM IR (-O0):
@getHardwareType.names = internal global [4 x i8*] [i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i32 0, i32 0)]
@.str = [8 x i8] c"Unknown\00"
@.str.1 = [18 x i8] c"HW_LOGIC_BOARD_V2\00"
@.str.2 = [18 x i8] c"HW_LOGIC_BOARD_V3\00"
@.str.3 = [18 x i8] c"HW_LOGIC_BOARD_V4\00"
define i8* @getHardwareType(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
store i32 %0, i32* %2
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %3
%4 = load i32, i32* %2
%5 = sext i32 %4 to i64
%6 = icmp ult i64 %5, 4
br i1 %6, label %7, label %12
7: ; preds = %1
%8 = load i32, i32* %2
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds [4 x i8*], [4 x i8*]* @getHardwareType.names, i64 0, i64 %9
%11 = load i8*, i8** %10
store i8* %11, i8** %3
br label %12
12: ; preds = %7, %1
%13 = load i8*, i8** %3
ret i8* %13
}

LLVM IR (-O2):
@reltable.getHardwareType = internal unnamed_addr constant [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str to i64), i64 ptrtoint ([4 x i32]* @reltable.getHardwareType to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.1 to i64), i64 ptrtoint ([4 x i32]* @reltable.getHardwareType to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.2 to i64), i64 ptrtoint ([4 x i32]* @reltable.getHardwareType to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.3 to i64), i64 ptrtoint ([4 x i32]* @reltable.getHardwareType to i64)) to i32)]
@.str = [8 x i8] c"Unknown\00"
@.str.1 = [18 x i8] c"HW_LOGIC_BOARD_V2\00"
@.str.2 = [18 x i8] c"HW_LOGIC_BOARD_V3\00"
@.str.3 = [18 x i8] c"HW_LOGIC_BOARD_V4\00"
define i8* @getHardwareType(i32 %0) {
%2 = icmp ult i32 %0, 4
br i1 %2, label %3, label %7
3: ; preds = %1
%4 = zext i32 %0 to i64
%5 = shl i64 %4, 2
%6 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.getHardwareType to i8*), i64 %5)
br label %7
7: ; preds = %3, %1
%8 = phi i8* [ %6, %3 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %8
}