// File: /workspace/github_cpp_makefile_star2_O2/kobanium[P]Ray/src/feature/Nakade.cpp
// Function: InitializeNakadeHash()
void
InitializeNakadeHash( void )
{
  int nakade3[6][3], nakade4[5][4], nakade5[9][5], nakade6[4][6];

  start = board_max / 2;

  // 3目のナカデ
  nakade3[0][0] = 0; nakade3[0][1] = 1;              nakade3[0][2] = 2;
  nakade3[1][0] = 0; nakade3[1][1] = board_size;     nakade3[1][2] = 2 * board_size;
  nakade3[2][0] = 0; nakade3[2][1] = 1;              nakade3[2][2] = board_size + 1;
  nakade3[3][0] = 0; nakade3[3][1] = board_size - 1; nakade3[3][2] = board_size;
  nakade3[4][0] = 0; nakade3[4][1] = board_size;     nakade3[4][2] = board_size + 1;
  nakade3[5][0] = 0; nakade3[5][1] = 1;              nakade3[5][2] = board_size;

  // 4目のナカデ
  nakade4[0][0] = 0;              nakade4[0][1] = board_size - 1; 
  nakade4[0][2] = board_size;     nakade4[0][3] = board_size + 1;
  nakade4[1][0] = 0;              nakade4[1][1] = board_size - 1; 
  nakade4[1][2] = board_size;     nakade4[1][3] = 2 * board_size; 
  nakade4[2][0] = 0;              nakade4[2][1] = board_size; 
  nakade4[2][2] = board_size + 1; nakade4[2][3] = 2 * board_size;
  nakade4[3][0] = 0;              nakade4[3][1] = 1; 
  nakade4[3][2] = 2;              nakade4[3][3] = board_size + 1;
  nakade4[4][0] = 0;              nakade4[4][1] = 1; 
  nakade4[4][2] = board_size;     nakade4[4][3] = board_size + 1;

  // 5目のナカデ
  nakade5[0][0] = 0;                  nakade5[0][1] = board_size - 1; nakade5[0][2] = board_size;
  nakade5[0][3] = board_size + 1;     nakade5[0][4] = 2 * board_size;
  nakade5[1][0] = 0;                  nakade5[1][1] = board_size - 1; nakade5[1][2] = board_size;
  nakade5[1][3] = 2 * board_size - 1; nakade5[1][4] = 2 * board_size;
  nakade5[2][0] = 0;                  nakade5[2][1] = 1;              nakade5[2][2] = board_size;
  nakade5[2][3] = board_size + 1;     nakade5[2][4] = board_size + 2;
  nakade5[3][0] = 0;                  nakade5[3][1] = 1;              nakade5[3][2] = board_size;
  nakade5[3][3] = board_size + 1;     nakade5[3][4] = 2 * board_size;
  nakade5[4][0] = 0;                  nakade5[4][1] = 1;              nakade5[4][2] = 2;
  nakade5[4][3] = board_size + 1;     nakade5[4][4] = board_size + 2;
  nakade5[5][0] = 0;                  nakade5[5][1] = board_size;     nakade5[5][2] = board_size + 1;
  nakade5[5][3] = 2 * board_size;     nakade5[5][4] = 2 * board_size + 1;
  nakade5[6][0] = 0;                  nakade5[6][1] = 1;              nakade5[6][2] = 2;
  nakade5[6][3] = board_size;         nakade5[6][4] = board_size + 1;
  nakade5[7][0] = 0;                  nakade5[7][1] = 1;              nakade5[7][2] = board_size;
  nakade5[7][3] = board_size + 1;     nakade5[7][4] = 2 * board_size + 1;
  nakade5[8][0] = 0;                  nakade5[8][1] = 1;              nakade5[8][2] = board_size - 1;
  nakade5[8][3] = board_size;         nakade5[8][4] = board_size + 1;

  nakade6[0][0] = 0;                  nakade6[0][1] = board_size - 1;     
  nakade6[0][2] = board_size;         nakade6[0][3] = board_size + 1; 
  nakade6[0][4] = 2 * board_size - 1; nakade6[0][5] = 2 * board_size;
  nakade6[1][0] = 0;                  nakade6[1][1] = 1; 
  nakade6[1][2] = board_size;         nakade6[1][3] = board_size + 1; 
  nakade6[1][4] = board_size + 2;     nakade6[1][5] = 2 * board_size;
  nakade6[2][0] = 0;                  nakade6[2][1] = 1;
  nakade6[2][2] = board_size - 1;     nakade6[2][3] = board_size; 
  nakade6[2][4] = board_size + 1;     nakade6[2][5] = 2 * board_size;
  nakade6[3][0] = 0;                  nakade6[3][1] = board_size - 1; 
  nakade6[3][2] = board_size;         nakade6[3][3] = board_size + 1; 
  nakade6[3][4] = 2 * board_size;     nakade6[3][5] = 2 * board_size + 1;

  nakade_pos[0][0] = 1;
  nakade_pos[0][1] = board_size;
  nakade_pos[0][2] = 1;
  nakade_pos[0][3] = board_size;
  nakade_pos[0][4] = board_size;
  nakade_pos[0][5] = 0;

  nakade_pos[1][0] = board_size;
  nakade_pos[1][1] = board_size;
  nakade_pos[1][2] = board_size;
  nakade_pos[1][3] = 1;
  nakade_pos[1][4] = 0;

  nakade_pos[2][0] = board_size;
  nakade_pos[2][1] = board_size;
  nakade_pos[2][2] = board_size + 1;
  nakade_pos[2][3] = board_size;
  nakade_pos[2][4] = 1;
  nakade_pos[2][5] = board_size;
  nakade_pos[2][6] = 1;
  nakade_pos[2][7] = board_size + 1;
  nakade_pos[2][8] = board_size;

  nakade_pos[3][0] = board_size;
  nakade_pos[3][1] = board_size + 1;
  nakade_pos[3][2] = board_size;
  nakade_pos[3][3] = board_size;

  for (int i = 0; i < NAKADE_3; i++) {
    nakade_hash[0][i] = 0;
    for (int j = 0; j < 3; j++) {
      nakade_hash[0][i] ^= shape_bit[start + nakade3[i][j]];
    }
  }

  for (int i = 0; i < NAKADE_4; i++) {
    nakade_hash[1][i] = 0;
    for (int j = 0; j < 4; j++) {
      nakade_hash[1][i] ^= shape_bit[start + nakade4[i][j]];
    }
  }

  for (int i = 0; i < NAKADE_5; i++) {
    nakade_hash[2][i] = 0;
    for (int j = 0; j < 5; j++) {
      nakade_hash[2][i] ^= shape_bit[start + nakade5[i][j]];
    }
  }

  for (int i = 0; i < NAKADE_6; i++) {
    nakade_hash[3][i] = 0;
    for (int j = 0; j < 6; j++) {
      nakade_hash[3][i] ^= shape_bit[start + nakade6[i][j]];
    }
  }

  // 初期化
  for (int i = 0; i < PAT3_MAX; i++) {
    nakade_pat3_mask[i] = 0xffff;
  }

  // ナカデが出現しないパターンの初期化
  for (int i = 0; i < 134; i++) {
    unsigned int tmp_pat3[16];
    Pat3Transpose16(nakade_none[i], tmp_pat3);
    for (int j = 0; j < 16; j++) {
      nakade_pat3_mask[tmp_pat3[j]] = 0;
    }
  }

  // ナカデが出現しうるパターンの初期化
  for (int i = 0; i < 446; i++) {
    unsigned int tmp_pat3[16], tmp_mask[16];
    Pat3Transpose16(nakade_mask[i][0], tmp_pat3);
    Pat3Transpose16(nakade_mask[i][1], tmp_mask);
    for (int j = 0; j < 16; j++) {
      nakade_pat3_mask[tmp_pat3[j]] = tmp_mask[j];
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x238, %rsp            # imm = 0x238
leaq 0x22398(%rip), %rax     # 0x618b8
movl (%rax), %eax
pushq $0x2
popq %rsi
cltd
idivl %esi
movaps 0x8981(%rip), %xmm0     # 0x47eb0
leaq 0x1f0(%rsp), %rcx
movaps %xmm0, (%rcx)
leaq 0x2237b(%rip), %rdx     # 0x618bc
movl (%rdx), %edi
movl %edi, 0x10(%rcx)
leal (%rdi,%rdi), %r11d
movl %r11d, 0x14(%rcx)
movabsq $0x100000000, %r8       # imm = 0x100000000
movq %r8, 0x18(%rcx)
leal 0x1(%rdi), %r9d
movl %r9d, 0x20(%rcx)
andl $0x0, 0x24(%rcx)
leal -0x1(%rdi), %r10d
movl %r10d, 0x28(%rcx)
movl %edi, 0x2c(%rcx)
andl $0x0, 0x30(%rcx)
andl $0x0, 0x60(%rsp)
movl %eax, 0x22356(%rip)     # 0x618d8
movl %r10d, 0x64(%rsp)
movl %edi, 0x68(%rsp)
movl %r9d, 0x6c(%rsp)
andl $0x0, 0x70(%rsp)
movl %edi, 0x34(%rcx)
movl %r9d, 0x38(%rcx)
movl %r10d, 0x74(%rsp)
movl %edi, 0x78(%rsp)
movl %r11d, 0x7c(%rsp)
andl $0x0, 0x80(%rsp)
movq %r8, 0x3c(%rcx)
movl %edi, 0x44(%rcx)
movl %edi, 0x84(%rsp)
movl %r9d, 0x88(%rsp)
movl %r11d, 0x8c(%rsp)
movq %r8, 0x90(%rsp)
movl %esi, 0x98(%rsp)
movl %r9d, 0x9c(%rsp)
movq %r8, 0xa0(%rsp)
andl $0x0, 0xb0(%rsp)
movl %r10d, 0xb4(%rsp)
movl %edi, 0xb8(%rsp)
movl %r9d, 0xbc(%rsp)
movl %r11d, 0xc0(%rsp)
andl $0x0, 0xc4(%rsp)
movl %r10d, 0xc8(%rsp)
movl %edi, 0xcc(%rsp)
leal -0x1(,%rdi,2), %ebx
movl %ebx, 0xd0(%rsp)
movl %r11d, 0xd4(%rsp)
movq %r8, 0xd8(%rsp)
movl %edi, 0xe0(%rsp)
movl %r9d, 0xe4(%rsp)
leal (%rdi,%rsi), %ebp
movl %ebp, 0xe8(%rsp)
movq %r8, 0xec(%rsp)
movl %edi, 0xf4(%rsp)
movl %r9d, 0xf8(%rsp)
movl %r11d, 0xfc(%rsp)
movq %r8, 0x100(%rsp)
movl %esi, 0x108(%rsp)
movl %r9d, 0x10c(%rsp)
movl %ebp, 0x110(%rsp)
andl $0x0, 0x114(%rsp)
movl %edi, 0xa8(%rsp)
movl %r9d, 0xac(%rsp)
movl %edi, 0x118(%rsp)
movl %r9d, 0x11c(%rsp)
movl %r11d, 0x120(%rsp)
andl $0x0, (%rsp)
pushq $0x1
popq %rax
movl %r10d, 0x4(%rsp)
movl %edi, 0x8(%rsp)
movl %r9d, 0xc(%rsp)
movl %ebx, 0x10(%rsp)
movl %r11d, 0x14(%rsp)
movq %r8, 0x18(%rsp)
movl %edi, 0x20(%rsp)
movl %r9d, 0x24(%rsp)
movl %ebp, 0x28(%rsp)
movl %r11d, 0x2c(%rsp)
movq %r8, 0x30(%rsp)
movl %r10d, 0x38(%rsp)
movl %edi, 0x3c(%rsp)
movl %r9d, 0x40(%rsp)
movl %r11d, 0x44(%rsp)
andl $0x0, 0x48(%rsp)
movl %r10d, 0x4c(%rsp)
movl %edi, 0x50(%rsp)
movl %r9d, 0x54(%rsp)
movl %r11d, 0x58(%rsp)
orl %eax, %r11d
movl %r11d, 0x124(%rsp)
movq %r8, 0x128(%rsp)
movl %esi, 0x130(%rsp)
movl %edi, 0x134(%rsp)
movl %r9d, 0x138(%rsp)
movq %r8, 0x13c(%rsp)
movl %edi, 0x144(%rsp)
movl %r9d, 0x148(%rsp)
movl %r11d, 0x14c(%rsp)
movq %r8, 0x150(%rsp)
movl %r10d, 0x158(%rsp)
movl %edi, 0x15c(%rsp)
movl %r9d, 0x160(%rsp)
movl (%rdx), %edx
leal (%rdx,%rdx), %esi
movl %eax, 0x1c6e1f5a(%rip)  # 0x1c721700
movl %edx, 0x1c6e1f58(%rip)  # 0x1c721704
movl %eax, 0x1c6e1f56(%rip)  # 0x1c721708
movl %edx, 0x1c6e1f54(%rip)  # 0x1c72170c
movl %edx, 0x1c6e1f52(%rip)  # 0x1c721710
andl $0x0, 0x1c6e1f4f(%rip)  # 0x1c721714
orl %eax, %esi
movl %esi, 0x5c(%rsp)
movl %edx, 0x1c6e1f53(%rip)  # 0x1c721724
movl %edx, 0x1c6e1f51(%rip)  # 0x1c721728
movl %edx, 0x1c6e1f4f(%rip)  # 0x1c72172c
movq $0x1, 0x1c6e1f48(%rip) # 0x1c721730
movl %edx, 0x1c6e1f5a(%rip)  # 0x1c721748
movl %edx, 0x1c6e1f58(%rip)  # 0x1c72174c
leal 0x1(%rdx), %esi
movl %esi, 0x1c6e1f53(%rip)  # 0x1c721750
movl %edx, 0x1c6e1f51(%rip)  # 0x1c721754
movl %eax, 0x1c6e1f4f(%rip)  # 0x1c721758
movl %edx, 0x1c6e1f4d(%rip)  # 0x1c72175c
movl %eax, 0x1c6e1f4b(%rip)  # 0x1c721760
movl %esi, 0x1c6e1f49(%rip)  # 0x1c721764
movl %edx, 0x1c6e1f47(%rip)  # 0x1c721768
movl %edx, 0x1c6e1f45(%rip)  # 0x1c72176c
movl %esi, 0x1c6e1f43(%rip)  # 0x1c721770
movl %edx, 0x1c6e1f41(%rip)  # 0x1c721774
movl %edx, 0x1c6e1f3f(%rip)  # 0x1c721778
movslq 0x22098(%rip), %rax     # 0x618d8
xorl %edi, %edi
leaq 0x1c6e1f47(%rip), %rdx  # 0x1c721790
leaq 0x1c6dfdf0(%rip), %rsi  # 0x1c71f640
cmpq $0x6, %rdi
je 0x3f87f
xorl %r9d, %r9d
xorl %r8d, %r8d
cmpq $0x3, %r9
je 0x3f872
movslq (%rcx,%r9,4), %r10
addq %rax, %r10
xorq (%rsi,%r10,8), %r8
incq %r9
jmp 0x3f85c
movq %r8, (%rdx,%rdi,8)
incq %rdi
addq $0xc, %rcx
jmp 0x3f850
leaq 0x60(%rsp), %rcx
xorl %edi, %edi
cmpq $0x5, %rdi
je 0x3f8b6
xorl %r9d, %r9d
xorl %r8d, %r8d
cmpq $0x4, %r9
je 0x3f8a8
movslq (%rcx,%r9,4), %r10
addq %rax, %r10
xorq (%rsi,%r10,8), %r8
incq %r9
jmp 0x3f892
movq %r8, 0x48(%rdx,%rdi,8)
incq %rdi
addq $0x10, %rcx
jmp 0x3f886
leaq 0xb0(%rsp), %rcx
xorl %edi, %edi
cmpq $0x9, %rdi
je 0x3f8f3
xorl %r9d, %r9d
xorl %r8d, %r8d
cmpq $0x5, %r9
je 0x3f8e2
movslq (%rcx,%r9,4), %r10
addq %rax, %r10
xorq (%rsi,%r10,8), %r8
incq %r9
jmp 0x3f8cc
movq %r8, 0x90(%rdx,%rdi,8)
incq %rdi
addq $0x14, %rcx
jmp 0x3f8c0
movq %rsp, %rcx
xorl %edi, %edi
cmpq $0x4, %rdi
je 0x3f92b
xorl %r9d, %r9d
xorl %r8d, %r8d
cmpq $0x6, %r9
je 0x3f91a
movslq (%rcx,%r9,4), %r10
addq %rax, %r10
xorq (%rsi,%r10,8), %r8
incq %r9
jmp 0x3f904
movq %r8, 0xd8(%rdx,%rdi,8)
incq %rdi
addq $0x18, %rcx
jmp 0x3f8f8
xorl %eax, %eax
leaq 0x1c6e1f7c(%rip), %r15  # 0x1c7218b0
cmpq $0x40000, %rax          # imm = 0x40000
je 0x3f94a
movl $0xffff, (%rax,%r15)    # imm = 0xFFFF
addq $0x4, %rax
jmp 0x3f934
xorl %r14d, %r14d
leaq 0x937c(%rip), %r12      # 0x48cd0
leaq 0x170(%rsp), %rbx
cmpq $0x86, %r14
je 0x3f98f
movl (%r12,%r14,4), %edi
movq %rbx, %rsi
callq 0x3733b
xorl %eax, %eax
cmpq $0x10, %rax
je 0x3f98a
movl 0x170(%rsp,%rax,4), %ecx
andl $0x0, (%r15,%rcx,4)
incq %rax
jmp 0x3f973
incq %r14
jmp 0x3f95c
xorl %r12d, %r12d
leaq 0x8547(%rip), %r13      # 0x47ee0
leaq 0x170(%rsp), %rbx
leaq 0x1b0(%rsp), %r14
cmpq $0x1be, %r12            # imm = 0x1BE
je 0x3f9f2
movl (%r13,%r12,8), %edi
movl 0x4(%r13,%r12,8), %ebp
movq %rbx, %rsi
callq 0x3733b
movl %ebp, %edi
movq %r14, %rsi
callq 0x3733b
xorl %eax, %eax
cmpq $0x10, %rax
je 0x3f9ed
movl 0x1b0(%rsp,%rax,4), %ecx
movl 0x170(%rsp,%rax,4), %edx
movl %ecx, (%r15,%rdx,4)
incq %rax
jmp 0x3f9d0
incq %r12
jmp 0x3f9a9
addq $0x238, %rsp            # imm = 0x238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq