#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 chkmv1(char *, char, int, int, int, int);
int chkmov(char b[64], char p, int x, int y) {
  if (b[x * 8 + y] != '-')
    return 0;
  return chkmv1(b, p, x, y, 0, 1) + chkmv1(b, p, x, y, 1, 0) +
         chkmv1(b, p, x, y, 0, -1) + chkmv1(b, p, x, y, -1, 0) +
         chkmv1(b, p, x, y, 1, 1) + chkmv1(b, p, x, y, 1, -1) +
         chkmv1(b, p, x, y, -1, 1) + chkmv1(b, p, x, y, -1, -1);
}


x86 assembly (clang, -O0):
<chkmov>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %sil,%al
mov    %rdi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
shl    $0x3,%ecx
add    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2d,%eax
je     1151 <chkmov+0x41>
movl   $0x0,-0x4(%rbp)
jmp    1290 <chkmov+0x180>
mov    -0x10(%rbp),%rdi
mov    -0x11(%rbp),%al
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
xor    %r8d,%r8d
mov    $0x1,%r9d
movsbl %al,%esi
call   1030 <chkmv1@plt>
mov    %eax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x11(%rbp),%al
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    $0x1,%r8d
xor    %r9d,%r9d
movsbl %al,%esi
call   1030 <chkmv1@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x11(%rbp),%al
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
xor    %r8d,%r8d
mov    $0xffffffff,%r9d
movsbl %al,%esi
call   1030 <chkmv1@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x11(%rbp),%al
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
movsbl %al,%esi
call   1030 <chkmv1@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x11(%rbp),%al
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    $0x1,%r9d
movsbl %al,%esi
mov    %r9d,%r8d
call   1030 <chkmv1@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x11(%rbp),%al
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    $0x1,%r8d
mov    $0xffffffff,%r9d
movsbl %al,%esi
call   1030 <chkmv1@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x11(%rbp),%al
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    $0xffffffff,%r8d
mov    $0x1,%r9d
movsbl %al,%esi
call   1030 <chkmv1@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x11(%rbp),%al
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    $0xffffffff,%r9d
movsbl %al,%esi
mov    %r9d,%r8d
call   1030 <chkmv1@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chkmov>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %edx,%r15d
lea    (%r14,%r15,8),%eax
movslq %eax,%rcx
xor    %eax,%eax
cmpb   $0x2d,(%rdi,%rcx,1)
jne    1230 <chkmov+0x120>
mov    %rdi,%r12
movsbl %sil,%r13d
mov    %r13d,%esi
mov    %r15d,%edx
mov    %r14d,%ecx
xor    %r8d,%r8d
mov    $0x1,%r9d
call   1030 <chkmv1@plt>
mov    %eax,%ebx
mov    %r12,%rdi
mov    %r13d,%esi
mov    %r15d,%edx
mov    %r14d,%ecx
mov    $0x1,%r8d
xor    %r9d,%r9d
call   1030 <chkmv1@plt>
mov    %eax,%ebp
add    %ebx,%ebp
mov    %r12,%rdi
mov    %r13d,%esi
mov    %r15d,%edx
mov    %r14d,%ecx
xor    %r8d,%r8d
mov    $0xffffffff,%r9d
call   1030 <chkmv1@plt>
mov    %eax,%ebx
add    %ebp,%ebx
mov    %r12,%rdi
mov    %r13d,%esi
mov    %r15d,%edx
mov    %r14d,%ecx
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1030 <chkmv1@plt>
mov    %eax,%ebp
add    %ebx,%ebp
mov    %r12,%rdi
mov    %r13d,%esi
mov    %r15d,%edx
mov    %r14d,%ecx
mov    $0x1,%r8d
mov    $0x1,%r9d
call   1030 <chkmv1@plt>
mov    %eax,%ebx
add    %ebp,%ebx
mov    %r12,%rdi
mov    %r13d,%esi
mov    %r15d,%edx
mov    %r14d,%ecx
mov    $0x1,%r8d
mov    $0xffffffff,%r9d
call   1030 <chkmv1@plt>
mov    %eax,%ebp
add    %ebx,%ebp
mov    %r12,%rdi
mov    %r13d,%esi
mov    %r15d,%edx
mov    %r14d,%ecx
mov    $0xffffffff,%r8d
mov    $0x1,%r9d
call   1030 <chkmv1@plt>
mov    %eax,%ebx
add    %ebp,%ebx
mov    %r12,%rdi
mov    %r13d,%esi
mov    %r15d,%edx
mov    %r14d,%ecx
mov    $0xffffffff,%r8d
mov    $0xffffffff,%r9d
call   1030 <chkmv1@plt>
add    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @chkmov(i8* %0, i8 signext %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %6
store i8 %1, i8* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%10 = load i8*, i8** %6
%11 = load i32, i32* %8
%12 = mul nsw i32 %11, 8
%13 = load i32, i32* %9
%14 = add nsw i32 %12, %13
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %10, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 45
br i1 %19, label %20, label %21
20: ; preds = %4
store i32 0, i32* %5
br label %69
21: ; preds = %4
%22 = load i8*, i8** %6
%23 = load i8, i8* %7
%24 = load i32, i32* %8
%25 = load i32, i32* %9
%26 = call i32 @chkmv1(i8* %22, i8 signext %23, i32 %24, i32 %25, i32 0, i32 1)
%27 = load i8*, i8** %6
%28 = load i8, i8* %7
%29 = load i32, i32* %8
%30 = load i32, i32* %9
%31 = call i32 @chkmv1(i8* %27, i8 signext %28, i32 %29, i32 %30, i32 1, i32 0)
%32 = add nsw i32 %26, %31
%33 = load i8*, i8** %6
%34 = load i8, i8* %7
%35 = load i32, i32* %8
%36 = load i32, i32* %9
%37 = call i32 @chkmv1(i8* %33, i8 signext %34, i32 %35, i32 %36, i32 0, i32 -1)
%38 = add nsw i32 %32, %37
%39 = load i8*, i8** %6
%40 = load i8, i8* %7
%41 = load i32, i32* %8
%42 = load i32, i32* %9
%43 = call i32 @chkmv1(i8* %39, i8 signext %40, i32 %41, i32 %42, i32 -1, i32 0)
%44 = add nsw i32 %38, %43
%45 = load i8*, i8** %6
%46 = load i8, i8* %7
%47 = load i32, i32* %8
%48 = load i32, i32* %9
%49 = call i32 @chkmv1(i8* %45, i8 signext %46, i32 %47, i32 %48, i32 1, i32 1)
%50 = add nsw i32 %44, %49
%51 = load i8*, i8** %6
%52 = load i8, i8* %7
%53 = load i32, i32* %8
%54 = load i32, i32* %9
%55 = call i32 @chkmv1(i8* %51, i8 signext %52, i32 %53, i32 %54, i32 1, i32 -1)
%56 = add nsw i32 %50, %55
%57 = load i8*, i8** %6
%58 = load i8, i8* %7
%59 = load i32, i32* %8
%60 = load i32, i32* %9
%61 = call i32 @chkmv1(i8* %57, i8 signext %58, i32 %59, i32 %60, i32 -1, i32 1)
%62 = add nsw i32 %56, %61
%63 = load i8*, i8** %6
%64 = load i8, i8* %7
%65 = load i32, i32* %8
%66 = load i32, i32* %9
%67 = call i32 @chkmv1(i8* %63, i8 signext %64, i32 %65, i32 %66, i32 -1, i32 -1)
%68 = add nsw i32 %62, %67
store i32 %68, i32* %5
br label %69
69: ; preds = %21, %20
%70 = load i32, i32* %5
ret i32 %70
}

LLVM IR (-O2):
define i32 @chkmov(i8* %0, i8 signext %1, i32 %2, i32 %3) {
%5 = shl nsw i32 %2, 3
%6 = add nsw i32 %5, %3
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 45
br i1 %10, label %11, label %27
11: ; preds = %4
%12 = tail call i32 @chkmv1(i8* %0, i8 signext %1, i32 %2, i32 %3, i32 0, i32 1)
%13 = tail call i32 @chkmv1(i8* %0, i8 signext %1, i32 %2, i32 %3, i32 1, i32 0)
%14 = add nsw i32 %13, %12
%15 = tail call i32 @chkmv1(i8* %0, i8 signext %1, i32 %2, i32 %3, i32 0, i32 -1)
%16 = add nsw i32 %14, %15
%17 = tail call i32 @chkmv1(i8* %0, i8 signext %1, i32 %2, i32 %3, i32 -1, i32 0)
%18 = add nsw i32 %16, %17
%19 = tail call i32 @chkmv1(i8* %0, i8 signext %1, i32 %2, i32 %3, i32 1, i32 1)
%20 = add nsw i32 %18, %19
%21 = tail call i32 @chkmv1(i8* %0, i8 signext %1, i32 %2, i32 %3, i32 1, i32 -1)
%22 = add nsw i32 %20, %21
%23 = tail call i32 @chkmv1(i8* %0, i8 signext %1, i32 %2, i32 %3, i32 -1, i32 1)
%24 = add nsw i32 %22, %23
%25 = tail call i32 @chkmv1(i8* %0, i8 signext %1, i32 %2, i32 %3, i32 -1, i32 -1)
%26 = add nsw i32 %24, %25
br label %27
27: ; preds = %4, %11
%28 = phi i32 [ %26, %11 ], [ 0, %4 ]
ret i32 %28
}