// File: /workspace/github_cpp_makefile_star2_O2/IHorvalds[P]RomAna/./processing/analyze_poet.hpp
// Function: PoetAnalyzer::saveFrequencies()
void saveFrequencies() {
    std::string filename = "poets/local/frequency/" + poet + "_local_frequencies.txt";
    std::ofstream out(filename);
    
    // Parse all his/her poems
    processPoems();
    
    /** Save in the file "poet_words_frequencies.txt"
      The encoding is:
      On the first line of the file: [countPoems] [sizeOfEachPoem]
      word = [word] count = [number of poems the words appears in] [list of pair(absolute frequency, index of poem)]
    **/
    
    // Print the first 2 lines
    out << countPoems;
    for (auto e : sizeOfPoems)
        out << " " << e;
    out << "\n";
    
    // And the rest
    for (auto iter : wordToFreqs) {
      std::string word = iter.first;
      std::vector<std::pair<uint32_t, uint32_t>> freqs = iter.second;

      // Sort the frequencies
      std::sort(freqs.begin(), freqs.end(), [](auto& left, auto& right) {
        return (left.first < right.first);
      });

      // And print the file
      out << word << " " << freqs.size();
      for (auto elem : freqs)
        out << " " << elem.first << " " << elem.second; 
      out << "\n";
    }
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2a8, %rsp            # imm = 0x2A8
movq %rdi, %r14
leaq 0x10(%rdi), %rdx
leaq 0x3d52(%rip), %rsi      # 0xa5a5
leaq 0xa8(%rsp), %rbx
movq %rbx, %rdi
callq 0x6670
leaq 0x3d52(%rip), %rdx      # 0xa5bc
leaq 0x50(%rsp), %rdi
movq %rbx, %rsi
callq 0x67cf
leaq 0xa8(%rsp), %rdi
callq 0x3120
leaq 0xa8(%rsp), %rdi
leaq 0x50(%rsp), %rsi
pushq $0x10
popq %rdx
callq 0x34d0
movq %r14, %rdi
callq 0x74a0
movl (%r14), %esi
leaq 0xa8(%rsp), %rdi
callq 0x3190
movq 0x30(%r14), %r12
movq %r14, %rbp
movq 0x38(%r14), %r13
leaq 0x388a(%rip), %rbx      # 0xa14d
leaq 0xa8(%rsp), %r14
cmpq %r13, %r12
je 0x68f0
movl (%r12), %r15d
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3250
movq %rax, %rdi
movq %r15, %rsi
callq 0x3190
addq $0x4, %r12
jmp 0x68cb
leaq 0x3cdc(%rip), %rsi      # 0xa5d3
leaq 0xa8(%rsp), %rdi
callq 0x3250
movq %rbp, %r15
movq 0x60(%rbp), %r12
addq $0x50, %r15
leaq 0x70(%rsp), %r13
leaq 0xa8(%rsp), %r14
leaq 0x382a(%rip), %rbx      # 0xa14d
movq %r15, 0x20(%rsp)
cmpq %r15, %r12
je 0x6a2f
leaq 0x20(%r12), %rsi
movq %r13, %rdi
callq 0x7978
leaq 0x30(%rsp), %rdi
movq %r13, %rsi
callq 0x3350
leaq 0x8(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x79b2
movq %r12, 0x28(%rsp)
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x84a8
movq %r14, %rdi
leaq 0x30(%rsp), %rsi
callq 0x3230
movq %rax, %rdi
movq %rbx, %rsi
callq 0x3250
movq 0x10(%rsp), %rsi
subq 0x8(%rsp), %rsi
sarq $0x3, %rsi
movq %rax, %rdi
callq 0x3190
movq 0x8(%rsp), %r13
movq 0x10(%rsp), %r15
cmpq %r15, %r13
je 0x69e8
movl (%r13), %r12d
movl 0x4(%r13), %ebp
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3250
movq %rax, %rdi
movq %r12, %rsi
callq 0x3190
movq %rax, %rdi
movq %rbx, %rsi
callq 0x3250
movq %rax, %rdi
movq %rbp, %rsi
callq 0x3190
addq $0x8, %r13
jmp 0x69a9
movq %r14, %rdi
leaq 0x3be1(%rip), %rsi      # 0xa5d3
callq 0x3250
leaq 0x8(%rsp), %rdi
callq 0x746c
leaq 0x30(%rsp), %rdi
callq 0x3120
leaq 0x70(%rsp), %r13
movq %r13, %rdi
callq 0x7456
movq 0x28(%rsp), %rdi
callq 0x31a0
movq %rax, %r12
movq 0x20(%rsp), %r15
jmp 0x6928
leaq 0xa8(%rsp), %rdi
callq 0x33a0
leaq 0x50(%rsp), %rdi
callq 0x3120
addq $0x2a8, %rsp            # imm = 0x2A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x6aad
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
jmp 0x6ab2
jmp 0x6a78
jmp 0x6a78
movq %rax, %rbx
jmp 0x6a96
movq %rax, %rbx
jmp 0x6a8c
movq %rax, %rbx
jmp 0x6aa0
jmp 0x6a7f
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x746c
leaq 0x30(%rsp), %rdi
callq 0x3120
leaq 0x70(%rsp), %rdi
callq 0x7456
leaq 0xa8(%rsp), %rdi
callq 0x33a0
leaq 0x50(%rsp), %rdi
callq 0x3120
movq %rbx, %rdi
callq 0x3480
nop