// File: aalto-speech[P]ftk/src/Unigrams.cc
// Function: Unigrams::read_corpus(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>>>&, int&, bool)
int
Unigrams::read_corpus(string fname,
                      map<string, flt_type> &vocab,
                      int &maxlen,
                      bool utf8)
{
    ifstream vocabfile(fname);
    if (!vocabfile) return -1;

    string line;
    maxlen = -1;
    while (getline(vocabfile, line)) {
        line = str::cleaned(line);
        vector<string> words = str::split(line, " \t", true);
        for (auto wit = words.begin(); wit != words.end(); ++wit)
            vocab[*wit] += 1.0;
    }
    vocabfile.close();

    for (auto wit = vocab.begin(); wit != vocab.end(); ++wit)
        maxlen = max(maxlen, (int)get_factor_length(wit->first, utf8));

    return vocab.size();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x310, %rsp            # imm = 0x310
movl %ecx, %eax
movq %rsi, %rcx
movq %rdi, %rsi
movq %rsi, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
andb $0x1, %al
movb %al, -0x21(%rbp)
leaq -0x230(%rbp), %rdi
movl $0x8, %edx
callq 0x4640
movq -0x230(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x230(%rbp,%rax), %rdi
callq 0x41d0
movb %al, -0x2bd(%rbp)
jmp 0x54e55
movb -0x2bd(%rbp), %al
testb $0x1, %al
jne 0x54e61
jmp 0x54e8e
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x240(%rbp)
jmp 0x5512d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x238(%rbp)
movl %eax, -0x23c(%rbp)
jmp 0x55145
leaq -0x260(%rbp), %rdi
callq 0x4560
movq -0x20(%rbp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
leaq -0x230(%rbp), %rdi
leaq -0x260(%rbp), %rsi
callq 0x40b0
movq %rax, -0x2c8(%rbp)
jmp 0x54ec0
movq -0x2c8(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x44a0
movb %al, -0x2c9(%rbp)
jmp 0x54ede
movb -0x2c9(%rbp), %al
testb $0x1, %al
jne 0x54eed
jmp 0x5503e
leaq 0x11600(%rip), %rdx     # 0x664f4
leaq -0x280(%rbp), %rdi
leaq -0x260(%rbp), %rsi
callq 0x58710
jmp 0x54f09
leaq -0x260(%rbp), %rdi
movq %rdi, -0x2d8(%rbp)
leaq -0x280(%rbp), %rsi
movq %rsi, -0x2e0(%rbp)
callq 0x4480
movq -0x2e0(%rbp), %rdi
callq 0x4828
movq -0x2d8(%rbp), %rsi
leaq 0x1132c(%rip), %rdx     # 0x66270
leaq -0x298(%rbp), %rdi
movl $0x1, %ecx
xorl %r8d, %r8d
callq 0xa1e0
jmp 0x54f5a
leaq -0x298(%rbp), %rdi
callq 0xb2f0
movq %rax, -0x2a0(%rbp)
leaq -0x298(%rbp), %rdi
callq 0xb320
movq %rax, -0x2a8(%rbp)
leaq -0x2a0(%rbp), %rdi
leaq -0x2a8(%rbp), %rsi
callq 0x11960
testb $0x1, %al
jne 0x54f9c
jmp 0x5502d
movq -0x18(%rbp), %rax
movq %rax, -0x2f0(%rbp)
leaq -0x2a0(%rbp), %rdi
callq 0x119d0
movq -0x2f0(%rbp), %rdi
movq %rax, %rsi
callq 0x47db0
movq %rax, -0x2e8(%rbp)
jmp 0x54fcb
movq -0x2e8(%rbp), %rax
movsd 0x117a6(%rip), %xmm0    # 0x66780
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
leaq -0x2a0(%rbp), %rdi
callq 0x117f0
jmp 0x54f6d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x238(%rbp)
movl %eax, -0x23c(%rbp)
jmp 0x5511f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x238(%rbp)
movl %eax, -0x23c(%rbp)
leaq -0x298(%rbp), %rdi
callq 0x6970
jmp 0x5511f
leaq -0x298(%rbp), %rdi
callq 0x6970
jmp 0x54ea4
leaq -0x230(%rbp), %rdi
callq 0x40c0
jmp 0x5504c
movq -0x18(%rbp), %rdi
callq 0x58790
movq %rax, -0x2b0(%rbp)
movq -0x18(%rbp), %rdi
callq 0x48c90
movq %rax, -0x2b8(%rbp)
leaq -0x2b0(%rbp), %rdi
leaq -0x2b8(%rbp), %rsi
callq 0x48c30
testb $0x1, %al
jne 0x55085
jmp 0x550fb
movq -0x20(%rbp), %rax
movq %rax, -0x300(%rbp)
leaq -0x2b0(%rbp), %rdi
callq 0x587c0
movq %rax, %rdi
movzbl -0x21(%rbp), %esi
andl $0x1, %esi
callq 0x54dc0
movl %eax, -0x2f4(%rbp)
jmp 0x550b3
movq -0x300(%rbp), %rdi
movl -0x2f4(%rbp), %eax
movl %eax, -0x2bc(%rbp)
leaq -0x2bc(%rbp), %rsi
callq 0x586d0
movq %rax, -0x308(%rbp)
jmp 0x550db
movq -0x308(%rbp), %rax
movl (%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
leaq -0x2b0(%rbp), %rdi
callq 0x4bba0
jmp 0x5505c
movq -0x18(%rbp), %rdi
callq 0x5fd0
movl %eax, -0x4(%rbp)
movl $0x1, -0x240(%rbp)
leaq -0x260(%rbp), %rdi
callq 0x4828
jmp 0x5512d
leaq -0x260(%rbp), %rdi
callq 0x4828
jmp 0x55145
leaq -0x230(%rbp), %rdi
callq 0x4100
movl -0x4(%rbp), %eax
addq $0x310, %rsp            # imm = 0x310
popq %rbp
retq
leaq -0x230(%rbp), %rdi
callq 0x4100
movq -0x238(%rbp), %rdi
callq 0x46e0
nopl (%rax)