// File: /workspace/github_cpp_makefile_star2_O3/BenLangmead[P]bowtie/./ebwt.h
// Function: Ebwt::writeFromMemory(bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&) const
void Ebwt::writeFromMemory(bool justHeader,
			   const string& out1,
			   const string& out2) const
{
	assert(isInMemory());
	assert(this->_eh.repOk());

	ofstream fout1(out1.c_str(), ios::binary);
	ofstream fout2(out2.c_str(), ios::binary);
	writeFromMemory(justHeader, fout1, fout2);
	fout1.close();
	fout2.close();

	// Read the file back in and assert that all components match
	// TODO: revisit this block
	if(_sanity) {
#if 0
		if(_verbose)
			cout << "Re-reading \"" << out1 << "\"/\"" << out2 << "\" for sanity check" << endl;
		Ebwt copy(out1, out2, _verbose, _sanity);
		assert(!isInMemory());
		copy.loadIntoMemory(eh._color ? 1 : 0, -1, false, false);
		assert(isInMemory());
	    assert_eq(eh._lineRate,     copy.eh()._lineRate);
	    assert_eq(eh._linesPerSide, copy.eh()._linesPerSide);
	    assert_eq(eh._offRate,      copy.eh()._offRate);
	    assert_eq(eh._isaRate,      copy.eh()._isaRate);
	    assert_eq(eh._ftabChars,    copy.eh()._ftabChars);
	    assert_eq(eh._len,          copy.eh()._len);
	    assert_eq(_zOff,             copy.zOff());
	    assert_eq(_zEbwtBpOff,       copy.zEbwtBpOff());
	    assert_eq(_zEbwtByteOff,     copy.zEbwtByteOff());
		assert_eq(_nPat,             copy.nPat());
		for(TIndexOffU i = 0; i < _nPat; i++)
			assert_eq(this->_plen[i], copy.plen()[i]);
		assert_eq(this->_nFrag, copy.nFrag());
		for(TIndexOffU i = 0; i < this->_nFrag*3; i++) {
			assert_eq(this->_rstarts[i], copy.rstarts()[i]);
		}
		for(uint32_t i = 0; i < 5; i++)
			assert_eq(this->_fchr[i], copy.fchr()[i]);
		for(TIndexOffU i = 0; i < eh._ftabLen; i++)
			assert_eq(this->ftab()[i], copy.ftab()[i]);
		for(TIndexOffU i = 0; i < eh._eftabLen; i++)
			assert_eq(this->eftab()[i], copy.eftab()[i]);
		for(TIndexOffU i = 0; i < eh._offsLen; i++)
			assert_eq(this->_offs[i], copy.offs()[i]);
		for(TIndexOffU i = 0; i < eh._isaLen; i++)
			assert_eq(this->_isa[i], copy.isa()[i]);
		for(TIndexOffU i = 0; i < eh._ebwtTotLen; i++)
			assert_eq(this->ebwt()[i], copy.ebwt()[i]);
		//copy.sanityCheckAll();
		if(_verbose)
			cout << "Read-in check passed for \"" << out1 << "\"/\"" << out2 << "\"" << endl;
#endif
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x408, %rsp            # imm = 0x408
movq %rcx, %r14
movq %rdx, %r15
movl %esi, %ebp
movq %rdi, %rbx
callq 0xf948
testb %al, %al
je 0xb172
leaq 0x108(%rbx), %rdi
callq 0x12e8c
testb %al, %al
je 0xb191
movq (%r15), %rsi
leaq 0x208(%rsp), %rdi
movl $0x4, %edx
callq 0x4370
movq (%r14), %rsi
leaq 0x8(%rsp), %rdi
movl $0x4, %edx
callq 0x4370
movzbl %bpl, %esi
leaq 0x208(%rsp), %rdx
leaq 0x8(%rsp), %rcx
movq %rbx, %rdi
callq 0xaaee
leaq 0x208(%rsp), %rbx
movq %rbx, %rdi
callq 0x44a0
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x44a0
movq 0x2be87(%rip), %rax     # 0x36f90
movq (%rax), %r15
movq 0x18(%rax), %r12
leaq 0x10(%rsp), %rdi
movq %r15, -0x8(%rdi)
movq -0x18(%r15), %rax
movq %r12, 0x8(%rsp,%rax)
callq 0x4280
movl $0xf8, %r13d
addq %r13, %r14
movq %r14, %rdi
callq 0x4120
leaq 0x210(%rsp), %rdi
movq %r15, -0x8(%rdi)
movq -0x18(%r15), %rax
movq %r12, 0x208(%rsp,%rax)
callq 0x4280
addq %r13, %rbx
movq %rbx, %rdi
callq 0x4120
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x20fe4(%rip), %rdi     # 0x2c15d
leaq 0x20fea(%rip), %rsi     # 0x2c16a
leaq 0x21b16(%rip), %rcx     # 0x2cc9d
movl $0xe60, %edx            # imm = 0xE60
callq 0x41c0
leaq 0x21b4c(%rip), %rdi     # 0x2cce4
leaq 0x20fcb(%rip), %rsi     # 0x2c16a
leaq 0x21af7(%rip), %rcx     # 0x2cc9d
movl $0xe61, %edx            # imm = 0xE61
callq 0x41c0
movq %rax, %rbx
jmp 0xb1c2
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x44d0
leaq 0x208(%rsp), %rdi
callq 0x44d0
movq %rbx, %rdi
callq 0x4620