#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 */
#define EOF 128
int /*<<< orphan*/ exit(int);
scalar_t__ isdigit(char);
scalar_t__ islower(char);
scalar_t__ isupper(char);
int /*<<< orphan*/ printf(char *, ...);
int charToType(char c) {
  if (islower(c))
    return 10;
  else if (isupper(c))
    return 11;
  else if (isdigit(c))
    return 12;
  switch (c) {
  case '&':
    return 1;
  case '|':
    return 2;
  case '-':
    return 3;
  case '>':
    return 4;
  case '<':
    return 5;
  case '@':
    return 6;
  case '#':
    return 7;
  case '=':
    return 8;
  case '!':
    return 9;
  case '_':
    return 13;
  case '(':
    return 14;
  case ')':
    return 15;
  case '~':
    return 16;
  case EOF:
    printf("EOF\n");
    exit(1);
  default:
    printf("Error, unrecognized symbol: %c (ascii %i)\n", c, c);
    exit(1);
  }
  return -1;
}


x86 assembly (clang, -O0):
<charToType>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%edi
call   1040 <islower@plt>
cmp    $0x0,%rax
je     117d <charToType+0x2d>
movl   $0xa,-0x4(%rbp)
jmp    12c3 <charToType+0x173>
movsbl -0x5(%rbp),%edi
call   1060 <isupper@plt>
cmp    $0x0,%rax
je     119c <charToType+0x4c>
movl   $0xb,-0x4(%rbp)
jmp    12c3 <charToType+0x173>
movsbl -0x5(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     11bb <charToType+0x6b>
movl   $0xc,-0x4(%rbp)
jmp    12c3 <charToType+0x173>
jmp    11c0 <charToType+0x70>
jmp    11c5 <charToType+0x75>
movsbl -0x5(%rbp),%eax
add    $0xffffffdf,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x5f,%eax
ja     12a3 <charToType+0x153>
mov    -0x10(%rbp),%rax
lea    0xe1a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x4(%rbp)
jmp    12c3 <charToType+0x173>
movl   $0x2,-0x4(%rbp)
jmp    12c3 <charToType+0x173>
movl   $0x3,-0x4(%rbp)
jmp    12c3 <charToType+0x173>
movl   $0x4,-0x4(%rbp)
jmp    12c3 <charToType+0x173>
movl   $0x5,-0x4(%rbp)
jmp    12c3 <charToType+0x173>
movl   $0x6,-0x4(%rbp)
jmp    12c3 <charToType+0x173>
movl   $0x7,-0x4(%rbp)
jmp    12c3 <charToType+0x173>
movl   $0x8,-0x4(%rbp)
jmp    12c3 <charToType+0x173>
movl   $0x9,-0x4(%rbp)
jmp    12c3 <charToType+0x173>
movl   $0xd,-0x4(%rbp)
jmp    12c3 <charToType+0x173>
movl   $0xe,-0x4(%rbp)
jmp    12c3 <charToType+0x173>
movl   $0xf,-0x4(%rbp)
jmp    12c3 <charToType+0x173>
movl   $0x10,-0x4(%rbp)
jmp    12c3 <charToType+0x173>
lea    0xeee(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
movsbl -0x5(%rbp),%esi
movsbl -0x5(%rbp),%edx
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<charToType>:
push   %rbx
mov    %edi,%ebx
call   1040 <islower@plt>
mov    %rax,%rcx
mov    $0xa,%eax
test   %rcx,%rcx
je     1167 <charToType+0x17>
pop    %rbx
ret
movsbl %bl,%ebx
mov    %ebx,%edi
call   1060 <isupper@plt>
mov    %rax,%rcx
mov    $0xb,%eax
test   %rcx,%rcx
jne    1165 <charToType+0x15>
mov    %ebx,%edi
call   1030 <isdigit@plt>
mov    %rax,%rcx
mov    $0xc,%eax
test   %rcx,%rcx
jne    1165 <charToType+0x15>
lea    -0x21(%rbx),%ecx
cmp    $0x5d,%ecx
ja     1203 <charToType+0xb3>
mov    $0x1,%eax
lea    0xe5a(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    $0x9,%eax
pop    %rbx
ret
mov    $0x7,%eax
pop    %rbx
ret
mov    $0xe,%eax
pop    %rbx
ret
mov    $0xf,%eax
pop    %rbx
ret
mov    $0x3,%eax
pop    %rbx
ret
mov    $0x5,%eax
pop    %rbx
ret
mov    $0x8,%eax
pop    %rbx
ret
mov    $0x4,%eax
pop    %rbx
ret
mov    $0x6,%eax
pop    %rbx
ret
mov    $0xd,%eax
pop    %rbx
ret
mov    $0x2,%eax
pop    %rbx
ret
mov    $0x10,%eax
pop    %rbx
ret
lea    0xf6e(%rip),%rdi
mov    %ebx,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"EOF\0A\00"
@.str.1 = [43 x i8] c"Error, unrecognized symbol: %c (ascii %i)\0A\00"
define i32 @charToType(i8 signext %0) {
%2 = alloca i32
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = call i64 @islower(i8 signext %4)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %1
store i32 10, i32* %2
br label %46
8: ; preds = %1
%9 = load i8, i8* %3
%10 = call i64 @isupper(i8 signext %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %8
store i32 11, i32* %2
br label %46
13: ; preds = %8
%14 = load i8, i8* %3
%15 = call i64 @isdigit(i8 signext %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %13
store i32 12, i32* %2
br label %46
18: ; preds = %13
br label %19
19: ; preds = %18
br label %20
20: ; preds = %19
%21 = load i8, i8* %3
%22 = sext i8 %21 to i32
switch i32 %22, label %39 [
i32 38, label %23
i32 124, label %24
i32 45, label %25
i32 62, label %26
i32 60, label %27
i32 64, label %28
i32 35, label %29
i32 61, label %30
i32 33, label %31
i32 95, label %32
i32 40, label %33
i32 41, label %34
i32 126, label %35
i32 128, label %36
]
23: ; preds = %20
store i32 1, i32* %2
br label %46
24: ; preds = %20
store i32 2, i32* %2
br label %46
25: ; preds = %20
store i32 3, i32* %2
br label %46
26: ; preds = %20
store i32 4, i32* %2
br label %46
27: ; preds = %20
store i32 5, i32* %2
br label %46
28: ; preds = %20
store i32 6, i32* %2
br label %46
29: ; preds = %20
store i32 7, i32* %2
br label %46
30: ; preds = %20
store i32 8, i32* %2
br label %46
31: ; preds = %20
store i32 9, i32* %2
br label %46
32: ; preds = %20
store i32 13, i32* %2
br label %46
33: ; preds = %20
store i32 14, i32* %2
br label %46
34: ; preds = %20
store i32 15, i32* %2
br label %46
35: ; preds = %20
store i32 16, i32* %2
br label %46
36: ; preds = %20
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%38 = call i32 @exit(i32 1)
unreachable
39: ; preds = %20
%40 = load i8, i8* %3
%41 = sext i8 %40 to i32
%42 = load i8, i8* %3
%43 = sext i8 %42 to i32
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i32 %41, i32 %43)
%45 = call i32 @exit(i32 1)
unreachable
46: ; preds = %35, %34, %33, %32, %31, %30, %29, %28, %27, %26, %25, %24, %23, %17, %12, %7
%47 = load i32, i32* %2
ret i32 %47
}

LLVM IR (-O2):
@.str.1 = [43 x i8] c"Error, unrecognized symbol: %c (ascii %i)\0A\00"
define i32 @charToType(i8 signext %0) {
%2 = tail call i64 @islower(i8 signext %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %27
4: ; preds = %1
%5 = tail call i64 @isupper(i8 signext %0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %27
7: ; preds = %4
%8 = tail call i64 @isdigit(i8 signext %0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %27
10: ; preds = %7
%11 = sext i8 %0 to i32
switch i32 %11, label %24 [
i32 38, label %27
i32 124, label %12
i32 45, label %13
i32 62, label %14
i32 60, label %15
i32 64, label %16
i32 35, label %17
i32 61, label %18
i32 33, label %19
i32 95, label %20
i32 40, label %21
i32 41, label %22
i32 126, label %23
]
12: ; preds = %10
br label %27
13: ; preds = %10
br label %27
14: ; preds = %10
br label %27
15: ; preds = %10
br label %27
16: ; preds = %10
br label %27
17: ; preds = %10
br label %27
18: ; preds = %10
br label %27
19: ; preds = %10
br label %27
20: ; preds = %10
br label %27
21: ; preds = %10
br label %27
22: ; preds = %10
br label %27
23: ; preds = %10
br label %27
24: ; preds = %10
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 %11)
%26 = tail call i32 @exit(i32 1)
unreachable
27: ; preds = %10, %7, %4, %1, %23, %22, %21, %20, %19, %18, %17, %16, %15, %14, %13, %12
%28 = phi i32 [ 16, %23 ], [ 15, %22 ], [ 14, %21 ], [ 13, %20 ], [ 9, %19 ], [ 8, %18 ], [ 7, %17 ], [ 6, %16 ], [ 5, %15 ], [ 4, %14 ], [ 3, %13 ], [ 2, %12 ], [ 10, %1 ], [ 11, %4 ], [ 12, %7 ], [ 1, %10 ]
ret i32 %28
}