#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 /*<<< orphan*/ displaymap(int **);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ reverse(int **, int, int, int, int, int);
int main() {
  int dx, dy;
  int x = 4;
  int y = 2;
  int c = 1;
  int a[8][8] = {{0, 0, 0, 0, 0, 0, 0, 0},  {0, 0, 0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0, 0, 0},  {0, 0, 0, 1, -1, 0, 0, 0},
                 {0, 0, 0, -1, 1, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0, 0, 0},  {0, 0, 0, 0, 0, 0, 0, 0}};
  displaymap(a);
  a[x][y] = c;
  for (dy = -1; dy < 2; dy++) {
    for (dx = -1; dx < 2; dx++) {
      reverse(a, c, x + dx, y + dy, dx, dy);
    }
  }
  printf("\n");
  displaymap(a);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x4,-0x10(%rbp)
movl   $0x2,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
lea    -0x120(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1050 <memset@plt>
movl   $0x1,-0xb4(%rbp)
movl   $0xffffffff,-0xb0(%rbp)
ff ff ff
movl   $0xffffffff,-0x94(%rbp)
ff ff ff
movl   $0x1,-0x90(%rbp)
lea    -0x120(%rbp),%rdi
call   1060 <displaymap@plt>
mov    -0x18(%rbp),%edx
movslq -0x10(%rbp),%rcx
lea    -0x120(%rbp),%rax
shl    $0x5,%rcx
add    %rcx,%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
movl   $0xffffffff,-0xc(%rbp)
cmpl   $0x2,-0xc(%rbp)
jge    1230 <main+0xf0>
movl   $0xffffffff,-0x8(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    121d <main+0xdd>
lea    -0x120(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x10(%rbp),%edx
add    -0x8(%rbp),%edx
mov    -0x14(%rbp),%ecx
add    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%r8d
mov    -0xc(%rbp),%r9d
call   1030 <reverse@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11e2 <main+0xa2>
jmp    1222 <main+0xe2>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11d1 <main+0x91>
lea    0xdc9(%rip),%rdi
call   1040 <printf@plt>
lea    -0x120(%rbp),%rdi
call   1060 <displaymap@plt>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x100,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movl   $0x1,0x6c(%rsp)
movl   $0xffffffff,0x70(%rsp)
ff
movl   $0xffffffff,0x8c(%rsp)
ff ff ff ff
movl   $0x1,0x90(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <displaymap@plt>
movl   $0x1,0x88(%rsp)
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x3,%edx
mov    $0x1,%ecx
mov    $0xffffffff,%r8d
mov    $0xffffffff,%r9d
call   1030 <reverse@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    $0x1,%ecx
xor    %r8d,%r8d
mov    $0xffffffff,%r9d
call   1030 <reverse@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x5,%edx
mov    $0x1,%ecx
mov    $0x1,%r8d
mov    $0xffffffff,%r9d
call   1030 <reverse@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x3,%edx
mov    $0x2,%ecx
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1030 <reverse@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    $0x2,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1030 <reverse@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x5,%edx
mov    $0x2,%ecx
mov    $0x1,%r8d
xor    %r9d,%r9d
call   1030 <reverse@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x3,%edx
mov    $0x3,%ecx
mov    $0xffffffff,%r8d
mov    $0x1,%r9d
call   1030 <reverse@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    $0x3,%ecx
xor    %r8d,%r8d
mov    $0x1,%r9d
call   1030 <reverse@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x5,%edx
mov    $0x3,%ecx
mov    $0x1,%r8d
mov    $0x1,%r9d
call   1030 <reverse@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %rbx,%rdi
call   1050 <displaymap@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [8 x [8 x i32]]
store i32 0, i32* %1
store i32 4, i32* %4
store i32 2, i32* %5
store i32 1, i32* %6
%8 = bitcast [8 x [8 x i32]]* %7 to i8*
%9 = bitcast i8* %8 to [8 x [8 x i32]]*
%10 = getelementptr inbounds [8 x [8 x i32]], [8 x [8 x i32]]* %9, i32 0, i32 3
%11 = getelementptr inbounds [8 x i32], [8 x i32]* %10, i32 0, i32 3
store i32 1, i32* %11
%12 = getelementptr inbounds [8 x i32], [8 x i32]* %10, i32 0, i32 4
store i32 -1, i32* %12
%13 = getelementptr inbounds [8 x [8 x i32]], [8 x [8 x i32]]* %9, i32 0, i32 4
%14 = getelementptr inbounds [8 x i32], [8 x i32]* %13, i32 0, i32 3
store i32 -1, i32* %14
%15 = getelementptr inbounds [8 x i32], [8 x i32]* %13, i32 0, i32 4
store i32 1, i32* %15
%16 = getelementptr inbounds [8 x [8 x i32]], [8 x [8 x i32]]* %7, i64 0, i64 0
%17 = bitcast [8 x i32]* %16 to i32**
%18 = call i32 @displaymap(i32** %17)
%19 = load i32, i32* %6
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [8 x [8 x i32]], [8 x [8 x i32]]* %7, i64 0, i64 %21
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [8 x i32], [8 x i32]* %22, i64 0, i64 %24
store i32 %19, i32* %25
store i32 -1, i32* %3
br label %26
26: ; preds = %50, %0
%27 = load i32, i32* %3
%28 = icmp slt i32 %27, 2
br i1 %28, label %29, label %53
29: ; preds = %26
store i32 -1, i32* %2
br label %30
30: ; preds = %46, %29
%31 = load i32, i32* %2
%32 = icmp slt i32 %31, 2
br i1 %32, label %33, label %49
33: ; preds = %30
%34 = getelementptr inbounds [8 x [8 x i32]], [8 x [8 x i32]]* %7, i64 0, i64 0
%35 = bitcast [8 x i32]* %34 to i32**
%36 = load i32, i32* %6
%37 = load i32, i32* %4
%38 = load i32, i32* %2
%39 = add nsw i32 %37, %38
%40 = load i32, i32* %5
%41 = load i32, i32* %3
%42 = add nsw i32 %40, %41
%43 = load i32, i32* %2
%44 = load i32, i32* %3
%45 = call i32 @reverse(i32** %35, i32 %36, i32 %39, i32 %42, i32 %43, i32 %44)
br label %46
46: ; preds = %33
%47 = load i32, i32* %2
%48 = add nsw i32 %47, 1
store i32 %48, i32* %2
br label %30
49: ; preds = %30
br label %50
50: ; preds = %49
%51 = load i32, i32* %3
%52 = add nsw i32 %51, 1
store i32 %52, i32* %3
br label %26
53: ; preds = %26
%54 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%55 = getelementptr inbounds [8 x [8 x i32]], [8 x [8 x i32]]* %7, i64 0, i64 0
%56 = bitcast [8 x i32]* %55 to i32**
%57 = call i32 @displaymap(i32** %56)
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca [8 x [8 x i32]]
%2 = bitcast [8 x [8 x i32]]* %1 to i8*
%3 = getelementptr inbounds [8 x [8 x i32]], [8 x [8 x i32]]* %1, i64 0, i64 3, i64 3
store i32 1, i32* %3
%4 = getelementptr inbounds [8 x [8 x i32]], [8 x [8 x i32]]* %1, i64 0, i64 3, i64 4
store i32 -1, i32* %4
%5 = getelementptr inbounds [8 x [8 x i32]], [8 x [8 x i32]]* %1, i64 0, i64 4, i64 3
store i32 -1, i32* %5
%6 = getelementptr inbounds [8 x [8 x i32]], [8 x [8 x i32]]* %1, i64 0, i64 4, i64 4
store i32 1, i32* %6
%7 = bitcast [8 x [8 x i32]]* %1 to i32**
%8 = call i32 @displaymap(i32** %7)
%9 = getelementptr inbounds [8 x [8 x i32]], [8 x [8 x i32]]* %1, i64 0, i64 4, i64 2
store i32 1, i32* %9
%10 = call i32 @reverse(i32** %7, i32 1, i32 3, i32 1, i32 -1, i32 -1)
%11 = call i32 @reverse(i32** %7, i32 1, i32 4, i32 1, i32 0, i32 -1)
%12 = call i32 @reverse(i32** %7, i32 1, i32 5, i32 1, i32 1, i32 -1)
%13 = call i32 @reverse(i32** %7, i32 1, i32 3, i32 2, i32 -1, i32 0)
%14 = call i32 @reverse(i32** %7, i32 1, i32 4, i32 2, i32 0, i32 0)
%15 = call i32 @reverse(i32** %7, i32 1, i32 5, i32 2, i32 1, i32 0)
%16 = call i32 @reverse(i32** %7, i32 1, i32 3, i32 3, i32 -1, i32 1)
%17 = call i32 @reverse(i32** %7, i32 1, i32 4, i32 3, i32 0, i32 1)
%18 = call i32 @reverse(i32** %7, i32 1, i32 5, i32 3, i32 1, i32 1)
%19 = call i32 @putchar(i32 10)
%20 = call i32 @displaymap(i32** %7)
ret i32 0
}