int _ctype(const char *ctype) {
  if (ctype[0] != '%')
    return -1;
  switch (ctype[1]) {
  case 'f':
    return 4;
  case 'F':
    return 3;
  case 'd':
    return 1;
  case 'D':
    return 2;
  case 'b':
    return 6;
  case 'h':
    return 8;
  case 'c':
    return 7;
  case 's':
    return 10;
  case 'a':
    return 9;
  default:
    return -1;
  }
}


x86 assembly (clang, -O0):
<_ctype>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x25,%eax
je     1124 <_ctype+0x24>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c5 <_ctype+0xc5>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
add    $0xffffffbc,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x2f,%eax
ja     11be <_ctype+0xbe>
mov    -0x18(%rbp),%rax
lea    0xeb7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x4,-0x4(%rbp)
jmp    11c5 <_ctype+0xc5>
movl   $0x3,-0x4(%rbp)
jmp    11c5 <_ctype+0xc5>
movl   $0x1,-0x4(%rbp)
jmp    11c5 <_ctype+0xc5>
movl   $0x2,-0x4(%rbp)
jmp    11c5 <_ctype+0xc5>
movl   $0x6,-0x4(%rbp)
jmp    11c5 <_ctype+0xc5>
movl   $0x8,-0x4(%rbp)
jmp    11c5 <_ctype+0xc5>
movl   $0x7,-0x4(%rbp)
jmp    11c5 <_ctype+0xc5>
movl   $0xa,-0x4(%rbp)
jmp    11c5 <_ctype+0xc5>
movl   $0x9,-0x4(%rbp)
jmp    11c5 <_ctype+0xc5>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<_ctype>:
mov    $0xffffffff,%eax
cmpb   $0x25,(%rdi)
jne    1136 <_ctype+0x36>
movsbl 0x1(%rdi),%ecx
add    $0xffffffbc,%ecx
cmp    $0x2f,%ecx
ja     1131 <_ctype+0x31>
mov    $0x4,%eax
lea    0xede(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    $0x2,%eax
ret
mov    $0xffffffff,%eax
ret
mov    $0x3,%eax
ret
mov    $0x9,%eax
ret
mov    $0x6,%eax
ret
mov    $0x7,%eax
ret
mov    $0x1,%eax
ret
mov    $0x8,%eax
ret
mov    $0xa,%eax
ret

LLVM IR (-O0):
define i32 @_ctype(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = getelementptr inbounds i8, i8* %4, i64 0
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = icmp ne i32 %7, 37
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 -1, i32* %2
br label %25
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = getelementptr inbounds i8, i8* %11, i64 1
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
switch i32 %14, label %24 [
i32 102, label %15
i32 70, label %16
i32 100, label %17
i32 68, label %18
i32 98, label %19
i32 104, label %20
i32 99, label %21
i32 115, label %22
i32 97, label %23
]
15: ; preds = %10
store i32 4, i32* %2
br label %25
16: ; preds = %10
store i32 3, i32* %2
br label %25
17: ; preds = %10
store i32 1, i32* %2
br label %25
18: ; preds = %10
store i32 2, i32* %2
br label %25
19: ; preds = %10
store i32 6, i32* %2
br label %25
20: ; preds = %10
store i32 8, i32* %2
br label %25
21: ; preds = %10
store i32 7, i32* %2
br label %25
22: ; preds = %10
store i32 10, i32* %2
br label %25
23: ; preds = %10
store i32 9, i32* %2
br label %25
24: ; preds = %10
store i32 -1, i32* %2
br label %25
25: ; preds = %24, %23, %22, %21, %20, %19, %18, %17, %16, %15, %9
%26 = load i32, i32* %2
ret i32 %26
}

LLVM IR (-O2):
define i32 @_ctype(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 37
br i1 %3, label %4, label %17
4: ; preds = %1
%5 = getelementptr inbounds i8, i8* %0, i64 1
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
switch i32 %7, label %16 [
i32 102, label %17
i32 70, label %8
i32 100, label %9
i32 68, label %10
i32 98, label %11
i32 104, label %12
i32 99, label %13
i32 115, label %14
i32 97, label %15
]
8: ; preds = %4
br label %17
9: ; preds = %4
br label %17
10: ; preds = %4
br label %17
11: ; preds = %4
br label %17
12: ; preds = %4
br label %17
13: ; preds = %4
br label %17
14: ; preds = %4
br label %17
15: ; preds = %4
br label %17
16: ; preds = %4
br label %17
17: ; preds = %4, %1, %16, %15, %14, %13, %12, %11, %10, %9, %8
%18 = phi i32 [ -1, %16 ], [ 9, %15 ], [ 10, %14 ], [ 7, %13 ], [ 8, %12 ], [ 6, %11 ], [ 2, %10 ], [ 1, %9 ], [ 3, %8 ], [ -1, %1 ], [ 4, %4 ]
ret i32 %18
}