// File: aalto-speech[P]ftk/src/Unigrams.cc
// Function: Unigrams::resegment_words(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&, StringSet 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::set<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>)
flt_type
Unigrams::resegment_words(const map<string, flt_type> &words,
                          const StringSet &vocab,
                          map<string, flt_type> &new_freqs,
                          set<string> special_words)
{
    new_freqs.clear();
    flt_type ll = 0.0;

    for (auto worditer = words.cbegin(); worditer != words.cend(); ++worditer) {

        // Special symbols like 
 
 etc. which should not be segmented
        if (special_words.size() > 0 && special_words.find(worditer->first) != special_words.end()) {
            new_freqs[worditer->first] += worditer->second;
            continue;
        }

        map<string, flt_type> stats;
        flt_type curr_ll = worditer->second * segf(vocab, worditer->first, stats, this->utf8);

        if (stats.size() == 0) {
            cerr << "warning, no segmentation for word: " << worditer->first << endl;
            continue;
        }

        ll += curr_ll;

        // Update statistics
        for (auto it = stats.begin(); it != stats.end(); ++it)
            new_freqs[it->first] += worditer->second * it->second;
    }

    return ll;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %r8, -0xb8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x20(%rbp), %rdi
callq 0x47d90
xorps %xmm0, %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1b260
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1b2c0
movq %rax, -0x40(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x1b290
testb $0x1, %al
jne 0x55e72
jmp 0x5617e
movq -0xb8(%rbp), %rdi
callq 0x58af0
movq %rax, %rcx
xorl %eax, %eax
cmpq $0x0, %rcx
movb %al, -0xb9(%rbp)
jbe 0x55ece
leaq -0x38(%rbp), %rdi
callq 0x1b2f0
movq -0xb8(%rbp), %rdi
movq %rax, %rsi
callq 0x58b10
movq -0xb8(%rbp), %rdi
movq %rax, -0x48(%rbp)
callq 0x23610
movq %rax, -0x50(%rbp)
leaq -0x48(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x235b0
movb %al, -0xb9(%rbp)
movb -0xb9(%rbp), %al
testb $0x1, %al
jne 0x55eda
jmp 0x55f28
leaq -0x38(%rbp), %rdi
callq 0x1b2f0
movsd 0x20(%rax), %xmm0
movsd %xmm0, -0xc8(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0xd0(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x1b2f0
movq -0xd0(%rbp), %rdi
movq %rax, %rsi
callq 0x47db0
movsd -0xc8(%rbp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
jmp 0x56170
leaq -0x80(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0x5fb0
leaq -0x38(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0x1b2f0
movq -0x100(%rbp), %rdi
movq %rax, %rcx
movq -0xb0(%rbp), %rax
movsd 0x20(%rcx), %xmm0
movsd %xmm0, -0xf8(%rbp)
movq (%rax), %rax
movq %rax, -0xe0(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0xf0(%rbp)
callq 0x1b2f0
movq -0xb0(%rbp), %rcx
movq -0xf0(%rbp), %rdi
movq -0xe8(%rbp), %rdx
movq %rax, %rsi
movq -0xe0(%rbp), %rax
movzbl 0x8(%rcx), %ecx
andl $0x1, %ecx
callq *%rax
movsd %xmm0, -0xd8(%rbp)
jmp 0x55fb2
movsd -0xd8(%rbp), %xmm1
movsd -0xf8(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x88(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x5fd0
cmpq $0x0, %rax
jne 0x56062
movq 0x3e000(%rip), %rdi     # 0x93fe8
leaq 0x10851(%rip), %rsi     # 0x66840
callq 0x43c0
movq %rax, -0x108(%rbp)
jmp 0x55ffd
leaq -0x38(%rbp), %rdi
callq 0x1b2f0
movq -0x108(%rbp), %rdi
movq %rax, %rsi
callq 0x4380
movq %rax, -0x110(%rbp)
jmp 0x5601e
movq -0x110(%rbp), %rdi
movq 0x3df6c(%rip), %rsi     # 0x93f98
callq 0x4400
jmp 0x56033
movl $0x4, -0x98(%rbp)
jmp 0x56157
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x6090
jmp 0x5618c
movsd -0x88(%rbp), %xmm0
addsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x58790
movq %rax, -0xa0(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x48c90
movq %rax, -0xa8(%rbp)
leaq -0xa0(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x48c30
testb $0x1, %al
jne 0x560b0
jmp 0x5614d
leaq -0x38(%rbp), %rdi
callq 0x1b2f0
movsd 0x20(%rax), %xmm0
movsd %xmm0, -0x138(%rbp)
leaq -0xa0(%rbp), %rdi
movq %rdi, -0x130(%rbp)
callq 0x587c0
movq -0x130(%rbp), %rdi
movsd 0x20(%rax), %xmm0
movsd %xmm0, -0x128(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x120(%rbp)
callq 0x587c0
movq -0x120(%rbp), %rdi
movq %rax, %rsi
callq 0x47db0
movq %rax, -0x118(%rbp)
jmp 0x56115
movq -0x118(%rbp), %rax
movsd -0x128(%rbp), %xmm2
movsd -0x138(%rbp), %xmm0
movsd (%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
leaq -0xa0(%rbp), %rdi
callq 0x4bba0
jmp 0x56084
movl $0x0, -0x98(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x6090
movl -0x98(%rbp), %eax
testl %eax, %eax
je 0x5616e
jmp 0x5616c
jmp 0x56170
jmp 0x56170
leaq -0x38(%rbp), %rdi
callq 0x1b320
jmp 0x55e4f
movsd -0x30(%rbp), %xmm0
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
movq -0x90(%rbp), %rdi
callq 0x46e0
nopl (%rax,%rax)