char *dev_to_string(unsigned int dev) {
  switch (dev >> 24) {
  case 1:
    switch ((dev >> 12) & 0x0fff) {
    case 0x003:
      return ("LEON3 V8 Processor");
      break;
    case 0x01D:
      return ("GR Ethernet MAC");
      break;
    case 0x014:
      return ("Fast 32-bit PCI Bridge");
      break;
    case 0x053:
      return ("LEON3FT V8 Processor");
      break;
    case 0x011:
      return ("Modular Timer unit");
      break;
    case 0x00D:
      return ("Interrupt Controller");
      break;
    case 0x00C:
      return ("UART");
      break;
    case 0x019:
      return ("OC CAN AHB interface");
      break;
    case 0x01A:
      return ("General Purpose I/O port");
      break;
    case 0x054:
      return ("PROM/SRAM/SDRAM Memory controller with EDAC");
      break;
    case 0x050:
      return ("Generic FT AHB SRAM module");
      break;
    case 0x051:
      return ("Simple FT SRAM Controller");
      break;
    case 0x01F:
      return ("SpaceWire Serial Link");
      break;
    case 0x02D:
      return ("SPI controller");
      break;
    case 0x028:
      return ("I2C master");
      break;
    default:
      return ("Unknown device");
    }
    break;
  case 4:
    switch ((dev >> 12) & 0x0fff) {
    case 0x002:
      return ("Leon2 SPARC V8 Processor");
      break;
    case 0x00F:
      return ("Leon2 Memory Controller");
      break;
    case 0x005:
      return ("Leon2 Interrupt Controller");
      break;
    default:
      return ("Unknown device");
    }
    break;
  default:
    return ("Unknown vendor");
  }
}


x86 assembly (clang, -O0):
<dev_to_string>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
shr    $0x18,%eax
mov    %eax,-0x10(%rbp)
sub    $0x1,%eax
je     112f <dev_to_string+0x2f>
jmp    111e <dev_to_string+0x1e>
mov    -0x10(%rbp),%eax
sub    $0x4,%eax
je     1260 <dev_to_string+0x160>
jmp    12de <dev_to_string+0x1de>
mov    -0xc(%rbp),%eax
shr    $0xc,%eax
and    $0xfff,%eax
add    $0xfffffffd,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x51,%eax
ja     1250 <dev_to_string+0x150>
mov    -0x18(%rbp),%rax
lea    0xea9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xfe1(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12e9 <dev_to_string+0x1e9>
lea    0xfe4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12e9 <dev_to_string+0x1e9>
lea    0xfe4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12e9 <dev_to_string+0x1e9>
lea    0xfeb(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12e9 <dev_to_string+0x1e9>
lea    0xff0(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12e9 <dev_to_string+0x1e9>
lea    0x10fd(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12e9 <dev_to_string+0x1e9>
lea    0xfe3(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12e9 <dev_to_string+0x1e9>
lea    0xfd8(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12e9 <dev_to_string+0x1e9>
lea    0xfdd(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12e9 <dev_to_string+0x1e9>
lea    0xfe6(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12e9 <dev_to_string+0x1e9>
lea    0x1002(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12e9 <dev_to_string+0x1e9>
lea    0x100d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12e9 <dev_to_string+0x1e9>
lea    0x1017(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12e9 <dev_to_string+0x1e9>
lea    0x101d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12e9 <dev_to_string+0x1e9>
lea    0x101c(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12e9 <dev_to_string+0x1e9>
lea    0x1017(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12e9 <dev_to_string+0x1e9>
mov    -0xc(%rbp),%eax
shr    $0xc,%eax
and    $0xfff,%eax
mov    %eax,-0x1c(%rbp)
sub    $0x2,%eax
je     129e <dev_to_string+0x19e>
jmp    127c <dev_to_string+0x17c>
mov    -0x1c(%rbp),%eax
sub    $0x5,%eax
je     12be <dev_to_string+0x1be>
jmp    128d <dev_to_string+0x18d>
mov    -0x1c(%rbp),%eax
sub    $0xf,%eax
je     12ae <dev_to_string+0x1ae>
jmp    12ce <dev_to_string+0x1ce>
lea    0xfd8(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12e9 <dev_to_string+0x1e9>
lea    0xfe1(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12e9 <dev_to_string+0x1e9>
lea    0xfe9(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12e9 <dev_to_string+0x1e9>
lea    0xf99(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12e9 <dev_to_string+0x1e9>
lea    0xfe4(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<dev_to_string>:
mov    %edi,%eax
shr    $0x18,%eax
cmp    $0x4,%al
je     113d <dev_to_string+0x3d>
cmp    $0x1,%al
jne    115d <dev_to_string+0x5d>
shr    $0xc,%edi
and    $0xfff,%edi
add    $0xfffffffd,%edi
cmp    $0x51,%edi
ja     1165 <dev_to_string+0x65>
lea    0x1023(%rip),%rax
lea    0xed4(%rip),%rcx
movslq (%rcx,%rdi,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
lea    0x106e(%rip),%rax
ret
shr    $0xc,%edi
and    $0xfff,%edi
cmp    $0x2,%edi
je     116d <dev_to_string+0x6d>
cmp    $0x5,%edi
je     1175 <dev_to_string+0x75>
cmp    $0xf,%edi
jne    1165 <dev_to_string+0x65>
lea    0x113a(%rip),%rax
ret
lea    0x1165(%rip),%rax
ret
lea    0x1102(%rip),%rax
ret
lea    0x1109(%rip),%rax
ret
lea    0x1132(%rip),%rax
ret
lea    0x1130(%rip),%rax
ret
lea    0x100b(%rip),%rax
ret
lea    0xfd7(%rip),%rax
ret
lea    0x1013(%rip),%rax
ret
lea    0x1020(%rip),%rax
ret
lea    0xfaf(%rip),%rax
ret
lea    0x108a(%rip),%rax
ret
lea    0x10a7(%rip),%rax
ret
lea    0x1090(%rip),%rax
ret
lea    0x103d(%rip),%rax
ret
lea    0x1050(%rip),%rax
ret
lea    0xfa6(%rip),%rax
ret
lea    0xff9(%rip),%rax
ret

LLVM IR (-O0):
@.str = [19 x i8] c"LEON3 V8 Processor\00"
@.str.1 = [16 x i8] c"GR Ethernet MAC\00"
@.str.2 = [23 x i8] c"Fast 32-bit PCI Bridge\00"
@.str.3 = [21 x i8] c"LEON3FT V8 Processor\00"
@.str.4 = [19 x i8] c"Modular Timer unit\00"
@.str.5 = [21 x i8] c"Interrupt Controller\00"
@.str.6 = [5 x i8] c"UART\00"
@.str.7 = [21 x i8] c"OC CAN AHB interface\00"
@.str.8 = [25 x i8] c"General Purpose I/O port\00"
@.str.9 = [44 x i8] c"PROM/SRAM/SDRAM Memory controller with EDAC\00"
@.str.10 = [27 x i8] c"Generic FT AHB SRAM module\00"
@.str.11 = [26 x i8] c"Simple FT SRAM Controller\00"
@.str.12 = [22 x i8] c"SpaceWire Serial Link\00"
@.str.13 = [15 x i8] c"SPI controller\00"
@.str.14 = [11 x i8] c"I2C master\00"
@.str.15 = [15 x i8] c"Unknown device\00"
@.str.16 = [25 x i8] c"Leon2 SPARC V8 Processor\00"
@.str.17 = [24 x i8] c"Leon2 Memory Controller\00"
@.str.18 = [27 x i8] c"Leon2 Interrupt Controller\00"
@.str.19 = [15 x i8] c"Unknown vendor\00"
define i8* @dev_to_string(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = lshr i32 %4, 24
switch i32 %5, label %34 [
i32 1, label %6
i32 4, label %26
]
6: ; preds = %1
%7 = load i32, i32* %3
%8 = lshr i32 %7, 12
%9 = and i32 %8, 4095
switch i32 %9, label %25 [
i32 3, label %10
i32 29, label %11
i32 20, label %12
i32 83, label %13
i32 17, label %14
i32 13, label %15
i32 12, label %16
i32 25, label %17
i32 26, label %18
i32 84, label %19
i32 80, label %20
i32 81, label %21
i32 31, label %22
i32 45, label %23
i32 40, label %24
]
10: ; preds = %6
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8** %2
br label %35
11: ; preds = %6
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %35
12: ; preds = %6
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %35
13: ; preds = %6
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %35
14: ; preds = %6
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %35
15: ; preds = %6
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %35
16: ; preds = %6
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %35
17: ; preds = %6
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %35
18: ; preds = %6
store i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i8** %2
br label %35
19: ; preds = %6
store i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.9, i64 0, i64 0), i8** %2
br label %35
20: ; preds = %6
store i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0), i8** %2
br label %35
21: ; preds = %6
store i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0), i8** %2
br label %35
22: ; preds = %6
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.12, i64 0, i64 0), i8** %2
br label %35
23: ; preds = %6
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.13, i64 0, i64 0), i8** %2
br label %35
24: ; preds = %6
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.14, i64 0, i64 0), i8** %2
br label %35
25: ; preds = %6
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.15, i64 0, i64 0), i8** %2
br label %35
26: ; preds = %1
%27 = load i32, i32* %3
%28 = lshr i32 %27, 12
%29 = and i32 %28, 4095
switch i32 %29, label %33 [
i32 2, label %30
i32 15, label %31
i32 5, label %32
]
30: ; preds = %26
store i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.16, i64 0, i64 0), i8** %2
br label %35
31: ; preds = %26
store i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.17, i64 0, i64 0), i8** %2
br label %35
32: ; preds = %26
store i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.18, i64 0, i64 0), i8** %2
br label %35
33: ; preds = %26
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.15, i64 0, i64 0), i8** %2
br label %35
34: ; preds = %1
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.19, i64 0, i64 0), i8** %2
br label %35
35: ; preds = %34, %33, %32, %31, %30, %25, %24, %23, %22, %21, %20, %19, %18, %17, %16, %15, %14, %13, %12, %11, %10
%36 = load i8*, i8** %2
ret i8* %36
}

LLVM IR (-O2):
@.str = [19 x i8] c"LEON3 V8 Processor\00"
@.str.1 = [16 x i8] c"GR Ethernet MAC\00"
@.str.2 = [23 x i8] c"Fast 32-bit PCI Bridge\00"
@.str.3 = [21 x i8] c"LEON3FT V8 Processor\00"
@.str.4 = [19 x i8] c"Modular Timer unit\00"
@.str.5 = [21 x i8] c"Interrupt Controller\00"
@.str.6 = [5 x i8] c"UART\00"
@.str.7 = [21 x i8] c"OC CAN AHB interface\00"
@.str.8 = [25 x i8] c"General Purpose I/O port\00"
@.str.9 = [44 x i8] c"PROM/SRAM/SDRAM Memory controller with EDAC\00"
@.str.10 = [27 x i8] c"Generic FT AHB SRAM module\00"
@.str.11 = [26 x i8] c"Simple FT SRAM Controller\00"
@.str.12 = [22 x i8] c"SpaceWire Serial Link\00"
@.str.13 = [15 x i8] c"SPI controller\00"
@.str.14 = [11 x i8] c"I2C master\00"
@.str.15 = [15 x i8] c"Unknown device\00"
@.str.16 = [25 x i8] c"Leon2 SPARC V8 Processor\00"
@.str.17 = [24 x i8] c"Leon2 Memory Controller\00"
@.str.18 = [27 x i8] c"Leon2 Interrupt Controller\00"
@.str.19 = [15 x i8] c"Unknown vendor\00"
define i8* @dev_to_string(i32 %0) {
%2 = lshr i32 %0, 24
%3 = trunc i32 %2 to i8
switch i8 %3, label %28 [
i8 1, label %4
i8 4, label %22
]
4: ; preds = %1
%5 = lshr i32 %0, 12
%6 = and i32 %5, 4095
switch i32 %6, label %21 [
i32 3, label %28
i32 29, label %7
i32 20, label %8
i32 83, label %9
i32 17, label %10
i32 13, label %11
i32 12, label %12
i32 25, label %13
i32 26, label %14
i32 84, label %15
i32 80, label %16
i32 81, label %17
i32 31, label %18
i32 45, label %19
i32 40, label %20
]
7: ; preds = %4
br label %28
8: ; preds = %4
br label %28
9: ; preds = %4
br label %28
10: ; preds = %4
br label %28
11: ; preds = %4
br label %28
12: ; preds = %4
br label %28
13: ; preds = %4
br label %28
14: ; preds = %4
br label %28
15: ; preds = %4
br label %28
16: ; preds = %4
br label %28
17: ; preds = %4
br label %28
18: ; preds = %4
br label %28
19: ; preds = %4
br label %28
20: ; preds = %4
br label %28
21: ; preds = %4
br label %28
22: ; preds = %1
%23 = lshr i32 %0, 12
%24 = and i32 %23, 4095
switch i32 %24, label %27 [
i32 2, label %28
i32 15, label %25
i32 5, label %26
]
25: ; preds = %22
br label %28
26: ; preds = %22
br label %28
27: ; preds = %22
br label %28
28: ; preds = %1, %22, %4, %27, %26, %25, %21, %20, %19, %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7
%29 = phi i8* [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.15, i64 0, i64 0), %27 ], [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str.18, i64 0, i64 0), %26 ], [ getelementptr inbounds ([24 x i8], [24 x i8]* @.str.17, i64 0, i64 0), %25 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.15, i64 0, i64 0), %21 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.14, i64 0, i64 0), %20 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.13, i64 0, i64 0), %19 ], [ getelementptr inbounds ([22 x i8], [22 x i8]* @.str.12, i64 0, i64 0), %18 ], [ getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0), %17 ], [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0), %16 ], [ getelementptr inbounds ([44 x i8], [44 x i8]* @.str.9, i64 0, i64 0), %15 ], [ getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), %14 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), %13 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), %12 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), %11 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), %10 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), %9 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), %8 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), %7 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %4 ], [ getelementptr inbounds ([25 x i8], [25 x i8]* @.str.16, i64 0, i64 0), %22 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.19, i64 0, i64 0), %1 ]
ret i8* %29
}