// File: /workspace/github_cpp_makefile_star2_O2/nachogoro[P]wordcrack-herminia/src/main.cpp
// Function: writeResultsToOutputFiles(std::map<Word, int, std::less<Word>, std::allocator<std::pair<Word const, int>>>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
void writeResultsToOutputFiles(
        std::map<Word,int>& foundWords,
        const std::string& outFileWords,
        const std::string& outFileCoords)
{
    // Sort results by score
    std::vector<std::pair<Word, int> > pairs;
    for (auto itr = foundWords.begin(); itr != foundWords.end(); ++itr) {
        pairs.push_back(*itr);
    }

    sort(pairs.begin(), pairs.end(), [=](const std::pair<Word, int>& a, const std::pair<Word, int>& b)
            {
            return a.second > b.second;
            }
        );

    std::ofstream wordOutput(outFileWords);
    std::ofstream coordOutput(outFileCoords);
    for (auto it = pairs.begin(); it != pairs.end(); ++it) {
        wordOutput << it->first.currentWord() << " " << it->second << std::endl;
        coordOutput << it->first.generateScreenCoords() << std::endl;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x448, %rsp            # imm = 0x448
movq %rdx, -0x48(%rbp)
movq %rsi, %r14
movq %rdi, %r15
callq 0x2180
xorps %xmm0, %xmm0
leaq -0x40(%rbp), %r12
andq $0x0, 0x10(%r12)
movaps %xmm0, (%r12)
movq 0x18(%r15), %rbx
addq $0x8, %r15
leaq -0x268(%rbp), %r13
cmpq %r15, %rbx
je 0x5b04
leaq 0x20(%rbx), %rsi
movq %r13, %rdi
callq 0x68e4
movq %r12, %rdi
movq %r13, %rsi
callq 0x75f0
movq %r13, %rdi
callq 0x68b2
movq %rbx, %rdi
callq 0x2140
movq %rax, %rbx
jmp 0x5ad3
movq -0x40(%rbp), %r12
movq -0x38(%rbp), %r15
cmpq %r15, %r12
je 0x5b79
movq %r15, %rbx
subq %r12, %rbx
movl $0xd8, %ecx
movq %rbx, %rax
cqto
idivq %rcx
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r12, %rdi
movq %r15, %rsi
callq 0x61f7
cmpq $0xd81, %rbx            # imm = 0xD81
jl 0x5b6e
leaq 0xd80(%r12), %rbx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x6604
cmpq %r15, %rbx
je 0x5b79
movq %rbx, %rdi
callq 0x66b7
addq $0xd8, %rbx
jmp 0x5b58
movq %r12, %rdi
movq %r15, %rsi
callq 0x6604
leaq -0x268(%rbp), %rdi
pushq $0x10
popq %rdx
movq %r14, %rsi
callq 0x2380
leaq -0x468(%rbp), %rdi
pushq $0x10
popq %rdx
movq -0x48(%rbp), %rsi
callq 0x2380
movq -0x40(%rbp), %rbx
leaq -0x68(%rbp), %r14
leaq -0x268(%rbp), %r15
leaq 0x262b(%rip), %r12      # 0x81df
leaq -0x468(%rbp), %r13
cmpq -0x38(%rbp), %rbx
je 0x5c37
addq $0x8, %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2260
movq %r15, %rdi
movq %r14, %rsi
callq 0x21a0
movq %rax, %rdi
movq %r12, %rsi
callq 0x21d0
movl 0xc8(%rbx), %esi
movq %rax, %rdi
callq 0x2320
movq %rax, %rdi
callq 0x2100
movq %r14, %rdi
callq 0x20f0
addq $-0x8, %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2a38
movq %r13, %rdi
movq %r14, %rsi
callq 0x21a0
movq %rax, %rdi
callq 0x2100
movq %r14, %rdi
callq 0x20f0
addq $0xd8, %rbx
jmp 0x5bbb
leaq -0x468(%rbp), %rdi
callq 0x2290
leaq -0x268(%rbp), %rdi
callq 0x2290
leaq -0x40(%rbp), %rdi
callq 0x6914
addq $0x448, %rsp            # imm = 0x448
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x5cac
jmp 0x5c7c
jmp 0x5c7c
jmp 0x5c7c
jmp 0x5c77
movq %rax, %rbx
jmp 0x5ca0
movq %rax, %rbx
jmp 0x5cb8
movq %rax, %rbx
leaq -0x268(%rbp), %rdi
callq 0x68b2
jmp 0x5cb8
jmp 0x5c94
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
callq 0x20f0
leaq -0x468(%rbp), %rdi
callq 0x2290
leaq -0x268(%rbp), %rdi
callq 0x2290
leaq -0x40(%rbp), %rdi
callq 0x6914
movq %rbx, %rdi
callq 0x2330