unsigned command_2_index(unsigned c, unsigned sc) {
  if (c & 0x80)
    c = 0x9 + (c & 0x0f);
  else if (c <= 0x0f)
    ;
  else if (c == 0x41)
    c = 0x9 + 0x1;
  else if (c == 0xff)
    c = 0x00;
  return (sc & 3) * (0x9 + 0x9) + c;
}


x86 assembly (clang, -O0):
<command_2_index>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
je     112c <command_2_index+0x2c>
mov    -0x4(%rbp),%eax
and    $0xf,%eax
add    $0x9,%eax
mov    %eax,-0x4(%rbp)
jmp    1174 <command_2_index+0x74>
cmpl   $0xf,-0x4(%rbp)
ja     113b <command_2_index+0x3b>
jmp    116f <command_2_index+0x6f>
cmpl   $0x41,-0x4(%rbp)
jne    1151 <command_2_index+0x51>
movl   $0xa,-0x4(%rbp)
jmp    116a <command_2_index+0x6a>
cmpl   $0xff,-0x4(%rbp)
jne    1165 <command_2_index+0x65>
movl   $0x0,-0x4(%rbp)
jmp    116a <command_2_index+0x6a>
jmp    116f <command_2_index+0x6f>
jmp    1174 <command_2_index+0x74>
mov    -0x8(%rbp),%eax
and    $0x3,%eax
imul   $0x12,%eax,%eax
add    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<command_2_index>:
test   $0x80,%dil
jne    110f <command_2_index+0xf>
cmp    $0x10,%edi
jae    1119 <command_2_index+0x19>
mov    %edi,%eax
jmp    112e <command_2_index+0x2e>
and    $0xf,%edi
add    $0x9,%edi
mov    %edi,%eax
jmp    112e <command_2_index+0x2e>
mov    $0xa,%eax
cmp    $0x41,%edi
je     112e <command_2_index+0x2e>
xor    %eax,%eax
cmp    $0xff,%edi
cmovne %edi,%eax
and    $0x3,%esi
lea    (%rsi,%rsi,8),%ecx
lea    (%rax,%rcx,2),%eax
ret

LLVM IR (-O0):
define i32 @command_2_index(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %3
%6 = and i32 %5, 128
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = load i32, i32* %3
%10 = and i32 %9, 15
%11 = add i32 9, %10
store i32 %11, i32* %3
br label %27
12: ; preds = %2
%13 = load i32, i32* %3
%14 = icmp ule i32 %13, 15
br i1 %14, label %15, label %16
15: ; preds = %12
br label %26
16: ; preds = %12
%17 = load i32, i32* %3
%18 = icmp eq i32 %17, 65
br i1 %18, label %19, label %20
19: ; preds = %16
store i32 10, i32* %3
br label %25
20: ; preds = %16
%21 = load i32, i32* %3
%22 = icmp eq i32 %21, 255
br i1 %22, label %23, label %24
23: ; preds = %20
store i32 0, i32* %3
br label %24
24: ; preds = %23, %20
br label %25
25: ; preds = %24, %19
br label %26
26: ; preds = %25, %15
br label %27
27: ; preds = %26, %8
%28 = load i32, i32* %4
%29 = and i32 %28, 3
%30 = mul i32 %29, 18
%31 = load i32, i32* %3
%32 = add i32 %30, %31
ret i32 %32
}

LLVM IR (-O2):
define i32 @command_2_index(i32 %0, i32 %1) {
%3 = and i32 %0, 128
%4 = icmp eq i32 %3, 0
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = and i32 %0, 15
%7 = add nuw nsw i32 %6, 9
br label %15
8: ; preds = %2
%9 = icmp ult i32 %0, 16
br i1 %9, label %15, label %10
10: ; preds = %8
%11 = icmp eq i32 %0, 65
br i1 %11, label %15, label %12
12: ; preds = %10
%13 = icmp eq i32 %0, 255
%14 = select i1 %13, i32 0, i32 %0
br label %15
15: ; preds = %10, %8, %12, %5
%16 = phi i32 [ %7, %5 ], [ %0, %8 ], [ %14, %12 ], [ 10, %10 ]
%17 = and i32 %1, 3
%18 = mul nuw nsw i32 %17, 18
%19 = add nuw i32 %16, %18
ret i32 %19
}