// File: /workspace/github_cpp_makefile_star2_O2/kmyk[P]codevs-for-student-2016/Main.cpp
// Function: std::vector<std::pair<point_t, int>, std::allocator<std::pair<point_t, int>>> simulation::collect_erases<19ul, 10ul>(primitive::blocks_t<19ul, 10ul> const&, std::vector<point_t, std::allocator<point_t>> const&)
vector<pair<point_t,int> > collect_erases(blocks_t<H,W> const & field, vector<point_t> const & modified_blocks) {
        static const int dy[] = { -1, -1, 0, 1 }; // 下 右下 右 右上
        static const int dx[] = {  0,  1, 1, 1 };
        vector<pair<point_t,int> > erases;
        for (point_t p : modified_blocks) { // 変化したところだけ見る
            assert (field.at[p.x][p.y] != empty_block and field.at[p.x][p.y] != obstacle_block);
            repeat (j, 4) {
                int cnt = 1;
                int acc = field.at[p.x][p.y];
                int ly = p.y - dy[j];
                int lx = p.x - dx[j];
                for (; is_on_field(ly, lx, H, W); ++ cnt) {
                    block_t block = field.at[lx][ly];
                    if (block == empty_block) break;
                    if (acc + block > erasing_sum) break;
                    acc += block;
                    ly -= dy[j];
                    lx -= dx[j];
                }
                // しゃくとり法っぽく
                int ry = p.y + dy[j];
                int rx = p.x + dx[j];
                while (cnt --) {
                    while (is_on_field(ry, rx, H, W)) {
                        block_t block = field.at[rx][ry];
                        if (block == empty_block) break;
                        if (acc + block > erasing_sum) break;
                        acc += block;
                        ry += dy[j];
                        rx += dx[j];
                    }
                    ly += dy[j];
                    lx += dx[j];
                    if (acc == erasing_sum) erases.emplace_back(point(ly, lx), j);
                    acc -= field.at[lx][ly];
                }
            }
        }
        whole(sort, erases);
        erases.erase(whole(unique, erases), erases.end()); // 重複排除
        return erases;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %r10
xorps %xmm0, %xmm0
andq $0x0, 0x10(%rdi)
movups %xmm0, (%rdi)
movq (%rdx), %rax
movq 0x8(%rdx), %rcx
movq %rcx, 0x30(%rsp)
leaq 0x2d3d(%rip), %rdi      # 0xd610
leaq 0x2d46(%rip), %r8       # 0xd620
movq %r10, 0x28(%rsp)
movq %rsi, 0x48(%rsp)
cmpq 0x30(%rsp), %rax
je 0xaa66
movslq (%rax), %rcx
movq %rcx, 0x20(%rsp)
movq %rax, 0x38(%rsp)
movslq 0x4(%rax), %rcx
movq %rcx, 0x18(%rsp)
imulq $0x13, %rcx, %rax
addq %rsi, %rax
movq %rax, 0x40(%rsp)
xorl %eax, %eax
movl %eax, 0x10(%rsp)
cmpl $0x4, %eax
jge 0xaa58
movq 0x20(%rsp), %rcx
movq 0x40(%rsp), %rdx
movsbl (%rdx,%rcx), %ebp
cltq
movl (%rdi,%rax,4), %r15d
movl (%r8,%rax,4), %r12d
movl %ecx, %r9d
subl %r15d, %r9d
movq 0x18(%rsp), %rax
movl %eax, %r11d
subl %r12d, %r11d
pushq $0x1
popq %rbx
testl %r9d, %r9d
js 0xa985
cmpl $0x12, %r9d
ja 0xa985
cmpl $0x9, %r11d
ja 0xa985
movl %r11d, %eax
imulq $0x13, %rax, %rax
addq %rsi, %rax
movl %r9d, %ecx
movsbl (%rcx,%rax), %eax
testl %eax, %eax
je 0xa985
addl %ebp, %eax
cmpl $0xa, %eax
jg 0xa985
incl %ebx
subl %r15d, %r9d
subl %r12d, %r11d
movl %eax, %ebp
jmp 0xa94c
addl 0x20(%rsp), %r15d
addl 0x18(%rsp), %r12d
movslq 0x10(%rsp), %rax
subl $0x1, %ebx
jb 0xaa51
testl %r15d, %r15d
js 0xa9d6
cmpl $0x12, %r15d
ja 0xa9d6
cmpl $0x9, %r12d
ja 0xa9d6
movl %r12d, %ecx
imulq $0x13, %rcx, %rcx
addq %rsi, %rcx
movl %r15d, %edx
movsbl (%rdx,%rcx), %ecx
testl %ecx, %ecx
je 0xa9d6
addl %ebp, %ecx
cmpl $0xa, %ecx
jg 0xa9d6
addl (%rdi,%rax,4), %r15d
addl (%r8,%rax,4), %r12d
movl %ecx, %ebp
jmp 0xa99d
movslq (%rdi,%rax,4), %rcx
movslq %r9d, %r9
addq %rcx, %r9
movslq (%r8,%rax,4), %rax
movslq %r11d, %r11
addq %rax, %r11
cmpl $0xa, %ebp
jne 0xaa3e
movl %ebx, 0x14(%rsp)
movq %rdi, %rbx
movq %r11, %r13
movq %r11, %rax
shlq $0x20, %rax
movq %r9, %r14
movl %r9d, %ecx
orq %rax, %rcx
movq %rcx, 0x50(%rsp)
movq %r10, %rdi
leaq 0x50(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0xad32
movq 0x28(%rsp), %r10
movq %rbx, %rdi
leaq 0x2bf1(%rip), %r8       # 0xd620
movq %r14, %r9
movq 0x48(%rsp), %rsi
movq %r13, %r11
movl 0x14(%rsp), %ebx
imulq $0x13, %r11, %rax
addq %rsi, %rax
movsbl (%r9,%rax), %eax
subl %eax, %ebp
jmp 0xa98f
incl %eax
jmp 0xa913
movq 0x38(%rsp), %rax
addq $0x8, %rax
jmp 0xa8e4
leaq 0xf(%rsp), %rdi
movq %r10, %rbx
movq %r10, %rsi
callq 0xad72
leaq 0xe(%rsp), %rdi
movq %rbx, %rsi
callq 0xad84
movq 0x8(%rbx), %rdx
movq %rbx, %rdi
movq %rax, %rsi
callq 0xad7e
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xaaaa
jmp 0xaaaa
jmp 0xaaaa
movq %rax, %r14
movq 0x28(%rsp), %rdi
callq 0xbde2
movq %r14, %rdi
callq 0x2250