#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 'p':
    return '1';
  case 'f':
  case 'v':
    return '2';
  case 'c':
  case 'k':
  case 's':
    return '3';
  case 'g':
  case 'j':
    return '4';
  case 'q':
  case 'x':
  case 'z':
    return '5';
  case 'd':
  case 't':
    return '6';
  case 'l':
    return '7';
  case 'm':
  case 'n':
    return '8';
  case 'r':
    return '9';
  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     119e <encode_char+0x8e>
mov    -0x10(%rbp),%rax
lea    0xebc(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movb   $0x31,-0x1(%rbp)
jmp    11a7 <encode_char+0x97>
movb   $0x32,-0x1(%rbp)
jmp    11a7 <encode_char+0x97>
movb   $0x33,-0x1(%rbp)
jmp    11a7 <encode_char+0x97>
movb   $0x34,-0x1(%rbp)
jmp    11a7 <encode_char+0x97>
movb   $0x35,-0x1(%rbp)
jmp    11a7 <encode_char+0x97>
movb   $0x36,-0x1(%rbp)
jmp    11a7 <encode_char+0x97>
movb   $0x37,-0x1(%rbp)
jmp    11a7 <encode_char+0x97>
movb   $0x38,-0x1(%rbp)
jmp    11a7 <encode_char+0x97>
movb   $0x39,-0x1(%rbp)
jmp    11a7 <encode_char+0x97>
jmp    11a3 <encode_char+0x93>
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 %15 [
i32 98, label %6
i32 112, label %6
i32 102, label %7
i32 118, label %7
i32 99, label %8
i32 107, label %8
i32 115, label %8
i32 103, label %9
i32 106, label %9
i32 113, label %10
i32 120, label %10
i32 122, label %10
i32 100, label %11
i32 116, label %11
i32 108, label %12
i32 109, label %13
i32 110, label %13
i32 114, label %14
]
6: ; preds = %1, %1
store i8 49, i8* %2
br label %17
7: ; preds = %1, %1
store i8 50, i8* %2
br label %17
8: ; preds = %1, %1, %1
store i8 51, i8* %2
br label %17
9: ; preds = %1, %1
store i8 52, i8* %2
br label %17
10: ; preds = %1, %1, %1
store i8 53, i8* %2
br label %17
11: ; preds = %1, %1
store i8 54, i8* %2
br label %17
12: ; preds = %1
store i8 55, i8* %2
br label %17
13: ; preds = %1, %1
store i8 56, i8* %2
br label %17
14: ; preds = %1
store i8 57, i8* %2
br label %17
15: ; preds = %1
br label %16
16: ; preds = %15
store i8 48, i8* %2
br label %17
17: ; preds = %16, %14, %13, %12, %11, %10, %9, %8, %7, %6
%18 = load i8, i8* %2
ret i8 %18
}

LLVM IR (-O2):
@switch.table.encode_char = [25 x i8] c"1360240043788015936020505"
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
}