// File: /workspace/github_cpp_makefile_star2_O3/kmyk[P]procon26/procon26.cpp
// Function: block::block(block_t const&)
block::block(block_t const & a) {
    for (flip_t f : { H, T }) {
        for (rot_t r : { R0, R90, R180, R270 }) {
            m_offset[f][r] = { 0, 0 };
            m_size[f][r] = { N, N };
        }
    }
    // > 石は 1 個以上かつ，16 個以下のブロックにより構成され，
    m_area = area_cell(a.a, true);
    assert (1 <= m_area and m_area <= 16);
    // > 石操作の順番として，はじめに石の裏表を決め，そのあとに回転させる。
    copy_cell(a.a, m_cell[H][R0]);
    copy_cell_flip(m_cell[H][R0], m_cell[T][R0]);
    for (flip_t f : { H, T }) {
        for (rot_t r : { R0, R90, R180 }) {
            copy_cell_rot90(m_cell[f][r], m_cell[f][rot90(r)]);
        }
    }
    for (flip_t f : { H, T }) {
        for (rot_t r : { R0, R90, R180, R270 }) {
            shrink_cell(m_cell[f][r], m_offset[f][r], m_size[f][r], false);
            m_stones[f][r] = collect_cell(m_cell[f][r], m_offset[f][r], m_size[f][r]);
            // skipが効きやすく
            std::sort(m_stones[f][r].begin(), m_stones[f][r].end(), [](point_t const & a, point_t const & b) {
                return std::make_pair(- a.x, - a.y) < std::make_pair(- b.x, - b.y);
            });
        }
    }
    for (flip_t f : { H, T }) {
        for (rot_t r : { R0, R90, R180, R270 }) {
            m_skips[f][r].resize(m_area);
            repeat (i, m_area) {
                point_t p = m_stones[f][r][i];
                m_skips[f][r][i] = 0;
                while (is_on_board(p) and m_cell[f][r][p.y][p.x]) {
                    p.x -= 1;
                    m_skips[f][r][i] += 1;
                }
            }
        }
    }
    std::set<uint64_t> sigs;
    for (flip_t f : { H, T }) {
        for (rot_t r : { R0, R90, R180, R270 }) {
            uint64_t sig = signature_block(m_cell[f][r], m_offset[f][r]);
            m_duplicated[f][r] = sigs.count(sig);
            sigs.insert(sig);
        }
    }
    m_signature = *sigs.begin();
    m_circumference = 0;
    repeat (i, m_area) {
        point_t p = m_stones[H][R0][i];
        repeat (j,4) {
            auto q = p + dp[j];
            m_circumference +=
                not is_on_board(q) ? 1 :
                m_cell[H][R0][q.y][q.x] == 0 ? 1 :
                0;
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rsi, %r15
movq %rdi, %rbx
addq $0x290, %rdi            # imm = 0x290
leaq 0x350(%rbx), %rax
movq %rax, 0x88(%rsp)
xorl %r14d, %r14d
movl $0x180, %edx            # imm = 0x180
movq %rdi, 0x30(%rsp)
xorl %esi, %esi
callq 0x20c0
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, 0x10(%rsp)
leaq 0x200(%rbx), %rax
movq %rax, 0x38(%rsp)
leaq 0x240(%rbx), %r8
movabsq $0x800000008, %rax      # imm = 0x800000008
movdqa 0x31e7(%rip), %xmm0     # 0xb260
movl 0x10(%rsp,%r14), %ecx
movdqa %xmm0, 0x50(%rsp)
shlq $0x5, %rcx
movq 0x38(%rsp), %rdx
addq %rcx, %rdx
addq %r8, %rcx
xorl %esi, %esi
movl 0x50(%rsp,%rsi), %edi
movq $0x0, (%rdx,%rdi,8)
movq %rax, (%rcx,%rdi,8)
addq $0x4, %rsi
cmpq $0x10, %rsi
jne 0x8095
addq $0x4, %r14
cmpq $0x8, %r14
jne 0x8079
xorl %eax, %eax
pxor %xmm0, %xmm0
xorl %ecx, %ecx
movd %ecx, %xmm1
movd (%r15,%rax,8), %xmm2
punpcklbw %xmm0, %xmm2    # xmm2 = xmm2[0],xmm0[0],xmm2[1],xmm0[1],xmm2[2],xmm0[2],xmm2[3],xmm0[3],xmm2[4],xmm0[4],xmm2[5],xmm0[5],xmm2[6],xmm0[6],xmm2[7],xmm0[7]
punpcklwd %xmm0, %xmm2    # xmm2 = xmm2[0],xmm0[0],xmm2[1],xmm0[1],xmm2[2],xmm0[2],xmm2[3],xmm0[3]
paddd %xmm1, %xmm2
movd 0x4(%r15,%rax,8), %xmm1
punpcklbw %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1],xmm1[2],xmm0[2],xmm1[3],xmm0[3],xmm1[4],xmm0[4],xmm1[5],xmm0[5],xmm1[6],xmm0[6],xmm1[7],xmm0[7]
punpcklwd %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1],xmm1[2],xmm0[2],xmm1[3],xmm0[3]
paddd %xmm2, %xmm1
pshufd $0xee, %xmm1, %xmm2     # xmm2 = xmm1[2,3,2,3]
paddd %xmm1, %xmm2
pshufd $0x55, %xmm2, %xmm1     # xmm1 = xmm2[1,1,1,1]
paddd %xmm2, %xmm1
movd %xmm1, %ecx
incq %rax
cmpq $0x8, %rax
jne 0x80c1
movl %ecx, 0x280(%rbx)
decl %ecx
cmpl $0xf, %ecx
ja 0x8726
xorl %eax, %eax
movq %rbx, %rcx
xorl %edx, %edx
movb (%r15,%rdx), %sil
movb %sil, (%rcx,%rdx)
incq %rdx
cmpq $0x8, %rdx
jne 0x8121
incq %rax
addq $0x8, %rcx
addq $0x8, %r15
cmpq $0x8, %rax
jne 0x811f
movq %r8, 0x90(%rsp)
leaq 0x107(%rbx), %rax
xorl %ecx, %ecx
movq %rbx, %rdx
movq %rax, %rsi
xorl %edi, %edi
movb (%rdx,%rdi), %r8b
movb %r8b, (%rsi)
incq %rdi
decq %rsi
cmpq $0x8, %rdi
jne 0x815c
incq %rcx
addq $0x8, %rax
addq $0x8, %rdx
cmpq $0x8, %rcx
jne 0x8157
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, 0x10(%rsp)
leaq 0x7(%rbx), %rax
movq %rax, (%rsp)
xorl %r12d, %r12d
movl 0x10(%rsp,%r12), %r13d
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, 0x50(%rsp)
movl $0x2, 0x58(%rsp)
shlq $0x8, %r13
movq (%rsp), %rax
leaq (%rax,%r13), %rbp
addq %rbx, %r13
xorl %r14d, %r14d
movl 0x50(%rsp,%r14), %r15d
movl %r15d, %edi
callq 0x98c3
movl %eax, %eax
shlq $0x6, %rax
addq %rbp, %rax
shlq $0x6, %r15
addq %r13, %r15
xorl %ecx, %ecx
xorl %edx, %edx
movb (%r15,%rdx), %sil
movb %sil, (%rax,%rdx,8)
incq %rdx
cmpq $0x8, %rdx
jne 0x81e9
incq %rcx
decq %rax
addq $0x8, %r15
cmpq $0x8, %rcx
jne 0x81e7
addq $0x4, %r14
cmpq $0xc, %r14
jne 0x81c8
addq $0x4, %r12
cmpq $0x8, %r12
jne 0x819a
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, 0x8(%rsp)
xorl %eax, %eax
leaq 0x50(%rsp), %r14
movq %rax, 0x98(%rsp)
movl 0x8(%rsp,%rax), %ecx
movaps 0x3015(%rip), %xmm0     # 0xb260
movaps %xmm0, 0x10(%rsp)
movq %rcx, %rax
shlq $0x8, %rax
addq %rbx, %rax
movq %rax, 0x48(%rsp)
leaq (%rcx,%rcx,2), %rdx
shlq $0x5, %rcx
movq 0x38(%rsp), %rax
addq %rcx, %rax
movq %rax, 0x40(%rsp)
addq 0x90(%rsp), %rcx
movq %rcx, 0x20(%rsp)
shlq $0x5, %rdx
addq 0x30(%rsp), %rdx
movq %rdx, (%rsp)
xorl %eax, %eax
movq %rax, 0x28(%rsp)
movl 0x10(%rsp,%rax), %r15d
movq %r15, %r12
shlq $0x6, %r12
addq 0x48(%rsp), %r12
movq 0x40(%rsp), %rax
leaq (%rax,%r15,8), %r13
movq 0x20(%rsp), %rax
leaq (%rax,%r15,8), %rbp
movb $0x0, 0x50(%rsp)
movq %r12, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movq %r14, %rcx
callq 0x9570
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %rbp, %rcx
callq 0x900a
leaq (%r15,%r15,2), %r12
movq (%rsp), %rcx
movq (%rcx,%r12,8), %rdi
movq 0x10(%rcx,%r12,8), %rsi
movdqa 0x50(%rsp), %xmm0
movdqu %xmm0, (%rcx,%r12,8)
movq 0x60(%rsp), %rax
movq %rax, 0x10(%rcx,%r12,8)
pxor %xmm0, %xmm0
movdqa %xmm0, 0x50(%rsp)
movq $0x0, 0x60(%rsp)
testq %rdi, %rdi
je 0x833d
subq %rdi, %rsi
callq 0x2190
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x833d
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
movq (%rsp), %rax
leaq (%rax,%r12,8), %rax
movq (%rax), %rbp
movq 0x8(%rax), %r12
cmpq %r12, %rbp
je 0x83d5
movq %r12, %r15
subq %rbp, %r15
movq %r15, %rax
sarq $0x3, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %rbp, %rdi
movq %r12, %rsi
callq 0x8cd0
cmpq $0x81, %r15
jl 0x83ca
leaq 0x80(%rbp), %r13
movq %rbp, %rdi
movq %r13, %rsi
callq 0x8f70
cmpq %r12, %r13
je 0x83d5
movq (%r13), %rax
movq %rax, %rcx
shrq $0x20, %rcx
movq %r13, %rdx
cmpl %eax, -0x8(%rdx)
jl 0x83b4
jg 0x83c1
cmpl %ecx, -0x4(%rdx)
jge 0x83c1
movq -0x8(%rdx), %rsi
movq %rsi, (%rdx)
addq $-0x8, %rdx
jmp 0x83a8
movq %rax, (%rdx)
addq $0x8, %r13
jmp 0x8395
movq %rbp, %rdi
movq %r12, %rsi
callq 0x8f70
movq 0x28(%rsp), %rax
addq $0x4, %rax
cmpq $0x10, %rax
leaq 0x50(%rsp), %r14
jne 0x8290
movq 0x98(%rsp), %rax
addq $0x4, %rax
cmpq $0x8, %rax
jne 0x8238
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, 0x10(%rsp)
movl 0x280(%rbx), %eax
xorl %ecx, %ecx
leaq 0x8(%rsp), %r15
movq %rcx, 0x40(%rsp)
movl 0x10(%rsp,%rcx), %edx
movdqa 0x2e30(%rip), %xmm0     # 0xb260
movdqa %xmm0, 0x50(%rsp)
leaq (%rdx,%rdx,2), %rsi
shlq $0x5, %rsi
movq 0x88(%rsp), %rcx
addq %rsi, %rcx
movq %rcx, 0x28(%rsp)
addq 0x30(%rsp), %rsi
movq %rsi, 0x48(%rsp)
shlq $0x8, %rdx
addq %rbx, %rdx
movq %rdx, 0x20(%rsp)
xorl %r13d, %r13d
movl 0x50(%rsp,%r13), %ebp
leaq (,%rbp,2), %r14
addq %rbp, %r14
movq 0x28(%rsp), %rcx
leaq (%rcx,%r14,8), %r12
movslq %eax, %rsi
movq %r12, %rdi
callq 0x4872
movl 0x280(%rbx), %eax
testl %eax, %eax
jle 0x8510
movq %r13, (%rsp)
movq 0x48(%rsp), %rax
leaq (%rax,%r14,8), %r14
shlq $0x6, %rbp
addq 0x20(%rsp), %rbp
xorl %r13d, %r13d
movq (%r14), %rax
movq (%rax,%r13,8), %rax
movq %rax, 0x8(%rsp)
movq (%r12), %rax
movl $0x0, (%rax,%r13,4)
movq %r15, %rdi
callq 0x9b40
testb %al, %al
je 0x84fd
movslq 0xc(%rsp), %rcx
movslq 0x8(%rsp), %rax
leaq (,%rcx,8), %rcx
addq %rbp, %rcx
cmpb $0x1, (%rax,%rcx)
jne 0x84fd
decl %eax
movl %eax, 0x8(%rsp)
movq (%r12), %rax
incl (%rax,%r13,4)
jmp 0x84c6
incq %r13
movslq 0x280(%rbx), %rax
cmpq %rax, %r13
jl 0x84ae
movq (%rsp), %r13
addq $0x4, %r13
cmpq $0x10, %r13
jne 0x8467
movq 0x40(%rsp), %rcx
addq $0x4, %rcx
cmpq $0x8, %rcx
jne 0x841f
leaq 0x58(%rsp), %r14
movl $0x0, (%r14)
xorl %ecx, %ecx
movq %rcx, 0x8(%r14)
movq %r14, 0x10(%r14)
movq %r14, 0x18(%r14)
movq %rcx, 0x20(%r14)
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, 0x8(%rsp)
leaq 0x288(%rbx), %rax
movq %rax, 0x20(%rsp)
movq %rcx, 0x28(%rsp)
movl 0x8(%rsp,%rcx), %ebp
movdqa 0x2ce5(%rip), %xmm0     # 0xb260
movdqa %xmm0, 0x10(%rsp)
movq %rbp, %r13
shlq $0x8, %r13
addq %rbx, %r13
movq 0x20(%rsp), %rax
leaq (%rax,%rbp,4), %rax
movq %rax, (%rsp)
shlq $0x5, %rbp
addq 0x38(%rsp), %rbp
xorl %r12d, %r12d
movl 0x10(%rsp,%r12), %r15d
movq %r15, %rdi
shlq $0x6, %rdi
addq %r13, %rdi
leaq (,%r15,8), %rsi
addq %rbp, %rsi
callq 0x7490
movq %rax, 0xa0(%rsp)
movq 0x60(%rsp), %r8
movq %r14, %r9
testq %r8, %r8
je 0x861a
movq %r14, %rsi
movq %rsi, %rcx
movq %r8, %rdx
movq 0x20(%r8), %rdi
xorl %r8d, %r8d
cmpq %rax, %rdi
setb %r8b
movq %rdx, %rsi
cmovbq %rcx, %rsi
movq 0x10(%rdx,%r8,8), %r8
testq %r8, %r8
jne 0x85db
movq %r14, %r9
cmpq %r14, %rsi
je 0x861a
cmpq %rax, %rdi
cmovbq %rcx, %rdx
cmpq 0x20(%rdx), %rax
cmovbq %r14, %rsi
movq %rsi, %r9
cmpq %r14, %r9
movq (%rsp), %rax
setne (%r15,%rax)
leaq 0x50(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x9652
addq $0x4, %r12
cmpq $0x10, %r12
jne 0x85a4
movq 0x28(%rsp), %rcx
addq $0x4, %rcx
cmpq $0x8, %rcx
jne 0x856a
movq 0x68(%rsp), %rax
movq 0x20(%rax), %rax
movq %rax, 0x410(%rbx)
movl $0x0, 0x284(%rbx)
cmpl $0x0, 0x280(%rbx)
jle 0x870a
xorl %ecx, %ecx
leaq 0x2be7(%rip), %r12      # 0xb270
leaq 0x10(%rsp), %r15
movq 0x30(%rsp), %rax
movq (%rax), %rax
movq %rcx, (%rsp)
movq (%rax,%rcx,8), %r13
movq %r13, %rbp
shrq $0x20, %rbp
xorl %r14d, %r14d
movl (%r12,%r14,8), %eax
addl %r13d, %eax
movl 0x4(%r12,%r14,8), %ecx
addl %ebp, %ecx
shlq $0x20, %rcx
orq %rcx, %rax
movq %rax, 0x10(%rsp)
movq %r15, %rdi
callq 0x9b40
movl $0x1, %ecx
testb %al, %al
je 0x86e8
movslq 0x14(%rsp), %rax
movslq 0x10(%rsp), %rcx
leaq (%rbx,%rax,8), %rax
movzbl (%rcx,%rax), %ecx
xorl $0x1, %ecx
addl %ecx, 0x284(%rbx)
incq %r14
cmpq $0x4, %r14
jne 0x86a8
movq (%rsp), %rcx
incq %rcx
movslq 0x280(%rbx), %rax
cmpq %rax, %rcx
jl 0x868e
leaq 0x50(%rsp), %rdi
callq 0x9154
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2ba7(%rip), %rdi      # 0xb2d4
leaq 0x2bbd(%rip), %rsi      # 0xb2f1
leaq 0x2bc3(%rip), %rcx      # 0xb2fe
movl $0x10f, %edx            # imm = 0x10F
callq 0x20e0
jmp 0x8747
movq %rax, %r14
leaq 0x50(%rsp), %rdi
callq 0x9154
jmp 0x8761
jmp 0x875e
jmp 0x875e
jmp 0x875e
jmp 0x875e
movq %rax, %r14
xorl %r15d, %r15d
movq 0x3f8(%rbx,%r15), %rdi
testq %rdi, %rdi
je 0x8781
movq 0x408(%rbx,%r15), %rsi
subq %rdi, %rsi
callq 0x2190
addq $-0x18, %r15
cmpq $-0xc0, %r15
jne 0x8764
xorl %r15d, %r15d
movq 0x338(%rbx,%r15), %rdi
testq %rdi, %rdi
je 0x87ae
movq 0x348(%rbx,%r15), %rsi
subq %rdi, %rsi
callq 0x2190
addq $-0x18, %r15
cmpq $-0xc0, %r15
jne 0x8791
movq %r14, %rdi
callq 0x22a0
nop