// File: aalto-speech[P]ftk/src/Bigrams.cc
// Function: Bigrams::remove_least_common(std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, double, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, double>>> const&, unsigned int, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, double, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, double>>>, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, double, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, double>>>>>>&, MultiStringFactorGraph&)
int
Bigrams::remove_least_common(const map<string, flt_type> &unigram_stats,
                             unsigned int num_removals,
                             transitions_t &transitions,
                             MultiStringFactorGraph &msfg)
{
    vector<pair<string, flt_type> > sorted_stats;
    Unigrams::sort_vocab(unigram_stats, sorted_stats, false);
    vector<string> to_remove;
    for (auto it = sorted_stats.begin(); it != sorted_stats.end(); ++it) {
        if (it->first.length() < 3) continue;
        to_remove.push_back(it->first);
        if (to_remove.size() >= num_removals) break;
    }

    remove_transitions(to_remove, transitions);

    for (unsigned int i=0; i<to_remove.size(); i++)
        msfg.remove_arcs(to_remove[i]);

    return to_remove.size();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
leaq -0x38(%rbp), %rdi
movq %rdi, -0x80(%rbp)
callq 0x587e0
movq -0x80(%rbp), %rsi
movq -0x8(%rbp), %rdi
xorl %edx, %edx
callq 0x55590
jmp 0x5ef68
leaq -0x60(%rbp), %rdi
callq 0xa160
leaq -0x38(%rbp), %rdi
callq 0x58a30
movq %rax, -0x68(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x58a60
movq %rax, -0x70(%rbp)
leaq -0x68(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x5ad80
testb $0x1, %al
jne 0x5ef9e
jmp 0x5f01c
leaq -0x68(%rbp), %rdi
callq 0x60b10
movq %rax, %rdi
callq 0x45e0
cmpq $0x3, %rax
jae 0x5efc8
jmp 0x5f00e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x5f0bb
leaq -0x68(%rbp), %rdi
callq 0x60b10
movq %rax, %rsi
leaq -0x60(%rbp), %rdi
callq 0xabb0
jmp 0x5efdf
leaq -0x60(%rbp), %rdi
callq 0x5f70
movl -0xc(%rbp), %ecx
cmpq %rcx, %rax
jb 0x5f00c
jmp 0x5f01c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x6970
jmp 0x5f0bb
jmp 0x5f00e
leaq -0x68(%rbp), %rdi
callq 0x5b5a0
jmp 0x5ef7e
movq -0x18(%rbp), %rsi
leaq -0x60(%rbp), %rdi
callq 0x5e820
jmp 0x5f02b
movl $0x0, -0x74(%rbp)
movl -0x74(%rbp), %eax
movq %rax, -0x88(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x5f70
movq %rax, %rcx
movq -0x88(%rbp), %rax
cmpq %rcx, %rax
jae 0x5f08b
movq -0x20(%rbp), %rax
movq %rax, -0x90(%rbp)
movl -0x74(%rbp), %eax
movl %eax, %esi
leaq -0x60(%rbp), %rdi
callq 0x5f90
movq -0x90(%rbp), %rdi
movq %rax, %rsi
callq 0x2e1c0
jmp 0x5f07e
jmp 0x5f080
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x5f032
leaq -0x60(%rbp), %rdi
callq 0x5f70
movl %eax, -0x94(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x6970
leaq -0x38(%rbp), %rdi
callq 0x58850
movl -0x94(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq
leaq -0x38(%rbp), %rdi
callq 0x58850
movq -0x40(%rbp), %rdi
callq 0x46e0
nopl (%rax)