#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__ chkmov(char *, char, int, int);
int chkmvs(char b[64], char p) {
  int i, j, k;
  k = 0;
  for (i = 0; i < 8; i++)
    for (j = 0; j < 8; j++)
      k += chkmov(b, p, i, j);
  return k;
}


x86 assembly (clang, -O0):
<chkmvs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x8,-0x10(%rbp)
jge    118e <chkmvs+0x7e>
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    117b <chkmvs+0x6b>
mov    -0x8(%rbp),%rdi
mov    -0x9(%rbp),%al
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
movsbl %al,%esi
call   1030 <chkmov@plt>
mov    %rax,%rcx
movslq -0x18(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1141 <chkmvs+0x31>
jmp    1180 <chkmvs+0x70>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1130 <chkmvs+0x20>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chkmvs>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r14
xor    %ebp,%ebp
movsbl %sil,%r15d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
mov    %r15d,%esi
mov    %ebx,%edx
xor    %ecx,%ecx
call   1030 <chkmov@plt>
mov    %rax,%r12
add    %ebp,%r12d
mov    %r14,%rdi
mov    %r15d,%esi
mov    %ebx,%edx
mov    $0x1,%ecx
call   1030 <chkmov@plt>
mov    %rax,%rbp
add    %r12d,%ebp
mov    %r14,%rdi
mov    %r15d,%esi
mov    %ebx,%edx
mov    $0x2,%ecx
call   1030 <chkmov@plt>
mov    %rax,%r12
add    %ebp,%r12d
mov    %r14,%rdi
mov    %r15d,%esi
mov    %ebx,%edx
mov    $0x3,%ecx
call   1030 <chkmov@plt>
mov    %rax,%rbp
add    %r12d,%ebp
mov    %r14,%rdi
mov    %r15d,%esi
mov    %ebx,%edx
mov    $0x4,%ecx
call   1030 <chkmov@plt>
mov    %rax,%r12
add    %ebp,%r12d
mov    %r14,%rdi
mov    %r15d,%esi
mov    %ebx,%edx
mov    $0x5,%ecx
call   1030 <chkmov@plt>
mov    %rax,%rbp
add    %r12d,%ebp
mov    %r14,%rdi
mov    %r15d,%esi
mov    %ebx,%edx
mov    $0x6,%ecx
call   1030 <chkmov@plt>
mov    %rax,%r12
add    %ebp,%r12d
mov    %r14,%rdi
mov    %r15d,%esi
mov    %ebx,%edx
mov    $0x7,%ecx
call   1030 <chkmov@plt>
mov    %rax,%rbp
add    %r12d,%ebp
add    $0x1,%ebx
cmp    $0x8,%ebx
jne    1130 <chkmvs+0x20>
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @chkmvs(i8* %0, i8 signext %1) {
%3 = alloca i8*
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i8 %1, i8* %4
store i32 0, i32* %7
store i32 0, i32* %5
br label %8
8: ; preds = %29, %2
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, 8
br i1 %10, label %11, label %32
11: ; preds = %8
store i32 0, i32* %6
br label %12
12: ; preds = %25, %11
%13 = load i32, i32* %6
%14 = icmp slt i32 %13, 8
br i1 %14, label %15, label %28
15: ; preds = %12
%16 = load i8*, i8** %3
%17 = load i8, i8* %4
%18 = load i32, i32* %5
%19 = load i32, i32* %6
%20 = call i64 @chkmov(i8* %16, i8 signext %17, i32 %18, i32 %19)
%21 = load i32, i32* %7
%22 = sext i32 %21 to i64
%23 = add nsw i64 %22, %20
%24 = trunc i64 %23 to i32
store i32 %24, i32* %7
br label %25
25: ; preds = %15
%26 = load i32, i32* %6
%27 = add nsw i32 %26, 1
store i32 %27, i32* %6
br label %12
28: ; preds = %12
br label %29
29: ; preds = %28
%30 = load i32, i32* %5
%31 = add nsw i32 %30, 1
store i32 %31, i32* %5
br label %8
32: ; preds = %8
%33 = load i32, i32* %7
ret i32 %33
}

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