#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 /*<<< orphan*/ strncmp(char *, char const *, int);
extern int grd5_type(const char *str) {
  switch (str[0]) {
  case 'b':
    if (strncmp("bool", str, 4) == 0)
      return 7;
    break;
  case 'd':
    if (strncmp("doub", str, 4) == 0)
      return 9;
    break;
  case 'e':
    if (strncmp("enum", str, 4) == 0)
      return 10;
    break;
  case 'l':
    if (strncmp("long", str, 4) == 0)
      return 8;
    break;
  case 'O':
    if (strncmp("Objc", str, 4) == 0)
      return 5;
    break;
  case 't':
    if (strncmp("tdta", str, 4) == 0)
      return 11;
    break;
  case 'T':
    if (strncmp("TEXT", str, 4) == 0)
      return 4;
    break;
  case 'p':
    if (strncmp("patt", str, 4) == 0)
      return 1;
    break;
  case 'U':
    if (strncmp("UntF", str, 4) == 0)
      return 6;
    break;
  case 'V':
    if (strncmp("VlLs", str, 4) == 0)
      return 3;
    break;
  default:
    return 0;
  }
  return 0;
}


x86 assembly (clang, -O0):
<grd5_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
add    $0xffffffb1,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x25,%eax
ja     131f <grd5_type+0x20f>
mov    -0x18(%rbp),%rax
lea    0xec0(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rsi
lea    0xf44(%rip),%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1173 <grd5_type+0x63>
movl   $0x7,-0x4(%rbp)
jmp    1332 <grd5_type+0x222>
jmp    132b <grd5_type+0x21b>
mov    -0x10(%rbp),%rsi
lea    0xf1a(%rip),%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11a2 <grd5_type+0x92>
movl   $0x9,-0x4(%rbp)
jmp    1332 <grd5_type+0x222>
jmp    132b <grd5_type+0x21b>
mov    -0x10(%rbp),%rsi
lea    0xef0(%rip),%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11d1 <grd5_type+0xc1>
movl   $0xa,-0x4(%rbp)
jmp    1332 <grd5_type+0x222>
jmp    132b <grd5_type+0x21b>
mov    -0x10(%rbp),%rsi
lea    0xec6(%rip),%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1200 <grd5_type+0xf0>
movl   $0x8,-0x4(%rbp)
jmp    1332 <grd5_type+0x222>
jmp    132b <grd5_type+0x21b>
mov    -0x10(%rbp),%rsi
lea    0xe9c(%rip),%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    122f <grd5_type+0x11f>
movl   $0x5,-0x4(%rbp)
jmp    1332 <grd5_type+0x222>
jmp    132b <grd5_type+0x21b>
mov    -0x10(%rbp),%rsi
lea    0xe72(%rip),%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    125e <grd5_type+0x14e>
movl   $0xb,-0x4(%rbp)
jmp    1332 <grd5_type+0x222>
jmp    132b <grd5_type+0x21b>
mov    -0x10(%rbp),%rsi
lea    0xe48(%rip),%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    128d <grd5_type+0x17d>
movl   $0x4,-0x4(%rbp)
jmp    1332 <grd5_type+0x222>
jmp    132b <grd5_type+0x21b>
mov    -0x10(%rbp),%rsi
lea    0xe1e(%rip),%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    12bc <grd5_type+0x1ac>
movl   $0x1,-0x4(%rbp)
jmp    1332 <grd5_type+0x222>
jmp    132b <grd5_type+0x21b>
mov    -0x10(%rbp),%rsi
lea    0xdf4(%rip),%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    12eb <grd5_type+0x1db>
movl   $0x6,-0x4(%rbp)
jmp    1332 <grd5_type+0x222>
jmp    132b <grd5_type+0x21b>
mov    -0x10(%rbp),%rsi
lea    0xdca(%rip),%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    131a <grd5_type+0x20a>
movl   $0x3,-0x4(%rbp)
jmp    1332 <grd5_type+0x222>
jmp    132b <grd5_type+0x21b>
movl   $0x0,-0x4(%rbp)
jmp    1332 <grd5_type+0x222>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<grd5_type>:
push   %rbx
movsbl (%rdi),%eax
xor    %ebx,%ebx
add    $0xffffffb1,%eax
cmp    $0x25,%eax
ja     126d <grd5_type+0x15d>
mov    %rdi,%rsi
lea    0xed4(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
xor    %ebx,%ebx
jmp    *%rax
lea    0xf6e(%rip),%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    126b <grd5_type+0x15b>
mov    $0x5,%ebx
jmp    126d <grd5_type+0x15d>
lea    0xf55(%rip),%rdi
mov    $0x4,%ebx
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    126b <grd5_type+0x15b>
jmp    126d <grd5_type+0x15d>
lea    0xf3c(%rip),%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    126b <grd5_type+0x15b>
mov    $0x6,%ebx
jmp    126d <grd5_type+0x15d>
lea    0xf1e(%rip),%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    126b <grd5_type+0x15b>
mov    $0x3,%ebx
jmp    126d <grd5_type+0x15d>
lea    0xece(%rip),%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    126b <grd5_type+0x15b>
mov    $0x7,%ebx
jmp    126d <grd5_type+0x15d>
lea    0xeb0(%rip),%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    126b <grd5_type+0x15b>
mov    $0x9,%ebx
jmp    126d <grd5_type+0x15d>
lea    0xe99(%rip),%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    126b <grd5_type+0x15b>
mov    $0xa,%ebx
jmp    126d <grd5_type+0x15d>
lea    0xe82(%rip),%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    126b <grd5_type+0x15b>
mov    $0x8,%ebx
jmp    126d <grd5_type+0x15d>
lea    0xe7a(%rip),%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    126b <grd5_type+0x15b>
mov    $0x1,%ebx
jmp    126d <grd5_type+0x15d>
lea    0xe54(%rip),%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1271 <grd5_type+0x161>
xor    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
ret
mov    $0xb,%ebx
jmp    126d <grd5_type+0x15d>

LLVM IR (-O0):
@.str = [5 x i8] c"bool\00"
@.str.1 = [5 x i8] c"doub\00"
@.str.2 = [5 x i8] c"enum\00"
@.str.3 = [5 x i8] c"long\00"
@.str.4 = [5 x i8] c"Objc\00"
@.str.5 = [5 x i8] c"tdta\00"
@.str.6 = [5 x i8] c"TEXT\00"
@.str.7 = [5 x i8] c"patt\00"
@.str.8 = [5 x i8] c"UntF\00"
@.str.9 = [5 x i8] c"VlLs\00"
define i32 @grd5_type(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
switch i32 %7, label %68 [
i32 98, label %8
i32 100, label %14
i32 101, label %20
i32 108, label %26
i32 79, label %32
i32 116, label %38
i32 84, label %44
i32 112, label %50
i32 85, label %56
i32 86, label %62
]
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i32 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %9, i32 4)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %8
store i32 7, i32* %2
br label %70
13: ; preds = %8
br label %69
14: ; preds = %1
%15 = load i8*, i8** %3
%16 = call i32 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %15, i32 4)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %14
store i32 9, i32* %2
br label %70
19: ; preds = %14
br label %69
20: ; preds = %1
%21 = load i8*, i8** %3
%22 = call i32 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %21, i32 4)
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %20
store i32 10, i32* %2
br label %70
25: ; preds = %20
br label %69
26: ; preds = %1
%27 = load i8*, i8** %3
%28 = call i32 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %27, i32 4)
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %26
store i32 8, i32* %2
br label %70
31: ; preds = %26
br label %69
32: ; preds = %1
%33 = load i8*, i8** %3
%34 = call i32 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %33, i32 4)
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %32
store i32 5, i32* %2
br label %70
37: ; preds = %32
br label %69
38: ; preds = %1
%39 = load i8*, i8** %3
%40 = call i32 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* %39, i32 4)
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %38
store i32 11, i32* %2
br label %70
43: ; preds = %38
br label %69
44: ; preds = %1
%45 = load i8*, i8** %3
%46 = call i32 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %45, i32 4)
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %49
48: ; preds = %44
store i32 4, i32* %2
br label %70
49: ; preds = %44
br label %69
50: ; preds = %1
%51 = load i8*, i8** %3
%52 = call i32 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8* %51, i32 4)
%53 = icmp eq i32 %52, 0
br i1 %53, label %54, label %55
54: ; preds = %50
store i32 1, i32* %2
br label %70
55: ; preds = %50
br label %69
56: ; preds = %1
%57 = load i8*, i8** %3
%58 = call i32 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8* %57, i32 4)
%59 = icmp eq i32 %58, 0
br i1 %59, label %60, label %61
60: ; preds = %56
store i32 6, i32* %2
br label %70
61: ; preds = %56
br label %69
62: ; preds = %1
%63 = load i8*, i8** %3
%64 = call i32 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i8* %63, i32 4)
%65 = icmp eq i32 %64, 0
br i1 %65, label %66, label %67
66: ; preds = %62
store i32 3, i32* %2
br label %70
67: ; preds = %62
br label %69
68: ; preds = %1
store i32 0, i32* %2
br label %70
69: ; preds = %67, %61, %55, %49, %43, %37, %31, %25, %19, %13
store i32 0, i32* %2
br label %70
70: ; preds = %69, %68, %66, %60, %54, %48, %42, %36, %30, %24, %18, %12
%71 = load i32, i32* %2
ret i32 %71
}

LLVM IR (-O2):
@.str = [5 x i8] c"bool\00"
@.str.1 = [5 x i8] c"doub\00"
@.str.2 = [5 x i8] c"enum\00"
@.str.3 = [5 x i8] c"long\00"
@.str.4 = [5 x i8] c"Objc\00"
@.str.5 = [5 x i8] c"tdta\00"
@.str.6 = [5 x i8] c"TEXT\00"
@.str.7 = [5 x i8] c"patt\00"
@.str.8 = [5 x i8] c"UntF\00"
@.str.9 = [5 x i8] c"VlLs\00"
define i32 @grd5_type(i8* %0) {
%2 = load i8, i8* %0
%3 = sext i8 %2 to i32
switch i32 %3, label %35 [
i32 98, label %4
i32 100, label %7
i32 101, label %10
i32 108, label %13
i32 79, label %16
i32 116, label %19
i32 84, label %22
i32 112, label %25
i32 85, label %28
i32 86, label %31
]
4: ; preds = %1
%5 = tail call i32 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0, i32 4)
%6 = icmp eq i32 %5, 0
br i1 %6, label %35, label %34
7: ; preds = %1
%8 = tail call i32 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 4)
%9 = icmp eq i32 %8, 0
br i1 %9, label %35, label %34
10: ; preds = %1
%11 = tail call i32 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %0, i32 4)
%12 = icmp eq i32 %11, 0
br i1 %12, label %35, label %34
13: ; preds = %1
%14 = tail call i32 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %0, i32 4)
%15 = icmp eq i32 %14, 0
br i1 %15, label %35, label %34
16: ; preds = %1
%17 = tail call i32 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %0, i32 4)
%18 = icmp eq i32 %17, 0
br i1 %18, label %35, label %34
19: ; preds = %1
%20 = tail call i32 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* %0, i32 4)
%21 = icmp eq i32 %20, 0
br i1 %21, label %35, label %34
22: ; preds = %1
%23 = tail call i32 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %0, i32 4)
%24 = icmp eq i32 %23, 0
br i1 %24, label %35, label %34
25: ; preds = %1
%26 = tail call i32 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8* %0, i32 4)
%27 = icmp eq i32 %26, 0
br i1 %27, label %35, label %34
28: ; preds = %1
%29 = tail call i32 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8* %0, i32 4)
%30 = icmp eq i32 %29, 0
br i1 %30, label %35, label %34
31: ; preds = %1
%32 = tail call i32 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i8* %0, i32 4)
%33 = icmp eq i32 %32, 0
br i1 %33, label %35, label %34
34: ; preds = %31, %28, %25, %22, %19, %16, %13, %10, %7, %4
br label %35
35: ; preds = %1, %31, %28, %25, %22, %19, %16, %13, %10, %7, %4, %34
%36 = phi i32 [ 0, %34 ], [ 7, %4 ], [ 9, %7 ], [ 10, %10 ], [ 8, %13 ], [ 5, %16 ], [ 11, %19 ], [ 4, %22 ], [ 1, %25 ], [ 6, %28 ], [ 3, %31 ], [ 0, %1 ]
ret i32 %36
}