// File: /workspace/github_cpp_makefile_star2_O3/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, %r13
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 0x633b
movq %r13, -0x68(%rbp)
leaq -0x258(%rbp), %rbx
leaq -0x270(%rbp), %r14
leaq -0x40(%rbp), %r13
leaq 0x20(%r12), %rsi
movq %r14, %rdi
callq 0x785c
movq %r13, %rdi
movq %r14, %rsi
callq 0x834e
leaq -0x1f8(%rbp), %rdi
callq 0x42d6
leaq -0x248(%rbp), %rdi
callq 0x3cbc
movq -0x268(%rbp), %rdi
cmpq %rbx, %rdi
je 0x62ab
callq 0x21e0
movq %r12, %rdi
callq 0x2150
movq %rax, %r12
cmpq %r15, %rax
jne 0x626a
movq -0x40(%rbp), %rbx
movq -0x38(%rbp), %r15
cmpq %r15, %rbx
movq -0x68(%rbp), %r13
je 0x633b
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 0x709a
cmpq $0xd81, %r14            # imm = 0xD81
jl 0x6330
leaq 0xd80(%rbx), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x75a8
cmpq %r15, %r14
je 0x633b
movq %r14, %rdi
callq 0x76e1
addq $0xd8, %r14
jmp 0x631a
movq %rbx, %rdi
movq %r15, %rsi
callq 0x75a8
leaq -0x270(%rbp), %rdi
movq -0x70(%rbp), %rsi
movl $0x10, %edx
callq 0x23c0
leaq -0x470(%rbp), %rdi
movq %r13, %rsi
movl $0x10, %edx
callq 0x23c0
movq -0x40(%rbp), %r15
cmpq -0x38(%rbp), %r15
je 0x646e
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 0x3dac
movq -0x60(%rbp), %rsi
movq -0x58(%rbp), %rdx
leaq -0x270(%rbp), %rdi
callq 0x2260
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0x2e91(%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 0x640a
callq 0x21e0
movq %r12, %rdi
movq %r15, %rsi
callq 0x2cc4
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 0x645d
callq 0x21e0
addq $0xd8, %r15
cmpq -0x38(%rbp), %r15
jne 0x6381
movq 0x6b43(%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 0x7908
addq $0x448, %rsp            # imm = 0x448
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6505
movq %rax, %r14
jmp 0x653a
jmp 0x6505
jmp 0x6505
jmp 0x6500
movq %rax, %r14
jmp 0x652e
movq %rax, %r14
jmp 0x6546
movq %rax, %r14
leaq -0x270(%rbp), %rdi
callq 0x7820
jmp 0x6546
jmp 0x651d
movq %rax, %r14
movq -0x60(%rbp), %rdi
cmpq %rbx, %rdi
je 0x652e
callq 0x21e0
leaq -0x470(%rbp), %rdi
callq 0x22b0
leaq -0x270(%rbp), %rdi
callq 0x22b0
leaq -0x40(%rbp), %rdi
callq 0x7908
movq %r14, %rdi
callq 0x2360