// File: /workspace/github_cpp_makefile_star2_O3/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 0xaca9
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 0x1baab(%rip), %xmm0    # 0x264b0
ja 0xad1f
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)
movl $0x0, %r13d
cmpl $0x0, -0x30(%rbp)
jle 0xab7a
xorl %ebx, %ebx
movq -0x280(%rbp), %rax
movq -0x18(%rax), %rax
testb $0x2, -0x260(%rbp,%rax)
jne 0xacdd
movq %r15, %rdi
movq %r12, %rsi
callq 0x4450
movl %ebx, -0x34(%rbp)
movq -0x58(%rbp), %r15
movq -0x50(%rbp), %r13
movl %r13d, %ebx
movl %r13d, %r14d
sarl $0x1f, %r14d
andl %r13d, %r14d
leal 0x1(%r13), %r12d
testl %ebx, %ebx
jle 0xaaa4
movsbl -0x1(%r15,%rbx), %esi
decq %rbx
movl $0x4, %edx
leaq 0x1baff(%rip), %rdi     # 0x26594
callq 0x43d0
decl %r12d
testq %rax, %rax
jne 0xaa7c
jmp 0xaaa7
movl %r14d, %r12d
movslq %r12d, %rdx
cmpq %rdx, %r13
jb 0xacc5
movq %rdx, -0x50(%rbp)
movb $0x0, (%r15,%rdx)
movq -0x50(%rbp), %rax
testl %eax, %eax
jle 0xab02
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 0x1baac(%rip), %rdi     # 0x26594
callq 0x43d0
testq %rax, %rax
je 0xaafd
incq %r14
cmpq %r14, %r12
jne 0xaad7
movq %rbx, %r14
movl %r14d, %edx
jmp 0xab04
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 0x7f60
incl %ebx
cmpl -0x30(%rbp), %ebx
jne 0xaa3c
movq -0x70(%rbp), %r13
cmpl $0x1, -0x30(%rbp)
jne 0xab7a
movq -0xe0(%rbp), %rdi
movq %r13, %rsi
callq 0x7f60
movq -0xd8(%rbp), %rax
movq 0x30(%rax), %r14
movq 0x38(%rax), %rbx
movq -0x70(%rbp), %rsi
movq -0xa0(%rbp), %rdi
callq 0x7dac
subq %r14, %rbx
shrq $0x5, %rbx
decl %ebx
movl %ebx, (%rax)
movq -0x70(%rbp), %r13
xorpd %xmm0, %xmm0
movapd %xmm0, -0x90(%rbp)
movq $0x0, -0x80(%rbp)
cmpq -0x68(%rbp), %r13
je 0xabd6
movq -0xa0(%rbp), %rdi
movq %r13, %rsi
callq 0x7dac
movq -0x88(%rbp), %rsi
cmpq -0x80(%rbp), %rsi
je 0xabc1
movl (%rax), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, -0x88(%rbp)
jmp 0xabd0
leaq -0x90(%rbp), %rdi
movq %rax, %rdx
callq 0xc43a
addq $0x20, %r13
jmp 0xab8e
leaq -0xd0(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0xb216
movq -0x280(%rbp), %rax
movq -0x18(%rax), %rax
testb $0x2, -0x260(%rbp,%rax)
jne 0xac0d
movq %r15, %rdi
leaq -0xb0(%rbp), %rsi
callq 0x4240
movq -0xf8(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0xb2fc
movq -0xe8(%rbp), %rdi
movq -0x98(%rbp), %rsi
movq -0xf0(%rbp), %rdx
callq 0xa051
movq -0x90(%rbp), %rdi
testq %rdi, %rdi
je 0xac4b
callq 0x4350
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0xac5d
callq 0x4350
leaq -0x70(%rbp), %rdi
callq 0x5d4e
movq -0xd0(%rbp), %rdi
testq %rdi, %rdi
je 0xac77
callq 0x4350
incl -0x2c(%rbp)
movq %r15, %rdi
movq 0x2930c(%rip), %rsi     # 0x33f90
callq 0x42c0
leaq -0x200(%rbp), %rdi
callq 0x4110
movq -0x98(%rbp), %rcx
cmpq $0x0, 0x8(%rcx)
jne 0xa9ba
jmp 0xacb0
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 0x1b757(%rip), %rdi     # 0x26423
leaq 0x1b73c(%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)
leaq 0x1b88a(%rip), %rsi     # 0x26582
leaq 0x1b894(%rip), %rdx     # 0x26593
movq %r14, %rdi
callq 0x5fac
leaq 0x29042(%rip), %rsi     # 0x33d50
movq 0x2928b(%rip), %rdx     # 0x33fa0
movq %r14, %rdi
callq 0x4610
jmp 0xad5f
movl $0x20, %edi
callq 0x4190
movq %rax, %r14
addq $0x10, %rax
movq %rax, (%r14)
leaq 0x1b830(%rip), %rsi     # 0x2656a
leaq 0x1b840(%rip), %rdx     # 0x26581
movq %r14, %rdi
callq 0x5fac
leaq 0x29000(%rip), %rsi     # 0x33d50
movq 0x29249(%rip), %rdx     # 0x33fa0
movq %r14, %rdi
callq 0x4610
jmp 0xad70
movq %rax, %rbx
movq %r14, %rdi
callq 0x42b0
jmp 0xadbc
jmp 0xad9e
movq %rax, %rbx
jmp 0xadbc
jmp 0xad88
jmp 0xad9e
movq %rax, %rbx
movq %r14, %rdi
callq 0x42b0
jmp 0xada1
jmp 0xad9e
movq %rax, %rbx
movq -0x90(%rbp), %rdi
testq %rdi, %rdi
je 0xada1
callq 0x4350
jmp 0xada1
movq %rax, %rbx
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0xadb3
callq 0x4350
leaq -0x70(%rbp), %rdi
callq 0x5d4e
movq -0xd0(%rbp), %rdi
testq %rdi, %rdi
je 0xadcd
callq 0x4350
movq 0x291bc(%rip), %rsi     # 0x33f90
leaq -0x280(%rbp), %rdi
callq 0x42c0
leaq -0x200(%rbp), %rdi
callq 0x4110
movq %rbx, %rdi
callq 0x4650