int idFromLetter(char l) {
  static char letters[27] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
                             'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                             's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '-'};
  int i = 0;
  for (; i < 27; i++) {
    if (letters[i] == l) {
      return i;
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<idFromLetter>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x5(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x1b,-0xc(%rbp)
jge    1154 <idFromLetter+0x54>
movslq -0xc(%rbp),%rcx
lea    0x2f0a(%rip),%rax
movsbl (%rax,%rcx,1),%eax
movsbl -0x5(%rbp),%ecx
cmp    %ecx,%eax
jne    1141 <idFromLetter+0x41>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    115b <idFromLetter+0x5b>
jmp    1146 <idFromLetter+0x46>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1111 <idFromLetter+0x11>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<idFromLetter>:
add    $0xd3,%dil
cmp    $0x4d,%dil
ja     1126 <idFromLetter+0x26>
xor    %eax,%eax
movzbl %dil,%ecx
lea    0xee9(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    $0x1a,%eax
ret
mov    $0xffffffff,%eax
ret
mov    $0x1,%eax
ret
mov    $0x2,%eax
ret
mov    $0x3,%eax
ret
mov    $0x4,%eax
ret
mov    $0x5,%eax
ret
mov    $0x6,%eax
ret
mov    $0x7,%eax
ret
mov    $0x8,%eax
ret
mov    $0x9,%eax
ret
mov    $0xa,%eax
ret
mov    $0xb,%eax
ret
mov    $0xc,%eax
ret
mov    $0xd,%eax
ret
mov    $0xe,%eax
ret
mov    $0xf,%eax
ret
mov    $0x10,%eax
ret
mov    $0x11,%eax
ret
mov    $0x12,%eax
ret
mov    $0x13,%eax
ret
mov    $0x14,%eax
ret
mov    $0x15,%eax
ret
mov    $0x16,%eax
ret
mov    $0x17,%eax
ret
mov    $0x18,%eax
ret
mov    $0x19,%eax
ret

LLVM IR (-O0):
@idFromLetter.letters = internal global [27 x i8] c"abcdefghijklmnopqrstuvwxyz-"
define i32 @idFromLetter(i8 signext %0) {
%2 = alloca i32
%3 = alloca i8
%4 = alloca i32
store i8 %0, i8* %3
store i32 0, i32* %4
br label %5
5: ; preds = %20, %1
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 27
br i1 %7, label %8, label %23
8: ; preds = %5
%9 = load i32, i32* %4
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [27 x i8], [27 x i8]* @idFromLetter.letters, i64 0, i64 %10
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = load i8, i8* %3
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %13, %15
br i1 %16, label %17, label %19
17: ; preds = %8
%18 = load i32, i32* %4
store i32 %18, i32* %2
br label %24
19: ; preds = %8
br label %20
20: ; preds = %19
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %5
23: ; preds = %5
store i32 -1, i32* %2
br label %24
24: ; preds = %23, %17
%25 = load i32, i32* %2
ret i32 %25
}

LLVM IR (-O2):
define i32 @idFromLetter(i8 signext %0) {
switch i8 %0, label %2 [
i8 97, label %29
i8 98, label %3
i8 99, label %4
i8 100, label %5
i8 101, label %6
i8 102, label %7
i8 103, label %8
i8 104, label %9
i8 105, label %10
i8 106, label %11
i8 107, label %12
i8 108, label %13
i8 109, label %14
i8 110, label %15
i8 111, label %16
i8 112, label %17
i8 113, label %18
i8 114, label %19
i8 115, label %20
i8 116, label %21
i8 117, label %22
i8 118, label %23
i8 119, label %24
i8 120, label %25
i8 121, label %26
i8 122, label %27
i8 45, label %28
]
2: ; preds = %1
br label %29
3: ; preds = %1
br label %29
4: ; preds = %1
br label %29
5: ; preds = %1
br label %29
6: ; preds = %1
br label %29
7: ; preds = %1
br label %29
8: ; preds = %1
br label %29
9: ; preds = %1
br label %29
10: ; preds = %1
br label %29
11: ; preds = %1
br label %29
12: ; preds = %1
br label %29
13: ; preds = %1
br label %29
14: ; preds = %1
br label %29
15: ; preds = %1
br label %29
16: ; preds = %1
br label %29
17: ; preds = %1
br label %29
18: ; preds = %1
br label %29
19: ; preds = %1
br label %29
20: ; preds = %1
br label %29
21: ; preds = %1
br label %29
22: ; preds = %1
br label %29
23: ; preds = %1
br label %29
24: ; preds = %1
br label %29
25: ; preds = %1
br label %29
26: ; preds = %1
br label %29
27: ; preds = %1
br label %29
28: ; preds = %1
br label %29
29: ; preds = %1, %28, %27, %26, %25, %24, %23, %22, %21, %20, %19, %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5, %4, %3, %2
%30 = phi i32 [ 0, %1 ], [ -1, %2 ], [ 1, %3 ], [ 2, %4 ], [ 3, %5 ], [ 4, %6 ], [ 5, %7 ], [ 6, %8 ], [ 7, %9 ], [ 8, %10 ], [ 9, %11 ], [ 10, %12 ], [ 11, %13 ], [ 12, %14 ], [ 13, %15 ], [ 14, %16 ], [ 15, %17 ], [ 16, %18 ], [ 17, %19 ], [ 18, %20 ], [ 19, %21 ], [ 20, %22 ], [ 21, %23 ], [ 22, %24 ], [ 23, %25 ], [ 24, %26 ], [ 25, %27 ], [ 26, %28 ]
ret i32 %30
}