#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 parse_face(char *);
int /*<<< orphan*/ skip_whitespace(char *);
int parse_move(char *p) {
  int twist, face;
  char *q = p;
  skip_whitespace(p);
  face = parse_face(q);
  if (face < 0)
    return -1;
  twist = 0;
  switch (*q) {
  case '1':
  case '+':
    twist = 0;
    break;
  case '2':
    twist = 1;
    break;
  case '3':
  case '\'':
  case '-':
    twist = 3 - 1;
    break;
  default:
    return -1;
  }
  p = q + 1;
  return face * 3 + twist;
}


x86 assembly (clang, -O0):
<parse_move>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <skip_whitespace@plt>
mov    -0x20(%rbp),%rdi
call   1030 <parse_face@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    115f <parse_move+0x3f>
movl   $0xffffffff,-0x4(%rbp)
jmp    1219 <parse_move+0xf9>
movl   $0x0,-0x14(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x24(%rbp)
sub    $0x27,%eax
je     11eb <parse_move+0xcb>
jmp    117e <parse_move+0x5e>
mov    -0x24(%rbp),%eax
sub    $0x2b,%eax
je     11d3 <parse_move+0xb3>
jmp    118f <parse_move+0x6f>
mov    -0x24(%rbp),%eax
sub    $0x2d,%eax
je     11eb <parse_move+0xcb>
jmp    11a0 <parse_move+0x80>
mov    -0x24(%rbp),%eax
sub    $0x31,%eax
je     11d3 <parse_move+0xb3>
jmp    11b1 <parse_move+0x91>
mov    -0x24(%rbp),%eax
sub    $0x32,%eax
je     11df <parse_move+0xbf>
jmp    11c2 <parse_move+0xa2>
mov    -0x24(%rbp),%eax
sub    $0x33,%eax
je     11eb <parse_move+0xcb>
jmp    11f7 <parse_move+0xd7>
movl   $0x0,-0x14(%rbp)
jmp    1203 <parse_move+0xe3>
movl   $0x1,-0x14(%rbp)
jmp    1203 <parse_move+0xe3>
movl   $0x2,-0x14(%rbp)
jmp    1203 <parse_move+0xe3>
movl   $0xffffffff,-0x4(%rbp)
jmp    1219 <parse_move+0xf9>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
imul   $0x3,-0x18(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_move>:
push   %rbx
mov    %rdi,%rbx
call   1040 <skip_whitespace@plt>
mov    %rbx,%rdi
call   1030 <parse_face@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
test   %ecx,%ecx
js     1165 <parse_move+0x45>
movsbl (%rbx),%edx
lea    -0x27(%rdx),%esi
cmp    $0xc,%esi
ja     1165 <parse_move+0x45>
mov    $0x1c51,%edi
bt     %esi,%edi
jae    1165 <parse_move+0x45>
movslq %edx,%rdx
lea    0xea5(%rip),%rsi
lea    (%rcx,%rcx,2),%eax
add    -0x9c(%rsi,%rdx,4),%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @parse_move(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
store i8* %0, i8** %3
%7 = load i8*, i8** %3
store i8* %7, i8** %6
%8 = load i8*, i8** %3
%9 = call i32 @skip_whitespace(i8* %8)
%10 = load i8*, i8** %6
%11 = call i32 @parse_face(i8* %10)
store i32 %11, i32* %5
%12 = load i32, i32* %5
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %1
store i32 -1, i32* %2
br label %30
15: ; preds = %1
store i32 0, i32* %4
%16 = load i8*, i8** %6
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
switch i32 %18, label %22 [
i32 49, label %19
i32 43, label %19
i32 50, label %20
i32 51, label %21
i32 39, label %21
i32 45, label %21
]
19: ; preds = %15, %15
store i32 0, i32* %4
br label %23
20: ; preds = %15
store i32 1, i32* %4
br label %23
21: ; preds = %15, %15, %15
store i32 2, i32* %4
br label %23
22: ; preds = %15
store i32 -1, i32* %2
br label %30
23: ; preds = %21, %20, %19
%24 = load i8*, i8** %6
%25 = getelementptr inbounds i8, i8* %24, i64 1
store i8* %25, i8** %3
%26 = load i32, i32* %5
%27 = mul nsw i32 %26, 3
%28 = load i32, i32* %4
%29 = add nsw i32 %27, %28
store i32 %29, i32* %2
br label %30
30: ; preds = %23, %22, %14
%31 = load i32, i32* %2
ret i32 %31
}

LLVM IR (-O2):
@switch.table.parse_move = [13 x i32] [i32 2, i32 0, i32 0, i32 0, i32 0, i32 0, i32 2, i32 0, i32 0, i32 0, i32 0, i32 1, i32 2]
define i32 @parse_move(i8* %0) {
%2 = tail call i32 @skip_whitespace(i8* %0)
%3 = tail call i32 @parse_face(i8* %0)
%4 = icmp slt i32 %3, 0
br i1 %4, label %21, label %5
5: ; preds = %1
%6 = load i8, i8* %0
%7 = sext i8 %6 to i32
%8 = add nsw i32 %7, -39
%9 = icmp ult i32 %8, 13
br i1 %9, label %10, label %21
10: ; preds = %5
%11 = trunc i32 %8 to i16
%12 = lshr i16 7249, %11
%13 = and i16 %12, 1
%14 = icmp eq i16 %13, 0
br i1 %14, label %21, label %15
15: ; preds = %10
%16 = sext i32 %8 to i64
%17 = getelementptr inbounds [13 x i32], [13 x i32]* @switch.table.parse_move, i64 0, i64 %16
%18 = load i32, i32* %17
%19 = mul nsw i32 %3, 3
%20 = add nsw i32 %18, %19
br label %21
21: ; preds = %10, %5, %1, %15
%22 = phi i32 [ %20, %15 ], [ -1, %1 ], [ -1, %5 ], [ -1, %10 ]
ret i32 %22
}