// File: /workspace/github_cpp_makefile_star2_O1/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 0xfb60
testb %al, %al
je 0xb2cc
leaq 0x108(%rbx), %rdi
callq 0x13086
testb %al, %al
je 0xb2eb
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 0xac36
leaq 0x208(%rsp), %rbx
movq %rbx, %rdi
callq 0x44a0
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x44a0
movq 0x2bd2d(%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 0x21dfa(%rip), %rdi     # 0x2d0cd
leaq 0x21e00(%rip), %rsi     # 0x2d0da
leaq 0x2292c(%rip), %rcx     # 0x2dc0d
movl $0xe60, %edx            # imm = 0xE60
callq 0x41c0
leaq 0x22962(%rip), %rdi     # 0x2dc54
leaq 0x21de1(%rip), %rsi     # 0x2d0da
leaq 0x2290d(%rip), %rcx     # 0x2dc0d
movl $0xe61, %edx            # imm = 0xE61
callq 0x41c0
movq %rax, %rbx
jmp 0xb31c
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x44d0
leaq 0x208(%rsp), %rdi
callq 0x44d0
movq %rbx, %rdi
callq 0x4620