#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 */

/* Variables and functions */
int tolower(char const);
char encode_char(const char c) {
  switch (tolower(c)) {
  case 'b':
  case 'f':
  case 'p':
  case 'v':
    return '1';
  case 'c':
  case 'g':
  case 'j':
  case 'k':
  case 'q':
  case 's':
  case 'x':
  case 'z':
    return '2';
  case 'd':
  case 't':
    return '3';
  case 'l':
    return '4';
  case 'm':
  case 'n':
    return '5';
  case 'r':
    return '6';
  default:
    break;
  }
  return '0';
}


x86 assembly (clang, -O0):
<encode_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x2(%rbp)
movsbl -0x2(%rbp),%edi
call   1030 <tolower@plt>
add    $0xffffff9e,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x18,%eax
ja     1183 <encode_char+0x73>
mov    -0x10(%rbp),%rax
lea    0xebc(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movb   $0x31,-0x1(%rbp)
jmp    118c <encode_char+0x7c>
movb   $0x32,-0x1(%rbp)
jmp    118c <encode_char+0x7c>
movb   $0x33,-0x1(%rbp)
jmp    118c <encode_char+0x7c>
movb   $0x34,-0x1(%rbp)
jmp    118c <encode_char+0x7c>
movb   $0x35,-0x1(%rbp)
jmp    118c <encode_char+0x7c>
movb   $0x36,-0x1(%rbp)
jmp    118c <encode_char+0x7c>
jmp    1188 <encode_char+0x78>
movb   $0x30,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<encode_char>:
push   %rax
call   1030 <tolower@plt>
add    $0xffffff9e,%eax
mov    $0x30,%cl
cmp    $0x18,%eax
ja     112c <encode_char+0x1c>
cltq
lea    0xed7(%rip),%rcx
mov    (%rax,%rcx,1),%cl
mov    %ecx,%eax
pop    %rcx
ret

LLVM IR (-O0):
define signext i8 @encode_char(i8 signext %0) {
%2 = alloca i8
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = call i32 @tolower(i8 signext %4)
switch i32 %5, label %12 [
i32 98, label %6
i32 102, label %6
i32 112, label %6
i32 118, label %6
i32 99, label %7
i32 103, label %7
i32 106, label %7
i32 107, label %7
i32 113, label %7
i32 115, label %7
i32 120, label %7
i32 122, label %7
i32 100, label %8
i32 116, label %8
i32 108, label %9
i32 109, label %10
i32 110, label %10
i32 114, label %11
]
6: ; preds = %1, %1, %1, %1
store i8 49, i8* %2
br label %14
7: ; preds = %1, %1, %1, %1, %1, %1, %1, %1
store i8 50, i8* %2
br label %14
8: ; preds = %1, %1
store i8 51, i8* %2
br label %14
9: ; preds = %1
store i8 52, i8* %2
br label %14
10: ; preds = %1, %1
store i8 53, i8* %2
br label %14
11: ; preds = %1
store i8 54, i8* %2
br label %14
12: ; preds = %1
br label %13
13: ; preds = %12
store i8 48, i8* %2
br label %14
14: ; preds = %13, %11, %10, %9, %8, %7, %6
%15 = load i8, i8* %2
ret i8 %15
}

LLVM IR (-O2):
@switch.table.encode_char = [25 x i8] c"1230120022455012623010202"
define signext i8 @encode_char(i8 signext %0) {
%2 = tail call i32 @tolower(i8 signext %0)
%3 = add i32 %2, -98
%4 = icmp ult i32 %3, 25
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = sext i32 %3 to i64
%7 = getelementptr inbounds [25 x i8], [25 x i8]* @switch.table.encode_char, i64 0, i64 %6
%8 = load i8, i8* %7
br label %9
9: ; preds = %1, %5
%10 = phi i8 [ %8, %5 ], [ 48, %1 ]
ret i8 %10
}