#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 */
scalar_t__ strcmp(char *, char *);
int type_check(char *name) {
  if (strcmp("char", name) == 0 || strcmp("CHAR", name) == 0)
    return 1;
  else if (strcmp("integer", name) == 0 || strcmp("INTEGER", name) == 0)
    return 2;
  else if (strcmp("real", name) == 0 || strcmp("REAL", name) == 0)
    return 3;
  else if (strcmp("boolean", name) == 0 || strcmp("BOOLEAN", name) == 0)
    return 4;
  else if (strcmp("string", name) == 0 || strcmp("STRING", name) == 0)
    return 5;
  else if (strcmp("array", name) == 0 || strcmp("ARRAY", name) == 0)
    return 6;
  else if (strcmp("record", name) == 0 || strcmp("RECORD", name) == 0)
    return 7;
  else if (strcmp("type", name) == 0)
    return 8;
  else if (strcmp("const", name) == 0)
    return 9;
  else
    return -1;
}


x86 assembly (clang, -O0):
<type_check>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xed9(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     1150 <type_check+0x40>
mov    -0x10(%rbp),%rsi
lea    0xec4(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    115c <type_check+0x4c>
movl   $0x1,-0x4(%rbp)
jmp    132f <type_check+0x21f>
mov    -0x10(%rbp),%rsi
lea    0xea3(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     1190 <type_check+0x80>
mov    -0x10(%rbp),%rsi
lea    0xe91(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    119c <type_check+0x8c>
movl   $0x2,-0x4(%rbp)
jmp    132f <type_check+0x21f>
mov    -0x10(%rbp),%rsi
lea    0xe73(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     11d0 <type_check+0xc0>
mov    -0x10(%rbp),%rsi
lea    0xe5e(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11dc <type_check+0xcc>
movl   $0x3,-0x4(%rbp)
jmp    132f <type_check+0x21f>
mov    -0x10(%rbp),%rsi
lea    0xe3d(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     1210 <type_check+0x100>
mov    -0x10(%rbp),%rsi
lea    0xe2b(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    121c <type_check+0x10c>
movl   $0x4,-0x4(%rbp)
jmp    132f <type_check+0x21f>
mov    -0x10(%rbp),%rsi
lea    0xe0d(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     1250 <type_check+0x140>
mov    -0x10(%rbp),%rsi
lea    0xdfa(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    125c <type_check+0x14c>
movl   $0x5,-0x4(%rbp)
jmp    132f <type_check+0x21f>
mov    -0x10(%rbp),%rsi
lea    0xddb(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     1290 <type_check+0x180>
mov    -0x10(%rbp),%rsi
lea    0xdc7(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    129c <type_check+0x18c>
movl   $0x6,-0x4(%rbp)
jmp    132f <type_check+0x21f>
mov    -0x10(%rbp),%rsi
lea    0xda7(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     12d0 <type_check+0x1c0>
mov    -0x10(%rbp),%rsi
lea    0xd94(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    12dc <type_check+0x1cc>
movl   $0x7,-0x4(%rbp)
jmp    132f <type_check+0x21f>
mov    -0x10(%rbp),%rsi
lea    0xd75(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1302 <type_check+0x1f2>
movl   $0x8,-0x4(%rbp)
jmp    132f <type_check+0x21f>
mov    -0x10(%rbp),%rsi
lea    0xd54(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1328 <type_check+0x218>
movl   $0x9,-0x4(%rbp)
jmp    132f <type_check+0x21f>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<type_check>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xee3(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
mov    $0x1,%ebp
test   %rax,%rax
je     12ab <type_check+0x19b>
lea    0xecb(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     12ab <type_check+0x19b>
lea    0xeb8(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
mov    $0x2,%ebp
test   %rax,%rax
je     12ab <type_check+0x19b>
lea    0xea3(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     12ab <type_check+0x19b>
lea    0xe93(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
mov    $0x3,%ebp
test   %rax,%rax
je     12ab <type_check+0x19b>
lea    0xe7b(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     12ab <type_check+0x19b>
lea    0xe68(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
mov    $0x4,%ebp
test   %rax,%rax
je     12ab <type_check+0x19b>
lea    0xe53(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     12ab <type_check+0x19b>
lea    0xe43(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
mov    $0x5,%ebp
test   %rax,%rax
je     12ab <type_check+0x19b>
lea    0xe2d(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     12ab <type_check+0x19b>
lea    0xe1c(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
mov    $0x6,%ebp
test   %rax,%rax
je     12ab <type_check+0x19b>
lea    0xe09(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     12ab <type_check+0x19b>
lea    0xdfb(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
mov    $0x7,%ebp
test   %rax,%rax
je     12ab <type_check+0x19b>
lea    0xde9(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     12ab <type_check+0x19b>
lea    0xddc(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     12a6 <type_check+0x196>
lea    0xdcd(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
neg    %rax
sbb    %ebp,%ebp
or     $0x9,%ebp
jmp    12ab <type_check+0x19b>
mov    $0x8,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"char\00"
@.str.1 = [5 x i8] c"CHAR\00"
@.str.2 = [8 x i8] c"integer\00"
@.str.3 = [8 x i8] c"INTEGER\00"
@.str.4 = [5 x i8] c"real\00"
@.str.5 = [5 x i8] c"REAL\00"
@.str.6 = [8 x i8] c"boolean\00"
@.str.7 = [8 x i8] c"BOOLEAN\00"
@.str.8 = [7 x i8] c"string\00"
@.str.9 = [7 x i8] c"STRING\00"
@.str.10 = [6 x i8] c"array\00"
@.str.11 = [6 x i8] c"ARRAY\00"
@.str.12 = [7 x i8] c"record\00"
@.str.13 = [7 x i8] c"RECORD\00"
@.str.14 = [5 x i8] c"type\00"
@.str.15 = [6 x i8] c"const\00"
define i32 @type_check(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i64 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %11, label %7
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = call i64 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %7, %1
store i32 1, i32* %2
br label %77
12: ; preds = %7
%13 = load i8*, i8** %3
%14 = call i64 @strcmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %12
%17 = load i8*, i8** %3
%18 = call i64 @strcmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %16, %12
store i32 2, i32* %2
br label %77
21: ; preds = %16
%22 = load i8*, i8** %3
%23 = call i64 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %22)
%24 = icmp eq i64 %23, 0
br i1 %24, label %29, label %25
25: ; preds = %21
%26 = load i8*, i8** %3
%27 = call i64 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %25, %21
store i32 3, i32* %2
br label %77
30: ; preds = %25
%31 = load i8*, i8** %3
%32 = call i64 @strcmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i8* %31)
%33 = icmp eq i64 %32, 0
br i1 %33, label %38, label %34
34: ; preds = %30
%35 = load i8*, i8** %3
%36 = call i64 @strcmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i8* %35)
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %34, %30
store i32 4, i32* %2
br label %77
39: ; preds = %34
%40 = load i8*, i8** %3
%41 = call i64 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i8* %40)
%42 = icmp eq i64 %41, 0
br i1 %42, label %47, label %43
43: ; preds = %39
%44 = load i8*, i8** %3
%45 = call i64 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i8* %44)
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %48
47: ; preds = %43, %39
store i32 5, i32* %2
br label %77
48: ; preds = %43
%49 = load i8*, i8** %3
%50 = call i64 @strcmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i8* %49)
%51 = icmp eq i64 %50, 0
br i1 %51, label %56, label %52
52: ; preds = %48
%53 = load i8*, i8** %3
%54 = call i64 @strcmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i8* %53)
%55 = icmp eq i64 %54, 0
br i1 %55, label %56, label %57
56: ; preds = %52, %48
store i32 6, i32* %2
br label %77
57: ; preds = %52
%58 = load i8*, i8** %3
%59 = call i64 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0), i8* %58)
%60 = icmp eq i64 %59, 0
br i1 %60, label %65, label %61
61: ; preds = %57
%62 = load i8*, i8** %3
%63 = call i64 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.13, i64 0, i64 0), i8* %62)
%64 = icmp eq i64 %63, 0
br i1 %64, label %65, label %66
65: ; preds = %61, %57
store i32 7, i32* %2
br label %77
66: ; preds = %61
%67 = load i8*, i8** %3
%68 = call i64 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0), i8* %67)
%69 = icmp eq i64 %68, 0
br i1 %69, label %70, label %71
70: ; preds = %66
store i32 8, i32* %2
br label %77
71: ; preds = %66
%72 = load i8*, i8** %3
%73 = call i64 @strcmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.15, i64 0, i64 0), i8* %72)
%74 = icmp eq i64 %73, 0
br i1 %74, label %75, label %76
75: ; preds = %71
store i32 9, i32* %2
br label %77
76: ; preds = %71
store i32 -1, i32* %2
br label %77
77: ; preds = %76, %75, %70, %65, %56, %47, %38, %29, %20, %11
%78 = load i32, i32* %2
ret i32 %78
}

LLVM IR (-O2):
@.str = [5 x i8] c"char\00"
@.str.1 = [5 x i8] c"CHAR\00"
@.str.2 = [8 x i8] c"integer\00"
@.str.3 = [8 x i8] c"INTEGER\00"
@.str.4 = [5 x i8] c"real\00"
@.str.5 = [5 x i8] c"REAL\00"
@.str.6 = [8 x i8] c"boolean\00"
@.str.7 = [8 x i8] c"BOOLEAN\00"
@.str.8 = [7 x i8] c"string\00"
@.str.9 = [7 x i8] c"STRING\00"
@.str.10 = [6 x i8] c"array\00"
@.str.11 = [6 x i8] c"ARRAY\00"
@.str.12 = [7 x i8] c"record\00"
@.str.13 = [7 x i8] c"RECORD\00"
@.str.14 = [5 x i8] c"type\00"
@.str.15 = [6 x i8] c"const\00"
define i32 @type_check(i8* %0) {
%2 = tail call i64 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %50, label %4
4: ; preds = %1
%5 = tail call i64 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %50, label %7
7: ; preds = %4
%8 = tail call i64 @strcmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %50, label %10
10: ; preds = %7
%11 = tail call i64 @strcmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %0)
%12 = icmp eq i64 %11, 0
br i1 %12, label %50, label %13
13: ; preds = %10
%14 = tail call i64 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %0)
%15 = icmp eq i64 %14, 0
br i1 %15, label %50, label %16
16: ; preds = %13
%17 = tail call i64 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* %0)
%18 = icmp eq i64 %17, 0
br i1 %18, label %50, label %19
19: ; preds = %16
%20 = tail call i64 @strcmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i8* %0)
%21 = icmp eq i64 %20, 0
br i1 %21, label %50, label %22
22: ; preds = %19
%23 = tail call i64 @strcmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i8* %0)
%24 = icmp eq i64 %23, 0
br i1 %24, label %50, label %25
25: ; preds = %22
%26 = tail call i64 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i8* %0)
%27 = icmp eq i64 %26, 0
br i1 %27, label %50, label %28
28: ; preds = %25
%29 = tail call i64 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i8* %0)
%30 = icmp eq i64 %29, 0
br i1 %30, label %50, label %31
31: ; preds = %28
%32 = tail call i64 @strcmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i8* %0)
%33 = icmp eq i64 %32, 0
br i1 %33, label %50, label %34
34: ; preds = %31
%35 = tail call i64 @strcmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i8* %0)
%36 = icmp eq i64 %35, 0
br i1 %36, label %50, label %37
37: ; preds = %34
%38 = tail call i64 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0), i8* %0)
%39 = icmp eq i64 %38, 0
br i1 %39, label %50, label %40
40: ; preds = %37
%41 = tail call i64 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.13, i64 0, i64 0), i8* %0)
%42 = icmp eq i64 %41, 0
br i1 %42, label %50, label %43
43: ; preds = %40
%44 = tail call i64 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0), i8* %0)
%45 = icmp eq i64 %44, 0
br i1 %45, label %50, label %46
46: ; preds = %43
%47 = tail call i64 @strcmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.15, i64 0, i64 0), i8* %0)
%48 = icmp eq i64 %47, 0
%49 = select i1 %48, i32 9, i32 -1
br label %50
50: ; preds = %46, %43, %37, %40, %31, %34, %25, %28, %19, %22, %13, %16, %7, %10, %1, %4
%51 = phi i32 [ 1, %4 ], [ 1, %1 ], [ 2, %10 ], [ 2, %7 ], [ 3, %16 ], [ 3, %13 ], [ 4, %22 ], [ 4, %19 ], [ 5, %28 ], [ 5, %25 ], [ 6, %34 ], [ 6, %31 ], [ 7, %40 ], [ 7, %37 ], [ 8, %43 ], [ %49, %46 ]
ret i32 %51
}