// File: aalto-speech[P]ftk/src/Bigrams.cc
// Function: Bigrams::iterate(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, unsigned int)
flt_type
Bigrams::iterate(const map<string, flt_type> &words,
                 MultiStringFactorGraph &msfg,
                 transitions_t &transitions,
                 bool forward_backward,
                 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);
        transitions.swap(trans_stats);
        Bigrams::freqs_to_logprobs(transitions);
    }
    return lp;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movb %cl, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
andb $0x1, %al
movb %al, -0x19(%rbp)
movl %r8d, -0x20(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x20(%rbp), %eax
jae 0x5c908
leaq -0x60(%rbp), %rdi
callq 0x5fb0
leaq -0x90(%rbp), %rdi
callq 0x48ab0
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x44450
jmp 0x5c861
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movzbl -0x19(%rbp), %r8d
andl $0x1, %r8d
leaq -0x90(%rbp), %rdx
leaq -0x60(%rbp), %rcx
callq 0x5c930
movsd %xmm0, -0xa8(%rbp)
jmp 0x5c88c
movsd -0xa8(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
movq -0x18(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x60720
movq -0x18(%rbp), %rdi
movsd 0x9f63(%rip), %xmm0     # 0x66818
callq 0x5cc20
jmp 0x5c8bc
leaq -0x90(%rbp), %rdi
callq 0x48ad0
leaq -0x60(%rbp), %rdi
callq 0x6090
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x5c831
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x48ad0
leaq -0x60(%rbp), %rdi
callq 0x6090
jmp 0x5c916
movsd -0x28(%rbp), %xmm0
addq $0xb0, %rsp
popq %rbp
retq
movq -0x98(%rbp), %rdi
callq 0x46e0
nopw %cs:(%rax,%rax)