#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 */
typedef int uint8_t;

/* Variables and functions */
int hole_space(int *, int, int);
int /*<<< orphan*/ memcpy(int *, int const *, int);
int holes(const uint8_t *table) {
  int x, y, area;
  uint8_t copytable[8];
  memcpy(copytable, table, 8 * sizeof *copytable);
  for (x = 0; x < 8; x++) {
    for (y = 0; y < 8; y++) {
      if (!(copytable[y] & (1 << (x)))) {
        copytable[y] |= (1 << (x));
        area = 1 + hole_space(copytable, x, y);
        area %= 5;
        if ((area == 1) || (area == 2) || (area == 3))
          return 1;
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<holes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x20,%edx
call   1030 <memcpy@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    120f <holes+0xef>
movl   $0x0,-0x18(%rbp)
cmpl   $0x8,-0x18(%rbp)
jge    11fc <holes+0xdc>
movslq -0x18(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%eax
mov    -0x14(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
jne    11e9 <holes+0xc9>
mov    -0x14(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,%ecx
movslq -0x18(%rbp),%rax
or     -0x40(%rbp,%rax,4),%ecx
mov    %ecx,-0x40(%rbp,%rax,4)
lea    -0x40(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1040 <hole_space@plt>
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
cmpl   $0x1,-0x1c(%rbp)
je     11d8 <holes+0xb8>
cmpl   $0x2,-0x1c(%rbp)
je     11d8 <holes+0xb8>
cmpl   $0x3,-0x1c(%rbp)
jne    11e4 <holes+0xc4>
movl   $0x1,-0x4(%rbp)
jmp    1216 <holes+0xf6>
jmp    11e9 <holes+0xc9>
jmp    11ee <holes+0xce>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1156 <holes+0x36>
jmp    1201 <holes+0xe1>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1145 <holes+0x25>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<holes>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rdi,%rsi
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x20,%edx
call   1030 <memcpy@plt>
xor    %r15d,%r15d
jmp    115a <holes+0x3a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%r15d
cmp    $0x8,%r15d
je     11cc <holes+0xac>
mov    $0x1,%ebp
mov    %r15d,%ecx
shl    %cl,%ebp
xor    %ebx,%ebx
jmp    117a <holes+0x5a>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    $0x8,%rbx
je     1150 <holes+0x30>
mov    (%rsp,%rbx,4),%eax
test   %ebp,%eax
jne    1170 <holes+0x50>
or     %ebp,%eax
mov    %eax,(%rsp,%rbx,4)
mov    %r14,%rdi
mov    %r15d,%esi
mov    %ebx,%edx
call   1040 <hole_space@plt>
lea    0x1(%rax),%ecx
movslq %ecx,%rcx
imul   $0x66666667,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%ecx
not    %ecx
add    %ecx,%eax
add    $0x1,%eax
cmp    $0x3,%eax
jae    1170 <holes+0x50>
mov    $0x1,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
jmp    11c1 <holes+0xa1>

LLVM IR (-O0):
define i32 @holes(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [8 x i32]
store i32* %0, i32** %3
%8 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 0
%9 = load i32*, i32** %3
%10 = call i32 @memcpy(i32* %8, i32* %9, i32 32)
store i32 0, i32* %4
br label %11
11: ; preds = %57, %1
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 8
br i1 %13, label %14, label %60
14: ; preds = %11
store i32 0, i32* %5
br label %15
15: ; preds = %53, %14
%16 = load i32, i32* %5
%17 = icmp slt i32 %16, 8
br i1 %17, label %18, label %56
18: ; preds = %15
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 %20
%22 = load i32, i32* %21
%23 = load i32, i32* %4
%24 = shl i32 1, %23
%25 = and i32 %22, %24
%26 = icmp ne i32 %25, 0
br i1 %26, label %52, label %27
27: ; preds = %18
%28 = load i32, i32* %4
%29 = shl i32 1, %28
%30 = load i32, i32* %5
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 %31
%33 = load i32, i32* %32
%34 = or i32 %33, %29
store i32 %34, i32* %32
%35 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 0
%36 = load i32, i32* %4
%37 = load i32, i32* %5
%38 = call i32 @hole_space(i32* %35, i32 %36, i32 %37)
%39 = add nsw i32 1, %38
store i32 %39, i32* %6
%40 = load i32, i32* %6
%41 = srem i32 %40, 5
store i32 %41, i32* %6
%42 = load i32, i32* %6
%43 = icmp eq i32 %42, 1
br i1 %43, label %50, label %44
44: ; preds = %27
%45 = load i32, i32* %6
%46 = icmp eq i32 %45, 2
br i1 %46, label %50, label %47
47: ; preds = %44
%48 = load i32, i32* %6
%49 = icmp eq i32 %48, 3
br i1 %49, label %50, label %51
50: ; preds = %47, %44, %27
store i32 1, i32* %2
br label %61
51: ; preds = %47
br label %52
52: ; preds = %51, %18
br label %53
53: ; preds = %52
%54 = load i32, i32* %5
%55 = add nsw i32 %54, 1
store i32 %55, i32* %5
br label %15
56: ; preds = %15
br label %57
57: ; preds = %56
%58 = load i32, i32* %4
%59 = add nsw i32 %58, 1
store i32 %59, i32* %4
br label %11
60: ; preds = %11
store i32 0, i32* %2
br label %61
61: ; preds = %60, %50
%62 = load i32, i32* %2
ret i32 %62
}

LLVM IR (-O2):
define i32 @holes(i32* %0) {
%2 = alloca [8 x i32]
%3 = bitcast [8 x i32]* %2 to i8*
%4 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 0
%5 = call i32 @memcpy(i32* %4, i32* %0, i32 32)
br label %6
6: ; preds = %1, %26
%7 = phi i32 [ 0, %1 ], [ %27, %26 ]
%8 = shl nuw i32 1, %7
br label %9
9: ; preds = %6, %23
%10 = phi i64 [ 0, %6 ], [ %24, %23 ]
%11 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 %10
%12 = load i32, i32* %11
%13 = and i32 %12, %8
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %23
15: ; preds = %9
%16 = or i32 %12, %8
store i32 %16, i32* %11
%17 = trunc i64 %10 to i32
%18 = call i32 @hole_space(i32* %4, i32 %7, i32 %17)
%19 = add nsw i32 %18, 1
%20 = srem i32 %19, 5
%21 = add nsw i32 %20, -1
%22 = icmp ult i32 %21, 3
br i1 %22, label %29, label %23
23: ; preds = %9, %15
%24 = add nuw nsw i64 %10, 1
%25 = icmp eq i64 %24, 8
br i1 %25, label %26, label %9
26: ; preds = %23
%27 = add nuw nsw i32 %7, 1
%28 = icmp eq i32 %27, 8
br i1 %28, label %29, label %6
29: ; preds = %26, %15
%30 = phi i32 [ 1, %15 ], [ 0, %26 ]
ret i32 %30
}