#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__ chkmv1(char *, char, int, int, int, int);
int /*<<< orphan*/ putmv1(char *, char, int, int, int, int);
void putmov(char b[64], char p, int x, int y) {
  int i, j;
  b[x * 8 + y] = p;
  for (i = -1; i <= 1; i++)
    for (j = -1; j <= 1; j++) {
      if ((i != 0 || j != 0) && chkmv1(b, p, x, y, i, j) > 0)
        putmv1(b, p, x, y, i, j);
    }
}


x86 assembly (clang, -O0):
<putmov>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x9(%rbp),%dl
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
shl    $0x3,%ecx
add    -0x14(%rbp),%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
movl   $0xffffffff,-0x18(%rbp)
cmpl   $0x1,-0x18(%rbp)
jg     11ee <putmov+0xce>
movl   $0xffffffff,-0x1c(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jg     11db <putmov+0xbb>
cmpl   $0x0,-0x18(%rbp)
jne    1184 <putmov+0x64>
cmpl   $0x0,-0x1c(%rbp)
je     11c8 <putmov+0xa8>
mov    -0x8(%rbp),%rdi
mov    -0x9(%rbp),%al
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    -0x1c(%rbp),%r9d
movsbl %al,%esi
call   1040 <chkmv1@plt>
cmp    $0x0,%rax
jle    11c8 <putmov+0xa8>
mov    -0x8(%rbp),%rdi
mov    -0x9(%rbp),%al
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    -0x1c(%rbp),%r9d
movsbl %al,%esi
call   1030 <putmv1@plt>
jmp    11cd <putmov+0xad>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1166 <putmov+0x46>
jmp    11e0 <putmov+0xc0>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1155 <putmov+0x35>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<putmov>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %rdi,%r12
lea    (%r14,%r15,8),%eax
cltq
mov    %sil,(%rdi,%rax,1)
mov    $0xffffffff,%ebp
movsbl %sil,%ebx
jmp    115c <putmov+0x3c>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%ebp
cmp    $0x2,%ebp
je     1208 <putmov+0xe8>
mov    %r12,%rdi
mov    %ebx,%esi
mov    %r15d,%edx
mov    %r14d,%ecx
mov    %ebp,%r8d
mov    $0xffffffff,%r9d
call   1040 <chkmv1@plt>
test   %rax,%rax
jle    1193 <putmov+0x73>
mov    %r12,%rdi
mov    %ebx,%esi
mov    %r15d,%edx
mov    %r14d,%ecx
mov    %ebp,%r8d
mov    $0xffffffff,%r9d
call   1030 <putmv1@plt>
test   %ebp,%ebp
je     11c8 <putmov+0xa8>
mov    %r12,%rdi
mov    %ebx,%esi
mov    %r15d,%edx
mov    %r14d,%ecx
mov    %ebp,%r8d
xor    %r9d,%r9d
call   1040 <chkmv1@plt>
test   %rax,%rax
jle    11c8 <putmov+0xa8>
mov    %r12,%rdi
mov    %ebx,%esi
mov    %r15d,%edx
mov    %r14d,%ecx
mov    %ebp,%r8d
xor    %r9d,%r9d
call   1030 <putmv1@plt>
mov    %r12,%rdi
mov    %ebx,%esi
mov    %r15d,%edx
mov    %r14d,%ecx
mov    %ebp,%r8d
mov    $0x1,%r9d
call   1040 <chkmv1@plt>
test   %rax,%rax
jle    1150 <putmov+0x30>
mov    %r12,%rdi
mov    %ebx,%esi
mov    %r15d,%edx
mov    %r14d,%ecx
mov    %ebp,%r8d
mov    $0x1,%r9d
call   1030 <putmv1@plt>
jmp    1150 <putmov+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @putmov(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
store i8 %1, i8* %8
br label %9
9: ; preds = %27, %4
%10 = phi i32 [ -1, %4 ], [ %28, %27 ]
%11 = icmp eq i32 %10, 0
%12 = tail call i64 @chkmv1(i8* %0, i8 signext %1, i32 %2, i32 %3, i32 %10, i32 -1)
%13 = icmp sgt i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = tail call i32 @putmv1(i8* %0, i8 signext %1, i32 %2, i32 %3, i32 %10, i32 -1)
br label %16
16: ; preds = %9, %14
br i1 %11, label %22, label %17
17: ; preds = %16
%18 = tail call i64 @chkmv1(i8* %0, i8 signext %1, i32 %2, i32 %3, i32 %10, i32 0)
%19 = icmp sgt i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = tail call i32 @putmv1(i8* %0, i8 signext %1, i32 %2, i32 %3, i32 %10, i32 0)
br label %22
22: ; preds = %16, %17, %20
%23 = tail call i64 @chkmv1(i8* %0, i8 signext %1, i32 %2, i32 %3, i32 %10, i32 1)
%24 = icmp sgt i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = tail call i32 @putmv1(i8* %0, i8 signext %1, i32 %2, i32 %3, i32 %10, i32 1)
br label %27
27: ; preds = %25, %22
%28 = add nsw i32 %10, 1
%29 = icmp eq i32 %28, 2
br i1 %29, label %30, label %9
30: ; preds = %27
ret void
}