// File: /workspace/github_cpp_makefile_star2_O2/ekg[P]fastahack/Fasta.cpp
// Function: FastaIndex::readIndexFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void FastaIndex::readIndexFile(string fname) {
    string line;
    long long linenum = 0;
    indexFile.open(fname.c_str(), ifstream::in);
    if (indexFile.is_open()) {
        while (getline (indexFile, line)) {
            ++linenum;
            // the fai format defined in samtools is tab-delimited, every line being:
            // fai->name[i], (int)x.len, (long long)x.offset, (int)x.line_blen, (int)x.line_len
            vector<string> fields = split(line, '\t');
            if (fields.size() == 5) {  // if we don't get enough fields then there is a problem with the file
                // note that fields[0] is the sequence name
                char* end;
                string name = split(fields[0], " \t").at(0);  // key by first token of name
                sequenceNames.push_back(name);
                this->insert(make_pair(name, FastaIndexEntry(fields[0], atoi(fields[1].c_str()),
                                                    strtoll(fields[2].c_str(), &end, 10),
                                                    atoi(fields[3].c_str()),
                                                    atoi(fields[4].c_str()))));
            } else {
                cerr << "Warning: malformed fasta index file " << fname << 
                    "does not have enough fields @ line " << linenum << endl;
                cerr << line << endl;
                exit(1);
            }
        }
    } else {
        cerr << "could not open index file " << fname << endl;
        exit(1);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movq %rsi, %rbx
leaq 0x60(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movq %rdi, %r13
movb $0x0, (%rax)
addq $0x78, %rdi
movq (%rsi), %rsi
pushq $0x8
popq %rdx
movq %rdi, 0x40(%rsp)
callq 0x3180
movq %rbx, 0x10(%rsp)
leaq 0xf0(%r13), %rdi
callq 0x30a0
testb %al, %al
je 0x3a5e
leaq 0x30(%r13), %rax
movq %rax, 0x38(%rsp)
pushq $0x1
popq %rbx
leaq 0x50(%rsp), %r14
leaq 0x18(%rsp), %r15
leaq 0xf0(%rsp), %rbp
leaq 0x90(%rsp), %r12
movq %r13, 0x30(%rsp)
movq 0x40(%rsp), %rdi
movq %r14, %rsi
callq 0x3080
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x39e5
movq %r15, %rdi
movq %r14, %rsi
pushq $0x9
popq %rdx
callq 0x6ccd
movq 0x18(%rsp), %r14
movq 0x20(%rsp), %rax
subq %r14, %rax
cmpq $0xa0, %rax
jne 0x3a01
movq %rbp, %rdi
leaq 0x476a(%rip), %rsi      # 0x8004
leaq 0xf(%rsp), %rdx
callq 0x492e
movq %r12, %rdi
movq %r14, %rsi
movq %rbp, %rdx
callq 0x6dbd
movq %r12, %rdi
xorl %esi, %esi
callq 0x48ea
leaq 0xc8(%rsp), %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x3330
movq %r12, %r15
movq %r12, %rdi
callq 0x490c
movq %rbp, %rdi
callq 0x3120
movq 0x38(%rsp), %rdi
movq %r14, %rsi
callq 0x496a
movq %rbx, 0x48(%rsp)
movq 0x18(%rsp), %rsi
leaq 0x70(%rsp), %rdi
callq 0x3330
movq 0x18(%rsp), %rbx
movq 0x20(%rbx), %rdi
callq 0x33b0
movl %eax, %ebp
movq 0x40(%rbx), %rdi
leaq 0xe8(%rsp), %rsi
pushq $0xa
popq %rdx
callq 0x3060
movq %rax, %r13
movq 0x18(%rsp), %rbx
movq 0x60(%rbx), %rdi
callq 0x33b0
movl %eax, %r14d
movq 0x80(%rbx), %rdi
callq 0x33b0
movl %eax, %ebx
movq %r15, %rdi
leaq 0x70(%rsp), %rsi
callq 0x3330
movl %ebp, 0xb0(%rsp)
movq %r13, 0xb8(%rsp)
movl %r14d, 0xc0(%rsp)
movl %ebx, 0xc4(%rsp)
leaq 0xf0(%rsp), %rbp
movq %rbp, %rdi
leaq 0xc8(%rsp), %rsi
movq %r15, %rdx
callq 0x4b9e
movq %r15, %r12
movq 0x30(%rsp), %rdi
movq %rbp, %rsi
callq 0x4ebe
movq 0x48(%rsp), %rbx
leaq 0x50(%rsp), %r14
leaq 0x18(%rsp), %r15
movq %rbp, %rdi
callq 0x4996
movq %r12, %rdi
callq 0x3120
leaq 0x70(%rsp), %rdi
callq 0x3120
leaq 0xc8(%rsp), %rdi
callq 0x3120
movq %r15, %rdi
callq 0x490c
incq %rbx
jmp 0x384a
leaq 0x50(%rsp), %rdi
callq 0x3120
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x85e8(%rip), %rdi      # 0xbff0
leaq 0x45f8(%rip), %rsi      # 0x8007
callq 0x3250
movq %rax, %rdi
movq 0x10(%rsp), %rsi
callq 0x3220
leaq 0x4604(%rip), %rsi      # 0x802c
movq %rax, %rdi
callq 0x3250
movq %rax, %rdi
movq %rbx, %rsi
callq 0x30f0
movq %rax, %rdi
callq 0x3130
movq 0x85a6(%rip), %rdi      # 0xbff0
leaq 0x50(%rsp), %rsi
callq 0x3220
movq %rax, %rdi
callq 0x3130
jmp 0x3a86
movq 0x858b(%rip), %rdi      # 0xbff0
leaq 0x45e4(%rip), %rsi      # 0x8050
callq 0x3250
movq 0x10(%rsp), %rsi
movq %rax, %rdi
callq 0x3220
movq %rax, %rdi
callq 0x3130
pushq $0x1
popq %rdi
callq 0x32f0
jmp 0x3ae0
jmp 0x3a92
movq %rax, %rbx
jmp 0x3b02
jmp 0x3ae0
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
callq 0x4996
jmp 0x3aae
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x3120
jmp 0x3ac2
jmp 0x3ad3
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x3120
jmp 0x3ad6
movq %rax, %rbx
jmp 0x3af5
movq %rax, %rbx
leaq 0xc8(%rsp), %rdi
jmp 0x3afd
movq %rax, %rbx
jmp 0x3b0c
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x490c
leaq 0xf0(%rsp), %rdi
callq 0x3120
leaq 0x18(%rsp), %rdi
callq 0x490c
leaq 0x50(%rsp), %rdi
callq 0x3120
movq %rbx, %rdi
callq 0x3430