// File: readmapping[P]alfalfa/src/sparseSA.cpp
// Function: sparseSA::save(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
void sparseSA::save(const string &prefix){
    string basic = prefix;
    string aux = basic + ".aux";
    string sa = basic + ".sa";
    string lcp = basic + ".lcp";
    string ref = basic + ".ref";
    //print auxiliary information
    ofstream aux_s (aux.c_str());
    if (aux_s.is_open()){
        aux_s << N << endl;
        aux_s << K << endl;
        aux_s << logN << endl;
        aux_s << NKm1 << endl;
        aux_s << (hasSufLink ? 1 : 0) << endl;
        aux_s << (hasChild ? 1 : 0) << endl;
        aux_s << (hasKmer ? 1 : 0) << endl;
        aux_s << startpos.size() << endl;
        for(size_t i = 0; i < startpos.size(); i++)
            aux_s << startpos[i] << endl;
        for(size_t i = 0; i < descr.size(); i++)
            aux_s << descr[i] << endl;
        aux_s.close();
    }
    else cerr << "Unable to open " << aux.c_str() << endl;
    //print S
    ofstream ref_s (ref.c_str());
    if (ref_s.is_open()){
        ref_s << S << endl;
    }
    else cerr << "Unable to open " << ref.c_str() << endl;
    //print sa
    ofstream sa_s (sa.c_str(), ios::binary);
    unsigned int sizeSA = SA.size();
    sa_s.write((const char*)&sizeSA,sizeof(sizeSA));
    sa_s.write((const char*)&SA[0],sizeSA*sizeof(unsigned int));
    sa_s.close();
    //print LCP
    ofstream lcp_s (lcp.c_str(), ios::binary);
    unsigned int sizeLCP = LCP.vec.size();
    unsigned int sizeM = LCP.M.size();
    lcp_s.write((const char*)&sizeLCP,sizeof(sizeLCP));
    lcp_s.write((const char*)&sizeM,sizeof(sizeM));
    lcp_s.write((const char*)&LCP.vec[0],sizeLCP*sizeof(unsigned char));
    lcp_s.write((const char*)&LCP.M[0],sizeM*sizeof(vec_uchar::item_t));
    lcp_s.close();
    //print ISA if nec
    if(hasSufLink){
        string isa = basic + ".isa";
        ofstream isa_s (isa.c_str(), ios::binary);
        unsigned int sizeISA = ISA.size();
        isa_s.write((const char*)&sizeISA,sizeof(sizeISA));
        isa_s.write((const char*)&ISA[0],sizeISA*sizeof(int));
        isa_s.close();
    }
    //print child if nec
    if(hasChild){
        string child = basic + ".child";
        ofstream child_s (child.c_str(), ios::binary);
        unsigned int sizeCHILD = CHILD.size();
        child_s.write((const char*)&sizeCHILD,sizeof(sizeCHILD));
        child_s.write((const char*)&CHILD[0],sizeCHILD*sizeof(int));
        child_s.close();
    }
    //print child if nec
    if(hasKmer){
        string kmer = basic + ".kmer";
        ofstream kmer_s (kmer.c_str(), ios::binary);
        unsigned int sizeKMR = KMR.size();
        kmer_s.write((const char*)&sizeKMR,sizeof(sizeKMR));
        kmer_s.write((const char*)&KMR[0],sizeKMR*sizeof(saTuple_t));
        kmer_s.close();
    }
}

// Assembly:
subq $0x1008, %rsp           # imm = 0x1008
movq %rdi, 0x1000(%rsp)
movq %rsi, 0xff8(%rsp)
movq 0x1000(%rsp), %rax
movq %rax, 0xa0(%rsp)
movq 0xff8(%rsp), %rsi
leaq 0xfd8(%rsp), %rdi
movq %rdi, 0xa8(%rsp)
callq 0x8180
movq 0xa8(%rsp), %rsi
leaq 0x64c82(%rip), %rdx     # 0x7d2c5
leaq 0xfb8(%rsp), %rdi
callq 0x1f400
jmp 0x18652
leaq 0x64c71(%rip), %rdx     # 0x7d2ca
leaq 0xf88(%rsp), %rdi
leaq 0xfd8(%rsp), %rsi
callq 0x1f400
jmp 0x18670
leaq 0x64c57(%rip), %rdx     # 0x7d2ce
leaq 0xf68(%rsp), %rdi
leaq 0xfd8(%rsp), %rsi
callq 0x1f400
jmp 0x1868e
leaq 0x64c3e(%rip), %rdx     # 0x7d2d3
leaq 0xf48(%rsp), %rdi
leaq 0xfd8(%rsp), %rsi
callq 0x1f400
jmp 0x186ac
leaq 0xfb8(%rsp), %rdi
callq 0x8170
movq %rax, %rsi
leaq 0xd48(%rsp), %rdi
movl $0x10, %edx
callq 0x83f0
jmp 0x186d0
leaq 0xd48(%rsp), %rdi
callq 0x82b0
movb %al, 0x9f(%rsp)
jmp 0x186e6
movb 0x9f(%rsp), %al
testb $0x1, %al
jne 0x186f6
jmp 0x18a87
movq 0xa0(%rsp), %rax
movq 0x38(%rax), %rsi
leaq 0xd48(%rsp), %rdi
callq 0x8790
movq %rax, 0x90(%rsp)
jmp 0x18719
movq 0x90(%rsp), %rdi
movq 0x7e888(%rip), %rsi     # 0x96fb0
callq 0x83b0
jmp 0x1872f
movq 0xa0(%rsp), %rax
movq 0xe8(%rax), %rsi
leaq 0xd48(%rsp), %rdi
callq 0x8790
movq %rax, 0x88(%rsp)
jmp 0x18755
movq 0x88(%rsp), %rdi
movq 0x7e84c(%rip), %rsi     # 0x96fb0
callq 0x83b0
jmp 0x1876b
movq 0xa0(%rsp), %rax
movq 0x40(%rax), %rsi
leaq 0xd48(%rsp), %rdi
callq 0x8790
movq %rax, 0x80(%rsp)
jmp 0x1878e
movq 0x80(%rsp), %rdi
movq 0x7e813(%rip), %rsi     # 0x96fb0
callq 0x83b0
jmp 0x187a4
movq 0xa0(%rsp), %rax
movq 0x48(%rax), %rsi
leaq 0xd48(%rsp), %rdi
callq 0x8790
movq %rax, 0x78(%rsp)
jmp 0x187c4
movq 0x78(%rsp), %rdi
movq 0x7e7e0(%rip), %rsi     # 0x96fb0
callq 0x83b0
jmp 0x187d7
movq 0xa0(%rsp), %rax
movzbl 0xf1(%rax), %esi
andl $0x1, %esi
leaq 0xd48(%rsp), %rdi
callq 0x8710
movq %rax, 0x70(%rsp)
jmp 0x187fd
movq 0x70(%rsp), %rdi
movq 0x7e7a7(%rip), %rsi     # 0x96fb0
callq 0x83b0
jmp 0x18810
movq 0xa0(%rsp), %rax
movzbl 0xf0(%rax), %esi
andl $0x1, %esi
leaq 0xd48(%rsp), %rdi
callq 0x8710
movq %rax, 0x68(%rsp)
jmp 0x18836
movq 0x68(%rsp), %rdi
movq 0x7e76e(%rip), %rsi     # 0x96fb0
callq 0x83b0
jmp 0x18849
movq 0xa0(%rsp), %rax
movzbl 0xf8(%rax), %esi
andl $0x1, %esi
leaq 0xd48(%rsp), %rdi
callq 0x8710
movq %rax, 0x60(%rsp)
jmp 0x1886f
movq 0x60(%rsp), %rdi
movq 0x7e735(%rip), %rsi     # 0x96fb0
callq 0x83b0
jmp 0x18882
movq 0xa0(%rsp), %rdi
addq $0x18, %rdi
callq 0x1f490
movq %rax, %rsi
leaq 0xd48(%rsp), %rdi
callq 0x8100
movq %rax, 0x58(%rsp)
jmp 0x188aa
movq 0x58(%rsp), %rdi
movq 0x7e6fa(%rip), %rsi     # 0x96fb0
callq 0x83b0
jmp 0x188bd
movq $0x0, 0xd40(%rsp)
movq 0xa0(%rsp), %rdi
movq 0xd40(%rsp), %rax
movq %rax, 0x50(%rsp)
addq $0x18, %rdi
callq 0x1f490
movq %rax, %rcx
movq 0x50(%rsp), %rax
cmpq %rcx, %rax
jae 0x189ec
movq 0xa0(%rsp), %rdi
addq $0x18, %rdi
movq 0xd40(%rsp), %rsi
callq 0xccd0
movq (%rax), %rsi
leaq 0xd48(%rsp), %rdi
callq 0x8790
movq %rax, 0x48(%rsp)
jmp 0x18928
movq 0x48(%rsp), %rdi
movq 0x7e67c(%rip), %rsi     # 0x96fb0
callq 0x83b0
jmp 0x1893b
jmp 0x1893d
movq 0xd40(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xd40(%rsp)
jmp 0x188c9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xfb0(%rsp)
movl %eax, 0xfac(%rsp)
jmp 0x1921b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xfb0(%rsp)
movl %eax, 0xfac(%rsp)
jmp 0x1920e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xfb0(%rsp)
movl %eax, 0xfac(%rsp)
jmp 0x19201
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xfb0(%rsp)
movl %eax, 0xfac(%rsp)
jmp 0x191f4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xfb0(%rsp)
movl %eax, 0xfac(%rsp)
jmp 0x191e7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xfb0(%rsp)
movl %eax, 0xfac(%rsp)
jmp 0x191da
movq $0x0, 0xd38(%rsp)
movq 0xa0(%rsp), %rdi
movq 0xd38(%rsp), %rax
movq %rax, 0x40(%rsp)
callq 0xccb0
movq %rax, %rcx
movq 0x40(%rsp), %rax
cmpq %rcx, %rax
jae 0x18a76
movq 0xa0(%rsp), %rdi
movq 0xd38(%rsp), %rsi
callq 0xccf0
movq %rax, %rsi
leaq 0xd48(%rsp), %rdi
callq 0x8330
movq %rax, 0x38(%rsp)
jmp 0x18a4b
movq 0x38(%rsp), %rdi
movq 0x7e559(%rip), %rsi     # 0x96fb0
callq 0x83b0
jmp 0x18a5e
jmp 0x18a60
movq 0xd38(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xd38(%rsp)
jmp 0x189f8
leaq 0xd48(%rsp), %rdi
callq 0x85b0
jmp 0x18a85
jmp 0x18ad7
movq 0x7e562(%rip), %rdi     # 0x96ff0
leaq 0x64843(%rip), %rsi     # 0x7d2d8
callq 0x8360
movq %rax, 0x30(%rsp)
jmp 0x18aa1
leaq 0xfb8(%rsp), %rdi
callq 0x8170
movq 0x30(%rsp), %rdi
movq %rax, %rsi
callq 0x8360
movq %rax, 0x28(%rsp)
jmp 0x18ac2
movq 0x28(%rsp), %rdi
movq 0x7e4e2(%rip), %rsi     # 0x96fb0
callq 0x83b0
jmp 0x18ad5
jmp 0x18ad7
leaq 0xf48(%rsp), %rdi
callq 0x8170
movq %rax, %rsi
leaq 0xb38(%rsp), %rdi
movl $0x10, %edx
callq 0x83f0
jmp 0x18afb
leaq 0xb38(%rsp), %rdi
callq 0x82b0
movb %al, 0x27(%rsp)
jmp 0x18b0e
movb 0x27(%rsp), %al
testb $0x1, %al
jne 0x18b18
jmp 0x18b66
movq 0xa0(%rsp), %rsi
addq $0x50, %rsi
leaq 0xb38(%rsp), %rdi
callq 0x8330
movq %rax, 0x18(%rsp)
jmp 0x18b38
movq 0x18(%rsp), %rdi
movq 0x7e46c(%rip), %rsi     # 0x96fb0
callq 0x83b0
jmp 0x18b4b
jmp 0x18bb6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xfb0(%rsp)
movl %eax, 0xfac(%rsp)
jmp 0x191cd
movq 0x7e483(%rip), %rdi     # 0x96ff0
leaq 0x64764(%rip), %rsi     # 0x7d2d8
callq 0x8360
movq %rax, 0x10(%rsp)
jmp 0x18b80
leaq 0xf48(%rsp), %rdi
callq 0x8170
movq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0x8360
movq %rax, 0x8(%rsp)
jmp 0x18ba1
movq 0x8(%rsp), %rdi
movq 0x7e403(%rip), %rsi     # 0x96fb0
callq 0x83b0
jmp 0x18bb4
jmp 0x18bb6
leaq 0xf88(%rsp), %rdi
callq 0x8170
movq %rax, %rsi
leaq 0x938(%rsp), %rdi
movl $0x4, %edx
callq 0x83f0
jmp 0x18bda
movq 0xa0(%rsp), %rdi
addq $0x70, %rdi
callq 0x1f4b0
movl %eax, 0x934(%rsp)
leaq 0x938(%rsp), %rdi
leaq 0x934(%rsp), %rsi
movl $0x4, %edx
callq 0x8550
jmp 0x18c0e
movq 0xa0(%rsp), %rdi
addq $0x70, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1ec60
movq %rax, %rsi
movl 0x934(%rsp), %eax
movl %eax, %edx
shlq $0x2, %rdx
leaq 0x938(%rsp), %rdi
callq 0x8550
jmp 0x18c42
leaq 0x938(%rsp), %rdi
callq 0x85b0
jmp 0x18c51
leaq 0xf68(%rsp), %rdi
callq 0x8170
movq %rax, %rsi
leaq 0x730(%rsp), %rdi
movl $0x4, %edx
callq 0x83f0
jmp 0x18c75
movq 0xa0(%rsp), %rdi
addq $0xa0, %rdi
callq 0x1f4d0
movq 0xa0(%rsp), %rdi
movl %eax, 0x72c(%rsp)
addq $0xb8, %rdi
callq 0x1e890
movl %eax, 0x728(%rsp)
leaq 0x730(%rsp), %rdi
leaq 0x72c(%rsp), %rsi
movl $0x4, %edx
callq 0x8550
jmp 0x18cc7
leaq 0x730(%rsp), %rdi
leaq 0x728(%rsp), %rsi
movl $0x4, %edx
callq 0x8550
jmp 0x18ce3
movq 0xa0(%rsp), %rdi
addq $0xa0, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1f4f0
movq %rax, %rsi
movl 0x72c(%rsp), %eax
movl %eax, %edx
leaq 0x730(%rsp), %rdi
callq 0x8550
jmp 0x18d16
movq 0xa0(%rsp), %rdi
addq $0xb8, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1f510
movq %rax, %rsi
movl 0x728(%rsp), %eax
movl %eax, %edx
shlq $0x4, %rdx
leaq 0x730(%rsp), %rdi
callq 0x8550
jmp 0x18d4d
leaq 0x730(%rsp), %rdi
callq 0x85b0
jmp 0x18d5c
movq 0xa0(%rsp), %rax
testb $0x1, 0xf1(%rax)
je 0x18ec7
leaq 0x64570(%rip), %rdx     # 0x7d2e8
leaq 0x708(%rsp), %rdi
leaq 0xfd8(%rsp), %rsi
callq 0x1f400
jmp 0x18d8f
leaq 0x708(%rsp), %rdi
callq 0x8170
movq %rax, %rsi
leaq 0x508(%rsp), %rdi
movl $0x4, %edx
callq 0x83f0
jmp 0x18db3
movq 0xa0(%rsp), %rdi
addq $0x88, %rdi
callq 0x1f530
movl %eax, 0x504(%rsp)
leaq 0x508(%rsp), %rdi
leaq 0x504(%rsp), %rsi
movl $0x4, %edx
callq 0x8550
jmp 0x18dea
movq 0xa0(%rsp), %rdi
addq $0x88, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1eb90
movq %rax, %rsi
movl 0x504(%rsp), %eax
movl %eax, %edx
shlq $0x2, %rdx
leaq 0x508(%rsp), %rdi
callq 0x8550
jmp 0x18e21
leaq 0x508(%rsp), %rdi
callq 0x85b0
jmp 0x18e30
leaq 0x508(%rsp), %rdi
callq 0x8610
leaq 0x708(%rsp), %rdi
callq 0x8858
jmp 0x18ec7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xfb0(%rsp)
movl %eax, 0xfac(%rsp)
jmp 0x191c0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xfb0(%rsp)
movl %eax, 0xfac(%rsp)
jmp 0x191b3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xfb0(%rsp)
movl %eax, 0xfac(%rsp)
jmp 0x18eb5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xfb0(%rsp)
movl %eax, 0xfac(%rsp)
leaq 0x508(%rsp), %rdi
callq 0x8610
leaq 0x708(%rsp), %rdi
callq 0x8858
jmp 0x191b3
movq 0xa0(%rsp), %rax
testb $0x1, 0xf0(%rax)
je 0x19000
leaq 0x6440a(%rip), %rdx     # 0x7d2ed
leaq 0x4e0(%rsp), %rdi
leaq 0xfd8(%rsp), %rsi
callq 0x1f400
jmp 0x18efa
leaq 0x4e0(%rsp), %rdi
callq 0x8170
movq %rax, %rsi
leaq 0x2e0(%rsp), %rdi
movl $0x4, %edx
callq 0x83f0
jmp 0x18f1e
movq 0xa0(%rsp), %rdi
addq $0xd0, %rdi
callq 0x1f530
movl %eax, 0x2dc(%rsp)
leaq 0x2e0(%rsp), %rdi
leaq 0x2dc(%rsp), %rsi
movl $0x4, %edx
callq 0x8550
jmp 0x18f55
movq 0xa0(%rsp), %rdi
addq $0xd0, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1eb90
movq %rax, %rsi
movl 0x2dc(%rsp), %eax
movl %eax, %edx
shlq $0x2, %rdx
leaq 0x2e0(%rsp), %rdi
callq 0x8550
jmp 0x18f8c
leaq 0x2e0(%rsp), %rdi
callq 0x85b0
jmp 0x18f9b
leaq 0x2e0(%rsp), %rdi
callq 0x8610
leaq 0x4e0(%rsp), %rdi
callq 0x8858
jmp 0x19000
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xfb0(%rsp)
movl %eax, 0xfac(%rsp)
jmp 0x18fee
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xfb0(%rsp)
movl %eax, 0xfac(%rsp)
leaq 0x2e0(%rsp), %rdi
callq 0x8610
leaq 0x4e0(%rsp), %rdi
callq 0x8858
jmp 0x191b3
movq 0xa0(%rsp), %rax
testb $0x1, 0xf8(%rax)
je 0x19136
leaq 0x642d8(%rip), %rdx     # 0x7d2f4
leaq 0x2b8(%rsp), %rdi
leaq 0xfd8(%rsp), %rsi
callq 0x1f400
jmp 0x19033
leaq 0x2b8(%rsp), %rdi
callq 0x8170
movq %rax, %rsi
leaq 0xb8(%rsp), %rdi
movl $0x4, %edx
callq 0x83f0
jmp 0x19057
movq 0xa0(%rsp), %rdi
addq $0x100, %rdi            # imm = 0x100
callq 0x1f550
movl %eax, 0xb4(%rsp)
leaq 0xb8(%rsp), %rdi
leaq 0xb4(%rsp), %rsi
movl $0x4, %edx
callq 0x8550
jmp 0x1908e
movq 0xa0(%rsp), %rdi
addq $0x100, %rdi            # imm = 0x100
xorl %eax, %eax
movl %eax, %esi
callq 0x1efa0
movq %rax, %rsi
movl 0xb4(%rsp), %eax
movl %eax, %edx
shlq $0x3, %rdx
leaq 0xb8(%rsp), %rdi
callq 0x8550
jmp 0x190c5
leaq 0xb8(%rsp), %rdi
callq 0x85b0
jmp 0x190d4
leaq 0xb8(%rsp), %rdi
callq 0x8610
leaq 0x2b8(%rsp), %rdi
callq 0x8858
jmp 0x19136
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xfb0(%rsp)
movl %eax, 0xfac(%rsp)
jmp 0x19127
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xfb0(%rsp)
movl %eax, 0xfac(%rsp)
leaq 0xb8(%rsp), %rdi
callq 0x8610
leaq 0x2b8(%rsp), %rdi
callq 0x8858
jmp 0x191b3
leaq 0x730(%rsp), %rdi
callq 0x8610
leaq 0x938(%rsp), %rdi
callq 0x8610
leaq 0xb38(%rsp), %rdi
callq 0x8610
leaq 0xd48(%rsp), %rdi
callq 0x8610
leaq 0xf48(%rsp), %rdi
callq 0x8858
leaq 0xf68(%rsp), %rdi
callq 0x8858
leaq 0xf88(%rsp), %rdi
callq 0x8858
leaq 0xfb8(%rsp), %rdi
callq 0x8858
leaq 0xfd8(%rsp), %rdi
callq 0x8858
addq $0x1008, %rsp           # imm = 0x1008
retq
leaq 0x730(%rsp), %rdi
callq 0x8610
leaq 0x938(%rsp), %rdi
callq 0x8610
leaq 0xb38(%rsp), %rdi
callq 0x8610
leaq 0xd48(%rsp), %rdi
callq 0x8610
leaq 0xf48(%rsp), %rdi
callq 0x8858
leaq 0xf68(%rsp), %rdi
callq 0x8858
leaq 0xf88(%rsp), %rdi
callq 0x8858
leaq 0xfb8(%rsp), %rdi
callq 0x8858
leaq 0xfd8(%rsp), %rdi
callq 0x8858
movq 0xfb0(%rsp), %rdi
callq 0x8730
nopw %cs:(%rax,%rax)