// File: /workspace/github_cpp_makefile_star2_O1/davidjosepha[P]slitherlink/src/generator/generator.cpp
// Function: Generator::findNumberToRemove()
void Generator::findNumberToRemove() {
    fillEligibleVector();
    bool coordsFound = false;

    while (!eligibleCoordinates_.empty() && !coordsFound) {
        int random = rand() % eligibleCoordinates_.size();
        Coordinates attempt = eligibleCoordinates_.at(random);
        eligibleCoordinates_.erase(eligibleCoordinates_.begin() + random);

        // Checks if the number in question is needed to retain a balance
        if (isBalanced(attempt.i, attempt.j)) {
            removeNumber(attempt.i, attempt.j);

            // If unsolvable, bring number back and look for another
            if (!checkIfSolved()) {
                setOldNumber(attempt.i, attempt.j);
                markNecessary(attempt.i, attempt.j);
            } else {
                ineligibleCoordinates_.push_back(attempt);
                coordsFound = true;
                numberCount_ --;
                minusCounts(oldNumbers_[attempt.i-1][attempt.j-1]);
            }
        }
    }

    // If no more candidates, bring back the previously removed number
    if (!coordsFound && numberCount_ < m_ * n_) {
        getNecessaryCoordinate();
        numberCount_ ++;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0xd498
movq 0xf8(%rbx), %rax
cmpq 0x100(%rbx), %rax
je 0xd462
leaq 0x48(%rbx), %r14
leaq 0x110(%rbx), %r15
xorl %r13d, %r13d
leaq -0x30(%rbp), %r12
callq 0x2080
cltq
movq 0xf8(%rbx), %rdi
movq 0x100(%rbx), %rcx
movq %rcx, %r8
subq %rdi, %r8
sarq $0x3, %r8
xorl %edx, %edx
divq %r8
movslq %edx, %rsi
cmpq %rsi, %r8
jbe 0xd487
leaq (%rdi,%rsi,8), %rax
addq $0x8, %rax
movq -0x8(%rax), %rdx
movq %rdx, -0x30(%rbp)
cmpq %rcx, %rax
je 0xd37d
leaq (%rdi,%rsi,8), %rdi
subq %rax, %rcx
movq %rax, %rsi
movq %rcx, %rdx
callq 0x2240
addq $-0x8, 0x100(%rbx)
movl -0x30(%rbp), %esi
movl -0x2c(%rbp), %edx
movq %rbx, %rdi
callq 0xd55a
testb %al, %al
je 0xd442
movl -0x30(%rbp), %esi
movl -0x2c(%rbp), %edx
movq %rbx, %rdi
callq 0xd664
movq %rbx, %rdi
callq 0xd034
testb %al, %al
je 0xd3d6
movq 0x118(%rbx), %rsi
cmpq 0x120(%rbx), %rsi
je 0xd411
movq -0x30(%rbp), %rax
movq %rax, (%rsi)
addq $0x8, 0x118(%rbx)
jmp 0xd41c
movslq -0x30(%rbp), %rsi
movslq -0x2c(%rbp), %rdx
movq 0x140(%rbx), %rax
movq -0x8(%rax,%rsi,8), %rax
movl -0x4(%rax,%rdx,4), %ecx
movq %r14, %rdi
callq 0x43d6
movslq -0x30(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq 0x138(%rbx), %rdx
movq -0x8(%rdx,%rax,8), %rax
movb $0x0, -0x1(%rax,%rcx)
jmp 0xd442
movq %r15, %rdi
movq %r12, %rdx
callq 0xdc64
decl 0x18(%rbx)
movq 0x140(%rbx), %rax
movslq -0x30(%rbp), %rcx
movq -0x8(%rax,%rcx,8), %rax
movslq -0x2c(%rbp), %rcx
movl -0x4(%rax,%rcx,4), %esi
movq %rbx, %rdi
callq 0xd2ba
movb $0x1, %r13b
movq 0xf8(%rbx), %rax
cmpq 0x100(%rbx), %rax
je 0xd45c
testb $0x1, %r13b
je 0xd326
testb $0x1, %r13b
jne 0xd478
movl 0x4(%rbx), %eax
imull (%rbx), %eax
cmpl %eax, 0x18(%rbx)
jge 0xd478
movq %rbx, %rdi
callq 0xd71e
incl 0x18(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2252(%rip), %rdi      # 0xf6e0
movq %r8, %rdx
xorl %eax, %eax
callq 0x2200