// File: readmapping[P]alfalfa/src/sparseSA.cpp
// Function: sparseSA::load(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
bool sparseSA::load(const string &prefix){
    cerr << "atempting to load index " << prefix  << " ... "<< endl;
    string basic = prefix;
    string aux = basic + ".aux";
    string sa = basic + ".sa";
    string lcp = basic + ".lcp";
    string ref = basic + ".ref";
    ifstream aux_s (aux.c_str());
    if(!aux_s.is_open()){
        cerr << "unable to open " << prefix << endl;
        return false;
    }
    string line;
    getline(aux_s,line); N = atol(line.c_str());
    getline(aux_s,line); K = atol(line.c_str());
    getline(aux_s,line); logN = atol(line.c_str());
    getline(aux_s,line); NKm1 = atol(line.c_str());
    getline(aux_s,line); hasSufLink = atoi(line.c_str()) == 1 ? true : false;
    getline(aux_s,line); hasChild = atoi(line.c_str()) == 1 ? true : false;
    getline(aux_s,line); hasKmer = atoi(line.c_str()) == 1 ? true : false;
    getline(aux_s,line); 
    int chromNumber = atoi(line.c_str());
    for(int i = 0; i < chromNumber; i++){
        getline(aux_s,line); 
        startpos.push_back(atol(line.c_str()));
    }
    for(int i = 0; i < chromNumber; i++){
        getline(aux_s,line); 
        descr.push_back(line);
    }
    //read auxiliary information
    aux_s.close();
    //read ref
    ifstream ref_s (ref.c_str());
    getline(ref_s,S);
    ref_s.close();
    //read sa
    ifstream sa_s (sa.c_str(), ios::binary);
    unsigned int sizeSA;
    sa_s.read((char*)&sizeSA,sizeof(sizeSA));
    SA.resize(sizeSA);
    sa_s.read((char*)&SA[0],sizeSA*sizeof(unsigned int));
    sa_s.close();
    //read LCP
    ifstream lcp_s (lcp.c_str(), ios::binary);
    unsigned int sizeLCP;
    unsigned int sizeM;
    lcp_s.read((char*)&sizeLCP,sizeof(sizeLCP));
    lcp_s.read((char*)&sizeM,sizeof(sizeM));
    LCP.vec.resize(sizeLCP);
    LCP.M.resize(sizeM);
    lcp_s.read((char*)&LCP.vec[0],sizeLCP*sizeof(unsigned char));
    lcp_s.read((char*)&LCP.M[0],sizeM*sizeof(vec_uchar::item_t));
    lcp_s.close();
    //read ISA if nec
    if(hasSufLink){
        string isa = basic + ".isa";
        ifstream isa_s (isa.c_str(), ios::binary);
        unsigned int sizeISA;
        isa_s.read((char*)&sizeISA,sizeof(sizeISA));
        ISA.resize(sizeISA);
        isa_s.read((char*)&ISA[0],sizeISA*sizeof(int));
        isa_s.close();
    }
    //read child if nec
    if(hasChild){
        string child = basic + ".child";
        ifstream child_s (child.c_str(), ios::binary);
        unsigned int sizeCHILD;
        child_s.read((char*)&sizeCHILD,sizeof(sizeCHILD));
        CHILD.resize(sizeCHILD);
        child_s.read((char*)&CHILD[0],sizeCHILD*sizeof(int));
        child_s.close();
    }
    //read kmer table if nec
    if(hasKmer){
        string kmer = basic + ".kmer";
        ifstream kmer_s (kmer.c_str(), ios::binary);
        unsigned int sizeKMR;
        kmer_s.read((char*)&sizeKMR,sizeof(sizeKMR));
        KMR.resize(sizeKMR);
        kmer_s.read((char*)&KMR[0],sizeKMR*sizeof(saTuple_t));
        kmer_s.close();
    }
    cerr << "index loaded succesful" << endl;
    return true;
}

// Assembly:
subq $0x1048, %rsp           # imm = 0x1048
movq %rdi, 0x1038(%rsp)
movq %rsi, 0x1030(%rsp)
movq 0x1038(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0x7dd85(%rip), %rdi     # 0x96ff0
leaq 0x64088(%rip), %rsi     # 0x7d2fa
callq 0x8360
movq %rax, %rdi
movq 0x1030(%rsp), %rsi
callq 0x8330
movq %rax, %rdi
leaq 0x6499c(%rip), %rsi     # 0x7dc2d
callq 0x8360
movq %rax, %rdi
movq 0x7dd10(%rip), %rsi     # 0x96fb0
callq 0x83b0
movq 0x1030(%rsp), %rsi
leaq 0x1010(%rsp), %rdi
movq %rdi, 0x78(%rsp)
callq 0x8180
movq 0x78(%rsp), %rsi
leaq 0x63ffa(%rip), %rdx     # 0x7d2c5
leaq 0xff0(%rsp), %rdi
callq 0x1f400
jmp 0x192da
leaq 0x63fe9(%rip), %rdx     # 0x7d2ca
leaq 0xfc0(%rsp), %rdi
leaq 0x1010(%rsp), %rsi
callq 0x1f400
jmp 0x192f8
leaq 0x63fcf(%rip), %rdx     # 0x7d2ce
leaq 0xfa0(%rsp), %rdi
leaq 0x1010(%rsp), %rsi
callq 0x1f400
jmp 0x19316
leaq 0x63fb6(%rip), %rdx     # 0x7d2d3
leaq 0xf80(%rsp), %rdi
leaq 0x1010(%rsp), %rsi
callq 0x1f400
jmp 0x19334
leaq 0xff0(%rsp), %rdi
callq 0x8170
movq %rax, %rsi
leaq 0xd78(%rsp), %rdi
movl $0x8, %edx
callq 0x87a0
jmp 0x19358
leaq 0xd78(%rsp), %rdi
callq 0x86a0
movb %al, 0x6f(%rsp)
jmp 0x1936b
movb 0x6f(%rsp), %al
testb $0x1, %al
jne 0x1946d
jmp 0x19379
movq 0x7dc70(%rip), %rdi     # 0x96ff0
leaq 0x63f8c(%rip), %rsi     # 0x7d313
callq 0x8360
movq %rax, 0x60(%rsp)
jmp 0x19393
movq 0x60(%rsp), %rdi
movq 0x1030(%rsp), %rsi
callq 0x8330
movq %rax, 0x58(%rsp)
jmp 0x193ac
movq 0x58(%rsp), %rdi
movq 0x7dbf8(%rip), %rsi     # 0x96fb0
callq 0x83b0
jmp 0x193bf
movb $0x0, 0x1047(%rsp)
movl $0x1, 0xd74(%rsp)
jmp 0x19de2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xfe8(%rsp)
movl %eax, 0xfe4(%rsp)
jmp 0x19e82
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xfe8(%rsp)
movl %eax, 0xfe4(%rsp)
jmp 0x19e75
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xfe8(%rsp)
movl %eax, 0xfe4(%rsp)
jmp 0x19e68
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xfe8(%rsp)
movl %eax, 0xfe4(%rsp)
jmp 0x19e5b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xfe8(%rsp)
movl %eax, 0xfe4(%rsp)
jmp 0x19e4e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xfe8(%rsp)
movl %eax, 0xfe4(%rsp)
jmp 0x19e41
leaq 0xd50(%rsp), %rdi
movq %rdi, 0x50(%rsp)
callq 0x8590
movq 0x50(%rsp), %rsi
leaq 0xd78(%rsp), %rdi
callq 0x80d0
jmp 0x19493
leaq 0xd50(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0x8170
movq %rax, %rdi
callq 0x8480
movq 0x48(%rsp), %rsi
movq %rax, %rcx
movq 0x70(%rsp), %rax
movq %rcx, 0x38(%rax)
leaq 0xd78(%rsp), %rdi
callq 0x80d0
jmp 0x194cd
leaq 0xd50(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0x8170
movq %rax, %rdi
callq 0x8480
movq 0x40(%rsp), %rsi
movq %rax, %rcx
movq 0x70(%rsp), %rax
movq %rcx, 0xe8(%rax)
leaq 0xd78(%rsp), %rdi
callq 0x80d0
jmp 0x1950a
leaq 0xd50(%rsp), %rdi
movq %rdi, 0x38(%rsp)
callq 0x8170
movq %rax, %rdi
callq 0x8480
movq 0x38(%rsp), %rsi
movq %rax, %rcx
movq 0x70(%rsp), %rax
movq %rcx, 0x40(%rax)
leaq 0xd78(%rsp), %rdi
callq 0x80d0
jmp 0x19544
leaq 0xd50(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0x8170
movq %rax, %rdi
callq 0x8480
movq 0x30(%rsp), %rsi
movq %rax, %rcx
movq 0x70(%rsp), %rax
movq %rcx, 0x48(%rax)
leaq 0xd78(%rsp), %rdi
callq 0x80d0
jmp 0x1957e
leaq 0xd50(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x8170
movq %rax, %rdi
callq 0x8670
movq 0x28(%rsp), %rsi
movl %eax, %ecx
movq 0x70(%rsp), %rax
subl $0x1, %ecx
sete 0xf1(%rax)
leaq 0xd78(%rsp), %rdi
callq 0x80d0
jmp 0x195bd
leaq 0xd50(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0x8170
movq %rax, %rdi
callq 0x8670
movq 0x20(%rsp), %rsi
movl %eax, %ecx
movq 0x70(%rsp), %rax
subl $0x1, %ecx
sete 0xf0(%rax)
leaq 0xd78(%rsp), %rdi
callq 0x80d0
jmp 0x195fc
leaq 0xd50(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x8170
movq %rax, %rdi
callq 0x8670
movq 0x18(%rsp), %rsi
movl %eax, %ecx
movq 0x70(%rsp), %rax
subl $0x1, %ecx
sete 0xf8(%rax)
leaq 0xd78(%rsp), %rdi
callq 0x80d0
jmp 0x1963b
leaq 0xd50(%rsp), %rdi
callq 0x8170
movq %rax, %rdi
callq 0x8670
movl %eax, 0xd4c(%rsp)
movl $0x0, 0xd48(%rsp)
movl 0xd48(%rsp), %eax
cmpl 0xd4c(%rsp), %eax
jge 0x196fa
leaq 0xd78(%rsp), %rdi
leaq 0xd50(%rsp), %rsi
callq 0x80d0
jmp 0x1968d
movq 0x70(%rsp), %rax
addq $0x18, %rax
movq %rax, 0x10(%rsp)
leaq 0xd50(%rsp), %rdi
callq 0x8170
movq %rax, %rdi
callq 0x8480
movq 0x10(%rsp), %rdi
movq %rax, 0xd40(%rsp)
leaq 0xd40(%rsp), %rsi
callq 0x1eaf0
jmp 0x196cc
jmp 0x196ce
movl 0xd48(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xd48(%rsp)
jmp 0x19662
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xfe8(%rsp)
movl %eax, 0xfe4(%rsp)
jmp 0x19dd3
movl $0x0, 0xd3c(%rsp)
movl 0xd3c(%rsp), %eax
cmpl 0xd4c(%rsp), %eax
jge 0x19755
leaq 0xd78(%rsp), %rdi
leaq 0xd50(%rsp), %rsi
callq 0x80d0
jmp 0x1972c
movq 0x70(%rsp), %rdi
leaq 0xd50(%rsp), %rsi
callq 0x1eb20
jmp 0x19740
jmp 0x19742
movl 0xd3c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xd3c(%rsp)
jmp 0x19705
leaq 0xd78(%rsp), %rdi
callq 0x80e0
jmp 0x19764
leaq 0xf80(%rsp), %rdi
callq 0x8170
movq %rax, %rsi
leaq 0xb30(%rsp), %rdi
movl $0x8, %edx
callq 0x87a0
jmp 0x19788
movq 0x70(%rsp), %rsi
addq $0x50, %rsi
leaq 0xb30(%rsp), %rdi
callq 0x80d0
jmp 0x197a0
leaq 0xb30(%rsp), %rdi
callq 0x80e0
jmp 0x197af
leaq 0xfc0(%rsp), %rdi
callq 0x8170
movq %rax, %rsi
leaq 0x928(%rsp), %rdi
movl $0x4, %edx
callq 0x87a0
jmp 0x197d3
leaq 0x928(%rsp), %rdi
leaq 0x924(%rsp), %rsi
movl $0x4, %edx
callq 0x8500
jmp 0x197ef
movq 0x70(%rsp), %rdi
addq $0x70, %rdi
movl 0x924(%rsp), %eax
movl %eax, %esi
callq 0x1f570
jmp 0x19808
movq 0x70(%rsp), %rdi
addq $0x70, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1ec60
movq %rax, %rsi
movl 0x924(%rsp), %eax
movl %eax, %edx
shlq $0x2, %rdx
leaq 0x928(%rsp), %rdi
callq 0x8500
jmp 0x19839
leaq 0x928(%rsp), %rdi
callq 0x80e0
jmp 0x19848
leaq 0xfa0(%rsp), %rdi
callq 0x8170
movq %rax, %rsi
leaq 0x718(%rsp), %rdi
movl $0x4, %edx
callq 0x87a0
jmp 0x1986c
leaq 0x718(%rsp), %rdi
leaq 0x714(%rsp), %rsi
movl $0x4, %edx
callq 0x8500
jmp 0x19888
leaq 0x718(%rsp), %rdi
leaq 0x710(%rsp), %rsi
movl $0x4, %edx
callq 0x8500
jmp 0x198a4
movq 0x70(%rsp), %rdi
addq $0xa0, %rdi
movl 0x714(%rsp), %eax
movl %eax, %esi
callq 0x1f610
jmp 0x198c0
movq 0x70(%rsp), %rdi
addq $0xb8, %rdi
movl 0x710(%rsp), %eax
movl %eax, %esi
callq 0x1f6b0
jmp 0x198dc
movq 0x70(%rsp), %rdi
addq $0xa0, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1f4f0
movq %rax, %rsi
movl 0x714(%rsp), %eax
movl %eax, %edx
leaq 0x718(%rsp), %rdi
callq 0x8500
jmp 0x1990c
movq 0x70(%rsp), %rdi
addq $0xb8, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1f510
movq %rax, %rsi
movl 0x710(%rsp), %eax
movl %eax, %edx
shlq $0x4, %rdx
leaq 0x718(%rsp), %rdi
callq 0x8500
jmp 0x19940
leaq 0x718(%rsp), %rdi
callq 0x80e0
jmp 0x1994f
movq 0x70(%rsp), %rax
testb $0x1, 0xf1(%rax)
je 0x19ad1
leaq 0x63980(%rip), %rdx     # 0x7d2e8
leaq 0x6f0(%rsp), %rdi
leaq 0x1010(%rsp), %rsi
callq 0x1f400
jmp 0x1997f
leaq 0x6f0(%rsp), %rdi
callq 0x8170
movq %rax, %rsi
leaq 0x4e8(%rsp), %rdi
movl $0x4, %edx
callq 0x87a0
jmp 0x199a3
leaq 0x4e8(%rsp), %rdi
leaq 0x4e4(%rsp), %rsi
movl $0x4, %edx
callq 0x8500
jmp 0x199bf
movq 0x70(%rsp), %rdi
addq $0x88, %rdi
movl 0x4e4(%rsp), %eax
movl %eax, %esi
callq 0x1f750
jmp 0x199db
movq 0x70(%rsp), %rdi
addq $0x88, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1eb90
movq %rax, %rsi
movl 0x4e4(%rsp), %eax
movl %eax, %edx
shlq $0x2, %rdx
leaq 0x4e8(%rsp), %rdi
callq 0x8500
jmp 0x19a0f
leaq 0x4e8(%rsp), %rdi
callq 0x80e0
jmp 0x19a1e
leaq 0x4e8(%rsp), %rdi
callq 0x8110
leaq 0x6f0(%rsp), %rdi
callq 0x8858
jmp 0x19ad1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xfe8(%rsp)
movl %eax, 0xfe4(%rsp)
jmp 0x19dc6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xfe8(%rsp)
movl %eax, 0xfe4(%rsp)
jmp 0x19db9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xfe8(%rsp)
movl %eax, 0xfe4(%rsp)
jmp 0x19dac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xfe8(%rsp)
movl %eax, 0xfe4(%rsp)
jmp 0x19abf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xfe8(%rsp)
movl %eax, 0xfe4(%rsp)
leaq 0x4e8(%rsp), %rdi
callq 0x8110
leaq 0x6f0(%rsp), %rdi
callq 0x8858
jmp 0x19dac
movq 0x70(%rsp), %rax
testb $0x1, 0xf0(%rax)
je 0x19c05
leaq 0x63803(%rip), %rdx     # 0x7d2ed
leaq 0x4c0(%rsp), %rdi
leaq 0x1010(%rsp), %rsi
callq 0x1f400
jmp 0x19b01
leaq 0x4c0(%rsp), %rdi
callq 0x8170
movq %rax, %rsi
leaq 0x2b8(%rsp), %rdi
movl $0x4, %edx
callq 0x87a0
jmp 0x19b25
leaq 0x2b8(%rsp), %rdi
leaq 0x2b4(%rsp), %rsi
movl $0x4, %edx
callq 0x8500
jmp 0x19b41
movq 0x70(%rsp), %rdi
addq $0xd0, %rdi
movl 0x2b4(%rsp), %eax
movl %eax, %esi
callq 0x1f750
jmp 0x19b5d
movq 0x70(%rsp), %rdi
addq $0xd0, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1eb90
movq %rax, %rsi
movl 0x2b4(%rsp), %eax
movl %eax, %edx
shlq $0x2, %rdx
leaq 0x2b8(%rsp), %rdi
callq 0x8500
jmp 0x19b91
leaq 0x2b8(%rsp), %rdi
callq 0x80e0
jmp 0x19ba0
leaq 0x2b8(%rsp), %rdi
callq 0x8110
leaq 0x4c0(%rsp), %rdi
callq 0x8858
jmp 0x19c05
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xfe8(%rsp)
movl %eax, 0xfe4(%rsp)
jmp 0x19bf3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xfe8(%rsp)
movl %eax, 0xfe4(%rsp)
leaq 0x2b8(%rsp), %rdi
callq 0x8110
leaq 0x4c0(%rsp), %rdi
callq 0x8858
jmp 0x19dac
movq 0x70(%rsp), %rax
testb $0x1, 0xf8(%rax)
je 0x19d36
leaq 0x636d6(%rip), %rdx     # 0x7d2f4
leaq 0x290(%rsp), %rdi
leaq 0x1010(%rsp), %rsi
callq 0x1f400
jmp 0x19c35
leaq 0x290(%rsp), %rdi
callq 0x8170
movq %rax, %rsi
leaq 0x88(%rsp), %rdi
movl $0x4, %edx
callq 0x87a0
jmp 0x19c59
leaq 0x88(%rsp), %rdi
leaq 0x84(%rsp), %rsi
movl $0x4, %edx
callq 0x8500
jmp 0x19c75
movq 0x70(%rsp), %rdi
addq $0x100, %rdi            # imm = 0x100
movl 0x84(%rsp), %eax
movl %eax, %esi
callq 0x1f7f0
jmp 0x19c91
movq 0x70(%rsp), %rdi
addq $0x100, %rdi            # imm = 0x100
xorl %eax, %eax
movl %eax, %esi
callq 0x1efa0
movq %rax, %rsi
movl 0x84(%rsp), %eax
movl %eax, %edx
shlq $0x3, %rdx
leaq 0x88(%rsp), %rdi
callq 0x8500
jmp 0x19cc5
leaq 0x88(%rsp), %rdi
callq 0x80e0
jmp 0x19cd4
leaq 0x88(%rsp), %rdi
callq 0x8110
leaq 0x290(%rsp), %rdi
callq 0x8858
jmp 0x19d36
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xfe8(%rsp)
movl %eax, 0xfe4(%rsp)
jmp 0x19d27
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xfe8(%rsp)
movl %eax, 0xfe4(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x8110
leaq 0x290(%rsp), %rdi
callq 0x8858
jmp 0x19dac
movq 0x7d2b3(%rip), %rdi     # 0x96ff0
leaq 0x635df(%rip), %rsi     # 0x7d323
callq 0x8360
movq %rax, 0x8(%rsp)
jmp 0x19d50
movq 0x8(%rsp), %rdi
movq 0x7d254(%rip), %rsi     # 0x96fb0
callq 0x83b0
jmp 0x19d63
movb $0x1, 0x1047(%rsp)
movl $0x1, 0xd74(%rsp)
leaq 0x718(%rsp), %rdi
callq 0x8110
leaq 0x928(%rsp), %rdi
callq 0x8110
leaq 0xb30(%rsp), %rdi
callq 0x8110
leaq 0xd50(%rsp), %rdi
callq 0x8858
jmp 0x19de2
leaq 0x718(%rsp), %rdi
callq 0x8110
leaq 0x928(%rsp), %rdi
callq 0x8110
leaq 0xb30(%rsp), %rdi
callq 0x8110
leaq 0xd50(%rsp), %rdi
callq 0x8858
jmp 0x19e41
leaq 0xd78(%rsp), %rdi
callq 0x8110
leaq 0xf80(%rsp), %rdi
callq 0x8858
leaq 0xfa0(%rsp), %rdi
callq 0x8858
leaq 0xfc0(%rsp), %rdi
callq 0x8858
leaq 0xff0(%rsp), %rdi
callq 0x8858
leaq 0x1010(%rsp), %rdi
callq 0x8858
movb 0x1047(%rsp), %al
andb $0x1, %al
addq $0x1048, %rsp           # imm = 0x1048
retq
leaq 0xd78(%rsp), %rdi
callq 0x8110
leaq 0xf80(%rsp), %rdi
callq 0x8858
leaq 0xfa0(%rsp), %rdi
callq 0x8858
leaq 0xfc0(%rsp), %rdi
callq 0x8858
leaq 0xff0(%rsp), %rdi
callq 0x8858
leaq 0x1010(%rsp), %rdi
callq 0x8858
movq 0xfe8(%rsp), %rdi
callq 0x8730
nopl (%rax)