// File: /workspace/github_cpp_makefile_star2_O1/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, -0x68(%rbp)
movq %rsi, -0x70(%rbp)
movq %rdi, %r15
callq 0x21a0
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
movq $0x0, -0x30(%rbp)
movq 0x18(%r15), %r12
addq $0x8, %r15
cmpq %r15, %r12
je 0x62c3
leaq -0x258(%rbp), %rbx
leaq -0x270(%rbp), %r14
leaq -0x40(%rbp), %r13
leaq 0x20(%r12), %rsi
movq %r14, %rdi
callq 0x7878
movq %r13, %rdi
movq %r14, %rsi
callq 0x837a
leaq -0x1f8(%rbp), %rdi
callq 0x42f0
leaq -0x248(%rbp), %rdi
callq 0x3cb8
movq -0x268(%rbp), %rdi
cmpq %rbx, %rdi
je 0x62b3
callq 0x21e0
movq %r12, %rdi
callq 0x2150
movq %rax, %r12
cmpq %r15, %rax
jne 0x6272
movq -0x40(%rbp), %rbx
movq -0x38(%rbp), %r15
cmpq %r15, %rbx
je 0x633f
movq %r15, %r14
subq %rbx, %r14
movq %r14, %rax
sarq $0x3, %rax
movabsq $-0x7b425ed097b425ed, %rcx # imm = 0x84BDA12F684BDA13
imulq %rax, %rcx
bsrq %rcx, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x709b
cmpq $0xd81, %r14            # imm = 0xD81
jl 0x6334
leaq 0xd80(%rbx), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x75c4
cmpq %r15, %r14
je 0x633f
movq %r14, %rdi
callq 0x76fd
addq $0xd8, %r14
jmp 0x631e
movq %rbx, %rdi
movq %r15, %rsi
callq 0x75c4
leaq -0x270(%rbp), %rdi
movq -0x70(%rbp), %rsi
movl $0x10, %edx
callq 0x23c0
leaq -0x470(%rbp), %rdi
movq -0x68(%rbp), %rsi
movl $0x10, %edx
callq 0x23c0
movq -0x40(%rbp), %r15
cmpq -0x38(%rbp), %r15
je 0x6473
leaq -0x50(%rbp), %rbx
leaq -0x60(%rbp), %r12
leaq -0x470(%rbp), %r14
movq %rbx, -0x60(%rbp)
movq 0x8(%r15), %rsi
movq 0x10(%r15), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x3da6
movq -0x60(%rbp), %rsi
movq -0x58(%rbp), %rdx
leaq -0x270(%rbp), %rdi
callq 0x2260
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0x2e8c(%rip), %rsi      # 0x924f
callq 0x2260
movl 0xd0(%r15), %esi
movq %r13, %rdi
callq 0x2350
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x2200
movsbl %al, %esi
movq %r13, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2140
movq -0x60(%rbp), %rdi
cmpq %rbx, %rdi
je 0x640f
callq 0x21e0
movq %r12, %rdi
movq %r15, %rsi
callq 0x2cc0
movq -0x60(%rbp), %rsi
movq -0x58(%rbp), %rdx
movq %r14, %rdi
callq 0x2260
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x2200
movsbl %al, %esi
movq %r13, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2140
movq -0x60(%rbp), %rdi
cmpq %rbx, %rdi
je 0x6462
callq 0x21e0
addq $0xd8, %r15
cmpq -0x38(%rbp), %r15
jne 0x6386
movq 0x6b3e(%rip), %rax      # 0xcfb8
movq (%rax), %rbx
movq 0x18(%rax), %r14
leaq -0x468(%rbp), %rdi
movq %rbx, -0x8(%rdi)
movq -0x18(%rbx), %rax
movq %r14, -0x470(%rbp,%rax)
callq 0x21c0
movl $0xf8, %r15d
leaq -0x470(%rbp), %rdi
addq %r15, %rdi
callq 0x20b0
leaq -0x268(%rbp), %rdi
movq %rbx, -0x8(%rdi)
movq -0x18(%rbx), %rax
movq %r14, -0x270(%rbp,%rax)
callq 0x21c0
leaq -0x270(%rbp), %rdi
addq %r15, %rdi
callq 0x20b0
leaq -0x40(%rbp), %rdi
callq 0x7924
addq $0x448, %rsp            # imm = 0x448
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
jmp 0x653f
jmp 0x650a
jmp 0x650a
jmp 0x650a
jmp 0x6505
movq %rax, %r14
jmp 0x6533
movq %rax, %r14
jmp 0x654b
movq %rax, %r14
leaq -0x270(%rbp), %rdi
callq 0x783c
jmp 0x654b
jmp 0x6522
movq %rax, %r14
movq -0x60(%rbp), %rdi
cmpq %rbx, %rdi
je 0x6533
callq 0x21e0
leaq -0x470(%rbp), %rdi
callq 0x22b0
leaq -0x270(%rbp), %rdi
callq 0x22b0
leaq -0x40(%rbp), %rdi
callq 0x7924
movq %r14, %rdi
callq 0x2360