// File: /workspace/github_cpp_makefile_star2_O1/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, -0xf0(%rbp)
movl %r8d, -0x30(%rbp)
movq %rdx, -0xf8(%rbp)
movq %rsi, -0xe8(%rbp)
cmpq $0x0, 0x8(%rcx)
je 0xad1a
leaq 0x30(%rdi), %rax
movq %rax, -0xe0(%rbp)
movq %rdi, -0xd8(%rbp)
leaq 0x48(%rdi), %rax
movq %rax, -0xa0(%rbp)
leaq -0x280(%rbp), %r15
leaq -0x58(%rbp), %r12
movl $0x0, -0x2c(%rbp)
movq %rcx, -0x98(%rbp)
movq %r15, %rdi
movq %rcx, %rsi
movl $0x18, %edx
callq 0x4580
xorps %xmm0, %xmm0
movaps %xmm0, -0xc0(%rbp)
movaps %xmm0, -0xd0(%rbp)
movq $0x0, -0xb0(%rbp)
movq %r15, %rdi
leaq -0xb8(%rbp), %rsi
callq 0x4240
movsd -0xb8(%rbp), %xmm0
ucomisd 0x1ba31(%rip), %xmm0    # 0x264b0
ja 0xad96
xorpd %xmm0, %xmm0
movapd %xmm0, -0x70(%rbp)
xorl %ecx, %ecx
movq %rcx, -0x60(%rbp)
leaq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
movq %rcx, -0x50(%rbp)
movb $0x0, -0x48(%rbp)
cmpl $0x0, -0x30(%rbp)
jle 0xaba7
xorl %ebx, %ebx
movq -0x280(%rbp), %rax
movq -0x18(%rax), %rax
testb $0x2, -0x260(%rbp,%rax)
jne 0xad4e
movq %r15, %rdi
movq %r12, %rsi
callq 0x4450
movl %ebx, -0x34(%rbp)
movq -0x58(%rbp), %r14
movq -0x50(%rbp), %r13
movl %r13d, %ebx
movl %r13d, %r12d
sarl $0x1f, %r12d
andl %r13d, %r12d
leal 0x1(%r13), %r15d
testl %ebx, %ebx
jle 0xab18
movsbl -0x1(%r14,%rbx), %esi
decq %rbx
movl $0x4, %edx
leaq 0x1ba8b(%rip), %rdi     # 0x26594
callq 0x43d0
decl %r15d
testq %rax, %rax
jne 0xaaf0
jmp 0xab1b
movl %r12d, %r15d
movslq %r15d, %rdx
cmpq %rdx, %r13
jb 0xad36
movq %rdx, -0x50(%rbp)
movb $0x0, (%r14,%rdx)
movq -0x50(%rbp), %rax
testl %eax, %eax
jle 0xab76
movl %eax, %ebx
movq -0x58(%rbp), %r15
movl %ebx, %r12d
andl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
xorl %r14d, %r14d
movsbl (%r15,%r14), %esi
movl $0x4, %edx
leaq 0x1ba38(%rip), %rdi     # 0x26594
callq 0x43d0
testq %rax, %rax
je 0xab71
incq %r14
cmpq %r14, %r12
jne 0xab4b
movq %rbx, %r14
movl %r14d, %edx
jmp 0xab78
xorl %edx, %edx
leaq -0x280(%rbp), %r15
leaq -0x58(%rbp), %r12
movl -0x34(%rbp), %ebx
movq %r12, %rdi
xorl %esi, %esi
callq 0x40b0
leaq -0x70(%rbp), %rdi
movq %r12, %rsi
callq 0x7f8c
incl %ebx
cmpl -0x30(%rbp), %ebx
jne 0xaab0
cmpl $0x1, -0x30(%rbp)
jne 0xabe7
movq -0x70(%rbp), %rsi
movq -0xe0(%rbp), %rdi
callq 0x7f8c
movq -0xd8(%rbp), %rax
movq 0x30(%rax), %r14
movq 0x38(%rax), %rbx
movq -0x70(%rbp), %rsi
movq -0xa0(%rbp), %rdi
callq 0x7dde
subq %r14, %rbx
shrq $0x5, %rbx
decl %ebx
movl %ebx, (%rax)
xorpd %xmm0, %xmm0
movapd %xmm0, -0x90(%rbp)
movq $0x0, -0x80(%rbp)
movq -0x70(%rbp), %r13
cmpq -0x68(%rbp), %r13
je 0xac47
movq -0xa0(%rbp), %rdi
movq %r13, %rsi
callq 0x7dde
movq -0x88(%rbp), %rsi
cmpq -0x80(%rbp), %rsi
je 0xac32
movl (%rax), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, -0x88(%rbp)
jmp 0xac41
leaq -0x90(%rbp), %rdi
movq %rax, %rdx
callq 0xc4e2
addq $0x20, %r13
jmp 0xabff
leaq -0xd0(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0xb308
movq -0x280(%rbp), %rax
movq -0x18(%rax), %rax
testb $0x2, -0x260(%rbp,%rax)
jne 0xac7e
movq %r15, %rdi
leaq -0xb0(%rbp), %rsi
callq 0x4240
movq -0xf8(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0xb3e0
movq -0xe8(%rbp), %rdi
movq -0x98(%rbp), %rsi
movq -0xf0(%rbp), %rdx
callq 0xa0d2
movq -0x90(%rbp), %rdi
testq %rdi, %rdi
je 0xacbc
callq 0x4350
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0xacce
callq 0x4350
leaq -0x70(%rbp), %rdi
callq 0x5d54
movq -0xd0(%rbp), %rdi
testq %rdi, %rdi
je 0xace8
callq 0x4350
incl -0x2c(%rbp)
movq %r15, %rdi
movq 0x2929b(%rip), %rsi     # 0x33f90
callq 0x42c0
leaq -0x200(%rbp), %rdi
callq 0x4110
movq -0x98(%rbp), %rcx
cmpq $0x0, 0x8(%rcx)
jne 0xaa34
jmp 0xad21
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1b6e6(%rip), %rdi     # 0x26423
leaq 0x1b6cb(%rip), %rsi     # 0x2640f
movq %r13, %rcx
xorl %eax, %eax
callq 0x4530
movl $0x20, %edi
callq 0x4190
movq %rax, %r14
addq $0x10, %rax
movq %rax, (%r14)
movb $0x1, %r15b
leaq 0x1b816(%rip), %rsi     # 0x26582
leaq 0x1b820(%rip), %rdx     # 0x26593
movq %r14, %rdi
callq 0x5fa4
xorl %r15d, %r15d
leaq 0x28fcb(%rip), %rsi     # 0x33d50
movq 0x29214(%rip), %rdx     # 0x33fa0
movq %r14, %rdi
callq 0x4610
jmp 0xaddc
movl $0x20, %edi
callq 0x4190
movq %rax, %r14
addq $0x10, %rax
movq %rax, (%r14)
movb $0x1, %r15b
leaq 0x1b7b6(%rip), %rsi     # 0x2656a
leaq 0x1b7c6(%rip), %rdx     # 0x26581
movq %r14, %rdi
callq 0x5fa4
xorl %r15d, %r15d
leaq 0x28f83(%rip), %rsi     # 0x33d50
movq 0x291cc(%rip), %rdx     # 0x33fa0
movq %r14, %rdi
callq 0x4610
jmp 0xae21
movq %rax, %rbx
jmp 0xae3f
movq %rax, %rbx
testb %r15b, %r15b
je 0xae3f
movq %r14, %rdi
callq 0x42b0
jmp 0xae3f
jmp 0xae0b
movq %rax, %rbx
testb %r15b, %r15b
je 0xae24
movq %r14, %rdi
callq 0x42b0
jmp 0xae24
jmp 0xae21
movq %rax, %rbx
movq -0x90(%rbp), %rdi
testq %rdi, %rdi
je 0xae24
callq 0x4350
jmp 0xae24
movq %rax, %rbx
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0xae36
callq 0x4350
leaq -0x70(%rbp), %rdi
callq 0x5d54
movq -0xd0(%rbp), %rdi
testq %rdi, %rdi
je 0xae50
callq 0x4350
movq 0x29139(%rip), %rsi     # 0x33f90
leaq -0x280(%rbp), %rdi
callq 0x42c0
leaq -0x200(%rbp), %rdi
callq 0x4110
movq %rbx, %rdi
callq 0x4650
nop