#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);
int chartoint(char c) {
  switch (tolower(c)) {
  case 'a':
    return 0;
  case 'c':
    return 1;
  case 'g':
    return 2;
  case 't':
    return 3;
  case '$':
    return 4;
  default:
    return -1;
  }
}


x86 assembly (clang, -O0):
<chartoint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%edi
call   1030 <tolower@plt>
mov    %eax,%ecx
mov    %ecx,-0xc(%rbp)
sub    $0x24,%eax
je     11ae <chartoint+0x9e>
jmp    113a <chartoint+0x2a>
mov    -0xc(%rbp),%eax
sub    $0x61,%eax
je     117e <chartoint+0x6e>
jmp    114b <chartoint+0x3b>
mov    -0xc(%rbp),%eax
sub    $0x63,%eax
je     118a <chartoint+0x7a>
jmp    115c <chartoint+0x4c>
mov    -0xc(%rbp),%eax
sub    $0x67,%eax
je     1196 <chartoint+0x86>
jmp    116d <chartoint+0x5d>
mov    -0xc(%rbp),%eax
sub    $0x74,%eax
je     11a2 <chartoint+0x92>
jmp    11ba <chartoint+0xaa>
movl   $0x0,-0x4(%rbp)
jmp    11c1 <chartoint+0xb1>
movl   $0x1,-0x4(%rbp)
jmp    11c1 <chartoint+0xb1>
movl   $0x2,-0x4(%rbp)
jmp    11c1 <chartoint+0xb1>
movl   $0x3,-0x4(%rbp)
jmp    11c1 <chartoint+0xb1>
movl   $0x4,-0x4(%rbp)
jmp    11c1 <chartoint+0xb1>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chartoint>:
push   %rax
call   1030 <tolower@plt>
lea    -0x61(%rax),%ecx
cmp    $0x13,%ecx
ja     1137 <chartoint+0x27>
xor    %eax,%eax
lea    0xed9(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    $0x1,%eax
pop    %rcx
ret
cmp    $0x24,%eax
jne    1143 <chartoint+0x33>
mov    $0x4,%eax
pop    %rcx
ret
mov    $0xffffffff,%eax
pop    %rcx
ret
mov    $0x2,%eax
pop    %rcx
ret
mov    $0x3,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @chartoint(i8 signext %0) {
%2 = alloca i32
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = call i32 @tolower(i8 signext %4)
switch i32 %5, label %11 [
i32 97, label %6
i32 99, label %7
i32 103, label %8
i32 116, label %9
i32 36, label %10
]
6: ; preds = %1
store i32 0, i32* %2
br label %12
7: ; preds = %1
store i32 1, i32* %2
br label %12
8: ; preds = %1
store i32 2, i32* %2
br label %12
9: ; preds = %1
store i32 3, i32* %2
br label %12
10: ; preds = %1
store i32 4, i32* %2
br label %12
11: ; preds = %1
store i32 -1, i32* %2
br label %12
12: ; preds = %11, %10, %9, %8, %7, %6
%13 = load i32, i32* %2
ret i32 %13
}

LLVM IR (-O2):
define i32 @chartoint(i8 signext %0) {
%2 = tail call i32 @tolower(i8 signext %0)
switch i32 %2, label %7 [
i32 97, label %8
i32 99, label %3
i32 103, label %4
i32 116, label %5
i32 36, label %6
]
3: ; preds = %1
br label %8
4: ; preds = %1
br label %8
5: ; preds = %1
br label %8
6: ; preds = %1
br label %8
7: ; preds = %1
br label %8
8: ; preds = %1, %7, %6, %5, %4, %3
%9 = phi i32 [ -1, %7 ], [ 4, %6 ], [ 3, %5 ], [ 2, %4 ], [ 1, %3 ], [ 0, %1 ]
ret i32 %9
}