// File: aalto-speech[P]ftk/src/Bigrams.cc
// Function: Bigrams::iterate_kn(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&, MultiStringFactorGraph&, 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>>>>>>&, bool, double, unsigned int)
flt_type
Bigrams::iterate_kn(const map<string, flt_type> &words,
                    MultiStringFactorGraph &msfg,
                    transitions_t &transitions,
                    bool forward_backward,
                    flt_type D,
                    unsigned int iterations)
{
    flt_type lp=0.0;
    for (unsigned int i=0; i<iterations; i++) {
        map<string, flt_type> unigram_stats;
        transitions_t trans_stats;
        assign_scores(transitions, msfg);
        lp = collect_trans_stats(words, msfg, trans_stats, unigram_stats, forward_backward);
        kn_smooth(trans_stats, transitions, D);
    }
    return lp;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movb %cl, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
andb $0x1, %al
movb %al, -0x19(%rbp)
movsd %xmm0, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jae 0x5cf89
leaq -0x70(%rbp), %rdi
callq 0x5fb0
leaq -0xa0(%rbp), %rdi
callq 0x48ab0
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x44450
jmp 0x5cee6
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movzbl -0x19(%rbp), %r8d
andl $0x1, %r8d
leaq -0xa0(%rbp), %rdx
leaq -0x70(%rbp), %rcx
callq 0x5c930
movsd %xmm0, -0xb8(%rbp)
jmp 0x5cf11
movsd -0xb8(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x18(%rbp), %rsi
movsd -0x28(%rbp), %xmm0
leaq -0xa0(%rbp), %rdi
movsd 0x98e2(%rip), %xmm1     # 0x66818
callq 0x5cfb0
jmp 0x5cf3d
leaq -0xa0(%rbp), %rdi
callq 0x48ad0
leaq -0x70(%rbp), %rdi
callq 0x6090
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x5ceb6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x48ad0
leaq -0x70(%rbp), %rdi
callq 0x6090
jmp 0x5cf97
movsd -0x38(%rbp), %xmm0
addq $0xc0, %rsp
popq %rbp
retq
movq -0xa8(%rbp), %rdi
callq 0x46e0
nopw %cs:(%rax,%rax)