// File: davidjosepha[P]slitherlink/src/generator/generator.cpp
// Function: Generator::deleteNumbers()
void Generator::deleteNumbers() {
    setCounts();
    int count = 0;
    int i = rand() % (m_) + 1;
    int j = rand() % (n_) + 1;
    Number oldNum = grid_.getNumber(i, j);
    while (count < ((m_)*(n_)*2/3 + 10)) {
        count++;
        int count2 = 0;
        while (true) {
            i = rand() % (m_) + 1;
            j = rand() % (n_) + 1;
            oldNum = grid_.getNumber(i, j);
            if (isBalanced(i, j, oldNum)) {
                break;
            }
            count2 ++;
            if (count2 > n_+m_) {
                if (eligible(i,j) or oldNum == NONE) {
                    count+= (m_+n_)/2;
                    break;
                }
            }
        }
        eliminateNumber(i, j);
        //exporter.print();

        // TODO: maybe modify selected rules

        Solver solver = Solver(grid_, rules_, contradictions_, selectedRules_, NUM_RULES - NUM_CONST_RULES, 1);
        if (!grid_.isSolved()) {
            grid_.setNumber(i, j, oldNum);
        } else {
            minusCounts(oldNum);
        }
        grid_.resetGrid();
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0xa0(%rbp)
callq 0x10bf0
movl $0x0, -0xc(%rbp)
callq 0x2070
movq -0xa0(%rbp), %rcx
cltd
idivl (%rcx)
addl $0x1, %edx
movl %edx, -0x10(%rbp)
callq 0x2070
movq -0xa0(%rbp), %rdi
cltd
idivl 0x4(%rdi)
addl $0x1, %edx
movl %edx, -0x14(%rbp)
addq $0x48, %rdi
movl -0x10(%rbp), %esi
movl -0x14(%rbp), %edx
callq 0x5b50
movl %eax, -0x18(%rbp)
movq -0xa0(%rbp), %rcx
movl -0xc(%rbp), %eax
movl %eax, -0xa4(%rbp)
movl (%rcx), %eax
imull 0x4(%rcx), %eax
shll %eax
movl $0x3, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0xa4(%rbp), %eax
addl $0xa, %ecx
cmpl %ecx, %eax
jge 0x11b8e
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
movl $0x0, -0x1c(%rbp)
callq 0x2070
movq -0xa0(%rbp), %rcx
cltd
idivl (%rcx)
addl $0x1, %edx
movl %edx, -0x10(%rbp)
callq 0x2070
movq -0xa0(%rbp), %rdi
cltd
idivl 0x4(%rdi)
addl $0x1, %edx
movl %edx, -0x14(%rbp)
addq $0x48, %rdi
movl -0x10(%rbp), %esi
movl -0x14(%rbp), %edx
callq 0x5b50
movq -0xa0(%rbp), %rdi
movl %eax, -0x18(%rbp)
movl -0x10(%rbp), %esi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
callq 0x11bb0
testb $0x1, %al
jne 0x11a4e
jmp 0x11a50
jmp 0x11aab
movq -0xa0(%rbp), %rdx
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movl 0x4(%rdx), %ecx
addl (%rdx), %ecx
cmpl %ecx, %eax
jle 0x11aa6
movq -0xa0(%rbp), %rdi
movl -0x10(%rbp), %esi
movl -0x14(%rbp), %edx
callq 0x11830
testb $0x1, %al
jne 0x11a88
cmpl $0x0, -0x18(%rbp)
jne 0x11aa4
movq -0xa0(%rbp), %rcx
movl (%rcx), %eax
addl 0x4(%rcx), %eax
movl $0x2, %ecx
cltd
idivl %ecx
addl -0xc(%rbp), %eax
movl %eax, -0xc(%rbp)
jmp 0x11aab
jmp 0x11aa6
jmp 0x119f6
movq -0xa0(%rbp), %rdi
movl -0x10(%rbp), %esi
movl -0x14(%rbp), %edx
callq 0x118e0
movq -0xa0(%rbp), %rax
movq %rax, %rsi
addq $0x48, %rsi
movq %rsi, -0xb0(%rbp)
movq 0x38(%rax), %r8
movq 0x128(%rax), %rdx
movq 0x130(%rax), %rcx
movq %rsp, %rax
movl $0x1, (%rax)
leaq -0x88(%rbp), %rdi
movl $0x1e, %r9d
callq 0xcbe0
movq -0xb0(%rbp), %rdi
callq 0x4830
movb %al, -0xa5(%rbp)
jmp 0x11b13
movb -0xa5(%rbp), %al
testb $0x1, %al
jne 0x11b5c
jmp 0x11b1f
movq -0xa0(%rbp), %rdi
addq $0x48, %rdi
movl -0x10(%rbp), %esi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
callq 0x5d90
jmp 0x11b3a
jmp 0x11b6b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x88(%rbp), %rdi
callq 0xfcf0
jmp 0x11b97
movq -0xa0(%rbp), %rdi
movl -0x18(%rbp), %esi
callq 0x11220
movq -0xa0(%rbp), %rdi
addq $0x48, %rdi
callq 0x2c70
jmp 0x11b7d
leaq -0x88(%rbp), %rdi
callq 0xfcf0
jmp 0x119b3
addq $0xc0, %rsp
popq %rbp
retq
movq -0x90(%rbp), %rdi
callq 0x22c0
nopw %cs:(%rax,%rax)