// File: /workspace/github_cpp_makefile_star2_O1/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, %r12
movq %rdi, %rbx
addq $0x290, %rdi            # imm = 0x290
xorl %r14d, %r14d
movl $0xc0, %edx
movq %rdi, 0x38(%rsp)
xorl %esi, %esi
callq 0x20c0
leaq 0x350(%rbx), %rdi
movl $0xc0, %edx
movq %rdi, 0x88(%rsp)
xorl %esi, %esi
callq 0x20c0
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, 0x18(%rsp)
leaq 0x200(%rbx), %rax
movq %rax, 0x40(%rsp)
leaq 0x240(%rbx), %r8
movabsq $0x800000008, %rax      # imm = 0x800000008
movaps 0x2e8a(%rip), %xmm0     # 0xb250
movl 0x18(%rsp,%r14), %ecx
movups %xmm0, 0x58(%rsp)
shlq $0x5, %rcx
movq 0x40(%rsp), %rdx
addq %rcx, %rdx
addq %r8, %rcx
xorl %esi, %esi
movl 0x58(%rsp,%rsi), %edi
movq $0x0, (%rdx,%rdi,8)
movq %rax, (%rcx,%rdi,8)
addq $0x4, %rsi
cmpq $0x10, %rsi
jne 0x83e1
addq $0x4, %r14
cmpq $0x8, %r14
jne 0x83c6
xorl %ecx, %ecx
movq %r12, %rdx
xorl %eax, %eax
xorl %esi, %esi
movzbl (%rdx,%rsi), %edi
addl %edi, %eax
incq %rsi
cmpq $0x8, %rsi
jne 0x840e
incq %rcx
addq $0x8, %rdx
cmpq $0x8, %rcx
jne 0x840c
movl %eax, 0x280(%rbx)
decl %eax
cmpl $0xf, %eax
ja 0x89ff
xorl %eax, %eax
movq %rbx, %rcx
xorl %edx, %edx
movb (%r12,%rdx), %sil
movb %sil, (%rcx,%rdx)
incq %rdx
cmpq $0x8, %rdx
jne 0x8442
incq %rax
addq $0x8, %rcx
addq $0x8, %r12
cmpq $0x8, %rax
jne 0x8440
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 0x847d
incq %rcx
addq $0x8, %rax
addq $0x8, %rdx
cmpq $0x8, %rcx
jne 0x8478
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, 0x18(%rsp)
leaq 0x7(%rbx), %rax
movq %rax, 0x8(%rsp)
xorl %r15d, %r15d
movl 0x18(%rsp,%r15), %r13d
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, 0x58(%rsp)
movl $0x2, 0x60(%rsp)
shlq $0x8, %r13
movq 0x8(%rsp), %rax
leaq (%rax,%r13), %rbp
addq %rbx, %r13
xorl %r14d, %r14d
movl 0x58(%rsp,%r14), %r12d
movl %r12d, %edi
callq 0x9cbf
movl %eax, %eax
shlq $0x6, %rax
addq %rbp, %rax
shlq $0x6, %r12
addq %r13, %r12
xorl %ecx, %ecx
xorl %edx, %edx
movb (%r12,%rdx), %sil
movb %sil, (%rax,%rdx,8)
incq %rdx
cmpq $0x8, %rdx
jne 0x850c
incq %rcx
decq %rax
addq $0x8, %r12
cmpq $0x8, %rcx
jne 0x850a
addq $0x4, %r14
cmpq $0xc, %r14
jne 0x84eb
addq $0x4, %r15
cmpq $0x8, %r15
jne 0x84bc
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, 0x10(%rsp)
xorl %eax, %eax
leaq 0x58(%rsp), %r14
movq %rax, 0x98(%rsp)
movl 0x10(%rsp,%rax), %ecx
movaps 0x2ce2(%rip), %xmm0     # 0xb250
movups %xmm0, 0x18(%rsp)
movq %rcx, %rax
shlq $0x8, %rax
addq %rbx, %rax
movq %rax, 0x28(%rsp)
leaq (%rcx,%rcx,2), %rdx
shlq $0x5, %rcx
movq 0x40(%rsp), %rax
addq %rcx, %rax
movq %rax, 0x50(%rsp)
addq 0x90(%rsp), %rcx
movq %rcx, 0x30(%rsp)
shlq $0x5, %rdx
addq 0x38(%rsp), %rdx
movq %rdx, 0x48(%rsp)
xorl %eax, %eax
movq %rax, 0x8(%rsp)
movl 0x18(%rsp,%rax), %r12d
movq %r12, %r15
shlq $0x6, %r15
addq 0x28(%rsp), %r15
movq 0x50(%rsp), %rax
leaq (%rax,%r12,8), %r13
movq 0x30(%rsp), %rax
leaq (%rax,%r12,8), %rbp
movb $0x0, 0x58(%rsp)
movq %r15, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movq %r14, %rcx
callq 0x98ba
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %rbp, %rcx
callq 0x92ff
leaq (%r12,%r12,2), %rax
movq 0x48(%rsp), %rcx
leaq (%rcx,%rax,8), %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0x9a0e
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x8632
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
movq (%r13), %r15
movq 0x8(%r13), %r13
cmpq %r13, %r15
je 0x86c3
movq %r13, %r12
subq %r15, %r12
movq %r12, %rax
sarq $0x3, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r15, %rdi
movq %r13, %rsi
callq 0x8fa3
cmpq $0x81, %r12
jl 0x86b8
leaq 0x80(%r15), %rbp
movq %r15, %rdi
movq %rbp, %rsi
callq 0x9265
cmpq %r13, %rbp
je 0x86c3
movq (%rbp), %rax
movq %rax, %rcx
shrq $0x20, %rcx
movq %rbp, %rdx
cmpl %eax, -0x8(%rdx)
jl 0x86a2
jg 0x86af
cmpl %ecx, -0x4(%rdx)
jge 0x86af
movq -0x8(%rdx), %rsi
movq %rsi, (%rdx)
addq $-0x8, %rdx
jmp 0x8696
movq %rax, (%rdx)
addq $0x8, %rbp
jmp 0x8683
movq %r15, %rdi
movq %r13, %rsi
callq 0x9265
movq 0x8(%rsp), %rax
addq $0x4, %rax
cmpq $0x10, %rax
leaq 0x58(%rsp), %r14
jne 0x85b4
movq 0x98(%rsp), %rax
addq $0x4, %rax
cmpq $0x8, %rax
jne 0x855b
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, 0x18(%rsp)
xorl %eax, %eax
leaq 0x10(%rsp), %r12
movq %rax, 0x48(%rsp)
movl 0x18(%rsp,%rax), %ecx
movaps 0x2b39(%rip), %xmm0     # 0xb250
movups %xmm0, 0x58(%rsp)
leaq (%rcx,%rcx,2), %rdx
shlq $0x5, %rdx
movq 0x88(%rsp), %rax
addq %rdx, %rax
movq %rax, 0x30(%rsp)
addq 0x38(%rsp), %rdx
movq %rdx, 0x50(%rsp)
shlq $0x8, %rcx
addq %rbx, %rcx
movq %rcx, 0x28(%rsp)
xorl %r15d, %r15d
movl 0x58(%rsp,%r15), %ebp
leaq (,%rbp,2), %r14
addq %rbp, %r14
movq 0x30(%rsp), %rax
leaq (%rax,%r14,8), %r13
movslq 0x280(%rbx), %rsi
movq %r13, %rdi
callq 0x48a0
movq %r15, 0x8(%rsp)
cmpl $0x0, 0x280(%rbx)
jle 0x87f6
movq 0x50(%rsp), %rax
leaq (%rax,%r14,8), %r14
shlq $0x6, %rbp
addq 0x28(%rsp), %rbp
xorl %r15d, %r15d
movq (%r14), %rax
movq (%rax,%r15,8), %rax
movq %rax, 0x10(%rsp)
movq (%r13), %rax
movl $0x0, (%rax,%r15,4)
movq %r12, %rdi
callq 0x9f30
testb %al, %al
je 0x87e7
movslq 0x14(%rsp), %rcx
movslq 0x10(%rsp), %rax
leaq (,%rcx,8), %rcx
addq %rbp, %rcx
cmpb $0x1, (%rax,%rcx)
jne 0x87e7
decl %eax
movl %eax, 0x10(%rsp)
movq (%r13), %rax
incl (%rax,%r15,4)
jmp 0x87b0
incq %r15
movslq 0x280(%rbx), %rax
cmpq %rax, %r15
jl 0x8798
movq 0x8(%rsp), %r15
addq $0x4, %r15
cmpq $0x10, %r15
jne 0x874d
movq 0x48(%rsp), %rax
addq $0x4, %rax
cmpq $0x8, %rax
jne 0x8707
leaq 0x60(%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, 0x10(%rsp)
leaq 0x288(%rbx), %rax
movq %rax, 0x28(%rsp)
movq %rcx, 0x30(%rsp)
movl 0x10(%rsp,%rcx), %ebp
movaps 0x29eb(%rip), %xmm0     # 0xb250
movups %xmm0, 0x18(%rsp)
movq %rbp, %r13
shlq $0x8, %r13
addq %rbx, %r13
movq 0x28(%rsp), %rax
leaq (%rax,%rbp,4), %rax
movq %rax, 0x8(%rsp)
shlq $0x5, %rbp
addq 0x40(%rsp), %rbp
xorl %r12d, %r12d
movl 0x18(%rsp,%r12), %r15d
movq %r15, %rdi
shlq $0x6, %rdi
addq %r13, %rdi
leaq (,%r15,8), %rsi
addq %rbp, %rsi
callq 0x7690
movq %rax, 0xa0(%rsp)
movq 0x68(%rsp), %rdx
movq %r14, %rcx
testq %rdx, %rdx
je 0x88dd
movq %r14, %rcx
xorl %esi, %esi
cmpq %rax, 0x20(%rdx)
setb %sil
cmovaeq %rdx, %rcx
movq 0x10(%rdx,%rsi,8), %rdx
testq %rdx, %rdx
jne 0x88c5
movq %r14, %rdx
cmpq %r14, %rcx
je 0x88f0
cmpq 0x20(%rcx), %rax
cmovbq %r14, %rcx
movq %rcx, %rdx
cmpq %r14, %rdx
movq 0x8(%rsp), %rax
setne (%r15,%rax)
leaq 0x58(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x9a4e
addq $0x4, %r12
cmpq $0x10, %r12
jne 0x888e
movq 0x30(%rsp), %rcx
addq $0x4, %rcx
cmpq $0x8, %rcx
jne 0x8855
movq 0x70(%rsp), %rax
movq 0x20(%rax), %rax
movq %rax, 0x410(%rbx)
movl $0x0, 0x284(%rbx)
cmpl $0x0, 0x280(%rbx)
jle 0x89e3
xorl %ecx, %ecx
leaq 0x2900(%rip), %r12      # 0xb260
leaq 0x18(%rsp), %r15
movq 0x38(%rsp), %rax
movq (%rax), %rax
movq %rcx, 0x8(%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, 0x18(%rsp)
movq %r15, %rdi
callq 0x9f30
movl $0x1, %ecx
testb %al, %al
je 0x89c0
movslq 0x1c(%rsp), %rax
movslq 0x18(%rsp), %rcx
leaq (%rbx,%rax,8), %rax
movzbl (%rcx,%rax), %ecx
xorl $0x1, %ecx
addl %ecx, 0x284(%rbx)
incq %r14
cmpq $0x4, %r14
jne 0x8980
movq 0x8(%rsp), %rcx
incq %rcx
movslq 0x280(%rbx), %rax
cmpq %rax, %rcx
jl 0x8965
leaq 0x58(%rsp), %rdi
callq 0x9442
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x28be(%rip), %rdi      # 0xb2c4
leaq 0x28d4(%rip), %rsi      # 0xb2e1
leaq 0x28da(%rip), %rcx      # 0xb2ee
movl $0x10f, %edx            # imm = 0x10F
callq 0x20e0
jmp 0x8a20
movq %rax, %r14
leaq 0x58(%rsp), %rdi
callq 0x9442
jmp 0x8a3a
jmp 0x8a37
jmp 0x8a37
jmp 0x8a37
jmp 0x8a37
movq %rax, %r14
xorl %r15d, %r15d
movq 0x3f8(%rbx,%r15), %rdi
testq %rdi, %rdi
je 0x8a5a
movq 0x408(%rbx,%r15), %rsi
subq %rdi, %rsi
callq 0x2190
addq $-0x18, %r15
cmpq $-0xc0, %r15
jne 0x8a3d
xorl %r15d, %r15d
movq 0x338(%rbx,%r15), %rdi
testq %rdi, %rdi
je 0x8a87
movq 0x348(%rbx,%r15), %rsi
subq %rdi, %rsi
callq 0x2190
addq $-0x18, %r15
cmpq $-0xc0, %r15
jne 0x8a6a
movq %r14, %rdi
callq 0x22a0