#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int uint32_t;

/* Variables and functions */
uint32_t to_cigar_int(uint32_t length, char op_letter) {
  switch (op_letter) {
  case 'M':
  default:
    return length << 4;
  case 'S':
    return (length << 4) | (4u);
  case 'D':
    return (length << 4) | (2u);
  case 'I':
    return (length << 4) | (1u);
  case 'H':
    return (length << 4) | (5u);
  case 'N':
    return (length << 4) | (3u);
  case 'P':
    return (length << 4) | (6u);
  case '=':
    return (length << 4) | (7u);
  case 'X':
    return (length << 4) | (8u);
  }
  return (uint32_t)-1;
}


x86 assembly (clang, -O0):
<to_cigar_int>:
push   %rbp
mov    %rsp,%rbp
mov    %sil,%al
mov    %edi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
add    $0xffffffc3,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x1b,%eax
ja     113c <to_cigar_int+0x3c>
mov    -0x18(%rbp),%rax
lea    0xed2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    113c <to_cigar_int+0x3c>
mov    -0x8(%rbp),%eax
shl    $0x4,%eax
mov    %eax,-0x4(%rbp)
jmp    11cd <to_cigar_int+0xcd>
mov    -0x8(%rbp),%eax
shl    $0x4,%eax
or     $0x4,%eax
mov    %eax,-0x4(%rbp)
jmp    11cd <to_cigar_int+0xcd>
mov    -0x8(%rbp),%eax
shl    $0x4,%eax
or     $0x2,%eax
mov    %eax,-0x4(%rbp)
jmp    11cd <to_cigar_int+0xcd>
mov    -0x8(%rbp),%eax
shl    $0x4,%eax
or     $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11cd <to_cigar_int+0xcd>
mov    -0x8(%rbp),%eax
shl    $0x4,%eax
or     $0x5,%eax
mov    %eax,-0x4(%rbp)
jmp    11cd <to_cigar_int+0xcd>
mov    -0x8(%rbp),%eax
shl    $0x4,%eax
or     $0x3,%eax
mov    %eax,-0x4(%rbp)
jmp    11cd <to_cigar_int+0xcd>
mov    -0x8(%rbp),%eax
shl    $0x4,%eax
or     $0x6,%eax
mov    %eax,-0x4(%rbp)
jmp    11cd <to_cigar_int+0xcd>
mov    -0x8(%rbp),%eax
shl    $0x4,%eax
or     $0x7,%eax
mov    %eax,-0x4(%rbp)
jmp    11cd <to_cigar_int+0xcd>
mov    -0x8(%rbp),%eax
shl    $0x4,%eax
or     $0x8,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<to_cigar_int>:
mov    %edi,%eax
add    $0xffffffc3,%esi
cmp    $0x1b,%esi
ja     1121 <to_cigar_int+0x21>
lea    0xeef(%rip),%rcx
movslq (%rcx,%rsi,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
shl    $0x4,%eax
or     $0x7,%eax
ret
shl    $0x4,%eax
ret
shl    $0x4,%eax
or     $0x2,%eax
ret
shl    $0x4,%eax
or     $0x5,%eax
ret
shl    $0x4,%eax
or     $0x1,%eax
ret
shl    $0x4,%eax
or     $0x3,%eax
ret
shl    $0x4,%eax
or     $0x6,%eax
ret
shl    $0x4,%eax
or     $0x4,%eax
ret
shl    $0x4,%eax
or     $0x8,%eax
ret

LLVM IR (-O0):
define i32 @to_cigar_int(i32 %0, i8 signext %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
store i32 %0, i32* %4
store i8 %1, i8* %5
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
switch i32 %7, label %9 [
i32 77, label %8
i32 83, label %12
i32 68, label %16
i32 73, label %20
i32 72, label %24
i32 78, label %28
i32 80, label %32
i32 61, label %36
i32 88, label %40
]
8: ; preds = %2
br label %9
9: ; preds = %2, %8
%10 = load i32, i32* %4
%11 = shl i32 %10, 4
store i32 %11, i32* %3
br label %44
12: ; preds = %2
%13 = load i32, i32* %4
%14 = shl i32 %13, 4
%15 = or i32 %14, 4
store i32 %15, i32* %3
br label %44
16: ; preds = %2
%17 = load i32, i32* %4
%18 = shl i32 %17, 4
%19 = or i32 %18, 2
store i32 %19, i32* %3
br label %44
20: ; preds = %2
%21 = load i32, i32* %4
%22 = shl i32 %21, 4
%23 = or i32 %22, 1
store i32 %23, i32* %3
br label %44
24: ; preds = %2
%25 = load i32, i32* %4
%26 = shl i32 %25, 4
%27 = or i32 %26, 5
store i32 %27, i32* %3
br label %44
28: ; preds = %2
%29 = load i32, i32* %4
%30 = shl i32 %29, 4
%31 = or i32 %30, 3
store i32 %31, i32* %3
br label %44
32: ; preds = %2
%33 = load i32, i32* %4
%34 = shl i32 %33, 4
%35 = or i32 %34, 6
store i32 %35, i32* %3
br label %44
36: ; preds = %2
%37 = load i32, i32* %4
%38 = shl i32 %37, 4
%39 = or i32 %38, 7
store i32 %39, i32* %3
br label %44
40: ; preds = %2
%41 = load i32, i32* %4
%42 = shl i32 %41, 4
%43 = or i32 %42, 8
store i32 %43, i32* %3
br label %44
44: ; preds = %40, %36, %32, %28, %24, %20, %16, %12, %9
%45 = load i32, i32* %3
ret i32 %45
}

LLVM IR (-O2):
define i32 @to_cigar_int(i32 %0, i8 signext %1) {
%3 = sext i8 %1 to i32
switch i32 %3, label %4 [
i32 88, label %27
i32 83, label %6
i32 68, label %9
i32 73, label %12
i32 72, label %15
i32 78, label %18
i32 80, label %21
i32 61, label %24
]
4: ; preds = %2
%5 = shl i32 %0, 4
br label %30
6: ; preds = %2
%7 = shl i32 %0, 4
%8 = or i32 %7, 4
br label %30
9: ; preds = %2
%10 = shl i32 %0, 4
%11 = or i32 %10, 2
br label %30
12: ; preds = %2
%13 = shl i32 %0, 4
%14 = or i32 %13, 1
br label %30
15: ; preds = %2
%16 = shl i32 %0, 4
%17 = or i32 %16, 5
br label %30
18: ; preds = %2
%19 = shl i32 %0, 4
%20 = or i32 %19, 3
br label %30
21: ; preds = %2
%22 = shl i32 %0, 4
%23 = or i32 %22, 6
br label %30
24: ; preds = %2
%25 = shl i32 %0, 4
%26 = or i32 %25, 7
br label %30
27: ; preds = %2
%28 = shl i32 %0, 4
%29 = or i32 %28, 8
br label %30
30: ; preds = %27, %24, %21, %18, %15, %12, %9, %6, %4
%31 = phi i32 [ %5, %4 ], [ %26, %24 ], [ %23, %21 ], [ %20, %18 ], [ %17, %15 ], [ %14, %12 ], [ %11, %9 ], [ %8, %6 ], [ %29, %27 ]
ret i32 %31
}