unsigned int mel_get_device_code(unsigned int dev_type) {
  unsigned int code = 0;
  if (dev_type & ((1 << 0))) {
    dev_type = (1 << 0);
  }
  if (dev_type & ((1 << 10))) {
    dev_type = (1 << 10);
  }
  if (!code) {
    switch (dev_type) {
    case (1 << 0):
      code = 0x90;
      break;
    case (1 << 1):
      code = 0x98;
      break;
    case (1 << 2):
      code = 0x9C;
      break;
    case (1 << 3):
      code = 0x9D;
      break;
    case (1 << 4):
      code = 0xC2;
      break;
    case (1 << 5):
      code = 0xC5;
      break;
    case (1 << 6):
      code = 0xA8;
      break;
    case (1 << 7):
      code = 0xAF;
      break;
    case (1 << 26):
      code = 0xD8;
      break;
    case (1 << 9):
      code = 0xF0;
      break;
    case (1 << 13):
      code = 0xCC;
      break;
    case (1 << 10):
      code = 0xF1;
      break;
    case (1 << 11):
      code = 0xF2;
      break;
    case (1 << 12):
      code = 0xF4;
      break;
    case (1 << 14):
      code = 0xCD;
      break;
    case (1 << 23):
      code = 0xF8;
      break;
    case (1 << 24):
      code = 0xAB;
      break;
    case (1 << 15):
      code = 0xE8;
      break;
    case (1 << 16):
      code = 0xE9;
      break;
    case (1 << 17):
      code = 0xEA;
      break;
    case (1 << 20):
      code = 0xD0;
      break;
    case (1 << 21):
      code = 0xD1;
      break;
    case (1 << 22):
      code = 0xD2;
      break;
    case (1 << 18):
      code = 0xEB;
      break;
    case (1 << 19):
      code = 0xEC;
      break;
    case (1 << 25):
      code = 0xEE;
      break;
    case (1 << 8):
      code = 0xAE;
      break;
    }
  }
  return (code);
}


x86 assembly (clang, -O0):
<mel_get_device_code>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1124 <mel_get_device_code+0x24>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0x400,%eax
cmp    $0x0,%eax
je     113c <mel_get_device_code+0x3c>
movl   $0x400,-0x4(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1480 <mel_get_device_code+0x380>
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0x1,%eax
je     133c <mel_get_device_code+0x23c>
jmp    115a <mel_get_device_code+0x5a>
mov    -0xc(%rbp),%eax
sub    $0x2,%eax
je     1348 <mel_get_device_code+0x248>
jmp    116b <mel_get_device_code+0x6b>
mov    -0xc(%rbp),%eax
sub    $0x4,%eax
je     1354 <mel_get_device_code+0x254>
jmp    117c <mel_get_device_code+0x7c>
mov    -0xc(%rbp),%eax
sub    $0x8,%eax
je     1360 <mel_get_device_code+0x260>
jmp    118d <mel_get_device_code+0x8d>
mov    -0xc(%rbp),%eax
sub    $0x10,%eax
je     136c <mel_get_device_code+0x26c>
jmp    119e <mel_get_device_code+0x9e>
mov    -0xc(%rbp),%eax
sub    $0x20,%eax
je     1378 <mel_get_device_code+0x278>
jmp    11af <mel_get_device_code+0xaf>
mov    -0xc(%rbp),%eax
sub    $0x40,%eax
je     1384 <mel_get_device_code+0x284>
jmp    11c0 <mel_get_device_code+0xc0>
mov    -0xc(%rbp),%eax
sub    $0x80,%eax
je     1390 <mel_get_device_code+0x290>
jmp    11d3 <mel_get_device_code+0xd3>
mov    -0xc(%rbp),%eax
sub    $0x100,%eax
je     1474 <mel_get_device_code+0x374>
jmp    11e6 <mel_get_device_code+0xe6>
mov    -0xc(%rbp),%eax
sub    $0x200,%eax
je     13a8 <mel_get_device_code+0x2a8>
jmp    11f9 <mel_get_device_code+0xf9>
mov    -0xc(%rbp),%eax
sub    $0x400,%eax
je     13c0 <mel_get_device_code+0x2c0>
jmp    120c <mel_get_device_code+0x10c>
mov    -0xc(%rbp),%eax
sub    $0x800,%eax
je     13cc <mel_get_device_code+0x2cc>
jmp    121f <mel_get_device_code+0x11f>
mov    -0xc(%rbp),%eax
sub    $0x1000,%eax
je     13d8 <mel_get_device_code+0x2d8>
jmp    1232 <mel_get_device_code+0x132>
mov    -0xc(%rbp),%eax
sub    $0x2000,%eax
je     13b4 <mel_get_device_code+0x2b4>
jmp    1245 <mel_get_device_code+0x145>
mov    -0xc(%rbp),%eax
sub    $0x4000,%eax
je     13e4 <mel_get_device_code+0x2e4>
jmp    1258 <mel_get_device_code+0x158>
mov    -0xc(%rbp),%eax
sub    $0x8000,%eax
je     1408 <mel_get_device_code+0x308>
jmp    126b <mel_get_device_code+0x16b>
mov    -0xc(%rbp),%eax
sub    $0x10000,%eax
je     1414 <mel_get_device_code+0x314>
jmp    127e <mel_get_device_code+0x17e>
mov    -0xc(%rbp),%eax
sub    $0x20000,%eax
je     1420 <mel_get_device_code+0x320>
jmp    1291 <mel_get_device_code+0x191>
mov    -0xc(%rbp),%eax
sub    $0x40000,%eax
je     1450 <mel_get_device_code+0x350>
jmp    12a4 <mel_get_device_code+0x1a4>
mov    -0xc(%rbp),%eax
sub    $0x80000,%eax
je     145c <mel_get_device_code+0x35c>
jmp    12b7 <mel_get_device_code+0x1b7>
mov    -0xc(%rbp),%eax
sub    $0x100000,%eax
je     142c <mel_get_device_code+0x32c>
jmp    12ca <mel_get_device_code+0x1ca>
mov    -0xc(%rbp),%eax
sub    $0x200000,%eax
je     1438 <mel_get_device_code+0x338>
jmp    12dd <mel_get_device_code+0x1dd>
mov    -0xc(%rbp),%eax
sub    $0x400000,%eax
je     1444 <mel_get_device_code+0x344>
jmp    12f0 <mel_get_device_code+0x1f0>
mov    -0xc(%rbp),%eax
sub    $0x800000,%eax
je     13f0 <mel_get_device_code+0x2f0>
jmp    1303 <mel_get_device_code+0x203>
mov    -0xc(%rbp),%eax
sub    $0x1000000,%eax
je     13fc <mel_get_device_code+0x2fc>
jmp    1316 <mel_get_device_code+0x216>
mov    -0xc(%rbp),%eax
sub    $0x2000000,%eax
je     1468 <mel_get_device_code+0x368>
jmp    1329 <mel_get_device_code+0x229>
mov    -0xc(%rbp),%eax
sub    $0x4000000,%eax
je     139c <mel_get_device_code+0x29c>
jmp    147b <mel_get_device_code+0x37b>
movl   $0x90,-0x8(%rbp)
jmp    147b <mel_get_device_code+0x37b>
movl   $0x98,-0x8(%rbp)
jmp    147b <mel_get_device_code+0x37b>
movl   $0x9c,-0x8(%rbp)
jmp    147b <mel_get_device_code+0x37b>
movl   $0x9d,-0x8(%rbp)
jmp    147b <mel_get_device_code+0x37b>
movl   $0xc2,-0x8(%rbp)
jmp    147b <mel_get_device_code+0x37b>
movl   $0xc5,-0x8(%rbp)
jmp    147b <mel_get_device_code+0x37b>
movl   $0xa8,-0x8(%rbp)
jmp    147b <mel_get_device_code+0x37b>
movl   $0xaf,-0x8(%rbp)
jmp    147b <mel_get_device_code+0x37b>
movl   $0xd8,-0x8(%rbp)
jmp    147b <mel_get_device_code+0x37b>
movl   $0xf0,-0x8(%rbp)
jmp    147b <mel_get_device_code+0x37b>
movl   $0xcc,-0x8(%rbp)
jmp    147b <mel_get_device_code+0x37b>
movl   $0xf1,-0x8(%rbp)
jmp    147b <mel_get_device_code+0x37b>
movl   $0xf2,-0x8(%rbp)
jmp    147b <mel_get_device_code+0x37b>
movl   $0xf4,-0x8(%rbp)
jmp    147b <mel_get_device_code+0x37b>
movl   $0xcd,-0x8(%rbp)
jmp    147b <mel_get_device_code+0x37b>
movl   $0xf8,-0x8(%rbp)
jmp    147b <mel_get_device_code+0x37b>
movl   $0xab,-0x8(%rbp)
jmp    147b <mel_get_device_code+0x37b>
movl   $0xe8,-0x8(%rbp)
jmp    147b <mel_get_device_code+0x37b>
movl   $0xe9,-0x8(%rbp)
jmp    147b <mel_get_device_code+0x37b>
movl   $0xea,-0x8(%rbp)
jmp    147b <mel_get_device_code+0x37b>
movl   $0xd0,-0x8(%rbp)
jmp    147b <mel_get_device_code+0x37b>
movl   $0xd1,-0x8(%rbp)
jmp    147b <mel_get_device_code+0x37b>
movl   $0xd2,-0x8(%rbp)
jmp    147b <mel_get_device_code+0x37b>
movl   $0xeb,-0x8(%rbp)
jmp    147b <mel_get_device_code+0x37b>
movl   $0xec,-0x8(%rbp)
jmp    147b <mel_get_device_code+0x37b>
movl   $0xee,-0x8(%rbp)
jmp    147b <mel_get_device_code+0x37b>
movl   $0xae,-0x8(%rbp)
jmp    1480 <mel_get_device_code+0x380>
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<mel_get_device_code>:
test   $0x1,%dil
mov    $0x1,%eax
cmove  %edi,%eax
test   $0x400,%eax
mov    $0x400,%ecx
cmove  %eax,%ecx
xor    %eax,%eax
cmp    $0x1fff,%ecx
jle    1161 <mel_get_device_code+0x61>
cmp    $0xfffff,%ecx
jg     1188 <mel_get_device_code+0x88>
cmp    $0xffff,%ecx
jle    11f0 <mel_get_device_code+0xf0>
cmp    $0x3ffff,%ecx
jg     126a <mel_get_device_code+0x16a>
cmp    $0x10000,%ecx
je     129a <mel_get_device_code+0x19a>
cmp    $0x20000,%ecx
jne    12d5 <mel_get_device_code+0x1d5>
mov    $0xea,%eax
ret
cmp    $0x7f,%ecx
jg     11be <mel_get_device_code+0xbe>
add    $0xffffffff,%ecx
cmp    $0x3f,%ecx
ja     12d5 <mel_get_device_code+0x1d5>
lea    0xe87(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    $0x90,%eax
ret
cmp    $0x7fffff,%ecx
jle    121a <mel_get_device_code+0x11a>
cmp    $0x1ffffff,%ecx
jg     1284 <mel_get_device_code+0x184>
cmp    $0x800000,%ecx
je     12c4 <mel_get_device_code+0x1c4>
cmp    $0x1000000,%ecx
jne    12d5 <mel_get_device_code+0x1d5>
mov    $0xab,%eax
ret
cmp    $0x3ff,%ecx
jg     1244 <mel_get_device_code+0x144>
cmp    $0x80,%ecx
je     12ca <mel_get_device_code+0x1ca>
cmp    $0x100,%ecx
je     12d0 <mel_get_device_code+0x1d0>
cmp    $0x200,%ecx
jne    12d5 <mel_get_device_code+0x1d5>
mov    $0xf0,%eax
ret
cmp    $0x2000,%ecx
je     12d6 <mel_get_device_code+0x1d6>
cmp    $0x4000,%ecx
je     12dc <mel_get_device_code+0x1dc>
cmp    $0x8000,%ecx
jne    12d5 <mel_get_device_code+0x1d5>
mov    $0xe8,%eax
ret
cmp    $0x100000,%ecx
je     12e2 <mel_get_device_code+0x1e2>
cmp    $0x200000,%ecx
je     12e8 <mel_get_device_code+0x1e8>
cmp    $0x400000,%ecx
jne    12d5 <mel_get_device_code+0x1d5>
mov    $0xd2,%eax
ret
cmp    $0x400,%ecx
je     12ee <mel_get_device_code+0x1ee>
cmp    $0x800,%ecx
je     12f4 <mel_get_device_code+0x1f4>
cmp    $0x1000,%ecx
jne    12d5 <mel_get_device_code+0x1d5>
mov    $0xf4,%eax
ret
cmp    $0x40000,%ecx
je     12fa <mel_get_device_code+0x1fa>
cmp    $0x80000,%ecx
jne    12d5 <mel_get_device_code+0x1d5>
mov    $0xec,%eax
ret
cmp    $0x2000000,%ecx
je     1300 <mel_get_device_code+0x200>
cmp    $0x4000000,%ecx
jne    12d5 <mel_get_device_code+0x1d5>
mov    $0xd8,%eax
ret
mov    $0xe9,%eax
ret
mov    $0x98,%eax
ret
mov    $0x9c,%eax
ret
mov    $0x9d,%eax
ret
mov    $0xc2,%eax
ret
mov    $0xc5,%eax
ret
mov    $0xa8,%eax
ret
mov    $0xf8,%eax
ret
mov    $0xaf,%eax
ret
mov    $0xae,%eax
ret
mov    $0xcc,%eax
ret
mov    $0xcd,%eax
ret
mov    $0xd0,%eax
ret
mov    $0xd1,%eax
ret
mov    $0xf1,%eax
ret
mov    $0xf2,%eax
ret
mov    $0xeb,%eax
ret
mov    $0xee,%eax
ret

LLVM IR (-O0):
define i32 @mel_get_device_code(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
%4 = load i32, i32* %2
%5 = and i32 %4, 1
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %1
store i32 1, i32* %2
br label %8
8: ; preds = %7, %1
%9 = load i32, i32* %2
%10 = and i32 %9, 1024
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %8
store i32 1024, i32* %2
br label %13
13: ; preds = %12, %8
%14 = load i32, i32* %3
%15 = icmp ne i32 %14, 0
br i1 %15, label %46, label %16
16: ; preds = %13
%17 = load i32, i32* %2
switch i32 %17, label %45 [
i32 1, label %18
i32 2, label %19
i32 4, label %20
i32 8, label %21
i32 16, label %22
i32 32, label %23
i32 64, label %24
i32 128, label %25
i32 67108864, label %26
i32 512, label %27
i32 8192, label %28
i32 1024, label %29
i32 2048, label %30
i32 4096, label %31
i32 16384, label %32
i32 8388608, label %33
i32 16777216, label %34
i32 32768, label %35
i32 65536, label %36
i32 131072, label %37
i32 1048576, label %38
i32 2097152, label %39
i32 4194304, label %40
i32 262144, label %41
i32 524288, label %42
i32 33554432, label %43
i32 256, label %44
]
18: ; preds = %16
store i32 144, i32* %3
br label %45
19: ; preds = %16
store i32 152, i32* %3
br label %45
20: ; preds = %16
store i32 156, i32* %3
br label %45
21: ; preds = %16
store i32 157, i32* %3
br label %45
22: ; preds = %16
store i32 194, i32* %3
br label %45
23: ; preds = %16
store i32 197, i32* %3
br label %45
24: ; preds = %16
store i32 168, i32* %3
br label %45
25: ; preds = %16
store i32 175, i32* %3
br label %45
26: ; preds = %16
store i32 216, i32* %3
br label %45
27: ; preds = %16
store i32 240, i32* %3
br label %45
28: ; preds = %16
store i32 204, i32* %3
br label %45
29: ; preds = %16
store i32 241, i32* %3
br label %45
30: ; preds = %16
store i32 242, i32* %3
br label %45
31: ; preds = %16
store i32 244, i32* %3
br label %45
32: ; preds = %16
store i32 205, i32* %3
br label %45
33: ; preds = %16
store i32 248, i32* %3
br label %45
34: ; preds = %16
store i32 171, i32* %3
br label %45
35: ; preds = %16
store i32 232, i32* %3
br label %45
36: ; preds = %16
store i32 233, i32* %3
br label %45
37: ; preds = %16
store i32 234, i32* %3
br label %45
38: ; preds = %16
store i32 208, i32* %3
br label %45
39: ; preds = %16
store i32 209, i32* %3
br label %45
40: ; preds = %16
store i32 210, i32* %3
br label %45
41: ; preds = %16
store i32 235, i32* %3
br label %45
42: ; preds = %16
store i32 236, i32* %3
br label %45
43: ; preds = %16
store i32 238, i32* %3
br label %45
44: ; preds = %16
store i32 174, i32* %3
br label %45
45: ; preds = %16, %44, %43, %42, %41, %40, %39, %38, %37, %36, %35, %34, %33, %32, %31, %30, %29, %28, %27, %26, %25, %24, %23, %22, %21, %20, %19, %18
br label %46
46: ; preds = %45, %13
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
define i32 @mel_get_device_code(i32 %0) {
%2 = and i32 %0, 1
%3 = icmp eq i32 %2, 0
%4 = select i1 %3, i32 %0, i32 1
%5 = and i32 %4, 1024
%6 = icmp eq i32 %5, 0
%7 = select i1 %6, i32 %4, i32 1024
switch i32 %7, label %35 [
i32 1, label %8
i32 2, label %9
i32 4, label %10
i32 8, label %11
i32 16, label %12
i32 32, label %13
i32 64, label %14
i32 128, label %15
i32 67108864, label %16
i32 512, label %17
i32 8192, label %18
i32 1024, label %19
i32 2048, label %20
i32 4096, label %21
i32 16384, label %22
i32 8388608, label %23
i32 16777216, label %24
i32 32768, label %25
i32 65536, label %26
i32 131072, label %27
i32 1048576, label %28
i32 2097152, label %29
i32 4194304, label %30
i32 262144, label %31
i32 524288, label %32
i32 33554432, label %33
i32 256, label %34
]
8: ; preds = %1
br label %35
9: ; preds = %1
br label %35
10: ; preds = %1
br label %35
11: ; preds = %1
br label %35
12: ; preds = %1
br label %35
13: ; preds = %1
br label %35
14: ; preds = %1
br label %35
15: ; preds = %1
br label %35
16: ; preds = %1
br label %35
17: ; preds = %1
br label %35
18: ; preds = %1
br label %35
19: ; preds = %1
br label %35
20: ; preds = %1
br label %35
21: ; preds = %1
br label %35
22: ; preds = %1
br label %35
23: ; preds = %1
br label %35
24: ; preds = %1
br label %35
25: ; preds = %1
br label %35
26: ; preds = %1
br label %35
27: ; preds = %1
br label %35
28: ; preds = %1
br label %35
29: ; preds = %1
br label %35
30: ; preds = %1
br label %35
31: ; preds = %1
br label %35
32: ; preds = %1
br label %35
33: ; preds = %1
br label %35
34: ; preds = %1
br label %35
35: ; preds = %8, %9, %10, %11, %12, %13, %14, %15, %16, %17, %18, %19, %20, %21, %22, %23, %24, %25, %26, %27, %28, %29, %30, %31, %32, %33, %34, %1
%36 = phi i32 [ 0, %1 ], [ 174, %34 ], [ 238, %33 ], [ 236, %32 ], [ 235, %31 ], [ 210, %30 ], [ 209, %29 ], [ 208, %28 ], [ 234, %27 ], [ 233, %26 ], [ 232, %25 ], [ 171, %24 ], [ 248, %23 ], [ 205, %22 ], [ 244, %21 ], [ 242, %20 ], [ 241, %19 ], [ 204, %18 ], [ 240, %17 ], [ 216, %16 ], [ 175, %15 ], [ 168, %14 ], [ 197, %13 ], [ 194, %12 ], [ 157, %11 ], [ 156, %10 ], [ 152, %9 ], [ 144, %8 ]
ret i32 %36
}