// File: /workspace/github_cpp_makefile_star2_O2/aalto-speech[P]ftk/util/Ngram.cc
// Function: Ngram::read_arpa_read_order(std::basic_ifstream<char, std::char_traits<char>>&, std::vector<Ngram::NgramInfo, std::allocator<Ngram::NgramInfo>>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, int, int&)
int
Ngram::read_arpa_read_order(ifstream &arpafile,
                            vector<NgramInfo> &order_ngrams,
                            string &line,
                            int curr_ngram_order,
                            int &linei)
{
    int ngrams_read = 0;

    while (line.length() > 0) {
        stringstream vals(line);

        NgramInfo ngram;
        vals >> ngram.prob;
        if (ngram.prob > 0.0)
            throw string("Invalid log probability");

        vector<string> curr_ngram_str;
        string tmp;
        for (int i=0; i<curr_ngram_order; i++) {
            if (vals.eof()) throw string("Invalid ARPA line");
            vals >> tmp;
            str::clean(tmp);
            curr_ngram_str.push_back(tmp);
        }
        if (curr_ngram_order == 1) {
            vocabulary.push_back(curr_ngram_str[0]);
            vocabulary_lookup[curr_ngram_str[0]] = vocabulary.size()-1;
        }

        vector<int> curr_ngram_words;
        for (auto sit = curr_ngram_str.begin(); sit != curr_ngram_str.end(); ++sit)
            curr_ngram_words.push_back(vocabulary_lookup[*sit]);
        ngram.ngram = curr_ngram_words;

        if (!vals.eof())
            vals >> ngram.backoff_prob;

        order_ngrams.push_back(ngram);
        _getline(arpafile, line, linei);
        ngrams_read++;
    }

    return ngrams_read;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x258, %rsp            # imm = 0x258
movq %r9, -0xa8(%rbp)
movq %rdx, -0xb0(%rbp)
movq %rsi, -0xa0(%rbp)
leaq 0x30(%rdi), %rax
movq %rax, -0x90(%rbp)
movq %rdi, -0x88(%rbp)
leaq 0x48(%rdi), %r12
movl $0x0, -0x2c(%rbp)
testl %r8d, %r8d
movl $0x0, %eax
movl %r8d, -0x30(%rbp)
cmovgl %r8d, %eax
movl %eax, -0x34(%rbp)
leaq -0x278(%rbp), %r14
leaq -0xf0(%rbp), %rbx
leaq -0xd0(%rbp), %r13
movq %rcx, -0x58(%rbp)
cmpq $0x0, 0x8(%rcx)
je 0x9b8e
movq %r14, %rdi
movq %rcx, %rsi
pushq $0x18
popq %rdx
callq 0x4520
xorps %xmm0, %xmm0
movaps %xmm0, -0x70(%rbp)
movaps %xmm0, -0x80(%rbp)
andq $0x0, -0x60(%rbp)
movq %r14, %rdi
leaq -0x68(%rbp), %rsi
callq 0x4240
movsd -0x68(%rbp), %xmm0
ucomisd 0x19a3e(%rip), %xmm0    # 0x23440
ja 0x9bdc
andq $0x0, -0x40(%rbp)
leaq -0xc0(%rbp), %rax
movq %rax, -0xd0(%rbp)
andq $0x0, -0xc8(%rbp)
xorpd %xmm0, %xmm0
movapd %xmm0, -0x50(%rbp)
movb $0x0, -0xc0(%rbp)
movl -0x34(%rbp), %r15d
subl $0x1, %r15d
jb 0x9a7e
movq -0x278(%rbp), %rax
movq -0x18(%rax), %rax
testb $0x2, -0x258(%rbp,%rax)
jne 0x9ba3
movq %r14, %rdi
movq %r13, %rsi
callq 0x43f0
movq %r13, %rdi
leaq 0x19ab9(%rip), %rsi     # 0x23524
callq 0xa01f
leaq -0x50(%rbp), %rdi
movq %r13, %rsi
callq 0x719e
jmp 0x9a37
movq -0x50(%rbp), %r15
cmpl $0x1, -0x30(%rbp)
jne 0x9ace
movq -0x90(%rbp), %rdi
movq %r15, %rsi
callq 0x719e
movq -0x88(%rbp), %rax
movq 0x30(%rax), %rcx
movq %rcx, -0x98(%rbp)
movq 0x38(%rax), %r15
movq -0x50(%rbp), %rsi
movq %r12, %rdi
callq 0x705c
subq -0x98(%rbp), %r15
shrq $0x5, %r15
decl %r15d
movl %r15d, (%rax)
movq -0x50(%rbp), %r15
xorpd %xmm0, %xmm0
movapd %xmm0, -0xf0(%rbp)
andq $0x0, -0xe0(%rbp)
cmpq -0x48(%rbp), %r15
je 0x9b04
movq %r12, %rdi
movq %r15, %rsi
callq 0x705c
movq %rbx, %rdi
movq %rax, %rsi
callq 0xa0ca
addq $0x20, %r15
jmp 0x9ae2
leaq -0x80(%rbp), %rdi
movq %rbx, %rsi
callq 0xa0f0
movq -0x278(%rbp), %rax
movq -0x18(%rax), %rax
testb $0x2, -0x258(%rbp,%rax)
jne 0x9b31
movq %r14, %rdi
leaq -0x60(%rbp), %rsi
callq 0x4240
movq -0xb0(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0xa1bc
movq -0xa0(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq -0xa8(%rbp), %rdx
callq 0x9294
incl -0x2c(%rbp)
movq %rbx, %rdi
callq 0xa2cc
movq %r13, %rdi
callq 0x46b8
leaq -0x50(%rbp), %rdi
callq 0x54b6
leaq -0x80(%rbp), %rdi
callq 0xa2cc
movq %r14, %rdi
callq 0x42b0
movq -0x58(%rbp), %rcx
jmp 0x99c0
movl -0x2c(%rbp), %eax
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x20
popq %rdi
callq 0x4190
movq %rax, %r14
leaq 0x1995d(%rip), %rsi     # 0x23512
leaq -0xf0(%rbp), %rdx
movq %rax, %rdi
callq 0x4140
leaq 0x2b18d(%rip), %rsi     # 0x34d58
movq 0x2b3ce(%rip), %rdx     # 0x34fa0
movq %r14, %rdi
callq 0x45c0
jmp 0x9c13
pushq $0x20
popq %rdi
callq 0x4190
movq %rax, %r14
leaq 0x1990c(%rip), %rsi     # 0x234fa
leaq -0xd0(%rbp), %rdx
movq %rax, %rdi
callq 0x4140
leaq 0x2b154(%rip), %rsi     # 0x34d58
movq 0x2b395(%rip), %rdx     # 0x34fa0
movq %r14, %rdi
callq 0x45c0
jmp 0x9c24
movq %rax, %rbx
movq %r14, %rdi
callq 0x4290
jmp 0x9c63
jmp 0x9c4b
movq %rax, %rbx
jmp 0x9c63
jmp 0x9c3a
jmp 0x9c4b
movq %rax, %rbx
movq %r14, %rdi
callq 0x4290
jmp 0x9c4e
movq %rax, %rbx
leaq -0xf0(%rbp), %rdi
callq 0xa2cc
jmp 0x9c4e
movq %rax, %rbx
leaq -0xd0(%rbp), %rdi
callq 0x46b8
leaq -0x50(%rbp), %rdi
callq 0x54b6
leaq -0x80(%rbp), %rdi
callq 0xa2cc
leaq -0x278(%rbp), %rdi
callq 0x42b0
movq %rbx, %rdi
callq 0x45f0