char *dev_to_subtest(int dev, int test) {
  switch (dev >> 24) {
  case 0x01:
    switch ((dev >> 12) & 0x0fff) {
    case 0x003:
    case 0x053:
    case 0x002:
      switch (test) {
      case 3:
        return "register file";
      case 4:
        return "multiplier";
      case 5:
        return "radix-2 divider";
      case 6:
        return "cache system";
      case 7:
        return "multi-processing";
      case 8:
        return "floating-point unit";
      case 9:
        return "itag cache ram";
      case 10:
        return "dtag cache ram";
      case 11:
        return "idata cache ram";
      case 12:
        return "ddata cache ram";
      case 13:
        return "GRFPU test";
      case 14:
        return "memory management unit";
      default:
        return "sub-test";
      }
      break;
    case 0x011:
      switch (test) {
      case 0:
        return "timer 0";
      case 1:
        return "timer 1";
      case 2:
        return "timer 2";
      case 3:
        return "timer 3";
      case 4:
        return "timer 4";
      case 5:
        return "timer 5";
      case 6:
        return "timer 6";
      case 7:
        return "timer 7";
      case 8:
        return "chain-mode";
      default:
        return "sub-test";
      }
      break;
    default:
      return ("sub-test");
    }
  }
  return "";
}


x86 assembly (clang, -O0):
<dev_to_subtest>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    -0x9(%rbp),%al
sub    $0x1,%al
jne    1329 <dev_to_subtest+0x229>
jmp    111a <dev_to_subtest+0x1a>
mov    -0xc(%rbp),%eax
shr    $0xc,%eax
and    $0xfff,%eax
mov    %eax,-0x14(%rbp)
add    $0xfffffffe,%eax
sub    $0x2,%eax
jb     115b <dev_to_subtest+0x5b>
jmp    1139 <dev_to_subtest+0x39>
mov    -0x14(%rbp),%eax
sub    $0x11,%eax
je     1254 <dev_to_subtest+0x154>
jmp    114a <dev_to_subtest+0x4a>
mov    -0x14(%rbp),%eax
sub    $0x53,%eax
jne    1319 <dev_to_subtest+0x219>
jmp    115b <dev_to_subtest+0x5b>
mov    -0x10(%rbp),%eax
add    $0xfffffffd,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0xb,%eax
ja     1244 <dev_to_subtest+0x144>
mov    -0x20(%rbp),%rax
lea    0xea9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xec9(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1334 <dev_to_subtest+0x234>
lea    0xec7(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1334 <dev_to_subtest+0x234>
lea    0xec2(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1334 <dev_to_subtest+0x234>
lea    0xec2(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1334 <dev_to_subtest+0x234>
lea    0xebf(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1334 <dev_to_subtest+0x234>
lea    0xec0(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1334 <dev_to_subtest+0x234>
lea    0xec4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1334 <dev_to_subtest+0x234>
lea    0xec3(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1334 <dev_to_subtest+0x234>
lea    0xec2(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1334 <dev_to_subtest+0x234>
lea    0xec2(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1334 <dev_to_subtest+0x234>
lea    0xec2(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1334 <dev_to_subtest+0x234>
lea    0xebd(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1334 <dev_to_subtest+0x234>
lea    0xec4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1334 <dev_to_subtest+0x234>
mov    -0x10(%rbp),%eax
mov    %rax,-0x28(%rbp)
sub    $0x8,%rax
ja     1309 <dev_to_subtest+0x209>
mov    -0x28(%rbp),%rax
lea    0xd90(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe98(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1334 <dev_to_subtest+0x234>
lea    0xe90(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1334 <dev_to_subtest+0x234>
lea    0xe88(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1334 <dev_to_subtest+0x234>
lea    0xe80(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1334 <dev_to_subtest+0x234>
lea    0xe78(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1334 <dev_to_subtest+0x234>
lea    0xe70(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1334 <dev_to_subtest+0x234>
lea    0xe68(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1334 <dev_to_subtest+0x234>
lea    0xe60(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1334 <dev_to_subtest+0x234>
lea    0xe58(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1334 <dev_to_subtest+0x234>
lea    0xdff(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1334 <dev_to_subtest+0x234>
lea    0xdef(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1334 <dev_to_subtest+0x234>
lea    0xdef(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<dev_to_subtest>:
mov    %edi,%eax
and    $0xff000000,%eax
cmp    $0x1000000,%eax
jne    1144 <dev_to_subtest+0x44>
shr    $0xc,%edi
and    $0xfff,%edi
lea    0xf9d(%rip),%rax
lea    -0x2(%rdi),%ecx
cmp    $0x2,%ecx
jb     1130 <dev_to_subtest+0x30>
cmp    $0x11,%edi
je     114c <dev_to_subtest+0x4c>
cmp    $0x53,%edi
jne    1162 <dev_to_subtest+0x62>
add    $0xfffffffd,%esi
cmp    $0xc,%esi
jae    1162 <dev_to_subtest+0x62>
movslq %esi,%rax
lea    0x2c66(%rip),%rcx
jmp    115b <dev_to_subtest+0x5b>
lea    0xf80(%rip),%rax
ret
cmp    $0x9,%esi
jae    1162 <dev_to_subtest+0x62>
movslq %esi,%rax
lea    0x2cad(%rip),%rcx
lea    (%rcx,%rax,8),%rax
mov    (%rax),%rax
ret

LLVM IR (-O0):
@.str = [14 x i8] c"register file\00"
@.str.1 = [11 x i8] c"multiplier\00"
@.str.2 = [16 x i8] c"radix-2 divider\00"
@.str.3 = [13 x i8] c"cache system\00"
@.str.4 = [17 x i8] c"multi-processing\00"
@.str.5 = [20 x i8] c"floating-point unit\00"
@.str.6 = [15 x i8] c"itag cache ram\00"
@.str.7 = [15 x i8] c"dtag cache ram\00"
@.str.8 = [16 x i8] c"idata cache ram\00"
@.str.9 = [16 x i8] c"ddata cache ram\00"
@.str.10 = [11 x i8] c"GRFPU test\00"
@.str.11 = [23 x i8] c"memory management unit\00"
@.str.12 = [9 x i8] c"sub-test\00"
@.str.13 = [8 x i8] c"timer 0\00"
@.str.14 = [8 x i8] c"timer 1\00"
@.str.15 = [8 x i8] c"timer 2\00"
@.str.16 = [8 x i8] c"timer 3\00"
@.str.17 = [8 x i8] c"timer 4\00"
@.str.18 = [8 x i8] c"timer 5\00"
@.str.19 = [8 x i8] c"timer 6\00"
@.str.20 = [8 x i8] c"timer 7\00"
@.str.21 = [11 x i8] c"chain-mode\00"
@.str.22 = [1 x i8] zeroinitializer
define i8* @dev_to_subtest(i32 %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %4
%7 = ashr i32 %6, 24
switch i32 %7, label %40 [
i32 1, label %8
]
8: ; preds = %2
%9 = load i32, i32* %4
%10 = ashr i32 %9, 12
%11 = and i32 %10, 4095
switch i32 %11, label %39 [
i32 3, label %12
i32 83, label %12
i32 2, label %12
i32 17, label %27
]
12: ; preds = %8, %8, %8
%13 = load i32, i32* %5
switch i32 %13, label %26 [
i32 3, label %14
i32 4, label %15
i32 5, label %16
i32 6, label %17
i32 7, label %18
i32 8, label %19
i32 9, label %20
i32 10, label %21
i32 11, label %22
i32 12, label %23
i32 13, label %24
i32 14, label %25
]
14: ; preds = %12
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8** %3
br label %41
15: ; preds = %12
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %41
16: ; preds = %12
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8** %3
br label %41
17: ; preds = %12
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8** %3
br label %41
18: ; preds = %12
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8** %3
br label %41
19: ; preds = %12
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8** %3
br label %41
20: ; preds = %12
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i8** %3
br label %41
21: ; preds = %12
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i8** %3
br label %41
22: ; preds = %12
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8** %3
br label %41
23: ; preds = %12
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), i8** %3
br label %41
24: ; preds = %12
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0), i8** %3
br label %41
25: ; preds = %12
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.11, i64 0, i64 0), i8** %3
br label %41
26: ; preds = %12
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i8** %3
br label %41
27: ; preds = %8
%28 = load i32, i32* %5
switch i32 %28, label %38 [
i32 0, label %29
i32 1, label %30
i32 2, label %31
i32 3, label %32
i32 4, label %33
i32 5, label %34
i32 6, label %35
i32 7, label %36
i32 8, label %37
]
29: ; preds = %27
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.13, i64 0, i64 0), i8** %3
br label %41
30: ; preds = %27
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.14, i64 0, i64 0), i8** %3
br label %41
31: ; preds = %27
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.15, i64 0, i64 0), i8** %3
br label %41
32: ; preds = %27
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.16, i64 0, i64 0), i8** %3
br label %41
33: ; preds = %27
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.17, i64 0, i64 0), i8** %3
br label %41
34: ; preds = %27
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.18, i64 0, i64 0), i8** %3
br label %41
35: ; preds = %27
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.19, i64 0, i64 0), i8** %3
br label %41
36: ; preds = %27
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.20, i64 0, i64 0), i8** %3
br label %41
37: ; preds = %27
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.21, i64 0, i64 0), i8** %3
br label %41
38: ; preds = %27
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i8** %3
br label %41
39: ; preds = %8
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i8** %3
br label %41
40: ; preds = %2
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.22, i64 0, i64 0), i8** %3
br label %41
41: ; preds = %40, %39, %38, %37, %36, %35, %34, %33, %32, %31, %30, %29, %26, %25, %24, %23, %22, %21, %20, %19, %18, %17, %16, %15, %14
%42 = load i8*, i8** %3
ret i8* %42
}

LLVM IR (-O2):
@.str = [14 x i8] c"register file\00"
@.str.1 = [11 x i8] c"multiplier\00"
@.str.2 = [16 x i8] c"radix-2 divider\00"
@.str.3 = [13 x i8] c"cache system\00"
@.str.4 = [17 x i8] c"multi-processing\00"
@.str.5 = [20 x i8] c"floating-point unit\00"
@.str.6 = [15 x i8] c"itag cache ram\00"
@.str.7 = [15 x i8] c"dtag cache ram\00"
@.str.8 = [16 x i8] c"idata cache ram\00"
@.str.9 = [16 x i8] c"ddata cache ram\00"
@.str.10 = [11 x i8] c"GRFPU test\00"
@.str.11 = [23 x i8] c"memory management unit\00"
@.str.12 = [9 x i8] c"sub-test\00"
@.str.13 = [8 x i8] c"timer 0\00"
@.str.14 = [8 x i8] c"timer 1\00"
@.str.15 = [8 x i8] c"timer 2\00"
@.str.16 = [8 x i8] c"timer 3\00"
@.str.17 = [8 x i8] c"timer 4\00"
@.str.18 = [8 x i8] c"timer 5\00"
@.str.19 = [8 x i8] c"timer 6\00"
@.str.20 = [8 x i8] c"timer 7\00"
@.str.21 = [11 x i8] c"chain-mode\00"
@.str.22 = [1 x i8] zeroinitializer
@switch.table.dev_to_subtest = [12 x i8*] [i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.11, i64 0, i64 0)]
@switch.table.dev_to_subtest.23 = [9 x i8*] [i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.15, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.18, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.19, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.20, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.21, i64 0, i64 0)]
define i8* @dev_to_subtest(i32 %0, i32 %1) {
%3 = and i32 %0, -16777216
%4 = icmp eq i32 %3, 16777216
br i1 %4, label %5, label %22
5: ; preds = %2
%6 = lshr i32 %0, 12
%7 = and i32 %6, 4095
switch i32 %7, label %22 [
i32 3, label %8
i32 83, label %8
i32 2, label %8
i32 17, label %11
]
8: ; preds = %5, %5, %5
%9 = add i32 %1, -3
%10 = icmp ult i32 %9, 12
br i1 %10, label %13, label %22
11: ; preds = %5
%12 = icmp ult i32 %1, 9
br i1 %12, label %16, label %22
13: ; preds = %8
%14 = sext i32 %9 to i64
%15 = getelementptr inbounds [12 x i8*], [12 x i8*]* @switch.table.dev_to_subtest, i64 0, i64 %14
br label %19
16: ; preds = %11
%17 = sext i32 %1 to i64
%18 = getelementptr inbounds [9 x i8*], [9 x i8*]* @switch.table.dev_to_subtest.23, i64 0, i64 %17
br label %19
19: ; preds = %13, %16
%20 = phi i8** [ %18, %16 ], [ %15, %13 ]
%21 = load i8*, i8** %20
br label %22
22: ; preds = %19, %11, %8, %2, %5
%23 = phi i8* [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), %5 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.22, i64 0, i64 0), %2 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), %8 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), %11 ], [ %21, %19 ]
ret i8* %23
}