// File: kmyk[P]codevs-for-student-2016/Main.cpp
// Function: std::vector<point_t, std::allocator<point_t>> simulation::erase_blocks<16ul, 10ul>(primitive::blocks_t<16ul, 10ul>&, std::array<int, 10ul>&, std::vector<point_t, std::allocator<point_t>> const&)
vector<point_t> erase_blocks(blocks_t<H,W> & field, array<int,W> & height_map, vector<point_t> const & points_to_erase) {
        auto & at = field.at;
        array<int,W> old_height_map = height_map;
        for (point_t p : points_to_erase) {
            at[p.x][p.y] = empty_block;
            setmin(height_map[p.x], p.y);
        }
        vector<point_t> modified_blocks;
        repeat (x,W) {
            for (int y = height_map[x] + 1; y < old_height_map[x]; ++ y) {
                if (at[x][y] != empty_block) {
                    at[x][height_map[x]] = at[x][y];
                    if (at[x][height_map[x]] != obstacle_block) {
                        modified_blocks.push_back(point(height_map[x], x));
                    }
                    ++ height_map[x];
                    at[x][y] = empty_block;
                }
            }
        }
        return modified_blocks;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0xa8(%rbp)
movq %rdi, %rax
movq %rax, -0xa0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rsi
leaq -0x50(%rbp), %rdi
movl $0x28, %edx
callq 0x2170
movq -0x20(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
callq 0x1c2d0
movq %rax, -0x60(%rbp)
movq -0x58(%rbp), %rdi
callq 0x1c300
movq %rax, -0x68(%rbp)
leaq -0x60(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x1d190
testb $0x1, %al
jne 0x6e8b
jmp 0x6edb
leaq -0x60(%rbp), %rdi
callq 0x1d1d0
movq (%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x28(%rbp), %rdi
movslq -0x6c(%rbp), %rsi
callq 0x6c90
movq %rax, %rdi
movslq -0x70(%rbp), %rsi
callq 0x6cc0
movb $0x0, (%rax)
movq -0x18(%rbp), %rdi
movslq -0x6c(%rbp), %rsi
callq 0x67f0
movq %rax, %rdi
leaq -0x70(%rbp), %rsi
callq 0x21cb0
leaq -0x60(%rbp), %rdi
callq 0x1d2d0
jmp 0x6e78
movq -0xa8(%rbp), %rdi
movb $0x0, -0x71(%rbp)
callq 0x6770
movl $0x0, -0x78(%rbp)
movslq -0x78(%rbp), %rax
cmpq $0xa, %rax
jae 0x7097
movq -0x18(%rbp), %rdi
movslq -0x78(%rbp), %rsi
callq 0x67f0
movl (%rax), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
movl %eax, -0xac(%rbp)
movslq -0x78(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x67f0
movq %rax, %rcx
movl -0xac(%rbp), %eax
cmpl (%rcx), %eax
jge 0x7087
movq -0x28(%rbp), %rdi
movslq -0x78(%rbp), %rsi
callq 0x6c90
movq %rax, %rdi
movslq -0x7c(%rbp), %rsi
callq 0x6cc0
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x7077
movq -0x28(%rbp), %rdi
movslq -0x78(%rbp), %rsi
callq 0x6c90
movq %rax, %rdi
movslq -0x7c(%rbp), %rsi
callq 0x6cc0
movb (%rax), %al
movb %al, -0xb9(%rbp)
movq -0x28(%rbp), %rdi
movslq -0x78(%rbp), %rsi
callq 0x6c90
movq %rax, -0xc8(%rbp)
movq -0x18(%rbp), %rdi
movslq -0x78(%rbp), %rsi
callq 0x67f0
movq -0xc8(%rbp), %rdi
movslq (%rax), %rsi
callq 0x6cc0
movb -0xb9(%rbp), %cl
movb %cl, (%rax)
movq -0x28(%rbp), %rdi
movslq -0x78(%rbp), %rsi
callq 0x6c90
movq %rax, -0xb8(%rbp)
movq -0x18(%rbp), %rdi
movslq -0x78(%rbp), %rsi
callq 0x67f0
movq -0xb8(%rbp), %rdi
movslq (%rax), %rsi
callq 0x6cc0
movsbl (%rax), %eax
cmpl $0xb, %eax
je 0x7047
movq -0x18(%rbp), %rdi
movslq -0x78(%rbp), %rsi
callq 0x67f0
movl (%rax), %edi
movl -0x78(%rbp), %esi
callq 0x2550
movq -0xa8(%rbp), %rdi
movq %rax, -0x84(%rbp)
leaq -0x84(%rbp), %rsi
callq 0x6820
jmp 0x7025
jmp 0x7047
movq -0xa8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
callq 0x6850
jmp 0x70bd
movq -0x18(%rbp), %rdi
movslq -0x78(%rbp), %rsi
callq 0x67f0
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movq -0x28(%rbp), %rdi
movslq -0x78(%rbp), %rsi
callq 0x6c90
movq %rax, %rdi
movslq -0x7c(%rbp), %rsi
callq 0x6cc0
movb $0x0, (%rax)
jmp 0x7079
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x6f15
jmp 0x7089
movl -0x78(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
jmp 0x6ef2
movb $0x1, -0x71(%rbp)
testb $0x1, -0x71(%rbp)
jne 0x70ad
movq -0xa8(%rbp), %rdi
callq 0x6850
movq -0xa0(%rbp), %rax
addq $0xd0, %rsp
popq %rbp
retq
movq -0x90(%rbp), %rdi
callq 0x22f0
nopl (%rax)