int bar_cnv(int bar_type) {
  switch (bar_type) {
  case 2:
  case (2 << 4) + 3:
    return 0;
  case 4:
    return 1;
  case (1 << 4) + 4:
    bar_type |= (2 << 8);
    break;
  case (1 << 8) + (4 << 4) + 4:
    bar_type |= (2 << 12);
    break;
  case (1 << 12) + (4 << 8) + (4 << 4) + 4:
    bar_type |= (2 << 16);
    break;
  case (4 << 4) + 1:
  case (4 << 8) + (4 << 4) + 1:
  case (4 << 12) + (4 << 8) + (4 << 4) + 1:
    bar_type <<= 4;
    bar_type |= 3;
    break;
  case (4 << 4) + 4:
    bar_type = (4 << 12) + (3 << 8) + (2 << 4) + 4;
    break;
  }
  return bar_type;
}


x86 assembly (clang, -O0):
<bar_cnv>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0x2,%eax
je     11bc <bar_cnv+0xbc>
jmp    111b <bar_cnv+0x1b>
mov    -0xc(%rbp),%eax
sub    $0x4,%eax
je     11c8 <bar_cnv+0xc8>
jmp    112c <bar_cnv+0x2c>
mov    -0xc(%rbp),%eax
sub    $0x14,%eax
je     11d4 <bar_cnv+0xd4>
jmp    113d <bar_cnv+0x3d>
mov    -0xc(%rbp),%eax
sub    $0x23,%eax
je     11bc <bar_cnv+0xbc>
jmp    114e <bar_cnv+0x4e>
mov    -0xc(%rbp),%eax
sub    $0x41,%eax
je     1204 <bar_cnv+0x104>
jmp    115f <bar_cnv+0x5f>
mov    -0xc(%rbp),%eax
sub    $0x44,%eax
je     121b <bar_cnv+0x11b>
jmp    1170 <bar_cnv+0x70>
mov    -0xc(%rbp),%eax
sub    $0x144,%eax
je     11e4 <bar_cnv+0xe4>
jmp    1183 <bar_cnv+0x83>
mov    -0xc(%rbp),%eax
sub    $0x441,%eax
je     1204 <bar_cnv+0x104>
jmp    1196 <bar_cnv+0x96>
mov    -0xc(%rbp),%eax
sub    $0x1444,%eax
je     11f4 <bar_cnv+0xf4>
jmp    11a9 <bar_cnv+0xa9>
mov    -0xc(%rbp),%eax
sub    $0x4441,%eax
je     1204 <bar_cnv+0x104>
jmp    1222 <bar_cnv+0x122>
movl   $0x0,-0x4(%rbp)
jmp    1228 <bar_cnv+0x128>
movl   $0x1,-0x4(%rbp)
jmp    1228 <bar_cnv+0x128>
mov    -0x8(%rbp),%eax
or     $0x200,%eax
mov    %eax,-0x8(%rbp)
jmp    1222 <bar_cnv+0x122>
mov    -0x8(%rbp),%eax
or     $0x2000,%eax
mov    %eax,-0x8(%rbp)
jmp    1222 <bar_cnv+0x122>
mov    -0x8(%rbp),%eax
or     $0x20000,%eax
mov    %eax,-0x8(%rbp)
jmp    1222 <bar_cnv+0x122>
mov    -0x8(%rbp),%eax
shl    $0x4,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
or     $0x3,%eax
mov    %eax,-0x8(%rbp)
jmp    1222 <bar_cnv+0x122>
movl   $0x4324,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<bar_cnv>:
cmp    $0x43,%edi
jg     1120 <bar_cnv+0x20>
lea    -0x2(%rdi),%ecx
cmp    $0x21,%ecx
ja     1157 <bar_cnv+0x57>
xor    %eax,%eax
lea    0xeea(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
ret
cmp    $0x440,%edi
jle    1142 <bar_cnv+0x42>
cmp    $0x441,%edi
je     115c <bar_cnv+0x5c>
cmp    $0x1444,%edi
je     117b <bar_cnv+0x7b>
cmp    $0x4441,%edi
je     115c <bar_cnv+0x5c>
jmp    1154 <bar_cnv+0x54>
cmp    $0x44,%edi
je     1173 <bar_cnv+0x73>
cmp    $0x144,%edi
jne    1154 <bar_cnv+0x54>
mov    $0x2144,%edi
mov    %edi,%eax
ret
cmp    $0x41,%edi
jne    1154 <bar_cnv+0x54>
shl    $0x4,%edi
or     $0x3,%edi
mov    %edi,%eax
ret
mov    $0x1,%eax
ret
mov    $0x214,%edi
mov    %edi,%eax
ret
mov    $0x4324,%edi
mov    %edi,%eax
ret
mov    $0x21444,%edi
mov    %edi,%eax
ret

LLVM IR (-O0):
define i32 @bar_cnv(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %22 [
i32 2, label %5
i32 35, label %5
i32 4, label %6
i32 20, label %7
i32 324, label %10
i32 5188, label %13
i32 65, label %16
i32 1089, label %16
i32 17473, label %16
i32 68, label %21
]
5: ; preds = %1, %1
store i32 0, i32* %2
br label %24
6: ; preds = %1
store i32 1, i32* %2
br label %24
7: ; preds = %1
%8 = load i32, i32* %3
%9 = or i32 %8, 512
store i32 %9, i32* %3
br label %22
10: ; preds = %1
%11 = load i32, i32* %3
%12 = or i32 %11, 8192
store i32 %12, i32* %3
br label %22
13: ; preds = %1
%14 = load i32, i32* %3
%15 = or i32 %14, 131072
store i32 %15, i32* %3
br label %22
16: ; preds = %1, %1, %1
%17 = load i32, i32* %3
%18 = shl i32 %17, 4
store i32 %18, i32* %3
%19 = load i32, i32* %3
%20 = or i32 %19, 3
store i32 %20, i32* %3
br label %22
21: ; preds = %1
store i32 17188, i32* %3
br label %22
22: ; preds = %1, %21, %16, %13, %10, %7
%23 = load i32, i32* %3
store i32 %23, i32* %2
br label %24
24: ; preds = %22, %6, %5
%25 = load i32, i32* %2
ret i32 %25
}

LLVM IR (-O2):
define i32 @bar_cnv(i32 %0) {
switch i32 %0, label %10 [
i32 2, label %12
i32 35, label %12
i32 4, label %2
i32 20, label %3
i32 324, label %4
i32 5188, label %5
i32 65, label %6
i32 1089, label %6
i32 17473, label %6
i32 68, label %9
]
2: ; preds = %1
br label %12
3: ; preds = %1
br label %10
4: ; preds = %1
br label %10
5: ; preds = %1
br label %10
6: ; preds = %1, %1, %1
%7 = shl nuw nsw i32 %0, 4
%8 = or i32 %7, 3
br label %10
9: ; preds = %1
br label %10
10: ; preds = %1, %9, %6, %5, %4, %3
%11 = phi i32 [ %0, %1 ], [ 17188, %9 ], [ %8, %6 ], [ 136260, %5 ], [ 8516, %4 ], [ 532, %3 ]
br label %12
12: ; preds = %1, %1, %10, %2
%13 = phi i32 [ %11, %10 ], [ 1, %2 ], [ 0, %1 ], [ 0, %1 ]
ret i32 %13
}