// File: kmyk[P]codevs-for-student-2016/Main.cpp
// Function: simulation::estimate_with_erasing_all(primitive::blocks_t<16ul, 10ul> const&)
vector<pair<result_t, int> > estimate_with_erasing_all(field_t const & field) {
        const array<int,width> height_map = make_height_map(field);
        vector<pair<result_t, int> > acc;
        repeat (x, width) {
            repeat_reverse (y, height_map[x]) {
                if (field.at[x][y] == empty_block or field.at[x][y] == obstacle_block) continue;
                bool erasable =
                    y+1 >= height
                    or (x-1 >= 0    and field.at[x-1][y+1] == empty_block)
                    or (                field.at[x  ][y+1] == empty_block)
                    or (x+1 < width and field.at[x+1][y+1] == empty_block);
                if (not erasable) break;
                field_t nfield = field;
                array<int,width> nheight_map = height_map;
                vector<point_t> modified_blocks { point(y, x) };
                modified_blocks = erase_blocks(nfield, nheight_map, modified_blocks);
                result_t result = simulate(nfield, nheight_map, modified_blocks, 1);
                int consumed = 0;
                repeat (x, width) consumed += height_map[x] - nheight_map[x];
                acc.emplace_back(result, consumed);
            }
        }
        if (acc.empty()) acc.emplace_back((result_t) { 0, 0 }, 0);
        return acc;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1f0, %rsp            # imm = 0x1F0
movq %rdi, -0x1b0(%rbp)
movq %rdi, %rax
movq %rax, -0x1b8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0x6940
movq -0x1b0(%rbp), %rdi
movb $0x0, -0x39(%rbp)
callq 0x6d30
movl $0x0, -0x40(%rbp)
cmpl $0xa, -0x40(%rbp)
jge 0x3aee
movslq -0x40(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0x6c60
movl (%rax), %eax
subl $0x1, %eax
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
jl 0x3ade
movq -0x10(%rbp), %rdi
movslq -0x40(%rbp), %rsi
callq 0x68e0
movq %rax, %rdi
movslq -0x44(%rbp), %rsi
callq 0x6910
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x3793
movq -0x10(%rbp), %rdi
movslq -0x40(%rbp), %rsi
callq 0x68e0
movq %rax, %rdi
movslq -0x44(%rbp), %rsi
callq 0x6910
movsbl (%rax), %eax
cmpl $0xb, %eax
jne 0x3798
jmp 0x3abf
movl -0x44(%rbp), %ecx
addl $0x1, %ecx
movb $0x1, %al
cmpl $0x10, %ecx
movb %al, -0x1b9(%rbp)
jge 0x386c
movl -0x40(%rbp), %eax
subl $0x1, %eax
cmpl $0x0, %eax
jl 0x37ed
movq -0x10(%rbp), %rdi
movl -0x40(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x68e0
movq %rax, %rdi
movl -0x44(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x6910
movsbl (%rax), %ecx
movb $0x1, %al
cmpl $0x0, %ecx
movb %al, -0x1b9(%rbp)
je 0x386c
movq -0x10(%rbp), %rdi
movslq -0x40(%rbp), %rsi
callq 0x68e0
movq %rax, %rdi
movl -0x44(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x6910
movsbl (%rax), %ecx
movb $0x1, %al
cmpl $0x0, %ecx
movb %al, -0x1b9(%rbp)
je 0x386c
movl -0x40(%rbp), %ecx
addl $0x1, %ecx
xorl %eax, %eax
cmpl $0xa, %ecx
movb %al, -0x1ba(%rbp)
jge 0x3860
movq -0x10(%rbp), %rdi
movl -0x40(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x68e0
movq %rax, %rdi
movl -0x44(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x6910
movsbl (%rax), %eax
cmpl $0x0, %eax
sete %al
movb %al, -0x1ba(%rbp)
movb -0x1ba(%rbp), %al
movb %al, -0x1b9(%rbp)
movb -0x1b9(%rbp), %al
andb $0x1, %al
movb %al, -0x45(%rbp)
testb $0x1, -0x45(%rbp)
jne 0x3882
jmp 0x3ade
movq -0x10(%rbp), %rsi
leaq -0xe5(%rbp), %rdi
movl $0xa0, %edx
callq 0x2170
movq -0x18(%rbp), %rax
movq %rax, -0xf0(%rbp)
movups -0x38(%rbp), %xmm0
movups -0x28(%rbp), %xmm1
movaps %xmm1, -0x100(%rbp)
movaps %xmm0, -0x110(%rbp)
movl -0x44(%rbp), %edi
movl -0x40(%rbp), %esi
callq 0x2550
movq %rax, -0x140(%rbp)
leaq -0x140(%rbp), %rax
movq %rax, -0x138(%rbp)
movq $0x1, -0x130(%rbp)
leaq -0x141(%rbp), %rdi
movq %rdi, -0x1c8(%rbp)
callq 0x6d50
movq -0x1c8(%rbp), %rcx
movq -0x138(%rbp), %rsi
movq -0x130(%rbp), %rdx
leaq -0x128(%rbp), %rdi
callq 0x6d70
jmp 0x3919
leaq -0x141(%rbp), %rdi
callq 0x6df0
leaq -0x170(%rbp), %rdi
leaq -0xe5(%rbp), %rsi
leaq -0x110(%rbp), %rdx
leaq -0x128(%rbp), %rcx
callq 0x6e10
jmp 0x3948
leaq -0x128(%rbp), %rdi
movq %rdi, -0x1d0(%rbp)
leaq -0x170(%rbp), %rsi
movq %rsi, -0x1d8(%rbp)
callq 0x70d0
movq -0x1d8(%rbp), %rdi
callq 0x6850
movq -0x1d0(%rbp), %rsi
leaq -0x190(%rbp), %rdi
callq 0x6b70
jmp 0x398a
leaq -0xe5(%rbp), %rdi
leaq -0x110(%rbp), %rsi
leaq -0x190(%rbp), %rdx
movl $0x1, %ecx
callq 0x7100
movq %rax, -0x1e0(%rbp)
jmp 0x39b2
movq -0x1e0(%rbp), %rax
movq %rax, -0x178(%rbp)
leaq -0x190(%rbp), %rdi
callq 0x6850
movl $0x0, -0x194(%rbp)
movl $0x0, -0x198(%rbp)
cmpl $0xa, -0x198(%rbp)
jge 0x3a97
movslq -0x198(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0x6c60
movl (%rax), %eax
movl %eax, -0x1e4(%rbp)
movslq -0x198(%rbp), %rsi
leaq -0x110(%rbp), %rdi
callq 0x67f0
movq %rax, %rcx
movl -0x1e4(%rbp), %eax
subl (%rcx), %eax
addl -0x194(%rbp), %eax
movl %eax, -0x194(%rbp)
movl -0x198(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x198(%rbp)
jmp 0x39e0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x150(%rbp)
movl %eax, -0x154(%rbp)
leaq -0x141(%rbp), %rdi
callq 0x6df0
jmp 0x3b76
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x150(%rbp)
movl %eax, -0x154(%rbp)
jmp 0x3acd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x150(%rbp)
movl %eax, -0x154(%rbp)
leaq -0x190(%rbp), %rdi
callq 0x6850
jmp 0x3acd
movq -0x1b0(%rbp), %rdi
leaq -0x178(%rbp), %rsi
leaq -0x194(%rbp), %rdx
callq 0x7280
jmp 0x3ab3
leaq -0x128(%rbp), %rdi
callq 0x6850
movl -0x44(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x3747
leaq -0x128(%rbp), %rdi
callq 0x6850
jmp 0x3b76
jmp 0x3ae0
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x3728
movq -0x1b0(%rbp), %rdi
callq 0x7300
testb $0x1, %al
jne 0x3b00
jmp 0x3b50
movq -0x1b0(%rbp), %rdi
movl $0x0, -0x1a0(%rbp)
movl $0x0, -0x19c(%rbp)
movl $0x0, -0x1a4(%rbp)
leaq -0x1a0(%rbp), %rsi
leaq -0x1a4(%rbp), %rdx
callq 0x7340
jmp 0x3b3a
jmp 0x3b50
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x150(%rbp)
movl %eax, -0x154(%rbp)
jmp 0x3b76
movb $0x1, -0x39(%rbp)
testb $0x1, -0x39(%rbp)
jne 0x3b66
movq -0x1b0(%rbp), %rdi
callq 0x73c0
movq -0x1b8(%rbp), %rax
addq $0x1f0, %rsp            # imm = 0x1F0
popq %rbp
retq
movq -0x1b0(%rbp), %rdi
callq 0x73c0
movq -0x150(%rbp), %rdi
callq 0x22f0
nop