// File: /workspace/github_cpp_makefile_star2_O1/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 $0x138, %rsp            # imm = 0x138
movq %rsi, %rbx
movq %rdi, %r15
leaq 0x60(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x78(%rdi), %r14
movq (%rsi), %rsi
movq %r14, %rdi
movl $0x8, %edx
callq 0x31b0
movq %r14, 0xd0(%rsp)
movq %rbx, (%rsp)
leaq 0xf0(%r15), %rdi
callq 0x30a0
testb %al, %al
je 0x3d19
leaq 0xe8(%rsp), %r13
leaq 0x40(%rsp), %r14
movq %r15, 0xc0(%rsp)
leaq 0x30(%r15), %rax
movq %rax, 0xc8(%rsp)
leaq 0x20(%rsp), %rbp
movl $0x1, %ebx
leaq 0xd8(%rsp), %r12
movq 0xd0(%rsp), %r15
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3290
movsbl %al, %edx
movq %r15, %rdi
leaq 0x50(%rsp), %rsi
callq 0x34c0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x3c5e
movq %rbx, 0x8(%rsp)
leaq 0x70(%rsp), %rdi
leaq 0x50(%rsp), %rsi
movl $0x9, %edx
callq 0x886a
movq 0x70(%rsp), %rbx
movq 0x78(%rsp), %rax
subq %rbx, %rax
cmpq $0xa0, %rax
leaq 0x88(%rsp), %r15
jne 0x3c8c
movq %r13, 0xd8(%rsp)
movq %r12, %rdi
leaq 0x55ba(%rip), %rsi      # 0x9004
leaq 0x55b5(%rip), %rdx      # 0x9006
callq 0x563c
movq %r15, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x8990
movq 0x88(%rsp), %rax
cmpq %rax, 0x90(%rsp)
je 0x3d07
movq %r14, 0x30(%rsp)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x30(%rsp), %rdi
callq 0x55ac
movq %r15, %rdi
callq 0x521e
movq 0xd8(%rsp), %rdi
cmpq %r13, %rdi
je 0x3ab8
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x32d0
movq 0xc8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x527a
movq 0x70(%rsp), %rax
movq %rbp, 0x10(%rsp)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x10(%rsp), %rdi
callq 0x55ac
movq 0x70(%rsp), %rbx
movq 0x20(%rbx), %rdi
callq 0x3400
movl %eax, %ebp
movq 0x40(%rbx), %rdi
leaq 0x130(%rsp), %rsi
movl $0xa, %edx
callq 0x3070
movq %rax, %rbx
movq 0x70(%rsp), %r13
movq 0x60(%r13), %rdi
callq 0x3400
movl %eax, %r14d
movq 0x80(%r13), %rdi
callq 0x3400
movl %eax, %r13d
leaq 0x98(%rsp), %rax
movq %rax, 0x88(%rsp)
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
addq %rsi, %rdx
leaq 0x88(%rsp), %r15
movq %r15, %rdi
callq 0x55ac
movl %ebp, 0xa8(%rsp)
movq %rbx, 0xb0(%rsp)
movl %r14d, 0xb8(%rsp)
movl %r13d, 0xbc(%rsp)
movq %r12, %rbx
movq %r12, %rdi
leaq 0x30(%rsp), %rsi
movq %r15, %rdx
callq 0x5538
movq 0xc0(%rsp), %rdi
movq %rbx, %rsi
leaq 0x40(%rsp), %r14
leaq 0x20(%rsp), %rbp
callq 0x5910
leaq 0xe8(%rsp), %r13
movq 0x8(%rsp), %rbx
movq 0xf8(%rsp), %rdi
leaq 0x108(%rsp), %rax
cmpq %rax, %rdi
je 0x3bdc
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x32d0
movq 0xd8(%rsp), %rdi
cmpq %r13, %rdi
je 0x3bf9
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x32d0
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x3c1e
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x32d0
movq 0x10(%rsp), %rdi
cmpq %rbp, %rdi
je 0x3c35
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x32d0
movq 0x30(%rsp), %rdi
cmpq %r14, %rdi
je 0x3c4c
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x32d0
leaq 0x70(%rsp), %rdi
callq 0x521e
incq %rbx
jmp 0x39c0
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x3c7a
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x32d0
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x935d(%rip), %rdi      # 0xcff0
leaq 0x536d(%rip), %rsi      # 0x9007
movl $0x24, %edx
callq 0x3320
movq (%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq 0x933a(%rip), %rdi      # 0xcff0
callq 0x3320
movq %rax, %rbx
leaq 0x5367(%rip), %rsi      # 0x902c
movl $0x23, %edx
movq %rax, %rdi
callq 0x3320
movq %rbx, %rdi
movq 0x8(%rsp), %rsi
callq 0x3120
movq %rax, %rdi
callq 0x3150
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rdx
movq 0x92f8(%rip), %rdi      # 0xcff0
callq 0x3320
movq %rax, %rdi
callq 0x3150
jmp 0x3d50
leaq 0x54b9(%rip), %rdi      # 0x91c7
xorl %esi, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x33d0
movq 0x92d0(%rip), %rdi      # 0xcff0
leaq 0x5329(%rip), %rsi      # 0x9050
movl $0x1a, %edx
callq 0x3320
movq (%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq 0x92ad(%rip), %rdi      # 0xcff0
callq 0x3320
movq %rax, %rdi
callq 0x3150
movl $0x1, %edi
callq 0x3360
jmp 0x3e34
jmp 0x3d61
movq %rax, %rbx
jmp 0x3e28
jmp 0x3e34
jmp 0x3d78
movq %rax, %rbx
jmp 0x3e11
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x521e
jmp 0x3d9f
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
callq 0x52b8
jmp 0x3dc6
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
leaq 0xe8(%rsp), %rax
cmpq %rax, %rdi
je 0x3e28
movq 0xe8(%rsp), %rsi
jmp 0x3e20
movq %rax, %rbx
jmp 0x3deb
movq %rax, %rbx
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x3deb
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x32d0
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x3e0c
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x32d0
jmp 0x3e0c
movq %rax, %rbx
leaq 0x40(%rsp), %r14
movq 0x30(%rsp), %rdi
cmpq %r14, %rdi
je 0x3e28
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x32d0
leaq 0x70(%rsp), %rdi
callq 0x521e
jmp 0x3e37
movq %rax, %rbx
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x3e53
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x32d0
movq %rbx, %rdi
callq 0x3490