// File: /workspace/github_cpp_makefile_star2_O3/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 $0x98, %rsp
movq %rdi, %rbx
callq 0xcf2c
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 0x42dc
movl (%rbx), %eax
imull 0x4(%rbx), %eax
addl %eax, %eax
cmpl $-0x1d, %eax
jl 0xdae6
xorl %eax, %eax
movq %rbx, -0x40(%rbp)
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 0x42dc
movl %eax, %r15d
movq %rbx, %rdi
movl %r12d, %esi
movl %r13d, %edx
movl %eax, %ecx
callq 0xdb12
testb %al, %al
jne 0xd9eb
movl (%rbx), %eax
addl 0x4(%rbx), %eax
cmpl %eax, %r14d
jl 0xd9df
movq -0x40(%rbp), %rcx
movq 0x138(%rcx), %rcx
movslq %r12d, %rbx
movq -0x8(%rcx,%rbx,8), %rcx
cmpb $0x1, -0x1(%rcx,%r13)
jne 0xd9da
movq -0x30(%rbp), %rdi
movl %r12d, %esi
movl %r13d, %edx
callq 0x42dc
testl %r15d, %r15d
je 0xd9f7
testl %eax, %eax
je 0xd9df
jmp 0xd9f7
testl %r15d, %r15d
je 0xda00
incl %r14d
movq -0x40(%rbp), %rbx
jmp 0xd958
movslq %r12d, %rbx
movslq %r13d, %rax
movq %rax, -0x48(%rbp)
jmp 0xda10
movq -0x40(%rbp), %rcx
movl 0x4(%rcx), %eax
addl (%rcx), %eax
movl %eax, %ecx
shrl $0x1f, %ecx
addl %eax, %ecx
sarl %ecx
addl %ecx, -0x34(%rbp)
movq %r13, -0x48(%rbp)
movq -0x30(%rbp), %r14
movq %r14, %rdi
movl %r12d, %esi
movl %r13d, %edx
xorl %ecx, %ecx
callq 0x43de
movq %r14, %rdi
callq 0x2b2c
movq -0x40(%rbp), %rcx
movq 0x138(%rcx), %rax
movq -0x8(%rax,%rbx,8), %rax
movq %rcx, %rbx
movq -0x48(%rbp), %rcx
movb $0x0, -0x1(%rax,%rcx)
movq 0x38(%rbx), %r8
movq 0x128(%rbx), %rdx
movq 0x130(%rbx), %rcx
movl $0x1, (%rsp)
leaq -0xb0(%rbp), %rdi
movq %r14, %rsi
movl $0x1e, %r9d
callq 0xaa98
movq %r14, %rdi
callq 0x37a2
testb %al, %al
je 0xda8f
movq %rbx, %rdi
movl %r15d, %esi
callq 0xd314
jmp 0xdaa1
movq -0x30(%rbp), %rdi
movl %r12d, %esi
movl %r13d, %edx
movl %r15d, %ecx
callq 0x43de
movq -0x30(%rbp), %rdi
callq 0x2b2c
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0xdab8
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 0xd950
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0xdb09
callq 0x2180
movq %rbx, %rdi
callq 0x2260
nop