#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 checkLegalInDirection(char **, int, char, char, char, int, int);
bool checkAvailable(char color, char board[][26], int n) {
  bool g, h, i, j, k, l, m, q;
  bool check = false;
  for (char row = 'a'; row <= 'a' + n - 1; row++) {
    for (char col = 'a'; col <= 'a' + n - 1; col++) {
      g = checkLegalInDirection(board, n, row, col, color, -1, -1);
      h = checkLegalInDirection(board, n, row, col, color, -1, 0);
      i = checkLegalInDirection(board, n, row, col, color, -1, 1);
      j = checkLegalInDirection(board, n, row, col, color, 0, 1);
      k = checkLegalInDirection(board, n, row, col, color, 1, 1);
      l = checkLegalInDirection(board, n, row, col, color, 1, 0);
      m = checkLegalInDirection(board, n, row, col, color, 1, -1);
      q = checkLegalInDirection(board, n, row, col, color, 0, -1);
      if (g == true || h == true || i == true || j == true || k == true ||
          l == true || m == true || q == true)
        check = true;
    }
  }
  return (check);
}


x86 assembly (clang, -O0):
<checkAvailable>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x38(%rbp)
movb   $0x61,-0x39(%rbp)
movsbl -0x39(%rbp),%eax
mov    -0x14(%rbp),%ecx
add    $0x61,%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     133f <checkAvailable+0x22f>
movb   $0x61,-0x3a(%rbp)
movsbl -0x3a(%rbp),%eax
mov    -0x14(%rbp),%ecx
add    $0x61,%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     132d <checkAvailable+0x21d>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x39(%rbp),%cl
mov    -0x3a(%rbp),%al
mov    $0xffffffff,%r9d
movsbl %cl,%edx
movsbl %al,%ecx
movsbl -0x1(%rbp),%r8d
movl   $0xffffffff,(%rsp)
call   1030 <checkLegalInDirection@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x39(%rbp),%cl
mov    -0x3a(%rbp),%al
mov    $0xffffffff,%r9d
xor    %edx,%edx
movsbl %cl,%edx
movsbl %al,%ecx
movsbl -0x1(%rbp),%r8d
movl   $0x0,(%rsp)
call   1030 <checkLegalInDirection@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x39(%rbp),%cl
mov    -0x3a(%rbp),%al
mov    $0xffffffff,%r9d
movsbl %cl,%edx
movsbl %al,%ecx
movsbl -0x1(%rbp),%r8d
movl   $0x1,(%rsp)
call   1030 <checkLegalInDirection@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x39(%rbp),%cl
mov    -0x3a(%rbp),%al
xor    %r9d,%r9d
movsbl %cl,%edx
movsbl %al,%ecx
movsbl -0x1(%rbp),%r8d
movl   $0x1,(%rsp)
call   1030 <checkLegalInDirection@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x39(%rbp),%cl
mov    -0x3a(%rbp),%al
mov    $0x1,%r9d
movsbl %cl,%edx
movsbl %al,%ecx
movsbl -0x1(%rbp),%r8d
movl   $0x1,(%rsp)
call   1030 <checkLegalInDirection@plt>
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x39(%rbp),%cl
mov    -0x3a(%rbp),%al
mov    $0x1,%r9d
xor    %edx,%edx
movsbl %cl,%edx
movsbl %al,%ecx
movsbl -0x1(%rbp),%r8d
movl   $0x0,(%rsp)
call   1030 <checkLegalInDirection@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x39(%rbp),%cl
mov    -0x3a(%rbp),%al
mov    $0x1,%r9d
movsbl %cl,%edx
movsbl %al,%ecx
movsbl -0x1(%rbp),%r8d
movl   $0xffffffff,(%rsp)
call   1030 <checkLegalInDirection@plt>
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x39(%rbp),%cl
mov    -0x3a(%rbp),%al
xor    %r9d,%r9d
movsbl %cl,%edx
movsbl %al,%ecx
movsbl -0x1(%rbp),%r8d
movl   $0xffffffff,(%rsp)
call   1030 <checkLegalInDirection@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x1,-0x18(%rbp)
je     1314 <checkAvailable+0x204>
cmpl   $0x1,-0x1c(%rbp)
je     1314 <checkAvailable+0x204>
cmpl   $0x1,-0x20(%rbp)
je     1314 <checkAvailable+0x204>
cmpl   $0x1,-0x24(%rbp)
je     1314 <checkAvailable+0x204>
cmpl   $0x1,-0x28(%rbp)
je     1314 <checkAvailable+0x204>
cmpl   $0x1,-0x2c(%rbp)
je     1314 <checkAvailable+0x204>
cmpl   $0x1,-0x30(%rbp)
je     1314 <checkAvailable+0x204>
cmpl   $0x1,-0x34(%rbp)
jne    131b <checkAvailable+0x20b>
movl   $0x1,-0x38(%rbp)
jmp    1320 <checkAvailable+0x210>
mov    -0x3a(%rbp),%al
add    $0x1,%al
mov    %al,-0x3a(%rbp)
jmp    1149 <checkAvailable+0x39>
jmp    1332 <checkAvailable+0x222>
mov    -0x39(%rbp),%al
add    $0x1,%al
mov    %al,-0x39(%rbp)
jmp    1130 <checkAvailable+0x20>
mov    -0x38(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkAvailable>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
test   %edx,%edx
jle    12f0 <checkAvailable+0x1e0>
mov    %rsi,0x38(%rsp)
mov    %rdx,0x40(%rsp)
lea    0x60(%rdx),%ecx
xor    %ebp,%ebp
mov    $0x61,%dl
movsbl %dil,%r12d
mov    %ecx,0x18(%rsp)
mov    0x38(%rsp),%r15
mov    0x40(%rsp),%r14
nopl   0x0(%rax)
mov    $0x61,%bl
mov    %dl,0x17(%rsp)
cs nopw 0x0(%rax,%rax,1)
movl   $0xffffffff,(%rsp)
movsbl %dl,%r13d
movsbl %bl,%ebx
mov    %r15,%rdi
mov    %r14d,%esi
mov    %r13d,%edx
mov    %ebx,%ecx
mov    %r12d,%r8d
mov    $0xffffffff,%r9d
call   1030 <checkLegalInDirection@plt>
mov    %eax,0x34(%rsp)
movl   $0x0,(%rsp)
mov    %r15,%rdi
mov    %r14d,%esi
mov    %r13d,%edx
mov    %ebx,%ecx
mov    %r12d,%r8d
mov    $0xffffffff,%r9d
call   1030 <checkLegalInDirection@plt>
mov    %eax,0x30(%rsp)
movl   $0x1,(%rsp)
mov    %r15,%rdi
mov    %r14d,%esi
mov    %r13d,%edx
mov    %ebx,%ecx
mov    %r12d,%r8d
mov    $0xffffffff,%r9d
call   1030 <checkLegalInDirection@plt>
mov    %eax,0x2c(%rsp)
movl   $0x1,(%rsp)
mov    %r15,%rdi
mov    %r14d,%esi
mov    %r13d,%edx
mov    %ebx,%ecx
mov    %r12d,%r8d
xor    %r9d,%r9d
call   1030 <checkLegalInDirection@plt>
mov    %eax,0x28(%rsp)
movl   $0x1,(%rsp)
mov    %r15,%rdi
mov    %r14d,%esi
mov    %r13d,%edx
mov    %ebx,%ecx
mov    %r12d,%r8d
mov    $0x1,%r9d
call   1030 <checkLegalInDirection@plt>
mov    %eax,0x24(%rsp)
movl   $0x0,(%rsp)
mov    %r15,%rdi
mov    %r14d,%esi
mov    %r13d,%edx
mov    %ebx,%ecx
mov    %r12d,%r8d
mov    $0x1,%r9d
call   1030 <checkLegalInDirection@plt>
mov    %eax,0x20(%rsp)
movl   $0xffffffff,(%rsp)
mov    %r15,%rdi
mov    %r14d,%esi
mov    %r13d,%edx
mov    %ebx,%ecx
mov    %r12d,%r8d
mov    $0x1,%r9d
call   1030 <checkLegalInDirection@plt>
mov    %eax,0x1c(%rsp)
movl   $0xffffffff,(%rsp)
mov    %r15,%rdi
mov    %r14d,%esi
mov    %r13d,%edx
mov    %ebx,%ecx
mov    %r12d,%r8d
xor    %r9d,%r9d
call   1030 <checkLegalInDirection@plt>
movzbl 0x17(%rsp),%edx
mov    0x18(%rsp),%ecx
cmp    $0x1,%eax
cmove  %eax,%ebp
mov    0x1c(%rsp),%eax
cmp    $0x1,%eax
cmove  %eax,%ebp
mov    0x20(%rsp),%eax
cmp    $0x1,%eax
cmove  %eax,%ebp
mov    0x24(%rsp),%eax
cmp    $0x1,%eax
cmove  %eax,%ebp
mov    0x28(%rsp),%eax
cmp    $0x1,%eax
cmove  %eax,%ebp
mov    0x2c(%rsp),%eax
cmp    $0x1,%eax
cmove  %eax,%ebp
mov    0x30(%rsp),%eax
cmp    $0x1,%eax
cmove  %eax,%ebp
mov    0x34(%rsp),%eax
cmp    $0x1,%eax
cmove  %eax,%ebp
add    $0x1,%bl
movsbl %bl,%eax
cmp    %eax,%ecx
jge    1160 <checkAvailable+0x50>
add    $0x1,%dl
movsbl %dl,%eax
cmp    %eax,%ecx
jge    1150 <checkAvailable+0x40>
jmp    12f2 <checkAvailable+0x1e2>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @checkAvailable(i8 signext %0, [26 x i8]* %1, i32 %2) {
%4 = alloca i8
%5 = alloca [26 x i8]*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i8
%17 = alloca i8
store i8 %0, i8* %4
store [26 x i8]* %1, [26 x i8]** %5
store i32 %2, i32* %6
store i32 0, i32* %15
store i8 97, i8* %16
br label %18
18: ; preds = %119, %3
%19 = load i8, i8* %16
%20 = sext i8 %19 to i32
%21 = load i32, i32* %6
%22 = add nsw i32 97, %21
%23 = sub nsw i32 %22, 1
%24 = icmp sle i32 %20, %23
br i1 %24, label %25, label %122
25: ; preds = %18
store i8 97, i8* %17
br label %26
26: ; preds = %115, %25
%27 = load i8, i8* %17
%28 = sext i8 %27 to i32
%29 = load i32, i32* %6
%30 = add nsw i32 97, %29
%31 = sub nsw i32 %30, 1
%32 = icmp sle i32 %28, %31
br i1 %32, label %33, label %118
33: ; preds = %26
%34 = load [26 x i8]*, [26 x i8]** %5
%35 = bitcast [26 x i8]* %34 to i8**
%36 = load i32, i32* %6
%37 = load i8, i8* %16
%38 = load i8, i8* %17
%39 = load i8, i8* %4
%40 = call i32 @checkLegalInDirection(i8** %35, i32 %36, i8 signext %37, i8 signext %38, i8 signext %39, i32 -1, i32 -1)
store i32 %40, i32* %7
%41 = load [26 x i8]*, [26 x i8]** %5
%42 = bitcast [26 x i8]* %41 to i8**
%43 = load i32, i32* %6
%44 = load i8, i8* %16
%45 = load i8, i8* %17
%46 = load i8, i8* %4
%47 = call i32 @checkLegalInDirection(i8** %42, i32 %43, i8 signext %44, i8 signext %45, i8 signext %46, i32 -1, i32 0)
store i32 %47, i32* %8
%48 = load [26 x i8]*, [26 x i8]** %5
%49 = bitcast [26 x i8]* %48 to i8**
%50 = load i32, i32* %6
%51 = load i8, i8* %16
%52 = load i8, i8* %17
%53 = load i8, i8* %4
%54 = call i32 @checkLegalInDirection(i8** %49, i32 %50, i8 signext %51, i8 signext %52, i8 signext %53, i32 -1, i32 1)
store i32 %54, i32* %9
%55 = load [26 x i8]*, [26 x i8]** %5
%56 = bitcast [26 x i8]* %55 to i8**
%57 = load i32, i32* %6
%58 = load i8, i8* %16
%59 = load i8, i8* %17
%60 = load i8, i8* %4
%61 = call i32 @checkLegalInDirection(i8** %56, i32 %57, i8 signext %58, i8 signext %59, i8 signext %60, i32 0, i32 1)
store i32 %61, i32* %10
%62 = load [26 x i8]*, [26 x i8]** %5
%63 = bitcast [26 x i8]* %62 to i8**
%64 = load i32, i32* %6
%65 = load i8, i8* %16
%66 = load i8, i8* %17
%67 = load i8, i8* %4
%68 = call i32 @checkLegalInDirection(i8** %63, i32 %64, i8 signext %65, i8 signext %66, i8 signext %67, i32 1, i32 1)
store i32 %68, i32* %11
%69 = load [26 x i8]*, [26 x i8]** %5
%70 = bitcast [26 x i8]* %69 to i8**
%71 = load i32, i32* %6
%72 = load i8, i8* %16
%73 = load i8, i8* %17
%74 = load i8, i8* %4
%75 = call i32 @checkLegalInDirection(i8** %70, i32 %71, i8 signext %72, i8 signext %73, i8 signext %74, i32 1, i32 0)
store i32 %75, i32* %12
%76 = load [26 x i8]*, [26 x i8]** %5
%77 = bitcast [26 x i8]* %76 to i8**
%78 = load i32, i32* %6
%79 = load i8, i8* %16
%80 = load i8, i8* %17
%81 = load i8, i8* %4
%82 = call i32 @checkLegalInDirection(i8** %77, i32 %78, i8 signext %79, i8 signext %80, i8 signext %81, i32 1, i32 -1)
store i32 %82, i32* %13
%83 = load [26 x i8]*, [26 x i8]** %5
%84 = bitcast [26 x i8]* %83 to i8**
%85 = load i32, i32* %6
%86 = load i8, i8* %16
%87 = load i8, i8* %17
%88 = load i8, i8* %4
%89 = call i32 @checkLegalInDirection(i8** %84, i32 %85, i8 signext %86, i8 signext %87, i8 signext %88, i32 0, i32 -1)
store i32 %89, i32* %14
%90 = load i32, i32* %7
%91 = icmp eq i32 %90, 1
br i1 %91, label %113, label %92
92: ; preds = %33
%93 = load i32, i32* %8
%94 = icmp eq i32 %93, 1
br i1 %94, label %113, label %95
95: ; preds = %92
%96 = load i32, i32* %9
%97 = icmp eq i32 %96, 1
br i1 %97, label %113, label %98
98: ; preds = %95
%99 = load i32, i32* %10
%100 = icmp eq i32 %99, 1
br i1 %100, label %113, label %101
101: ; preds = %98
%102 = load i32, i32* %11
%103 = icmp eq i32 %102, 1
br i1 %103, label %113, label %104
104: ; preds = %101
%105 = load i32, i32* %12
%106 = icmp eq i32 %105, 1
br i1 %106, label %113, label %107
107: ; preds = %104
%108 = load i32, i32* %13
%109 = icmp eq i32 %108, 1
br i1 %109, label %113, label %110
110: ; preds = %107
%111 = load i32, i32* %14
%112 = icmp eq i32 %111, 1
br i1 %112, label %113, label %114
113: ; preds = %110, %107, %104, %101, %98, %95, %92, %33
store i32 1, i32* %15
br label %114
114: ; preds = %113, %110
br label %115
115: ; preds = %114
%116 = load i8, i8* %17
%117 = add i8 %116, 1
store i8 %117, i8* %17
br label %26
118: ; preds = %26
br label %119
119: ; preds = %118
%120 = load i8, i8* %16
%121 = add i8 %120, 1
store i8 %121, i8* %16
br label %18
122: ; preds = %18
%123 = load i32, i32* %15
ret i32 %123
}

LLVM IR (-O2):
define i32 @checkAvailable(i8 signext %0, [26 x i8]* %1, i32 %2) {
%4 = add nsw i32 %2, 96
%5 = icmp slt i32 %2, 1
br i1 %5, label %11, label %6
6: ; preds = %3
%7 = bitcast [26 x i8]* %1 to i8**
br label %8
8: ; preds = %13, %6
%9 = phi i8 [ 97, %6 ], [ %14, %13 ]
%10 = phi i32 [ 0, %6 ], [ %43, %13 ]
br label %17
11: ; preds = %13, %3
%12 = phi i32 [ 0, %3 ], [ %43, %13 ]
ret i32 %12
13: ; preds = %17
%14 = add i8 %9, 1
%15 = sext i8 %14 to i32
%16 = icmp slt i32 %4, %15
br i1 %16, label %11, label %8
17: ; preds = %8, %17
%18 = phi i8 [ %44, %17 ], [ 97, %8 ]
%19 = phi i32 [ %43, %17 ], [ %10, %8 ]
%20 = tail call i32 @checkLegalInDirection(i8** %7, i32 %2, i8 signext %9, i8 signext %18, i8 signext %0, i32 -1, i32 -1)
%21 = tail call i32 @checkLegalInDirection(i8** %7, i32 %2, i8 signext %9, i8 signext %18, i8 signext %0, i32 -1, i32 0)
%22 = tail call i32 @checkLegalInDirection(i8** %7, i32 %2, i8 signext %9, i8 signext %18, i8 signext %0, i32 -1, i32 1)
%23 = tail call i32 @checkLegalInDirection(i8** %7, i32 %2, i8 signext %9, i8 signext %18, i8 signext %0, i32 0, i32 1)
%24 = tail call i32 @checkLegalInDirection(i8** %7, i32 %2, i8 signext %9, i8 signext %18, i8 signext %0, i32 1, i32 1)
%25 = tail call i32 @checkLegalInDirection(i8** %7, i32 %2, i8 signext %9, i8 signext %18, i8 signext %0, i32 1, i32 0)
%26 = tail call i32 @checkLegalInDirection(i8** %7, i32 %2, i8 signext %9, i8 signext %18, i8 signext %0, i32 1, i32 -1)
%27 = tail call i32 @checkLegalInDirection(i8** %7, i32 %2, i8 signext %9, i8 signext %18, i8 signext %0, i32 0, i32 -1)
%28 = icmp eq i32 %20, 1
%29 = icmp eq i32 %21, 1
%30 = select i1 %28, i1 true, i1 %29
%31 = icmp eq i32 %22, 1
%32 = select i1 %30, i1 true, i1 %31
%33 = icmp eq i32 %23, 1
%34 = select i1 %32, i1 true, i1 %33
%35 = icmp eq i32 %24, 1
%36 = select i1 %34, i1 true, i1 %35
%37 = icmp eq i32 %25, 1
%38 = select i1 %36, i1 true, i1 %37
%39 = icmp eq i32 %26, 1
%40 = select i1 %38, i1 true, i1 %39
%41 = icmp eq i32 %27, 1
%42 = select i1 %40, i1 true, i1 %41
%43 = select i1 %42, i32 1, i32 %19
%44 = add i8 %18, 1
%45 = sext i8 %44 to i32
%46 = icmp slt i32 %4, %45
br i1 %46, label %13, label %17
}