// File: 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
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
leaq -0xa0(%rbp), %rdi
leaq 0x13d17(%rip), %rsi     # 0xafeb0
movl $0x40, %edx
callq 0x7430
movq 0x13db6(%rip), %rax     # 0xaff60
movq %rax, -0xb0(%rbp)
movq 0x13db0(%rip), %rax     # 0xaff68
movq %rax, -0xa8(%rbp)
leaq -0xe0(%rbp), %rdi
leaq 0x13d23(%rip), %rsi     # 0xafef0
movl $0x30, %edx
callq 0x7430
movq 0x13cc2(%rip), %rax     # 0xafea0
movq %rax, -0xe8(%rbp)
movq 0x13d84(%rip), %rax     # 0xaff70
movq %rax, -0x100(%rbp)
movq 0x13d7e(%rip), %rax     # 0xaff78
movq %rax, -0xf8(%rbp)
movq 0x13d18(%rip), %rax     # 0xaff20
movq %rax, -0x120(%rbp)
movq 0x13d12(%rip), %rax     # 0xaff28
movq %rax, -0x118(%rbp)
movq 0x13d0c(%rip), %rax     # 0xaff30
movq %rax, -0x110(%rbp)
movq 0x13d0e(%rip), %rax     # 0xaff40
movq %rax, -0x140(%rbp)
movq 0x13d08(%rip), %rax     # 0xaff48
movq %rax, -0x138(%rbp)
movl 0x13d03(%rip), %eax     # 0xaff50
movl %eax, -0x130(%rbp)
movb $0x0, -0x141(%rbp)
leaq 0x1ab245ff(%rip), %rdi  # 0x1abc0860
movl $0x10000, %esi          # imm = 0x10000
leaq -0x141(%rbp), %rdx
callq 0x9eba0
movl $0x0, -0x148(%rbp)
cmpl $0xc, -0x148(%rbp)
jge 0x9c2eb
movslq -0x148(%rbp), %rax
movl -0xe0(%rbp,%rax,4), %edi
leaq -0x60(%rbp), %rsi
callq 0x92da0
movl $0x0, -0x14c(%rbp)
cmpl $0x10, -0x14c(%rbp)
jge 0x9c2d8
movslq -0x14c(%rbp), %rax
movl -0x60(%rbp,%rax,4), %eax
movl %eax, %ecx
leaq 0x1ab2459d(%rip), %rax  # 0x1abc0860
movb $0x1, (%rax,%rcx)
movl -0x14c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14c(%rbp)
jmp 0x9c2a6
jmp 0x9c2da
movl -0x148(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x148(%rbp)
jmp 0x9c27c
movl $0x0, -0x150(%rbp)
cmpl $0x2, -0x150(%rbp)
jge 0x9c364
movslq -0x150(%rbp), %rax
movl -0xe8(%rbp,%rax,4), %edi
leaq -0x60(%rbp), %rsi
callq 0x92da0
movl $0x0, -0x154(%rbp)
cmpl $0x10, -0x154(%rbp)
jge 0x9c351
movslq -0x154(%rbp), %rax
movl -0x60(%rbp,%rax,4), %eax
movl %eax, %ecx
leaq 0x1ab24524(%rip), %rax  # 0x1abc0860
movb $0x2, (%rax,%rcx)
movl -0x154(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x154(%rbp)
jmp 0x9c31f
jmp 0x9c353
movl -0x150(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x150(%rbp)
jmp 0x9c2f5
movl $0x0, -0x158(%rbp)
cmpl $0x4, -0x158(%rbp)
jge 0x9c3dd
movslq -0x158(%rbp), %rax
movl -0x100(%rbp,%rax,4), %edi
leaq -0x60(%rbp), %rsi
callq 0x92da0
movl $0x0, -0x15c(%rbp)
cmpl $0x10, -0x15c(%rbp)
jge 0x9c3ca
movslq -0x15c(%rbp), %rax
movl -0x60(%rbp,%rax,4), %eax
movl %eax, %ecx
leaq 0x1ab244ab(%rip), %rax  # 0x1abc0860
movb $0x3, (%rax,%rcx)
movl -0x15c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x15c(%rbp)
jmp 0x9c398
jmp 0x9c3cc
movl -0x158(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x158(%rbp)
jmp 0x9c36e
movl $0x0, -0x160(%rbp)
cmpl $0x6, -0x160(%rbp)
jge 0x9c456
movslq -0x160(%rbp), %rax
movl -0x120(%rbp,%rax,4), %edi
leaq -0x60(%rbp), %rsi
callq 0x92da0
movl $0x0, -0x164(%rbp)
cmpl $0x10, -0x164(%rbp)
jge 0x9c443
movslq -0x164(%rbp), %rax
movl -0x60(%rbp,%rax,4), %eax
movl %eax, %ecx
leaq 0x1ab24432(%rip), %rax  # 0x1abc0860
movb $0x4, (%rax,%rcx)
movl -0x164(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x164(%rbp)
jmp 0x9c411
jmp 0x9c445
movl -0x160(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x160(%rbp)
jmp 0x9c3e7
movl $0x0, -0x168(%rbp)
cmpl $0x5, -0x168(%rbp)
jge 0x9c4cf
movslq -0x168(%rbp), %rax
movl -0x140(%rbp,%rax,4), %edi
leaq -0x60(%rbp), %rsi
callq 0x92da0
movl $0x0, -0x16c(%rbp)
cmpl $0x10, -0x16c(%rbp)
jge 0x9c4bc
movslq -0x16c(%rbp), %rax
movl -0x60(%rbp,%rax,4), %eax
movl %eax, %ecx
leaq 0x1ab243b9(%rip), %rax  # 0x1abc0860
movb $0x5, (%rax,%rcx)
movl -0x16c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x16c(%rbp)
jmp 0x9c48a
jmp 0x9c4be
movl -0x168(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x168(%rbp)
jmp 0x9c460
movb $0x1, 0x1aae98df(%rip)  # 0x1ab85db5
movl $0x5555, %edi           # imm = 0x5555
callq 0x92e00
movl %eax, %eax
movl %eax, %ecx
leaq 0x1aae4375(%rip), %rax  # 0x1ab80860
movb $0x2, (%rax,%rcx)
movb $0x1, 0x1aae54ae(%rip)  # 0x1ab819a4
movl $0x1144, %edi           # imm = 0x1144
callq 0x92e00
movl %eax, %eax
movl %eax, %ecx
leaq 0x1aae4355(%rip), %rax  # 0x1ab80860
movb $0x2, (%rax,%rcx)
movl $0x0, -0x170(%rbp)
cmpl $0xe, -0x170(%rbp)
jge 0x9c5ae
movslq -0x170(%rbp), %rax
movl -0xa0(%rbp,%rax,4), %edi
leaq -0x20(%rbp), %rsi
callq 0x92bd0
movl $0x0, -0x174(%rbp)
cmpl $0x8, -0x174(%rbp)
jge 0x9c598
movslq -0x174(%rbp), %rax
movl -0x20(%rbp,%rax,4), %eax
movl %eax, %ecx
leaq 0x1aae42fc(%rip), %rax  # 0x1ab80860
movb $0x1, (%rax,%rcx)
movslq -0x174(%rbp), %rax
movl -0x20(%rbp,%rax,4), %edi
callq 0x92e00
movl %eax, %eax
movl %eax, %ecx
leaq 0x1aae42dd(%rip), %rax  # 0x1ab80860
movb $0x2, (%rax,%rcx)
movl -0x174(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x174(%rbp)
jmp 0x9c547
jmp 0x9c59a
movl -0x170(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x170(%rbp)
jmp 0x9c519
movl $0x0, -0x178(%rbp)
cmpl $0x4, -0x178(%rbp)
jge 0x9c64d
movslq -0x178(%rbp), %rax
movl -0xb0(%rbp,%rax,4), %edi
leaq -0x20(%rbp), %rsi
callq 0x92bd0
movl $0x0, -0x17c(%rbp)
cmpl $0x8, -0x17c(%rbp)
jge 0x9c637
movslq -0x17c(%rbp), %rax
movl -0x20(%rbp,%rax,4), %eax
movl %eax, %ecx
leaq 0x1aaf425d(%rip), %rax  # 0x1ab90860
movb $0x1, (%rax,%rcx)
movslq -0x17c(%rbp), %rax
movl -0x20(%rbp,%rax,4), %edi
callq 0x92e00
movl %eax, %eax
movl %eax, %ecx
leaq 0x1aaf423e(%rip), %rax  # 0x1ab90860
movb $0x2, (%rax,%rcx)
movl -0x17c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x17c(%rbp)
jmp 0x9c5e6
jmp 0x9c639
movl -0x178(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x178(%rbp)
jmp 0x9c5b8
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
nopw %cs:(%rax,%rax)