// File: 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
movq %rsp, %rbp
subq $0x240, %rsp            # imm = 0x240
movq %rsi, -0x198(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x1a0(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x3430
movq -0x1a0(%rbp), %rax
movq -0x198(%rbp), %rdi
movq $0x0, -0x38(%rbp)
addq $0x78, %rax
movq %rax, -0x190(%rbp)
callq 0x3120
movq -0x190(%rbp), %rdi
movq %rax, %rsi
movl $0x8, %edx
callq 0x31b0
jmp 0x3a9a
movq -0x1a0(%rbp), %rdi
addq $0x78, %rdi
callq 0x34e0
movb %al, -0x1a1(%rbp)
jmp 0x3ab2
movb -0x1a1(%rbp), %al
testb $0x1, %al
jne 0x3ac1
jmp 0x3f34
jmp 0x3ac3
movq -0x1a0(%rbp), %rdi
addq $0x78, %rdi
leaq -0x30(%rbp), %rsi
callq 0x30b0
movq %rax, -0x1b0(%rbp)
jmp 0x3ae0
movq -0x1b0(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x33e0
movb %al, -0x1b1(%rbp)
jmp 0x3afe
movb -0x1b1(%rbp), %al
testb $0x1, %al
jne 0x3b0d
jmp 0x3f32
movq -0x38(%rbp), %rax
incq %rax
movq %rax, -0x38(%rbp)
leaq -0x60(%rbp), %rdi
leaq -0x30(%rbp), %rsi
movl $0x9, %edx
callq 0xc900
jmp 0x3b2c
leaq -0x60(%rbp), %rdi
callq 0x5b40
cmpq $0x5, %rax
jne 0x3e51
xorl %eax, %eax
movl %eax, %esi
leaq -0x60(%rbp), %rdi
callq 0x5b60
movq %rax, -0x1c8(%rbp)
leaq -0xc1(%rbp), %rdi
movq %rdi, -0x1c0(%rbp)
callq 0x3550
movq -0x1c0(%rbp), %rdx
leaq 0xa4a0(%rip), %rsi      # 0xe014
leaq -0xc0(%rbp), %rdi
callq 0x5b80
jmp 0x3b82
movq -0x1c8(%rbp), %rsi
leaq -0xa0(%rbp), %rdi
leaq -0xc0(%rbp), %rdx
callq 0xcaf0
jmp 0x3b9e
xorl %eax, %eax
movl %eax, %esi
leaq -0xa0(%rbp), %rdi
callq 0x5a00
movq %rax, -0x1d0(%rbp)
jmp 0x3bb7
movq -0x1d0(%rbp), %rsi
leaq -0x88(%rbp), %rdi
callq 0x3130
jmp 0x3bcc
leaq -0xa0(%rbp), %rdi
callq 0x5a40
leaq -0xc0(%rbp), %rdi
callq 0x31a0
leaq -0xc1(%rbp), %rdi
callq 0x3340
movq -0x1a0(%rbp), %rdi
addq $0x30, %rdi
leaq -0x88(%rbp), %rsi
callq 0x5c30
jmp 0x3c09
xorl %eax, %eax
movl %eax, %esi
leaq -0x60(%rbp), %rdi
callq 0x5b60
movq %rax, %rsi
leaq -0x178(%rbp), %rdi
callq 0x3130
jmp 0x3c27
leaq -0x60(%rbp), %rdi
movq %rdi, -0x1f0(%rbp)
movl $0x1, %esi
callq 0x5b60
movq %rax, %rdi
callq 0x3120
movq %rax, %rdi
callq 0x34a0
movq -0x1f0(%rbp), %rdi
movl %eax, -0x1e4(%rbp)
movl $0x2, %esi
callq 0x5b60
movq %rax, %rdi
callq 0x3120
movq %rax, %rdi
leaq -0x68(%rbp), %rsi
movl $0xa, %edx
callq 0x3080
movq -0x1f0(%rbp), %rdi
movq %rax, -0x1e0(%rbp)
movl $0x3, %esi
callq 0x5b60
movq %rax, %rdi
callq 0x3120
movq %rax, %rdi
callq 0x34a0
movq -0x1f0(%rbp), %rdi
movl %eax, -0x1d4(%rbp)
movl $0x4, %esi
callq 0x5b60
movq %rax, %rdi
callq 0x3120
movq %rax, %rdi
callq 0x34a0
movl -0x1e4(%rbp), %edx
movq -0x1e0(%rbp), %rcx
movl -0x1d4(%rbp), %r8d
movl %eax, %r9d
leaq -0x158(%rbp), %rdi
leaq -0x178(%rbp), %rsi
callq 0x3750
jmp 0x3cf7
leaq -0x120(%rbp), %rdi
leaq -0x88(%rbp), %rsi
leaq -0x158(%rbp), %rdx
callq 0x5ce0
jmp 0x3d13
movq -0x1a0(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0x5ca0
movb %dl, -0x1f9(%rbp)
movq %rax, -0x1f8(%rbp)
jmp 0x3d35
movb -0x1f9(%rbp), %al
movq -0x1f8(%rbp), %rcx
movq %rcx, -0x188(%rbp)
movb %al, -0x180(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x5d20
leaq -0x158(%rbp), %rdi
callq 0x3840
leaq -0x178(%rbp), %rdi
callq 0x31a0
leaq -0x88(%rbp), %rdi
callq 0x31a0
jmp 0x3f19
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x3f9d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x3dd5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x3dc9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x5a40
leaq -0xc0(%rbp), %rdi
callq 0x31a0
leaq -0xc1(%rbp), %rdi
callq 0x3340
jmp 0x3f27
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x3e40
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x3e34
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x3e28
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x5d20
leaq -0x158(%rbp), %rdi
callq 0x3840
leaq -0x178(%rbp), %rdi
callq 0x31a0
leaq -0x88(%rbp), %rdi
callq 0x31a0
jmp 0x3f27
movq 0x10198(%rip), %rdi     # 0x13ff0
leaq 0xa1b8(%rip), %rsi      # 0xe017
callq 0x32c0
movq %rax, -0x208(%rbp)
jmp 0x3e6d
movq -0x198(%rbp), %rsi
movq -0x208(%rbp), %rdi
callq 0x3290
movq %rax, -0x210(%rbp)
jmp 0x3e89
movq -0x210(%rbp), %rdi
leaq 0xa1a5(%rip), %rsi      # 0xe03c
callq 0x32c0
movq %rax, -0x218(%rbp)
jmp 0x3ea5
movq -0x218(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x3160
movq %rax, -0x220(%rbp)
jmp 0x3ebe
movq -0x220(%rbp), %rdi
movq 0x100dc(%rip), %rsi     # 0x13fa8
callq 0x3320
jmp 0x3ed3
movq 0x10116(%rip), %rdi     # 0x13ff0
leaq -0x30(%rbp), %rsi
callq 0x3290
movq %rax, -0x228(%rbp)
jmp 0x3eec
movq -0x228(%rbp), %rdi
movq 0x100ae(%rip), %rsi     # 0x13fa8
callq 0x3320
jmp 0x3f01
movl $0x1, %edi
callq 0x33b0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x3f27
leaq -0x60(%rbp), %rdi
callq 0x5a40
jmp 0x3ac3
leaq -0x60(%rbp), %rdi
callq 0x5a40
jmp 0x3f9d
jmp 0x3f8b
movq 0x100b5(%rip), %rdi     # 0x13ff0
leaq 0xa11e(%rip), %rsi      # 0xe060
callq 0x32c0
movq %rax, -0x230(%rbp)
jmp 0x3f50
movq -0x198(%rbp), %rsi
movq -0x230(%rbp), %rdi
callq 0x3290
movq %rax, -0x238(%rbp)
jmp 0x3f6c
movq -0x238(%rbp), %rdi
movq 0x1002e(%rip), %rsi     # 0x13fa8
callq 0x3320
jmp 0x3f81
movl $0x1, %edi
callq 0x33b0
leaq -0x30(%rbp), %rdi
callq 0x31a0
addq $0x240, %rsp            # imm = 0x240
popq %rbp
retq
leaq -0x30(%rbp), %rdi
callq 0x31a0
movq -0x40(%rbp), %rdi
callq 0x3540
nop