#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 uint8_t;
typedef int uint32_t;

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


x86 assembly (clang, -O0):
<to_cigar_int>:
push   %rbp
mov    %rsp,%rbp
mov    %sil,%al
mov    %edi,-0x4(%rbp)
mov    %al,-0x5(%rbp)
movsbl -0x5(%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>
movl   $0x0,-0x10(%rbp)
jmp    11a3 <to_cigar_int+0xa3>
movl   $0x1,-0x10(%rbp)
jmp    11a3 <to_cigar_int+0xa3>
movl   $0x2,-0x10(%rbp)
jmp    11a3 <to_cigar_int+0xa3>
movl   $0x3,-0x10(%rbp)
jmp    11a3 <to_cigar_int+0xa3>
movl   $0x4,-0x10(%rbp)
jmp    11a3 <to_cigar_int+0xa3>
movl   $0x5,-0x10(%rbp)
jmp    11a3 <to_cigar_int+0xa3>
movl   $0x6,-0x10(%rbp)
jmp    11a3 <to_cigar_int+0xa3>
movl   $0x7,-0x10(%rbp)
jmp    11a3 <to_cigar_int+0xa3>
movl   $0x8,-0x10(%rbp)
mov    -0x4(%rbp),%eax
shl    $0x4,%eax
or     -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
pop    %rbp
ret

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

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

LLVM IR (-O2):
define i32 @to_cigar_int(i32 %0, i8 signext %1) {
%3 = sext i8 %1 to i32
switch i32 %3, label %12 [
i32 88, label %11
i32 73, label %4
i32 68, label %5
i32 78, label %6
i32 83, label %7
i32 72, label %8
i32 80, label %9
i32 61, label %10
]
4: ; preds = %2
br label %12
5: ; preds = %2
br label %12
6: ; preds = %2
br label %12
7: ; preds = %2
br label %12
8: ; preds = %2
br label %12
9: ; preds = %2
br label %12
10: ; preds = %2
br label %12
11: ; preds = %2
br label %12
12: ; preds = %2, %11, %10, %9, %8, %7, %6, %5, %4
%13 = phi i32 [ 7, %10 ], [ 6, %9 ], [ 5, %8 ], [ 4, %7 ], [ 3, %6 ], [ 2, %5 ], [ 1, %4 ], [ 8, %11 ], [ 0, %2 ]
%14 = shl i32 %0, 4
%15 = or i32 %13, %14
ret i32 %15
}