// File: 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
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xf0(%rbp)
movl $0x0, -0x14(%rbp)
cmpl $0x100, -0x14(%rbp)     # imm = 0x100
jge 0x19fa9
movq -0xf0(%rbp), %rax
movslq -0x14(%rbp), %rcx
movb $-0x1, 0x1c(%rax,%rcx)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x19f85
leaq -0x48(%rbp), %rdi
callq 0xa120
movq -0x10(%rbp), %rdi
callq 0x1b450
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1b480
movq %rax, -0x58(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x1b290
testb $0x1, %al
jne 0x19fe2
jmp 0x1a088
leaq -0x50(%rbp), %rdi
callq 0x1b2f0
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rdi
callq 0x43b0
movq %rax, -0x68(%rbp)
movq -0x60(%rbp), %rdi
callq 0x4770
movq %rax, -0x70(%rbp)
leaq -0x68(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x1b8b0
testb $0x1, %al
jne 0x1a01c
jmp 0x1a078
leaq -0x68(%rbp), %rdi
callq 0x1b8f0
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movb (%rax), %al
movb %al, -0x79(%rbp)
leaq -0x48(%rbp), %rdi
leaq -0x79(%rbp), %rsi
callq 0x1b910
movq %rax, -0xf8(%rbp)
jmp 0x1a048
movq -0xf8(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
leaq -0x68(%rbp), %rdi
callq 0x1b9f0
jmp 0x1a009
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x1a27c
jmp 0x1a07a
leaq -0x50(%rbp), %rdi
callq 0x1b320
jmp 0x19fbf
leaq -0xa8(%rbp), %rdi
callq 0x1ba10
leaq -0x48(%rbp), %rdi
callq 0x1ba30
movq %rax, -0xb0(%rbp)
leaq -0x48(%rbp), %rdi
callq 0xa5c0
movq %rax, -0xb8(%rbp)
leaq -0xb0(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0xa560
testb $0x1, %al
jne 0x1a0d0
jmp 0x1a16b
leaq -0xb0(%rbp), %rdi
movq %rdi, -0x110(%rbp)
callq 0xaa80
movq -0x110(%rbp), %rdi
movq %rax, -0x108(%rbp)
callq 0xaa80
movq -0x108(%rbp), %rdi
movq %rax, %rsi
addq $0x4, %rsi
callq 0x1ba60
movq %rax, -0x100(%rbp)
jmp 0x1a112
movq -0x100(%rbp), %rax
movq %rax, -0xc0(%rbp)
leaq -0xa8(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x1ba90
jmp 0x1a135
jmp 0x1a137
leaq -0xb0(%rbp), %rdi
callq 0xe220
jmp 0x1a0a4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x1bc50
jmp 0x1a27c
leaq -0xa8(%rbp), %rdi
movq %rdi, -0x118(%rbp)
callq 0x1bb50
movq -0x118(%rbp), %rdi
movq %rax, -0xc8(%rbp)
callq 0x1bb80
movq %rax, -0xd0(%rbp)
movq -0xc8(%rbp), %rdi
movq -0xd0(%rbp), %rsi
leaq 0xf83(%rip), %rdx       # 0x1b130
callq 0x1bb00
jmp 0x1a1b4
movb $0x0, -0xd1(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x1bbb0
movq %rax, %rcx
movq -0xf0(%rbp), %rax
movl %ecx, 0x11c(%rax)
leaq -0xa8(%rbp), %rdi
callq 0x1bb50
movq %rax, -0xe0(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x1bb80
movq %rax, -0xe8(%rbp)
leaq -0xe0(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x1bbd0
testb $0x1, %al
jne 0x1a213
jmp 0x1a25e
movb -0xd1(%rbp), %al
movb %al, -0x119(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x1bc10
movb -0x119(%rbp), %dl
movq %rax, %rcx
movq -0xf0(%rbp), %rax
movzbl (%rcx), %ecx
movb %dl, 0x1c(%rax,%rcx)
movb -0xd1(%rbp), %al
addb $0x1, %al
movb %al, -0xd1(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x1bc30
jmp 0x1a1e7
leaq -0xa8(%rbp), %rdi
callq 0x1bc50
leaq -0x48(%rbp), %rdi
callq 0x69f0
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
leaq -0x48(%rbp), %rdi
callq 0x69f0
movq -0x88(%rbp), %rdi
callq 0x46e0
nopw %cs:(%rax,%rax)