// File: /workspace/github_cpp_makefile_star2_O3/aalto-speech[P]ftk/src/StringSet.cc
// Function: StringSet::learn_map(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&)
void
StringSet::learn_map(const map<string, flt_type> &vocab)
{
    for (int i=0; i<256; i++) charmap[i] = 255;

    map<unsigned char, int> charcounts;
    for (auto it = vocab.begin(); it != vocab.end(); ++it) {
        for (const char &chr : it->first) charcounts[(unsigned char)chr]++;
    }

    vector<pair<unsigned char, int> > sorted_charcounts;
    for (auto it = charcounts.begin(); it != charcounts.end(); ++it) {
        pair<unsigned char, int> ccount = make_pair(it->first, it->second);
        sorted_charcounts.push_back(ccount);
    }
    sort(sorted_charcounts.begin(), sorted_charcounts.end(), rank_desc_sort);

    unsigned char idx = 0;
    character_count = charcounts.size();
    for (auto it = sorted_charcounts.begin(); it != sorted_charcounts.end(); ++it) {
        charmap[it->first] = idx;
        idx++;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rsi, %r14
movq %rdi, %r13
leaq 0x1c(%rdi), %rbx
movl $0x100, %edx            # imm = 0x100
movq %rbx, %rdi
movl $0xff, %esi
callq 0x41d0
leaq -0x90(%rbp), %rcx
movl $0x0, (%rcx)
xorl %eax, %eax
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
movq 0x18(%r14), %rax
addq $0x8, %r14
movq %r14, -0x60(%rbp)
cmpq %r14, %rax
je 0xc9cc
movq %r13, -0x50(%rbp)
movq %rbx, -0x58(%rbp)
leaq -0x98(%rbp), %r13
leaq -0x40(%rbp), %r14
movq %rax, -0x48(%rbp)
movq 0x28(%rax), %rbx
testq %rbx, %rbx
je 0xc8f2
movq -0x48(%rbp), %rax
movq 0x20(%rax), %r15
xorl %r12d, %r12d
movb (%r15,%r12), %al
movb %al, -0x40(%rbp)
movq %r13, %rdi
movq %r14, %rsi
callq 0xd3a0
incl (%rax)
incq %r12
cmpq %r12, %rbx
jne 0xc8d6
movq -0x48(%rbp), %rdi
callq 0x4410
cmpq -0x60(%rbp), %rax
jne 0xc8be
movq -0x80(%rbp), %r15
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
movq $0x0, -0x30(%rbp)
leaq -0x90(%rbp), %rax
cmpq %rax, %r15
movq -0x58(%rbp), %rbx
movq -0x50(%rbp), %r13
je 0xc9db
leaq -0x40(%rbp), %r14
leaq -0x68(%rbp), %r12
movzbl 0x20(%r15), %ecx
movl 0x24(%r15), %eax
shlq $0x20, %rax
orq %rcx, %rax
movq %rax, -0x68(%rbp)
movq -0x38(%rbp), %rsi
cmpq -0x30(%rbp), %rsi
je 0xc95c
movq %rax, (%rsi)
addq $0x8, -0x38(%rbp)
jmp 0xc967
movq %r14, %rdi
movq %r12, %rdx
callq 0xda4a
movq %r15, %rdi
callq 0x4280
movq %rax, %r15
leaq -0x90(%rbp), %rax
cmpq %rax, %r15
jne 0xc934
movq -0x40(%rbp), %r15
movq -0x38(%rbp), %r14
cmpq %r14, %r15
je 0xc9de
movq %r14, %rax
subq %r15, %rax
sarq $0x3, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
leaq 0x960(%rip), %rcx       # 0xd309
movq %r15, %rdi
movq %r14, %rsi
callq 0xdb86
leaq 0x94e(%rip), %rdx       # 0xd309
movq %r15, %rdi
movq %r14, %rsi
callq 0xdc59
movq -0x40(%rbp), %r15
jmp 0xc9de
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
movq $0x0, -0x30(%rbp)
xorl %r15d, %r15d
movl -0x70(%rbp), %eax
movl %eax, 0x11c(%r13)
movq -0x38(%rbp), %rax
cmpq %rax, %r15
je 0xca07
xorl %ecx, %ecx
movq %r15, %rdx
movzbl (%rdx), %esi
movb %cl, (%rbx,%rsi)
incb %cl
addq $0x8, %rdx
cmpq %rax, %rdx
jne 0xc9f6
testq %r15, %r15
je 0xca14
movq %r15, %rdi
callq 0x4350
leaq -0x98(%rbp), %rdi
callq 0x5e44
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xca31
movq %rax, %rbx
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0xca47
callq 0x4350
jmp 0xca47
movq %rax, %rbx
leaq -0x98(%rbp), %rdi
callq 0x5e44
movq %rbx, %rdi
callq 0x4650
nop