// File: /workspace/github_cpp_makefile_star2_O1/chrischute[P]are-you-the-one/src/ayto.cpp
// Function: getBestGuessFromSubset(ArgsForMinimaxThread const*)
void getBestGuessFromSubset(const ArgsForMinimaxThread *args)
{
    // Find the query in possibleGuesses which eliminates the most possible answers.
    Pm bestGuess = DIGITS;
    long numRemainingAfterBestGuess = args->_possibleAnswers->size();

    for (PmSet::const_iterator possibleGuess = args->_possibleGuesses->begin();
         possibleGuess != args->_possibleGuesses->end();
         ++possibleGuess) {
        Pm guess = *possibleGuess;

        if (!args->_guessesAlreadyMade->contains(guess)) {
            vector<int> numRemainingGivenResponse(PERM_LENGTH + 1, 0);
            // Check how many possibilities would remain after guessing guess
            for (PmSet::const_iterator it = args->_possibleAnswers->begin();
                 it != args->_possibleAnswers->end();
                 ++it) {
                numRemainingGivenResponse[numInCommon(guess, *it)] += 1;
            }
            // Find the # remaining in the worst-case scenario.
            int numRemainingAfterWorstResponse =
                    *max_element(numRemainingGivenResponse.begin(),
                                 numRemainingGivenResponse.end());
            // If this is lowest worst-case #remaining, set low water mark.
            if (numRemainingAfterWorstResponse < numRemainingAfterBestGuess) {
                bestGuess = guess;
                numRemainingAfterBestGuess = numRemainingAfterWorstResponse;
            }
        }
    }

    // After finding best guess in the chunk, write result to the shared dictionary.
    args->_writeLock->lock();
    args->_bestGuesses->insert(pair<Pm, int>(bestGuess, numRemainingAfterBestGuess));
    args->_writeLock->unlock();

    return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
leaq 0x10(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x286e(%rip), %rsi      # 0x7025
leaq 0x2871(%rip), %rdx      # 0x702f
movq %rsp, %rdi
callq 0x5320
movq 0x8(%rbx), %rdi
callq 0x64f0
movq %rax, %r14
movq 0x10(%rbx), %rdi
callq 0x6210
movq %rax, %r15
leaq 0x20(%rsp), %r12
movq 0x10(%rbx), %rdi
callq 0x623a
cmpq %rax, %r15
je 0x48d7
leaq 0x30(%rsp), %rax
movq %rax, 0x20(%rsp)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x53b0
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0x6218
testb %al, %al
jne 0x48b2
movl $0x2c, %edi
callq 0x2240
movq %rax, %rbp
xorps %xmm0, %xmm0
movups %xmm0, 0x1c(%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, (%rax)
movq 0x8(%rbx), %rdi
callq 0x6210
movq %rax, %r13
movq 0x8(%rbx), %rdi
callq 0x623a
cmpq %rax, %r13
je 0x4871
movq %r12, %rdi
movq %r13, %rsi
callq 0x612c
cltq
incl (%rbp,%rax,4)
addq $0x20, %r13
jmp 0x484c
movl $0x4, %eax
movq %rbp, %rcx
movl (%rcx), %edx
cmpl (%rbp,%rax), %edx
jge 0x4885
leaq (%rax,%rbp), %rcx
addq $0x4, %rax
cmpq $0x2c, %rax
jne 0x4879
movslq (%rcx), %r13
cmpq %r13, %r14
jle 0x48a5
movq %rsp, %rdi
movq %r12, %rsi
callq 0x2120
movq %r13, %r14
movl $0x2c, %esi
movq %rbp, %rdi
callq 0x2250
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x48ce
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2250
addq $0x20, %r15
jmp 0x47e3
movq 0x28(%rbx), %rdi
callq 0x22d0
testl %eax, %eax
jne 0x496a
movq 0x20(%rbx), %r15
leaq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
movq %rax, (%rdi)
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
addq %rsi, %rdx
callq 0x53b0
leaq 0x20(%rsp), %rsi
movl %r14d, 0x20(%rsi)
movq %r15, %rdi
callq 0x5f60
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x4937
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2250
movq 0x28(%rbx), %rdi
callq 0x21c0
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x495b
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x2250
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %edi
callq 0x2150
jmp 0x4981
jmp 0x4986
jmp 0x4986
jmp 0x4986
jmp 0x498d
jmp 0x4981
jmp 0x498d
jmp 0x4986
movq %rax, %rbx
jmp 0x499d
movq %rax, %rbx
jmp 0x49b9
jmp 0x498d
movq %rax, %rbx
movl $0x2c, %esi
movq %rbp, %rdi
callq 0x2250
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x49b9
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2250
leaq 0x10(%rsp), %rax
movq (%rsp), %rdi
cmpq %rax, %rdi
je 0x49d4
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x2250
movq %rbx, %rdi
callq 0x2370