// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdi, %rbx
callq 0xcede
callq 0x2080
cltd
idivl (%rbx)
leal 0x1(%rdx), %r15d
callq 0x2080
cltd
idivl 0x4(%rbx)
incl %edx
leaq 0x48(%rbx), %rdi
movq %rdi, -0x30(%rbp)
movl %r15d, %esi
callq 0x42d4
movl (%rbx), %eax
imull 0x4(%rbx), %eax
addl %eax, %eax
cmpl $-0x1d, %eax
jl 0xda7a
xorl %eax, %eax
incl %eax
movl %eax, -0x34(%rbp)
xorl %r14d, %r14d
callq 0x2080
cltd
idivl (%rbx)
movl %edx, %r12d
incl %r12d
callq 0x2080
cltd
idivl 0x4(%rbx)
movslq %edx, %r13
incq %r13
movq -0x30(%rbp), %rdi
movl %r12d, %esi
movl %r13d, %edx
callq 0x42d4
movl %eax, %r15d
movq %rbx, %rdi
movl %r12d, %esi
movl %r13d, %edx
movl %eax, %ecx
callq 0xdaa6
testb %al, %al
jne 0xd9ab
movl (%rbx), %eax
addl 0x4(%rbx), %eax
cmpl %eax, %r14d
jl 0xd992
movq 0x138(%rbx), %rax
movslq %r12d, %rcx
movq -0x8(%rax,%rcx,8), %rax
cmpb $0x1, -0x1(%rax,%r13)
jne 0xd987
movq -0x30(%rbp), %rdi
movl %r12d, %esi
movl %r13d, %edx
callq 0x42d4
movb $0x1, %cl
testl %eax, %eax
jne 0xd989
xorl %ecx, %ecx
testl %r15d, %r15d
je 0xd99a
testb %cl, %cl
jne 0xd99a
incl %r14d
jmp 0xd90e
movl 0x4(%rbx), %eax
addl (%rbx), %eax
movl %eax, %ecx
shrl $0x1f, %ecx
addl %eax, %ecx
sarl %ecx
addl %ecx, -0x34(%rbp)
movq -0x30(%rbp), %r14
movq %r14, %rdi
movl %r12d, %esi
movl %r13d, %edx
xorl %ecx, %ecx
callq 0x43d6
movq %r14, %rdi
callq 0x2b0e
movq 0x138(%rbx), %rax
movslq %r12d, %rcx
movq -0x8(%rax,%rcx,8), %rax
movb $0x0, -0x1(%rax,%r13)
movq 0x38(%rbx), %r8
movq 0x128(%rbx), %rdx
movq 0x130(%rbx), %rcx
movl $0x1, (%rsp)
leaq -0xa0(%rbp), %rdi
movq %r14, %rsi
movl $0x1e, %r9d
callq 0xaa7c
movq %r14, %rdi
callq 0x376a
testb %al, %al
je 0xda23
movq %rbx, %rdi
movl %r15d, %esi
callq 0xd2ba
jmp 0xda35
movq -0x30(%rbp), %rdi
movl %r12d, %esi
movl %r13d, %edx
movl %r15d, %ecx
callq 0x43d6
movq -0x30(%rbp), %rdi
callq 0x2b0e
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0xda4c
callq 0x2180
movl (%rbx), %eax
imull 0x4(%rbx), %eax
addl %eax, %eax
cltq
imulq $0x55555556, %rax, %rax # imm = 0x55555556
movq %rax, %rcx
shrq $0x20, %rcx
shrq $0x3f, %rax
addl %ecx, %eax
addl $0xa, %eax
movl -0x34(%rbp), %ecx
cmpl %eax, %ecx
movl %ecx, %eax
jl 0xd906
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0xda9d
callq 0x2180
movq %rbx, %rdi
callq 0x2260
nop