// File: /workspace/github_cpp_makefile_star2_O3/kmyk[P]codevs-for-student-2016/Main.cpp
// Function: std::pair<int, std::vector<point_t, std::allocator<point_t>>> simulation::apply_erases<19ul, 10ul>(primitive::blocks_t<19ul, 10ul> const&, std::vector<std::pair<point_t, int>, std::allocator<std::pair<point_t, int>>> const&)
pair<int, vector<point_t> > apply_erases(blocks_t<H,W> const & field, vector<pair<point_t,int> > const & erases) {
        static const int dy[] = { -1, -1, 0, 1 }; // 下 右下 右 右上
        static const int dx[] = {  0,  1, 1, 1 };
        int erase_count = 0;
        vector<point_t> used;
        for (auto && it : erases) {
            point_t p; int j; tie(p, j) = it;
            int cnt = 0, acc = 0;
            for (; acc != erasing_sum; ++ cnt) {
                acc += field.at[p.x][p.y];
                used.push_back(p);
                p.y += dy[j];
                p.x += dx[j];
            }
            erase_count += cnt;
        }
        whole(sort, used);
        used.erase(whole(unique, used), used.end());
        return { erase_count, used };
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq (%rdx), %rcx
movq 0x8(%rdx), %rax
movq %rax, 0x38(%rsp)
cmpq %rax, %rcx
je 0xc61d
movq %rsi, %r14
movq %rbx, 0x30(%rsp)
xorl %ebp, %ebp
leaq 0x3167(%rip), %r15      # 0xf650
movq (%rcx), %rax
movq %rax, 0x8(%rsp)
movq %rcx, 0x40(%rsp)
movslq 0x8(%rcx), %r12
movq %rax, %rcx
shrq $0x20, %rcx
xorl %r13d, %r13d
movslq %ecx, %rcx
leaq (%rcx,%rcx,8), %rdx
leaq (%rcx,%rdx,2), %rcx
addq %r14, %rcx
cltq
movsbl (%rax,%rcx), %ebx
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0xc534
movq 0x8(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0x18(%rsp)
jmp 0xc543
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0xd182
addl %ebx, %r13d
movl 0x8(%rsp), %eax
movl 0xc(%rsp), %ecx
leaq 0x30eb(%rip), %rdx      # 0xf640
addl (%rdx,%r12,4), %eax
addl (%r15,%r12,4), %ecx
movl %eax, 0x8(%rsp)
movl %ecx, 0xc(%rsp)
incl %ebp
cmpl $0xa, %r13d
jne 0xc504
movq 0x40(%rsp), %rcx
addq $0xc, %rcx
cmpq 0x38(%rsp), %rcx
jne 0xc4e9
movq 0x10(%rsp), %r15
movq 0x18(%rsp), %r14
cmpq %r14, %r15
je 0xc5c7
movq %r14, %rax
subq %r15, %rax
sarq $0x3, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0xd25e
movq %r15, %rdi
movq %r14, %rsi
callq 0xd311
movq 0x10(%rsp), %r15
movq 0x18(%rsp), %r14
cmpq %r14, %r15
je 0xc616
addq $0x8, %r15
cmpq %r14, %r15
je 0xc616
movq -0x8(%r15), %rcx
leaq 0x8(%r15), %rdx
cmpq (%r15), %rcx
movq %rdx, %r15
jne 0xc5d0
leaq -0x10(%rdx), %rax
cmpq %r14, %rdx
je 0xc621
movq 0x30(%rsp), %rbx
movq %rcx, %rsi
movq (%rdx), %rcx
cmpq %rcx, %rsi
je 0xc606
movq %rcx, 0x8(%rax)
addq $0x8, %rax
addq $0x8, %rdx
cmpq %r14, %rdx
jne 0xc5f3
movq 0x18(%rsp), %r14
jmp 0xc626
movq 0x30(%rsp), %rbx
jmp 0xc634
xorl %ebp, %ebp
jmp 0xc634
movq 0x30(%rsp), %rbx
addq $0x8, %rax
cmpq %r14, %rax
je 0xc634
movq %rax, 0x18(%rsp)
movl %ebp, (%rbx)
leaq 0x8(%rbx), %rdi
leaq 0x10(%rsp), %rsi
callq 0x48f0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xc65b
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xc671
jmp 0xc671
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xc68b
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
movq %rbx, %rdi
callq 0x2230