// File: /workspace/github_cpp_makefile_star2_O2/kobanium[P]Ray/src/board/GoBoard.cpp
// Function: InitializeEye()
static void
InitializeEye( void )
{
  unsigned int transp[8], pat3_transp16[16];
  //  眼のパターンはそれぞれ1か所あたり2ビットで表現
  //        123
  //        4*5
  //        678
  //  それぞれの番号×2ビットだけシフトさせる
  //        O:自分の石
  //        X:相手の石
  //        +:空点
  //        #:盤外
  const int eye_pat3[] = {
    // +OO     XOO     +O+     XO+
    // O*O     O*O     O*O     O*O
    // OOO     OOO     OOO     OOO
    0x5554, 0x5556, 0x5544, 0x5546,

    // +OO     XOO     +O+     XO+
    // O*O     O*O     O*O     O*O
    // OO+     OO+     OO+     OO+
    0x1554, 0x1556, 0x1544, 0x1546,

    // +OX     XO+     +OO     OOO
    // O*O     O*O     O*O     O*O
    // OO+     +O+     ###     ###
    0x1564, 0x1146, 0xFD54, 0xFD55,

    // +O#     OO#     XOX     XOX
    // O*#     O*#     O+O     O+O
    // ###     ###     OOO     ###
    0xFF74, 0xFF75, 0x5566, 0xFD66,
  };
  const unsigned int false_eye_pat3[4] = {
    // OOX     OOO     XOO     XO# 
    // O*O     O*O     O*O     O*# 
    // XOO     XOX     ###     ### 
    0x5965, 0x9955, 0xFD56, 0xFF76,
  };

  const unsigned int complete_half_eye[12] = {
    // XOX     OOX     XOX     XOX     XOX
    // O*O     O*O     O*O     O*O     O*O
    // OOO     XOO     +OO     XOO     +O+
    0x5566, 0x5965, 0x5166, 0x5966, 0x1166,
    // +OX     XOX     XOX     XOO     XO+
    // O*O     O*O     O*O     O*O     O*O
    // XO+     XO+     XOX     ###     ###
    0x1964, 0x1966, 0x9966, 0xFD56, 0xFD46,
    // XOX     XO#
    // O*O     O*#
    // ###     ###
    0xFD66, 0xFF76
  };
  const unsigned int half_3_eye[2] = {
    // +O+     XO+
    // O*O     O*O
    // +O+     +O+
    0x1144, 0x1146
  };
  const unsigned int half_2_eye[4] = {
    // +O+     XO+     +OX     +O+
    // O*O     O*O     O*O     O*O
    // +OO     +OO     +OO     ###
    0x5144, 0x5146, 0x5164, 0xFD44,
  };
  const unsigned int half_1_eye[6] = {
    // +O+     XO+     OOX     OOX     +OO
    // O*O     O*O     O*O     O*O     O*O
    // OOO     OOO     +OO     +OO     ###
    0x5544, 0x5564, 0x5145, 0x5165, 0xFD54,
    // +O#
    // O*#
    // ###
    0xFF74,
  };
  const unsigned int complete_one_eye[5] = {
    // OOO     +OO     XOO     OOO     OO#
    // O*O     O*O     O*O     O*O     O*#
    // OOO     OOO     OOO     ###     ###
    0x5555, 0x5554, 0x5556, 0xFD55, 0xFF75,
  };

  std::fill_n(eye_condition, PAT3_MAX, E_NOT_EYE);
  
  for (int i = 0; i < 12; i++) {
    Pat3Transpose16(complete_half_eye[i], pat3_transp16);
    for (int j = 0; j < 16; j++) {
      eye_condition[pat3_transp16[j]] = E_COMPLETE_HALF_EYE;
    }
  }

  for (int i = 0; i < 2; i++) {
    Pat3Transpose16(half_3_eye[i], pat3_transp16);
    for (int j = 0; j < 16; j++) {
      eye_condition[pat3_transp16[j]] = E_HALF_3_EYE;
    }
  }

  for (int i = 0; i < 4; i++) {
    Pat3Transpose16(half_2_eye[i], pat3_transp16);
    for (int j = 0; j < 16; j++) {
      eye_condition[pat3_transp16[j]] = E_HALF_2_EYE;
    }
  }

  for (int i = 0; i < 6; i++) {
    Pat3Transpose16(half_1_eye[i], pat3_transp16);
    for (int j = 0; j < 16; j++) {
      eye_condition[pat3_transp16[j]] = E_HALF_1_EYE;
    }
  }

  for (int i = 0; i < 5; i++) {
    Pat3Transpose16(complete_one_eye[i], pat3_transp16);
    for (int j = 0; j < 16; j++) {
      eye_condition[pat3_transp16[j]] = E_COMPLETE_ONE_EYE;
    }
  }

  // BBB
  // B*B
  // BBB
  eye[0x5555] = S_BLACK;

  // WWW
  // W*W
  // WWW
  eye[Pat3Reverse(0x5555)] = S_WHITE;

  // +B+
  // B*B
  // +B+
  eye[0x1144] = S_BLACK;

  // +W+
  // W*W
  // +W+
  eye[Pat3Reverse(0x1144)] = S_WHITE;

  for (int i = 0; i < 14; i++) {
    Pat3Transpose8(eye_pat3[i], transp);
    for (int j = 0; j < 8; j++) {
      eye[transp[j]] = S_BLACK;
      eye[Pat3Reverse(transp[j])] = S_WHITE;
    }
  }

  for (int i = 0; i < 4; i++) {
    Pat3Transpose8(false_eye_pat3[i], transp);
    for (int j = 0; j < 8; j++) {
      false_eye[transp[j]] = S_BLACK;
      false_eye[Pat3Reverse(transp[j])] = S_WHITE;
    }
  }

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
xorl %eax, %eax
leaq 0x1aaff2ff(%rip), %r14  # 0x1ab3a6e0
cmpq $0x10000, %rax          # imm = 0x10000
je 0x3b3f3
movb $0x0, (%rax,%r14)
incq %rax
jmp 0x3b3e1
xorl %r15d, %r15d
leaq 0xc9d3(%rip), %r12      # 0x47dd0
movq %rsp, %rbx
cmpq $0xc, %r15
je 0x3b42c
movl (%r12,%r15,4), %edi
movq %rbx, %rsi
callq 0x3733b
xorl %eax, %eax
cmpq $0x10, %rax
je 0x3b427
movl (%rsp,%rax,4), %ecx
movb $0x1, (%rcx,%r14)
incq %rax
jmp 0x3b414
incq %r15
jmp 0x3b400
xorl %r15d, %r15d
leaq 0xc9fe(%rip), %r12      # 0x47e34
movq %rsp, %rbx
cmpq $0x2, %r15
je 0x3b465
movl (%r12,%r15,4), %edi
movq %rbx, %rsi
callq 0x3733b
xorl %eax, %eax
cmpq $0x10, %rax
je 0x3b460
movl (%rsp,%rax,4), %ecx
movb $0x2, (%rcx,%r14)
incq %rax
jmp 0x3b44d
incq %r15
jmp 0x3b439
xorl %r15d, %r15d
leaq 0xc911(%rip), %r12      # 0x47d80
movq %rsp, %rbx
cmpq $0x4, %r15
je 0x3b49e
movl (%r12,%r15,4), %edi
movq %rbx, %rsi
callq 0x3733b
xorl %eax, %eax
cmpq $0x10, %rax
je 0x3b499
movl (%rsp,%rax,4), %ecx
movb $0x3, (%rcx,%r14)
incq %rax
jmp 0x3b486
incq %r15
jmp 0x3b472
xorl %r15d, %r15d
leaq 0xc958(%rip), %r12      # 0x47e00
movq %rsp, %rbx
cmpq $0x6, %r15
je 0x3b4d7
movl (%r12,%r15,4), %edi
movq %rbx, %rsi
callq 0x3733b
xorl %eax, %eax
cmpq $0x10, %rax
je 0x3b4d2
movl (%rsp,%rax,4), %ecx
movb $0x4, (%rcx,%r14)
incq %rax
jmp 0x3b4bf
incq %r15
jmp 0x3b4ab
xorl %r15d, %r15d
leaq 0xc93f(%rip), %r12      # 0x47e20
movq %rsp, %rbx
cmpq $0x5, %r15
je 0x3b510
movl (%r12,%r15,4), %edi
movq %rbx, %rsi
callq 0x3733b
xorl %eax, %eax
cmpq $0x10, %rax
je 0x3b50b
movl (%rsp,%rax,4), %ecx
movb $0x5, (%rcx,%r14)
incq %rax
jmp 0x3b4f8
incq %r15
jmp 0x3b4e4
movb $0x1, %bl
movb %bl, 0x1aac471d(%rip)   # 0x1aaffc35
leaq 0x1aabf1c1(%rip), %r14  # 0x1aafa6e0
movl $0x5555, %edi           # imm = 0x5555
callq 0x3736c
movl %eax, %eax
movb $0x2, %bpl
movb %bpl, (%rax,%r14)
movb %bl, 0x1aac02ec(%rip)   # 0x1aafb824
movl $0x1144, %edi           # imm = 0x1144
callq 0x3736c
movl %eax, %eax
movb %bpl, (%rax,%r14)
xorl %r15d, %r15d
leaq 0xc83e(%rip), %r12      # 0x47d90
leaq 0x40(%rsp), %rbx
cmpq $0xe, %r15
je 0x3b592
movl (%r12,%r15,4), %edi
movq %rbx, %rsi
callq 0x371f1
xorl %r13d, %r13d
cmpq $0x8, %r13
je 0x3b58d
movl 0x40(%rsp,%r13,4), %edi
movb $0x1, (%rdi,%r14)
callq 0x3736c
movl %eax, %eax
movb $0x2, (%rax,%r14)
incq %r13
jmp 0x3b56c
incq %r15
jmp 0x3b557
xorl %r14d, %r14d
leaq 0xc7d4(%rip), %r15      # 0x47d70
leaq 0x40(%rsp), %rbx
leaq 0x1aacf138(%rip), %r12  # 0x1ab0a6e0
cmpq $0x4, %r14
je 0x3b5e3
movl (%r15,%r14,4), %edi
movq %rbx, %rsi
callq 0x371f1
xorl %r13d, %r13d
cmpq $0x8, %r13
je 0x3b5de
movl 0x40(%rsp,%r13,4), %edi
movb $0x1, (%rdi,%r12)
callq 0x3736c
movl %eax, %eax
movb $0x2, (%rax,%r12)
incq %r13
jmp 0x3b5bd
incq %r14
jmp 0x3b5a8
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq