// File: 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
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
movq %rdi, -0x8(%rbp)
leaq -0x29(%rbp), %rdi
movq %rdi, -0x118(%rbp)
callq 0x34e0
movq -0x118(%rbp), %rdx
leaq 0xdbc8(%rip), %rsi      # 0x14025
leaq -0x28(%rbp), %rdi
callq 0x6e80
jmp 0x6468
leaq -0x29(%rbp), %rdi
callq 0x3340
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x107a0
movq %rax, -0x120(%rbp)
jmp 0x6487
movq -0x120(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x10280
movq %rax, -0x128(%rbp)
jmp 0x64a8
movq -0x128(%rbp), %rax
movq %rax, -0x58(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x6f70
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x10320
movq %rax, -0x130(%rbp)
jmp 0x64d6
movq -0x130(%rbp), %rax
movq %rax, -0x60(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x6fb0
testb $0x1, %al
jne 0x64f7
jmp 0x677e
leaq -0x50(%rbp), %rdi
callq 0x6ff0
movq %rax, %rsi
leaq -0x80(%rbp), %rdi
callq 0x30f0
jmp 0x650e
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x80(%rbp), %rsi
callq 0x102b0
movb %al, -0x131(%rbp)
jmp 0x6527
movb -0x131(%rbp), %al
testb $0x1, %al
jne 0x6759
jmp 0x6537
movl $0x0, -0x9c(%rbp)
leaq -0x9d(%rbp), %rdi
movq %rdi, -0x140(%rbp)
callq 0x8240
movq -0x140(%rbp), %rcx
leaq -0x98(%rbp), %rdi
movl $0xb, %esi
leaq -0x9c(%rbp), %rdx
callq 0x8260
jmp 0x6575
leaq -0x9d(%rbp), %rdi
callq 0x82e0
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x10280
movq %rax, -0x148(%rbp)
jmp 0x6597
movq -0x148(%rbp), %rax
movq %rax, -0xb0(%rbp)
leaq -0xa8(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x6f70
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x10320
movq %rax, -0x150(%rbp)
jmp 0x65ce
movq -0x150(%rbp), %rax
movq %rax, -0xb8(%rbp)
leaq -0xa8(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x6fb0
testb $0x1, %al
jne 0x65f8
jmp 0x66bb
leaq -0xa8(%rbp), %rdi
callq 0x6ff0
movq %rax, %rsi
leaq -0x80(%rbp), %rdi
callq 0x10040
movl %eax, -0x154(%rbp)
jmp 0x6618
movl -0x154(%rbp), %eax
movslq %eax, %rsi
leaq -0x98(%rbp), %rdi
callq 0x8300
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
leaq -0xa8(%rbp), %rdi
callq 0x7010
jmp 0x65b8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x29(%rbp), %rdi
callq 0x3340
jmp 0x683c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x6833
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x6770
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x9d(%rbp), %rdi
callq 0x82e0
jmp 0x6770
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x83e0
jmp 0x6770
leaq -0x98(%rbp), %rdi
movq %rdi, -0x168(%rbp)
callq 0x8360
movq -0x168(%rbp), %rdi
movq %rax, -0xd0(%rbp)
callq 0x8390
movq %rax, -0xd8(%rbp)
movq -0xd0(%rbp), %rdi
movq -0xd8(%rbp), %rsi
callq 0x8320
movq %rax, -0x160(%rbp)
jmp 0x6704
movq -0x160(%rbp), %rax
movq %rax, -0xc8(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x83c0
movl (%rax), %eax
movl %eax, -0xbc(%rbp)
movslq -0xbc(%rbp), %rax
cmpq -0x48(%rbp), %rax
jge 0x674d
leaq -0x28(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x3050
jmp 0x6742
movslq -0xbc(%rbp), %rax
movq %rax, -0x48(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x83e0
leaq -0x80(%rbp), %rdi
callq 0x3190
leaq -0x50(%rbp), %rdi
callq 0x7010
jmp 0x64c0
leaq -0x80(%rbp), %rdi
callq 0x3190
jmp 0x6833
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x8440
jmp 0x678d
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x170(%rbp)
leaq -0x100(%rbp), %rdi
leaq -0x28(%rbp), %rsi
leaq -0x48(%rbp), %rdx
callq 0x84b0
jmp 0x67b2
movq -0x170(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x8470
movb %dl, -0x179(%rbp)
movq %rax, -0x178(%rbp)
jmp 0x67d4
movb -0x179(%rbp), %al
movq -0x178(%rbp), %rcx
movq %rcx, -0x110(%rbp)
movb %al, -0x108(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x84f0
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x8510
jmp 0x6809
leaq -0x28(%rbp), %rdi
callq 0x3190
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x84f0
leaq -0x28(%rbp), %rdi
callq 0x3190
movq -0x38(%rbp), %rdi
callq 0x34d0
nopw %cs:(%rax,%rax)