int gettyp(token)
char *token;
{
  register char c;
  c = *token;
  if (c == 0)
    return (0);
  if (c >= '0' && c <= '9')
    return (8);
  switch (c) {
  case '"':
    return (9);
  case '!':
    return (6);
  case '@':
    return (1);
  case '#':
    return (2);
  case '$':
    return (4);
  case '%':
    return (3);
  case '&':
    return (5);
  case '*':
    return (7);
  default:
    return (10);
  }
}


x86 assembly (clang, -O0):
<gettyp>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
cmp    $0x0,%eax
jne    112a <gettyp+0x2a>
movl   $0x0,-0x4(%rbp)
jmp    11e1 <gettyp+0xe1>
movsbl -0x11(%rbp),%eax
cmp    $0x30,%eax
jl     1150 <gettyp+0x50>
movsbl -0x11(%rbp),%eax
cmp    $0x39,%eax
jg     1150 <gettyp+0x50>
movl   $0x8,-0x4(%rbp)
jmp    11e1 <gettyp+0xe1>
movsbl -0x11(%rbp),%eax
add    $0xffffffdf,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x1f,%eax
ja     11da <gettyp+0xda>
mov    -0x20(%rbp),%rax
lea    0xe8f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x9,-0x4(%rbp)
jmp    11e1 <gettyp+0xe1>
movl   $0x6,-0x4(%rbp)
jmp    11e1 <gettyp+0xe1>
movl   $0x1,-0x4(%rbp)
jmp    11e1 <gettyp+0xe1>
movl   $0x2,-0x4(%rbp)
jmp    11e1 <gettyp+0xe1>
movl   $0x4,-0x4(%rbp)
jmp    11e1 <gettyp+0xe1>
movl   $0x3,-0x4(%rbp)
jmp    11e1 <gettyp+0xe1>
movl   $0x5,-0x4(%rbp)
jmp    11e1 <gettyp+0xe1>
movl   $0x7,-0x4(%rbp)
jmp    11e1 <gettyp+0xe1>
movl   $0xa,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<gettyp>:
movsbl (%rdi),%ecx
test   %ecx,%ecx
je     1115 <gettyp+0x15>
lea    -0x30(%rcx),%edx
mov    $0x8,%eax
cmp    $0xa,%dl
jae    1118 <gettyp+0x18>
ret
xor    %eax,%eax
ret
add    $0xffffffdf,%ecx
cmp    $0x1f,%ecx
ja     1153 <gettyp+0x53>
mov    $0x9,%eax
lea    0xed4(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    $0x6,%eax
ret
mov    $0x2,%eax
ret
mov    $0x4,%eax
ret
mov    $0x3,%eax
ret
mov    $0x5,%eax
ret
mov    $0xa,%eax
ret
mov    $0x7,%eax
ret
mov    $0x1,%eax
ret

LLVM IR (-O0):
define i32 @gettyp(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = load i8, i8* %5
store i8 %6, i8* %4
%7 = load i8, i8* %4
%8 = sext i8 %7 to i32
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 0, i32* %2
br label %32
11: ; preds = %1
%12 = load i8, i8* %4
%13 = sext i8 %12 to i32
%14 = icmp sge i32 %13, 48
br i1 %14, label %15, label %20
15: ; preds = %11
%16 = load i8, i8* %4
%17 = sext i8 %16 to i32
%18 = icmp sle i32 %17, 57
br i1 %18, label %19, label %20
19: ; preds = %15
store i32 8, i32* %2
br label %32
20: ; preds = %15, %11
%21 = load i8, i8* %4
%22 = sext i8 %21 to i32
switch i32 %22, label %31 [
i32 34, label %23
i32 33, label %24
i32 64, label %25
i32 35, label %26
i32 36, label %27
i32 37, label %28
i32 38, label %29
i32 42, label %30
]
23: ; preds = %20
store i32 9, i32* %2
br label %32
24: ; preds = %20
store i32 6, i32* %2
br label %32
25: ; preds = %20
store i32 1, i32* %2
br label %32
26: ; preds = %20
store i32 2, i32* %2
br label %32
27: ; preds = %20
store i32 4, i32* %2
br label %32
28: ; preds = %20
store i32 3, i32* %2
br label %32
29: ; preds = %20
store i32 5, i32* %2
br label %32
30: ; preds = %20
store i32 7, i32* %2
br label %32
31: ; preds = %20
store i32 10, i32* %2
br label %32
32: ; preds = %31, %30, %29, %28, %27, %26, %25, %24, %23, %19, %10
%33 = load i32, i32* %2
ret i32 %33
}

LLVM IR (-O2):
define i32 @gettyp(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = sext i8 %2 to i32
%4 = icmp eq i8 %2, 0
br i1 %4, label %17, label %5
5: ; preds = %1
%6 = add i8 %2, -48
%7 = icmp ult i8 %6, 10
br i1 %7, label %17, label %8
8: ; preds = %5
switch i32 %3, label %16 [
i32 34, label %17
i32 33, label %9
i32 64, label %10
i32 35, label %11
i32 36, label %12
i32 37, label %13
i32 38, label %14
i32 42, label %15
]
9: ; preds = %8
br label %17
10: ; preds = %8
br label %17
11: ; preds = %8
br label %17
12: ; preds = %8
br label %17
13: ; preds = %8
br label %17
14: ; preds = %8
br label %17
15: ; preds = %8
br label %17
16: ; preds = %8
br label %17
17: ; preds = %8, %5, %1, %16, %15, %14, %13, %12, %11, %10, %9
%18 = phi i32 [ 10, %16 ], [ 7, %15 ], [ 5, %14 ], [ 3, %13 ], [ 4, %12 ], [ 2, %11 ], [ 1, %10 ], [ 6, %9 ], [ 0, %1 ], [ 8, %5 ], [ 9, %8 ]
ret i32 %18
}