unsigned int h2r_to_r2h_bits(int cmd) {
  unsigned int mask = 0;
  switch (cmd) {
  case 12:
  case 1:
  case 2:
  case 3:
  case 4:
  case 6:
  case 7:
  case 8:
  case 10:
  case 11:
  case 20:
    mask |= (((cmd) > 0) ? (1 << ((cmd)-1)) : 0);
    break;
  case 5:
    mask |= ((((13) > 0) ? (1 << ((13) - 1)) : 0) |
             (((14) > 0) ? (1 << ((14) - 1)) : 0) |
             (((15) > 0) ? (1 << ((15) - 1)) : 0) |
             (((16) > 0) ? (1 << ((16) - 1)) : 0));
    break;
  case 9:
    mask |= (((13) > 0) ? (1 << ((13) - 1)) : 0);
    break;
  }
  return (mask |= (((32) > 0) ? (1 << ((32) - 1)) : 0));
}


x86 assembly (clang, -O0):
<h2r_to_r2h_bits>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
add    $0xffffffff,%eax
sub    $0x4,%eax
jb     1180 <h2r_to_r2h_bits+0x80>
jmp    1125 <h2r_to_r2h_bits+0x25>
mov    -0xc(%rbp),%eax
sub    $0x5,%eax
je     11b7 <h2r_to_r2h_bits+0xb7>
jmp    1136 <h2r_to_r2h_bits+0x36>
mov    -0xc(%rbp),%eax
add    $0xfffffffa,%eax
sub    $0x3,%eax
jb     1180 <h2r_to_r2h_bits+0x80>
jmp    114a <h2r_to_r2h_bits+0x4a>
mov    -0xc(%rbp),%eax
sub    $0x9,%eax
je     11c7 <h2r_to_r2h_bits+0xc7>
jmp    115b <h2r_to_r2h_bits+0x5b>
mov    -0xc(%rbp),%eax
add    $0xfffffff6,%eax
sub    $0x3,%eax
jb     1180 <h2r_to_r2h_bits+0x80>
jmp    116f <h2r_to_r2h_bits+0x6f>
mov    -0xc(%rbp),%eax
sub    $0x14,%eax
jne    11d2 <h2r_to_r2h_bits+0xd2>
jmp    1180 <h2r_to_r2h_bits+0x80>
cmpl   $0x0,-0x4(%rbp)
jle    119f <h2r_to_r2h_bits+0x9f>
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x10(%rbp)
jmp    11a9 <h2r_to_r2h_bits+0xa9>
xor    %eax,%eax
mov    %eax,-0x10(%rbp)
jmp    11a9 <h2r_to_r2h_bits+0xa9>
mov    -0x10(%rbp),%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    11d2 <h2r_to_r2h_bits+0xd2>
mov    -0x8(%rbp),%eax
or     $0xf000,%eax
mov    %eax,-0x8(%rbp)
jmp    11d2 <h2r_to_r2h_bits+0xd2>
mov    -0x8(%rbp),%eax
or     $0x1000,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
or     $0x80000000,%eax
mov    %eax,-0x8(%rbp)
pop    %rbp
ret

x86 assembly (clang, -O2):
<h2r_to_r2h_bits>:
add    $0xffffffff,%edi
mov    $0x80000000,%eax
cmp    $0x13,%edi
ja     111a <h2r_to_r2h_bits+0x1a>
movslq %edi,%rax
lea    0xee9(%rip),%rcx
mov    (%rcx,%rax,4),%eax
ret

LLVM IR (-O0):
define i32 @h2r_to_r2h_bits(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
%4 = load i32, i32* %2
switch i32 %4, label %23 [
i32 12, label %5
i32 1, label %5
i32 2, label %5
i32 3, label %5
i32 4, label %5
i32 6, label %5
i32 7, label %5
i32 8, label %5
i32 10, label %5
i32 11, label %5
i32 20, label %5
i32 5, label %17
i32 9, label %20
]
5: ; preds = %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1
%6 = load i32, i32* %2
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %5
%9 = load i32, i32* %2
%10 = sub nsw i32 %9, 1
%11 = shl i32 1, %10
br label %13
12: ; preds = %5
br label %13
13: ; preds = %12, %8
%14 = phi i32 [ %11, %8 ], [ 0, %12 ]
%15 = load i32, i32* %3
%16 = or i32 %15, %14
store i32 %16, i32* %3
br label %23
17: ; preds = %1
%18 = load i32, i32* %3
%19 = or i32 %18, 61440
store i32 %19, i32* %3
br label %23
20: ; preds = %1
%21 = load i32, i32* %3
%22 = or i32 %21, 4096
store i32 %22, i32* %3
br label %23
23: ; preds = %1, %20, %17, %13
%24 = load i32, i32* %3
%25 = or i32 %24, -2147483648
store i32 %25, i32* %3
ret i32 %25
}

LLVM IR (-O2):
@switch.table.h2r_to_r2h_bits = [20 x i32] [i32 -2147483647, i32 -2147483646, i32 -2147483644, i32 -2147483640, i32 -2147422208, i32 -2147483616, i32 -2147483584, i32 -2147483520, i32 -2147479552, i32 -2147483136, i32 -2147482624, i32 -2147481600, i32 -2147483648, i32 -2147483648, i32 -2147483648, i32 -2147483648, i32 -2147483648, i32 -2147483648, i32 -2147483648, i32 -2146959360]
define i32 @h2r_to_r2h_bits(i32 %0) {
%2 = add i32 %0, -1
%3 = icmp ult i32 %2, 20
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = sext i32 %2 to i64
%6 = getelementptr inbounds [20 x i32], [20 x i32]* @switch.table.h2r_to_r2h_bits, i64 0, i64 %5
%7 = load i32, i32* %6
br label %8
8: ; preds = %4, %1
%9 = phi i32 [ -2147483648, %1 ], [ %7, %4 ]
ret i32 %9
}