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");
      }
    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");
    }
  }
}


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    1324 <dev_to_subtest+0x224>
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    1324 <dev_to_subtest+0x224>
lea    0xec7(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1324 <dev_to_subtest+0x224>
lea    0xec2(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1324 <dev_to_subtest+0x224>
lea    0xec2(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1324 <dev_to_subtest+0x224>
lea    0xebf(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1324 <dev_to_subtest+0x224>
lea    0xec0(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1324 <dev_to_subtest+0x224>
lea    0xec4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1324 <dev_to_subtest+0x224>
lea    0xec3(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1324 <dev_to_subtest+0x224>
lea    0xec2(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1324 <dev_to_subtest+0x224>
lea    0xec2(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1324 <dev_to_subtest+0x224>
lea    0xec2(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1324 <dev_to_subtest+0x224>
lea    0xebd(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1324 <dev_to_subtest+0x224>
lea    0xec4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1324 <dev_to_subtest+0x224>
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    1324 <dev_to_subtest+0x224>
lea    0xe90(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1324 <dev_to_subtest+0x224>
lea    0xe88(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1324 <dev_to_subtest+0x224>
lea    0xe80(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1324 <dev_to_subtest+0x224>
lea    0xe78(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1324 <dev_to_subtest+0x224>
lea    0xe70(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1324 <dev_to_subtest+0x224>
lea    0xe68(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1324 <dev_to_subtest+0x224>
lea    0xe60(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1324 <dev_to_subtest+0x224>
lea    0xe58(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1324 <dev_to_subtest+0x224>
lea    0xdff(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1324 <dev_to_subtest+0x224>
lea    0xdef(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<dev_to_subtest>:
mov    %edi,%ecx
and    $0xff000000,%ecx
cmp    $0x1000000,%ecx
jne    115c <dev_to_subtest+0x5c>
shr    $0xc,%edi
and    $0xfff,%edi
lea    0xf9b(%rip),%rax
lea    -0x2(%rdi),%ecx
cmp    $0x2,%ecx
jb     1132 <dev_to_subtest+0x32>
cmp    $0x11,%edi
je     1146 <dev_to_subtest+0x46>
cmp    $0x53,%edi
jne    115c <dev_to_subtest+0x5c>
add    $0xfffffffd,%esi
cmp    $0xc,%esi
jae    115c <dev_to_subtest+0x5c>
movslq %esi,%rax
lea    0x2c64(%rip),%rcx
jmp    1155 <dev_to_subtest+0x55>
cmp    $0x9,%esi
jae    115c <dev_to_subtest+0x5c>
movslq %esi,%rax
lea    0x2cb3(%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"
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 %40
15: ; preds = %12
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %40
16: ; preds = %12
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8** %3
br label %40
17: ; preds = %12
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8** %3
br label %40
18: ; preds = %12
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8** %3
br label %40
19: ; preds = %12
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8** %3
br label %40
20: ; preds = %12
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i8** %3
br label %40
21: ; preds = %12
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i8** %3
br label %40
22: ; preds = %12
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8** %3
br label %40
23: ; preds = %12
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), i8** %3
br label %40
24: ; preds = %12
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0), i8** %3
br label %40
25: ; preds = %12
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.11, i64 0, i64 0), i8** %3
br label %40
26: ; preds = %12
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i8** %3
br label %40
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 %40
30: ; preds = %27
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.14, i64 0, i64 0), i8** %3
br label %40
31: ; preds = %27
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.15, i64 0, i64 0), i8** %3
br label %40
32: ; preds = %27
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.16, i64 0, i64 0), i8** %3
br label %40
33: ; preds = %27
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.17, i64 0, i64 0), i8** %3
br label %40
34: ; preds = %27
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.18, i64 0, i64 0), i8** %3
br label %40
35: ; preds = %27
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.19, i64 0, i64 0), i8** %3
br label %40
36: ; preds = %27
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.20, i64 0, i64 0), i8** %3
br label %40
37: ; preds = %27
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.21, i64 0, i64 0), i8** %3
br label %40
38: ; preds = %27
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i8** %3
br label %40
39: ; preds = %8
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i8** %3
br label %40
40: ; preds = %14, %15, %16, %17, %18, %19, %20, %21, %22, %23, %24, %25, %26, %29, %30, %31, %32, %33, %34, %35, %36, %37, %38, %39, %2
%41 = load i8*, i8** %3
ret i8* %41
}

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"
@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.22 = [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.22, 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, %5, %2
%23 = phi i8* [ undef, %2 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), %5 ], [ 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
}