#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 strtokey1(char const **);
int strtokey(const char **pp) {
  const char *p;
  int key;
  p = *pp;
  if (p[0] == 'M' && p[1] == '-') {
    p += 2;
    key = ((strtokey1(&p)) | 0xe000);
  } else if (p[0] == 'C' && p[1] == '-' && p[2] == 'M' && p[3] == '-') {
    p += 4;
    key = ((((strtokey1(&p)) & 0x001f)) | 0xe000);
  } else {
    key = strtokey1(&p);
  }
  *pp = p;
  return key;
}


x86 assembly (clang, -O0):
<strtokey>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x4d,%eax
jne    116a <strtokey+0x5a>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2d,%eax
jne    116a <strtokey+0x5a>
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x10(%rbp)
lea    -0x10(%rbp),%rdi
call   1030 <strtokey1@plt>
or     $0xe000,%eax
mov    %eax,-0x14(%rbp)
jmp    11e3 <strtokey+0xd3>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x43,%eax
jne    11d2 <strtokey+0xc2>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2d,%eax
jne    11d2 <strtokey+0xc2>
mov    -0x10(%rbp),%rax
movsbl 0x2(%rax),%eax
cmp    $0x4d,%eax
jne    11d2 <strtokey+0xc2>
mov    -0x10(%rbp),%rax
movsbl 0x3(%rax),%eax
cmp    $0x2d,%eax
jne    11d2 <strtokey+0xc2>
mov    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x10(%rbp)
lea    -0x10(%rbp),%rdi
call   1030 <strtokey1@plt>
and    $0x1f,%eax
or     $0xe000,%eax
mov    %eax,-0x14(%rbp)
jmp    11de <strtokey+0xce>
lea    -0x10(%rbp),%rdi
call   1030 <strtokey1@plt>
mov    %eax,-0x14(%rbp)
jmp    11e3 <strtokey+0xd3>
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strtokey>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    (%rdi),%rax
mov    %rax,0x8(%rsp)
mov    (%rax),%cl
cmp    $0x43,%cl
je     114c <strtokey+0x3c>
cmp    $0x4d,%cl
jne    117b <strtokey+0x6b>
cmpb   $0x2d,0x1(%rax)
jne    117b <strtokey+0x6b>
add    $0x2,%rax
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rdi
call   1030 <strtokey1@plt>
or     $0xe000,%eax
jmp    1185 <strtokey+0x75>
cmpb   $0x2d,0x1(%rax)
jne    117b <strtokey+0x6b>
cmpb   $0x4d,0x2(%rax)
jne    117b <strtokey+0x6b>
cmpb   $0x2d,0x3(%rax)
jne    117b <strtokey+0x6b>
add    $0x4,%rax
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rdi
call   1030 <strtokey1@plt>
and    $0x1f,%eax
or     $0xe000,%eax
jmp    1185 <strtokey+0x75>
lea    0x8(%rsp),%rdi
call   1030 <strtokey1@plt>
mov    0x8(%rsp),%rcx
mov    %rcx,(%rbx)
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @strtokey(i8** %0) {
%2 = alloca i8**
%3 = alloca i8*
%4 = alloca i32
store i8** %0, i8*** %2
%5 = load i8**, i8*** %2
%6 = load i8*, i8** %5
store i8* %6, i8** %3
%7 = load i8*, i8** %3
%8 = getelementptr inbounds i8, i8* %7, i64 0
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 77
br i1 %11, label %12, label %23
12: ; preds = %1
%13 = load i8*, i8** %3
%14 = getelementptr inbounds i8, i8* %13, i64 1
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 45
br i1 %17, label %18, label %23
18: ; preds = %12
%19 = load i8*, i8** %3
%20 = getelementptr inbounds i8, i8* %19, i64 2
store i8* %20, i8** %3
%21 = call i32 @strtokey1(i8** %3)
%22 = or i32 %21, 57344
store i32 %22, i32* %4
br label %56
23: ; preds = %12, %1
%24 = load i8*, i8** %3
%25 = getelementptr inbounds i8, i8* %24, i64 0
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 67
br i1 %28, label %29, label %53
29: ; preds = %23
%30 = load i8*, i8** %3
%31 = getelementptr inbounds i8, i8* %30, i64 1
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 45
br i1 %34, label %35, label %53
35: ; preds = %29
%36 = load i8*, i8** %3
%37 = getelementptr inbounds i8, i8* %36, i64 2
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 77
br i1 %40, label %41, label %53
41: ; preds = %35
%42 = load i8*, i8** %3
%43 = getelementptr inbounds i8, i8* %42, i64 3
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp eq i32 %45, 45
br i1 %46, label %47, label %53
47: ; preds = %41
%48 = load i8*, i8** %3
%49 = getelementptr inbounds i8, i8* %48, i64 4
store i8* %49, i8** %3
%50 = call i32 @strtokey1(i8** %3)
%51 = and i32 %50, 31
%52 = or i32 %51, 57344
store i32 %52, i32* %4
br label %55
53: ; preds = %41, %35, %29, %23
%54 = call i32 @strtokey1(i8** %3)
store i32 %54, i32* %4
br label %55
55: ; preds = %53, %47
br label %56
56: ; preds = %55, %18
%57 = load i8*, i8** %3
%58 = load i8**, i8*** %2
store i8* %57, i8** %58
%59 = load i32, i32* %4
ret i32 %59
}

LLVM IR (-O2):
define i32 @strtokey(i8** nocapture %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
%4 = load i8*, i8** %0
store i8* %4, i8** %2
%5 = load i8, i8* %4
switch i8 %5, label %31 [
i8 77, label %6
i8 67, label %14
]
6: ; preds = %1
%7 = getelementptr inbounds i8, i8* %4, i64 1
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 45
br i1 %9, label %10, label %31
10: ; preds = %6
%11 = getelementptr inbounds i8, i8* %4, i64 2
store i8* %11, i8** %2
%12 = call i32 @strtokey1(i8** %2)
%13 = or i32 %12, 57344
br label %33
14: ; preds = %1
%15 = getelementptr inbounds i8, i8* %4, i64 1
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 45
br i1 %17, label %18, label %31
18: ; preds = %14
%19 = getelementptr inbounds i8, i8* %4, i64 2
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 77
br i1 %21, label %22, label %31
22: ; preds = %18
%23 = getelementptr inbounds i8, i8* %4, i64 3
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, 45
br i1 %25, label %26, label %31
26: ; preds = %22
%27 = getelementptr inbounds i8, i8* %4, i64 4
store i8* %27, i8** %2
%28 = call i32 @strtokey1(i8** %2)
%29 = and i32 %28, 31
%30 = or i32 %29, 57344
br label %33
31: ; preds = %1, %6, %22, %18, %14
%32 = call i32 @strtokey1(i8** %2)
br label %33
33: ; preds = %26, %31, %10
%34 = phi i32 [ %13, %10 ], [ %30, %26 ], [ %32, %31 ]
%35 = load i8*, i8** %2
store i8* %35, i8** %0
ret i32 %34
}