// File: aalto-speech[P]ftk/src/Bigrams.cc
// Function: Bigrams::cutoff(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&, double, 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>>>>>>&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, FactorGraph*, 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, FactorGraph*>>>&)
int
Bigrams::cutoff(const map<string, flt_type> &unigram_stats,
                flt_type cutoff,
                transitions_t &transitions,
                map<string, FactorGraph*> &fg_words)
{
    vector<string> to_remove;
    for (auto it = unigram_stats.begin(); it != unigram_stats.end(); ++it)
        if (it->second < cutoff && it->first.length() > 2) to_remove.push_back(it->first);

    remove_transitions(to_remove, transitions);

    for (auto fgit = fg_words.begin(); fgit != fg_words.end(); ++fgit) {
        for (unsigned int i=0; i<to_remove.size(); i++) {
            size_t found = fgit->first.find(to_remove[i]);
            if (found != std::string::npos) fgit->second->remove_arcs(to_remove[i]);
        }
    }

    return to_remove.size();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movsd %xmm0, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
leaq -0x38(%rbp), %rdi
callq 0xa160
movq -0x8(%rbp), %rdi
callq 0x1b450
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
callq 0x1b480
movq %rax, -0x48(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x1b290
testb $0x1, %al
jne 0x5ea12
jmp 0x5ea85
leaq -0x40(%rbp), %rdi
callq 0x1b2f0
movsd 0x20(%rax), %xmm1
movsd -0x10(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x5ea75
leaq -0x40(%rbp), %rdi
callq 0x1b2f0
movq %rax, %rdi
callq 0x45e0
cmpq $0x2, %rax
jbe 0x5ea75
leaq -0x40(%rbp), %rdi
callq 0x1b2f0
movq %rax, %rsi
leaq -0x38(%rbp), %rdi
callq 0xabb0
jmp 0x5ea59
jmp 0x5ea75
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x6970
jmp 0x5eba3
jmp 0x5ea77
leaq -0x40(%rbp), %rdi
callq 0x1b320
jmp 0x5e9f2
movq -0x18(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0x5e820
jmp 0x5ea94
movq -0x20(%rbp), %rdi
callq 0x60840
movq %rax, -0x60(%rbp)
movq -0x20(%rbp), %rdi
callq 0x608a0
movq %rax, -0x68(%rbp)
leaq -0x60(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x60870
testb $0x1, %al
jne 0x5eac4
jmp 0x5eb7c
movl $0x0, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
movq %rax, -0x80(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x5f70
movq %rax, %rcx
movq -0x80(%rbp), %rax
cmpq %rcx, %rax
jae 0x5eb6c
leaq -0x60(%rbp), %rdi
callq 0x608d0
movq %rax, -0x88(%rbp)
movl -0x6c(%rbp), %eax
movl %eax, %esi
leaq -0x38(%rbp), %rdi
callq 0x5f90
movq -0x88(%rbp), %rdi
movq %rax, %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x4810
movq %rax, -0x78(%rbp)
cmpq $-0x1, -0x78(%rbp)
je 0x5eb5c
leaq -0x60(%rbp), %rdi
callq 0x608d0
movq 0x20(%rax), %rax
movq %rax, -0x90(%rbp)
movl -0x6c(%rbp), %eax
movl %eax, %esi
leaq -0x38(%rbp), %rdi
callq 0x5f90
movq -0x90(%rbp), %rdi
movq %rax, %rsi
callq 0x22ae0
jmp 0x5eb5a
jmp 0x5eb5c
jmp 0x5eb5e
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x5eacb
jmp 0x5eb6e
leaq -0x60(%rbp), %rdi
callq 0x60900
jmp 0x5eaa1
leaq -0x38(%rbp), %rdi
callq 0x5f70
movl %eax, -0x94(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x6970
movl -0x94(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0x46e0
nopl (%rax)