// File: /workspace/github_cpp_makefile_star2_O3/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 0x291d(%rip), %rsi      # 0x7025
leaq 0x2920(%rip), %rdx      # 0x702f
movq %rsp, %rdi
callq 0x5256
movq 0x8(%rbx), %rdi
callq 0x63ea
movq %rax, %r14
movq 0x10(%rbx), %rdi
callq 0x6112
movq %rax, %r15
leaq 0x20(%rsp), %r12
movq 0x10(%rbx), %rdi
callq 0x613c
cmpq %rax, %r15
je 0x4830
leaq 0x30(%rsp), %rax
movq %rax, 0x20(%rsp)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x52ec
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0x611a
testb %al, %al
jne 0x480b
movl $0x2c, %edi
callq 0x2230
movq %rax, %rbp
xorps %xmm0, %xmm0
movups %xmm0, 0x1c(%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, (%rax)
movq 0x8(%rbx), %rdi
callq 0x6112
movq %rax, %r13
movq 0x8(%rbx), %rdi
callq 0x613c
cmpq %rax, %r13
je 0x47c2
movq %r12, %rdi
movq %r13, %rsi
callq 0x6030
cltq
incl (%rbp,%rax,4)
addq $0x20, %r13
jmp 0x479d
movl (%rbp), %eax
movl $0x4, %ecx
movq %rbp, %rdx
leaq (%rcx,%rbp), %rsi
movl (%rbp,%rcx), %edi
cmpl %edi, %eax
cmovlel %edi, %eax
cmovlq %rsi, %rdx
addq $0x4, %rcx
cmpq $0x2c, %rcx
jne 0x47cd
movslq (%rdx), %r13
cmpq %r13, %r14
jle 0x47fe
movq %rsp, %rdi
movq %r12, %rsi
callq 0x2110
movq %r13, %r14
movl $0x2c, %esi
movq %rbp, %rdi
callq 0x2240
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x4827
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2240
addq $0x20, %r15
jmp 0x4734
movq 0x28(%rbx), %rdi
callq 0x22c0
testl %eax, %eax
jne 0x48c3
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 0x52ec
leaq 0x20(%rsp), %rsi
movl %r14d, 0x20(%rsi)
movq %r15, %rdi
callq 0x5e64
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x4890
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2240
movq 0x28(%rbx), %rdi
callq 0x21b0
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x48b4
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x2240
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %edi
callq 0x2140
jmp 0x48da
jmp 0x48df
jmp 0x48df
jmp 0x48df
jmp 0x48e6
jmp 0x48da
jmp 0x48e6
jmp 0x48df
movq %rax, %rbx
jmp 0x48f6
movq %rax, %rbx
jmp 0x4912
jmp 0x48e6
movq %rax, %rbx
movl $0x2c, %esi
movq %rbp, %rdi
callq 0x2240
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x4912
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2240
leaq 0x10(%rsp), %rax
movq (%rsp), %rdi
cmpq %rax, %rdi
je 0x492d
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x2240
movq %rbx, %rdi
callq 0x2360