// File: /workspace/github_cpp_makefile_star2_O2/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, 0x90(%rsp)
xorl %r14d, %r14d
movl $0x180, %edx            # imm = 0x180
movq %rdi, 0x40(%rsp)
xorl %esi, %esi
callq 0x20b0
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, 0x10(%rsp)
leaq 0x200(%rbx), %rax
movq %rax, 0x48(%rsp)
leaq 0x240(%rbx), %rax
movq %rax, 0x58(%rsp)
movabsq $0x800000008, %rax      # imm = 0x800000008
movaps 0x3237(%rip), %xmm0     # 0xb250
cmpq $0x8, %r14
je 0x805b
movl 0x10(%rsp,%r14), %ecx
movaps %xmm0, 0x60(%rsp)
shlq $0x5, %rcx
movq 0x48(%rsp), %rdx
addq %rcx, %rdx
addq 0x58(%rsp), %rcx
xorl %esi, %esi
cmpq $0x10, %rsi
je 0x8055
movl 0x60(%rsp,%rsi), %edi
andq $0x0, (%rdx,%rdi,8)
movq %rax, (%rcx,%rdi,8)
addq $0x4, %rsi
jmp 0x803c
addq $0x4, %r14
jmp 0x8019
pushq $0x1
popq %rsi
movq %r15, %rdi
callq 0x8db9
movl %eax, 0x280(%rbx)
decl %eax
cmpl $0x10, %eax
jae 0x8539
movq %r15, %rdi
movq %rbx, %rsi
callq 0x8de8
leaq 0x100(%rbx), %rsi
movq %rbx, %rdi
callq 0x8e11
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, 0x10(%rsp)
xorl %r14d, %r14d
cmpq $0x8, %r14
je 0x8106
movl 0x10(%rsp,%r14), %r12d
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, 0x60(%rsp)
movl $0x2, 0x68(%rsp)
shlq $0x8, %r12
addq %rbx, %r12
xorl %r13d, %r13d
cmpq $0xc, %r13
je 0x8100
movl 0x60(%rsp,%r13), %r15d
movl %r15d, %edi
callq 0x9c12
shlq $0x6, %r15
addq %r12, %r15
movl %eax, %esi
shlq $0x6, %rsi
addq %r12, %rsi
movq %r15, %rdi
callq 0x8e49
addq $0x4, %r13
jmp 0x80cf
addq $0x4, %r14
jmp 0x80a3
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, (%rsp)
xorl %eax, %eax
leaq 0x60(%rsp), %r15
cmpq $0x8, %rax
je 0x8270
movq %rax, 0x98(%rsp)
movl (%rsp,%rax), %ecx
movaps 0x3119(%rip), %xmm0     # 0xb250
movaps %xmm0, 0x10(%rsp)
movq %rcx, %rax
shlq $0x8, %rax
addq %rbx, %rax
movq %rax, 0x30(%rsp)
imulq $0x60, %rcx, %rdx
shlq $0x5, %rcx
movq 0x48(%rsp), %rax
addq %rcx, %rax
movq %rax, 0x28(%rsp)
addq 0x58(%rsp), %rcx
movq %rcx, 0x38(%rsp)
addq 0x40(%rsp), %rdx
movq %rdx, 0x50(%rsp)
xorl %eax, %eax
cmpq $0x10, %rax
je 0x825f
movq %rax, 0x8(%rsp)
movl 0x10(%rsp,%rax), %ebp
movq %rbp, %r14
shlq $0x6, %r14
addq 0x30(%rsp), %r14
movq 0x28(%rsp), %rax
leaq (%rax,%rbp,8), %r12
movq 0x38(%rsp), %rax
leaq (%rax,%rbp,8), %r13
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rdx
xorl %ecx, %ecx
callq 0x8e75
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %r13, %rcx
callq 0x8e87
imulq $0x18, %rbp, %r14
movq 0x50(%rsp), %r12
leaq (%r12,%r14), %rdi
movq %r15, %rsi
callq 0x988e
movq %r15, %rdi
callq 0x409a
movq (%r14,%r12), %r13
movq 0x8(%r14,%r12), %r12
cmpq %r12, %r13
je 0x8251
movq %r12, %r14
subq %r13, %r14
movq %r14, %rax
sarq $0x3, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r13, %rdi
movq %r12, %rsi
callq 0x8a4a
cmpq $0x81, %r14
jl 0x8246
leaq 0x80(%r13), %r14
movq %r13, %rdi
movq %r14, %rsi
callq 0x8cb6
cmpq %r12, %r14
je 0x8251
movq %r14, %rdi
callq 0x8d26
addq $0x8, %r14
jmp 0x8233
movq %r13, %rdi
movq %r12, %rsi
callq 0x8cb6
movq 0x8(%rsp), %rax
addq $0x4, %rax
jmp 0x8176
movq 0x98(%rsp), %rax
addq $0x4, %rax
jmp 0x811b
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, 0x10(%rsp)
xorl %eax, %eax
movq %rsp, %r15
cmpq $0x8, %rax
je 0x8388
movq %rax, 0x50(%rsp)
movl 0x10(%rsp,%rax), %ecx
movaps 0x2fb2(%rip), %xmm0     # 0xb250
movaps %xmm0, 0x60(%rsp)
imulq $0x60, %rcx, %rdx
movq 0x90(%rsp), %rax
addq %rdx, %rax
movq %rax, 0x38(%rsp)
addq 0x40(%rsp), %rdx
movq %rdx, 0x28(%rsp)
shlq $0x8, %rcx
addq %rbx, %rcx
movq %rcx, 0x30(%rsp)
xorl %r14d, %r14d
cmpq $0x10, %r14
je 0x837a
movl 0x60(%rsp,%r14), %ebp
imulq $0x18, %rbp, %r13
movq 0x38(%rsp), %rax
leaq (%rax,%r13), %r12
movslq 0x280(%rbx), %rsi
movq %r12, %rdi
callq 0x40e6
movq %r14, 0x8(%rsp)
addq 0x28(%rsp), %r13
shlq $0x6, %rbp
addq 0x30(%rsp), %rbp
xorl %r14d, %r14d
movslq 0x280(%rbx), %rax
cmpq %rax, %r14
jge 0x836c
movq (%r13), %rax
movq (%rax,%r14,8), %rax
movq %rax, (%rsp)
movq (%r12), %rax
andl $0x0, (%rax,%r14,4)
movq %r15, %rdi
callq 0x9de0
testb %al, %al
je 0x8367
movslq 0x4(%rsp), %rcx
movslq (%rsp), %rax
leaq (,%rcx,8), %rcx
addq %rbp, %rcx
cmpb $0x1, (%rax,%rcx)
jne 0x8367
decl %eax
movl %eax, (%rsp)
movq (%r12), %rax
incl (%rax,%r14,4)
jmp 0x8332
incq %r14
jmp 0x8311
movq 0x8(%rsp), %r14
addq $0x4, %r14
jmp 0x82d0
movq 0x50(%rsp), %rax
addq $0x4, %rax
jmp 0x8284
leaq 0x68(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, (%rsp)
leaq 0x288(%rbx), %rax
movq %rax, 0x28(%rsp)
xorl %eax, %eax
cmpq $0x8, %rax
je 0x8478
movq %rax, 0x30(%rsp)
movl (%rsp,%rax), %ebp
movaps 0x2e79(%rip), %xmm0     # 0xb250
movaps %xmm0, 0x10(%rsp)
movq %rbp, %rax
shlq $0x8, %rax
addq %rbx, %rax
movq %rax, 0x8(%rsp)
movq 0x28(%rsp), %rax
leaq (%rax,%rbp,4), %rax
movq %rax, 0x38(%rsp)
shlq $0x5, %rbp
addq 0x48(%rsp), %rbp
xorl %r15d, %r15d
cmpq $0x10, %r15
je 0x846a
movl 0x10(%rsp,%r15), %r12d
movq %r12, %rdi
shlq $0x6, %rdi
addq 0x8(%rsp), %rdi
leaq (,%r12,8), %rsi
addq %rbp, %rsi
callq 0x7508
movq %rax, 0xa0(%rsp)
leaq 0x60(%rsp), %r13
movq %r13, %rdi
leaq 0xa0(%rsp), %r14
movq %r14, %rsi
callq 0x8f1e
testq %rax, %rax
movq 0x38(%rsp), %rax
setne (%r12,%rax)
movq %r13, %rdi
movq %r14, %rsi
callq 0x9936
addq $0x4, %r15
jmp 0x8405
movq 0x30(%rsp), %rax
addq $0x4, %rax
jmp 0x83be
movq 0x78(%rsp), %rax
movq 0x20(%rax), %rax
movq %rax, 0x410(%rbx)
andl $0x0, 0x284(%rbx)
xorl %ecx, %ecx
leaq 0x2dc8(%rip), %r12      # 0xb260
leaq 0x10(%rsp), %r15
movslq 0x280(%rbx), %rax
cmpq %rax, %rcx
jge 0x851d
movq 0x40(%rsp), %rax
movq (%rax), %rax
movq %rcx, 0x8(%rsp)
movq (%rax,%rcx,8), %r13
movq %r13, %rbp
shrq $0x20, %rbp
xorl %r14d, %r14d
cmpq $0x4, %r14
je 0x8513
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 0x9de0
pushq $0x1
popq %rcx
testb %al, %al
je 0x8508
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
jmp 0x84c4
movq 0x8(%rsp), %rcx
incq %rcx
jmp 0x849d
leaq 0x60(%rsp), %rdi
callq 0x8f86
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2d84(%rip), %rdi      # 0xb2c4
leaq 0x2d9a(%rip), %rsi      # 0xb2e1
leaq 0x2da0(%rip), %rcx      # 0xb2ee
movl $0x10f, %edx            # imm = 0x10F
callq 0x20d0
jmp 0x8571
jmp 0x8562
jmp 0x8571
jmp 0x8571
jmp 0x8571
movq %rax, %r14
leaq 0x60(%rsp), %rdi
callq 0x8f86
jmp 0x8574
movq %rax, %r14
leaq 0x3f8(%rbx), %r15
xorl %r12d, %r12d
leaq (%r15,%r12), %rdi
callq 0x3f70
addq $-0x18, %r12
cmpq $-0xc0, %r12
jne 0x857e
addq $0x338, %rbx            # imm = 0x338
xorl %r15d, %r15d
leaq (%rbx,%r15), %rdi
callq 0x409a
addq $-0x18, %r15
cmpq $-0xc0, %r15
jne 0x859e
movq %r14, %rdi
callq 0x2270