#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 const *, char *);
int strlen(char const *);
unsigned char gettype(const char *s) {
  if (strlen(s) == 1)
    switch (s[0]) {
    case '+':
      return 1;
    case '-':
      return 2;
    case 'x':
      return 3;
    case '/':
      return 4;
    case '^':
      return 5;
    case 's':
      return 6;
    case 'i':
      return 7;
    case 'n':
      return 8;
    case '!':
      return 9;
    case 'f':
      return 13;
    case 'r':
      return 14;
    case 'c':
      return 15;
    }
  if (strcmp(s, "gcd") == 0)
    return 10;
  if (strcmp(s, "rnd") == 0)
    return 11;
  if (strcmp(s, "rand") == 0)
    return 12;
  if (strcmp(s, "mod") == 0)
    return 16;
  return -1;
}


x86 assembly (clang, -O0):
<gettype>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x1,%eax
jne    11dc <gettype+0xbc>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
add    $0xffffffdf,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x57,%eax
ja     11d7 <gettype+0xb7>
mov    -0x18(%rbp),%rax
lea    0xe9e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movb   $0x1,-0x1(%rbp)
jmp    126c <gettype+0x14c>
movb   $0x2,-0x1(%rbp)
jmp    126c <gettype+0x14c>
movb   $0x3,-0x1(%rbp)
jmp    126c <gettype+0x14c>
movb   $0x4,-0x1(%rbp)
jmp    126c <gettype+0x14c>
movb   $0x5,-0x1(%rbp)
jmp    126c <gettype+0x14c>
movb   $0x6,-0x1(%rbp)
jmp    126c <gettype+0x14c>
movb   $0x7,-0x1(%rbp)
jmp    126c <gettype+0x14c>
movb   $0x8,-0x1(%rbp)
jmp    126c <gettype+0x14c>
movb   $0x9,-0x1(%rbp)
jmp    126c <gettype+0x14c>
movb   $0xd,-0x1(%rbp)
jmp    126c <gettype+0x14c>
movb   $0xe,-0x1(%rbp)
jmp    126c <gettype+0x14c>
movb   $0xf,-0x1(%rbp)
jmp    126c <gettype+0x14c>
jmp    11dc <gettype+0xbc>
mov    -0x10(%rbp),%rdi
lea    0xf79(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11ff <gettype+0xdf>
movb   $0xa,-0x1(%rbp)
jmp    126c <gettype+0x14c>
mov    -0x10(%rbp),%rdi
lea    0xf5a(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1222 <gettype+0x102>
movb   $0xb,-0x1(%rbp)
jmp    126c <gettype+0x14c>
mov    -0x10(%rbp),%rdi
lea    0xf3b(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1245 <gettype+0x125>
movb   $0xc,-0x1(%rbp)
jmp    126c <gettype+0x14c>
mov    -0x10(%rbp),%rdi
lea    0xf1d(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1268 <gettype+0x148>
movb   $0x10,-0x1(%rbp)
jmp    126c <gettype+0x14c>
movb   $0xff,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gettype>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
cmp    $0x1,%eax
jne    114f <gettype+0x2f>
movsbl (%rbx),%ecx
add    $0xffffffdf,%ecx
cmp    $0x57,%ecx
ja     114f <gettype+0x2f>
mov    $0x1,%al
lea    0xebe(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    $0x9,%al
pop    %rbx
ret
lea    0x100a(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11a3 <gettype+0x83>
lea    0xffa(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11a7 <gettype+0x87>
lea    0xfea(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11ab <gettype+0x8b>
lea    0xfdb(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
neg    %rax
sbb    %eax,%eax
or     $0x10,%al
pop    %rbx
ret
mov    $0xa,%al
pop    %rbx
ret
mov    $0xb,%al
pop    %rbx
ret
mov    $0xc,%al
pop    %rbx
ret
mov    $0x2,%al
pop    %rbx
ret
mov    $0x4,%al
pop    %rbx
ret
mov    $0x5,%al
pop    %rbx
ret
mov    $0xf,%al
pop    %rbx
ret
mov    $0xd,%al
pop    %rbx
ret
mov    $0x7,%al
pop    %rbx
ret
mov    $0x8,%al
pop    %rbx
ret
mov    $0xe,%al
pop    %rbx
ret
mov    $0x6,%al
pop    %rbx
ret
mov    $0x3,%al
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"gcd\00"
@.str.1 = [4 x i8] c"rnd\00"
@.str.2 = [5 x i8] c"rand\00"
@.str.3 = [4 x i8] c"mod\00"
define zeroext i8 @gettype(i8* %0) {
%2 = alloca i8
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i32 @strlen(i8* %4)
%6 = icmp eq i32 %5, 1
br i1 %6, label %7, label %25
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = getelementptr inbounds i8, i8* %8, i64 0
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
switch i32 %11, label %24 [
i32 43, label %12
i32 45, label %13
i32 120, label %14
i32 47, label %15
i32 94, label %16
i32 115, label %17
i32 105, label %18
i32 110, label %19
i32 33, label %20
i32 102, label %21
i32 114, label %22
i32 99, label %23
]
12: ; preds = %7
store i8 1, i8* %2
br label %46
13: ; preds = %7
store i8 2, i8* %2
br label %46
14: ; preds = %7
store i8 3, i8* %2
br label %46
15: ; preds = %7
store i8 4, i8* %2
br label %46
16: ; preds = %7
store i8 5, i8* %2
br label %46
17: ; preds = %7
store i8 6, i8* %2
br label %46
18: ; preds = %7
store i8 7, i8* %2
br label %46
19: ; preds = %7
store i8 8, i8* %2
br label %46
20: ; preds = %7
store i8 9, i8* %2
br label %46
21: ; preds = %7
store i8 13, i8* %2
br label %46
22: ; preds = %7
store i8 14, i8* %2
br label %46
23: ; preds = %7
store i8 15, i8* %2
br label %46
24: ; preds = %7
br label %25
25: ; preds = %24, %1
%26 = load i8*, i8** %3
%27 = call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %25
store i8 10, i8* %2
br label %46
30: ; preds = %25
%31 = load i8*, i8** %3
%32 = call i64 @strcmp(i8* %31, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %30
store i8 11, i8* %2
br label %46
35: ; preds = %30
%36 = load i8*, i8** %3
%37 = call i64 @strcmp(i8* %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %35
store i8 12, i8* %2
br label %46
40: ; preds = %35
%41 = load i8*, i8** %3
%42 = call i64 @strcmp(i8* %41, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %45
44: ; preds = %40
store i8 16, i8* %2
br label %46
45: ; preds = %40
store i8 -1, i8* %2
br label %46
46: ; preds = %45, %44, %39, %34, %29, %23, %22, %21, %20, %19, %18, %17, %16, %15, %14, %13, %12
%47 = load i8, i8* %2
ret i8 %47
}

LLVM IR (-O2):
@.str = [4 x i8] c"gcd\00"
@.str.1 = [4 x i8] c"rnd\00"
@.str.2 = [5 x i8] c"rand\00"
@.str.3 = [4 x i8] c"mod\00"
define zeroext i8 @gettype(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp eq i32 %2, 1
br i1 %3, label %4, label %18
4: ; preds = %1
%5 = load i8, i8* %0
%6 = sext i8 %5 to i32
switch i32 %6, label %18 [
i32 43, label %31
i32 45, label %7
i32 120, label %8
i32 47, label %9
i32 94, label %10
i32 115, label %11
i32 105, label %12
i32 110, label %13
i32 33, label %14
i32 102, label %15
i32 114, label %16
i32 99, label %17
]
7: ; preds = %4
br label %31
8: ; preds = %4
br label %31
9: ; preds = %4
br label %31
10: ; preds = %4
br label %31
11: ; preds = %4
br label %31
12: ; preds = %4
br label %31
13: ; preds = %4
br label %31
14: ; preds = %4
br label %31
15: ; preds = %4
br label %31
16: ; preds = %4
br label %31
17: ; preds = %4
br label %31
18: ; preds = %4, %1
%19 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %31, label %21
21: ; preds = %18
%22 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %31, label %24
24: ; preds = %21
%25 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %31, label %27
27: ; preds = %24
%28 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
%30 = select i1 %29, i8 16, i8 -1
br label %31
31: ; preds = %27, %24, %21, %18, %4, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7
%32 = phi i8 [ 15, %17 ], [ 14, %16 ], [ 13, %15 ], [ 9, %14 ], [ 8, %13 ], [ 7, %12 ], [ 6, %11 ], [ 5, %10 ], [ 4, %9 ], [ 3, %8 ], [ 2, %7 ], [ 1, %4 ], [ 10, %18 ], [ 11, %21 ], [ 12, %24 ], [ %30, %27 ]
ret i8 %32
}