// File: /workspace/github_cpp_makefile_star2_O2/BenLangmead[P]bowtie/hit.cpp
// Function: VerboseHitSink::append(SStringExpandable<char, 25, 2, 0>&, Hit const&, EList<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, 128> const*, bool, int, int, bool, Bitset const&)
void VerboseHitSink::append(
	BTString& o,
	const Hit& h,
	const EList<string>* refnames,
	bool fullRef,
	int partition,
	int offBase,
	bool cost,
	const Bitset& suppress)
{
	bool spill = false;
	int spillAmt = 0;
	uint32_t pdiv = 0xffffffff;
	uint32_t pmod = 0xffffffff;
	do {
		bool dospill = false;
		if(spill) {
			// The read spilled over a partition boundary and so
			// needs to be printed more than once
			spill = false;
			dospill = true;
			spillAmt++;
		}
		assert(!spill);
		size_t field = 0;
		bool firstfield = true;
		if(partition != 0) {
			int pospart = abs(partition);
			if(!suppress.test((uint32_t)field++)) {
				if(firstfield) firstfield = false;
				else o << '\t';
				// Output a partitioning key
				// First component of the key is the reference index
				if(refnames != NULL && h.h.first < refnames->size()) {
					printUptoWs(o, (*refnames)[h.h.first], !fullRef);
				} else {
					o << h.h.first;
				}
			}
			// Next component of the key is the partition id
			if(!dospill) {
				pdiv = (h.h.second + offBase) / pospart;
				pmod = (h.h.second + offBase) % pospart;
			}
			assert_neq(0xffffffff, pdiv);
			assert_neq(0xffffffff, pmod);
			if(dospill) assert_gt(spillAmt, 0);
			if(partition > 0 &&
			   (pmod + h.length()) >= ((uint32_t)pospart * (spillAmt + 1))) {
				// Spills into the next partition so we need to
				// output another alignment for that partition
				spill = true;
			}
			if(!suppress.test((uint32_t)field++)) {
				if(firstfield) {
					firstfield = false;
				} else {
					o << '\t';
				}
				// Print partition id with leading 0s so that Hadoop
				// can do lexicographical sort (modern Hadoop versions
				// seen to support numeric)
				int padding = 10;
				uint32_t part = (pdiv + (dospill ? spillAmt : 0));
				uint32_t parttmp = part;
				while(parttmp > 0) {
					padding--;
					parttmp /= 10;
				}
				assert_geq(padding, 0);
				for(int i = 0; i < padding; i++) {
					o << '0';
				}
				o << part;
			}
			if(!suppress.test((uint32_t)field++)) {
				if(firstfield) {
					firstfield = false;
				} else {
					o << '\t';
				}
				// Print offset with leading 0s
				int padding = 9;
				uint32_t off = h.h.second + offBase;
				uint32_t offtmp = off;
				while(offtmp > 0) {
					padding--;
					offtmp /= 10;
				}
				assert_geq(padding, 0);
				for(int i = 0; i < padding; i++) {
					o << '0';
				}
				o << off;
			}
			if(!suppress.test((uint32_t)field++)) {
				if(firstfield) firstfield = false;
				else o << '\t';
				o << (h.fw? "+":"-");
			}
			// end if(partition != 0)
		} else {
			assert(!dospill);
			if(!suppress.test((uint32_t)field++)) {
				if(firstfield) firstfield = false;
				else o << '\t';
				for (size_t i = 0; i < h.patName.length(); i++)
					o << h.patName[i];
			}
			if(!suppress.test((uint32_t)field++)) {
				if(firstfield) firstfield = false;
				else o << '\t';
				o << (h.fw? '+' : '-');
			}
			if(!suppress.test((uint32_t)field++)) {
				if(firstfield) firstfield = false;
				else o << '\t';
				// .first is text id, .second is offset
				if(refnames != NULL && h.h.first < refnames->size()) {
					printUptoWs(o, (*refnames)[h.h.first], !fullRef);
				} else {
					o << h.h.first;
				}
			}
			if(!suppress.test((uint32_t)field++)) {
				if(firstfield) firstfield = false;
				else o << '\t';
				o << (h.h.second + offBase);
			}
			// end else clause of if(partition != 0)
		}
		if(!suppress.test((uint32_t)field++)) {
			if(firstfield) firstfield = false;
			else o << '\t';
			o << h.patSeq.toZBuf();
		}
		if(!suppress.test((uint32_t)field++)) {
			if(firstfield) firstfield = false;
			else o << '\t';
			o << h.quals.toZBuf();
		}
		if(!suppress.test((uint32_t)field++)) {
			if(firstfield) firstfield = false;
			else o << '\t';
			o << h.oms;
		}
		if(!suppress.test((uint32_t)field++)) {
			if(firstfield) firstfield = false;
			else o << '\t';
			// Output mismatch column
			bool firstmm = true;
			for (unsigned int i = 0; i < h.patSeq.length(); ++ i) {
				if(h.mms.test(i)) {
					// There's a mismatch at this position
					if (!firstmm) {
						o << ",";
					}
					o << i; // position
					assert_gt(h.refcs.size(), i);
					char refChar = toupper(h.refcs[i]);
					char qryChar = (h.fw ? h.patSeq.toChar(i) : h.patSeq.toChar(h.patSeq.length()-i-1));
					assert_neq(refChar, qryChar);
					o << ":" << refChar << ">" << qryChar;
					firstmm = false;
				}
			}
			if(partition != 0 && firstmm) o << '-';
		}
		if(partition != 0) {
			// Fields addded as of Crossbow 0.1.4
			if(!suppress.test((uint32_t)field++)) {
				if(firstfield) firstfield = false;
				else o << '\t';
				o << (int)h.mate;
			}
			// Print label, or whole read name if label isn't found
			if(!suppress.test((uint32_t)field++)) {
				if(firstfield) firstfield = false;
				else o << '\t';
				int labelOff = -1;
				// If LB: field is present, print its value
				for(int i = 0; i < (int)h.patName.length() - 3; i++) {
					if(h.patName[i]   == 'L' &&
					   h.patName[i+1] == 'B' &&
					   h.patName[i+2] == ':' &&
					   ((i == 0) || h.patName[i-1] == ';'))
					{
						labelOff = i+3;
						for(int j = labelOff; j < (int)h.patName.length(); j++) {
							if(h.patName[j] != ';') {
								o << h.patName[j];
							} else {
								break;
							}
						}
					}
				}
				// Otherwise, print the whole read name
				if(labelOff == -1) {
					for (size_t i = 0; i < h.patName.length(); i++)
						o << h.patName[i];
				}
			}
		}
		if(cost) {
			// Stratum
			if(!suppress.test((uint32_t)field++)) {
				if(firstfield) firstfield = false;
				else o << '\t';
				o << (int)h.stratum;
			}
			// Cost
			if(!suppress.test((uint32_t)field++)) {
				if(firstfield) firstfield = false;
				else o << '\t';
				o << (int)h.cost;
			}
		}
		if(showSeed) {
			// Seed
			if(!suppress.test((uint32_t)field++)) {
				if(firstfield) firstfield = false;
				else o << '\t';
				o << h.seed;
			}
		}
		o << '\n';
	} while(spill);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %r9d, 0x10(%rsp)
movq %rdx, 0x20(%rsp)
movq %rsi, %r12
movq %rdi, %r13
movq 0x98(%rsp), %rbx
movl %r8d, %eax
negl %eax
movl %r8d, 0xc(%rsp)
cmovsl %r8d, %eax
movl %eax, 0x18(%rsp)
xorb $0x1, %cl
movl %ecx, 0x34(%rsp)
leaq 0x48(%rsi), %rax
movq %rax, 0x50(%rsp)
leaq 0x91(%rsi), %rax
movq %rax, 0x40(%rsp)
leaq 0x178(%rsi), %rax
movq %rax, 0x48(%rsp)
leaq 0x18c(%rsi), %rax
movq %rax, 0x38(%rsp)
pushq $-0x1
popq %rax
movl %eax, 0x14(%rsp)
movl %eax, 0x1c(%rsp)
movq $0x0, 0x28(%rsp)
xorl %r14d, %r14d
movq 0x28(%rsp), %rcx
leal 0x1(%rcx), %eax
testb $0x1, %r14b
movl $0x0, %ebp
cmovnel %eax, %ebp
cmovnel %eax, %ecx
movq %rcx, 0x28(%rsp)
movzbl %r14b, %r15d
movl $0x0, %eax
cmovnel %eax, %r15d
movl 0x10(%rbx), %eax
movzbl 0x34(%rsp), %ecx
movl %ecx, 0x8(%rsp)
cmpl $0x0, 0xc(%rsp)
je 0x457ea
testl %eax, %eax
je 0x457c0
movq 0x18(%rbx), %rax
movb $0x1, %cl
testb $0x1, (%rax)
jne 0x4582a
movq 0x20(%rsp), %rax
testq %rax, %rax
je 0x4581d
movl (%r12), %esi
cmpq %rsi, 0x18(%rax)
jbe 0x4581d
shlq $0x5, %rsi
addq 0x8(%rax), %rsi
movq %r13, %rdi
movl 0x8(%rsp), %edx
callq 0x451d8
jmp 0x45828
testl %eax, %eax
je 0x457fe
movq 0x18(%rbx), %rcx
movb $0x1, %r14b
testb $0x1, (%rcx)
jne 0x45887
xorl %ebx, %ebx
cmpq 0x38(%r12), %rbx
jae 0x45879
movq 0x20(%r12), %rax
movsbl (%rax,%rbx), %esi
movq %r13, %rdi
callq 0x45297
incq %rbx
jmp 0x45800
movq %r13, %rdi
movq %r12, %rsi
callq 0x452b8
xorl %ecx, %ecx
testb $0x1, %r14b
jne 0x45847
movl 0x4(%r12), %eax
addl 0x10(%rsp), %eax
xorl %edx, %edx
divl 0x18(%rsp)
movl %edx, 0x14(%rsp)
movl %eax, 0x1c(%rsp)
cmpl $0x0, 0xc(%rsp)
movl %ecx, %r14d
jle 0x458aa
movl 0x14(%rsp), %eax
addq 0x68(%r12), %rax
movq 0x28(%rsp), %rcx
incl %ecx
imull 0x18(%rsp), %ecx
cmpq %rcx, %rax
movzbl %r15b, %ecx
pushq $0x1
popq %rax
cmovael %eax, %ecx
movl %ecx, 0x8(%rsp)
jmp 0x458af
movq 0x98(%rsp), %rbx
movl 0x10(%rbx), %eax
xorl %r14d, %r14d
cmpl $0x2, %eax
jb 0x45899
movq 0x18(%rbx), %rcx
testb $0x2, (%rcx)
jne 0x45a16
testb %r14b, %r14b
je 0x459ed
xorl %r14d, %r14d
jmp 0x459f8
movl %r15d, 0x8(%rsp)
movl 0x10(%rbx), %eax
cmpl $0x2, %eax
jb 0x458c0
movq 0x18(%rbx), %rcx
testb $0x2, (%rcx)
jne 0x45927
testb %r14b, %r14b
je 0x458ca
xorl %r14d, %r14d
jmp 0x458d5
movq %r13, %rdi
pushq $0x9
popq %rsi
callq 0x45297
pushq $0xa
popq %rcx
addl 0x1c(%rsp), %ebp
movl %ebp, 0x4(%rsp)
movl %ecx, %ebx
testl %ebp, %ebp
je 0x458f2
decl %ebx
movl %ebp, %eax
xorl %edx, %edx
divl %ecx
movl %eax, %ebp
jmp 0x458e2
testl %ebx, %ebx
movl $0x0, %eax
cmovlel %eax, %ebx
pushq $0x30
popq %rbp
movq %r13, %rdi
subl $0x1, %ebx
jb 0x45910
movl %ebp, %esi
callq 0x45297
jmp 0x458ff
leaq 0x4(%rsp), %rsi
callq 0x452b8
movq 0x98(%rsp), %rbx
movl 0x10(%rbx), %eax
jmp 0x4592a
pushq $0x30
popq %rbp
cmpl $0x3, %eax
jb 0x45938
movq 0x18(%rbx), %rcx
testb $0x4, (%rcx)
jne 0x4599e
testb %r14b, %r14b
je 0x45945
xorl %r14d, %r14d
pushq $0x9
popq %rbx
jmp 0x45952
movq %r13, %rdi
pushq $0x9
popq %rbx
movl %ebx, %esi
callq 0x45297
pushq $0xa
popq %rcx
movl 0x4(%r12), %eax
addl 0x10(%rsp), %eax
movl %eax, 0x4(%rsp)
testl %eax, %eax
je 0x4596e
decl %ebx
xorl %edx, %edx
divl %ecx
jmp 0x45962
testl %ebx, %ebx
movl $0x0, %eax
cmovlel %eax, %ebx
movq %r13, %rdi
subl $0x1, %ebx
jb 0x45989
movl %ebp, %esi
callq 0x45297
jmp 0x45978
leaq 0x4(%rsp), %rsi
callq 0x452b8
movq 0x98(%rsp), %rbx
movl 0x10(%rbx), %eax
cmpl $0x4, %eax
jb 0x459b0
movq 0x18(%rbx), %rax
testb $0x8, (%rax)
jne 0x45ab1
testb %r14b, %r14b
je 0x459ba
xorl %r14d, %r14d
jmp 0x459c5
movq %r13, %rdi
pushq $0x9
popq %rsi
callq 0x45297
cmpb $0x0, 0x17c(%r12)
leaq 0x5252(%rip), %rsi      # 0x4ac27
leaq 0x6a04(%rip), %rax      # 0x4c3e0
cmovneq %rax, %rsi
movq %r13, %rdi
callq 0x453a8
jmp 0x45ab1
movq %r13, %rdi
pushq $0x9
popq %rsi
callq 0x45297
movzbl 0x17c(%r12), %eax
xorl $0x1, %eax
leal 0x2b(,%rax,2), %esi
movq %r13, %rdi
callq 0x45297
movl 0x10(%rbx), %eax
cmpl $0x3, %eax
jb 0x45a24
movq 0x18(%rbx), %rax
testb $0x4, (%rax)
jne 0x45a6e
testb %r14b, %r14b
je 0x45a2e
xorl %r14d, %r14d
jmp 0x45a39
movq %r13, %rdi
pushq $0x9
popq %rsi
callq 0x45297
movq 0x20(%rsp), %rax
testq %rax, %rax
je 0x45a63
movl (%r12), %esi
cmpq %rsi, 0x18(%rax)
jbe 0x45a63
shlq $0x5, %rsi
addq 0x8(%rax), %rsi
movq %r13, %rdi
movl 0x8(%rsp), %edx
callq 0x451d8
jmp 0x45a6e
movq %r13, %rdi
movq %r12, %rsi
callq 0x452b8
cmpl $0x4, 0x10(%rbx)
jb 0x45a7d
movq 0x18(%rbx), %rax
testb $0x8, (%rax)
jne 0x45aac
testb %r14b, %r14b
je 0x45a87
xorl %r14d, %r14d
jmp 0x45a92
movq %r13, %rdi
pushq $0x9
popq %rsi
callq 0x45297
movl 0x4(%r12), %eax
addl 0x10(%rsp), %eax
movl %eax, 0x4(%rsp)
movq %r13, %rdi
leaq 0x4(%rsp), %rsi
callq 0x452b8
movl %r15d, 0x8(%rsp)
movl 0x10(%rbx), %eax
cmpl $0x5, %eax
jb 0x45ac2
movq 0x18(%rbx), %rcx
testb $0x10, (%rcx)
jne 0x45aef
testb %r14b, %r14b
je 0x45acc
xorl %r14d, %r14d
jmp 0x45ad7
movq %r13, %rdi
pushq $0x9
popq %rsi
callq 0x45297
movq 0x50(%rsp), %rdi
callq 0x1d988
movq %r13, %rdi
movq %rax, %rsi
callq 0x453a8
movl 0x10(%rbx), %eax
cmpl $0x6, %eax
jb 0x45afd
movq 0x18(%rbx), %rcx
testb $0x20, (%rcx)
jne 0x45b48
testb %r14b, %r14b
je 0x45b07
xorl %r14d, %r14d
jmp 0x45b12
movq %r13, %rdi
pushq $0x9
popq %rsi
callq 0x45297
movq 0x98(%r12), %rax
testq %rax, %rax
je 0x45b35
movq 0x80(%r12), %rcx
movb $0x0, (%rcx,%rax)
movq 0x80(%r12), %rsi
jmp 0x45b3d
movq 0x40(%rsp), %rsi
movb $0x0, (%rsi)
movq %r13, %rdi
callq 0x453a8
movl 0x10(%rbx), %eax
cmpl $0x7, %eax
jb 0x45b56
movq 0x18(%rbx), %rcx
testb $0x40, (%rcx)
jne 0x45b7b
testb %r14b, %r14b
je 0x45b60
xorl %r14d, %r14d
jmp 0x45b6b
movq %r13, %rdi
pushq $0x9
popq %rsi
callq 0x45297
movq %r13, %rdi
movq 0x48(%rsp), %rsi
callq 0x452b8
movl 0x10(%rbx), %eax
cmpl $0x8, %eax
jb 0x45b8d
movq 0x18(%rbx), %rax
testb $-0x80, (%rax)
jne 0x45cad
xorl %ebp, %ebp
movl $0x0, %ebx
testb %r14b, %r14b
jne 0x45ba7
movq %r13, %rdi
pushq $0x9
popq %rsi
callq 0x45297
movl %r14d, %ebx
movb $0x1, %al
movl %ebp, 0x4(%rsp)
movl %ebp, %ecx
cmpq %rcx, 0x68(%r12)
jbe 0x45c7f
movl %ebp, %ecx
shrl $0x5, %ecx
movl 0xb0(%r12,%rcx,4), %ecx
btl %ebp, %ecx
jae 0x45c78
testb $0x1, %al
jne 0x45be3
movq %r13, %rdi
leaq 0x5861(%rip), %rsi      # 0x4b43f
callq 0x453a8
movq %r13, %rdi
leaq 0x4(%rsp), %rsi
callq 0x452b8
movl 0x4(%rsp), %r14d
movq 0x140(%r12), %rax
movsbl (%rax,%r14), %edi
callq 0x99b0
movl %eax, %ebp
movq 0x50(%r12), %rax
leaq (%rax,%r14), %rcx
addq 0x68(%r12), %rax
notq %r14
addq %r14, %rax
cmpb $0x0, 0x17c(%r12)
cmovneq %rcx, %rax
movsbq (%rax), %rax
leaq 0x4b6d(%rip), %rcx      # 0x4a7a2
movsbl (%rax,%rcx), %r15d
movq %r13, %rdi
leaq 0x2311(%rip), %rsi      # 0x47f55
callq 0x453a8
movsbl %bpl, %esi
movq %r13, %rdi
callq 0x45297
movq %rax, %rbp
movq %rax, %rdi
leaq 0x4d45(%rip), %rsi      # 0x4a9a7
callq 0x453a8
movq %rbp, %rdi
movl %r15d, %esi
callq 0x45297
xorl %eax, %eax
movl 0x4(%rsp), %ebp
incl %ebp
jmp 0x45ba9
cmpl $0x0, 0xc(%rsp)
je 0x45ca2
testb $0x1, %al
je 0x45c95
movq %r13, %rdi
pushq $0x2d
popq %rsi
callq 0x45297
movl %ebx, %r14d
movq 0x98(%rsp), %rbx
jmp 0x45cbb
pushq $0x8
popq %rbp
movl %ebx, %r14d
jmp 0x45da5
pushq $0x8
popq %rbp
cmpl $0x0, 0xc(%rsp)
je 0x45dad
movl 0x10(%rbx), %eax
cmpl $0x9, %eax
jb 0x45ccd
movq 0x18(%rbx), %rcx
testb $0x1, 0x1(%rcx)
jne 0x45cff
testb %r14b, %r14b
je 0x45cd7
xorl %r14d, %r14d
jmp 0x45ce2
movq %r13, %rdi
pushq $0x9
popq %rsi
callq 0x45297
movzbl 0x188(%r12), %eax
movl %eax, 0x4(%rsp)
movq %r13, %rdi
leaq 0x4(%rsp), %rsi
callq 0x452f4
movl 0x10(%rbx), %eax
cmpl $0xa, %eax
jb 0x45d12
movq 0x18(%rbx), %rax
testb $0x2, 0x1(%rax)
jne 0x45df8
testb %r14b, %r14b
je 0x45d1c
xorl %r14d, %r14d
jmp 0x45d27
movq %r13, %rdi
pushq $0x9
popq %rsi
callq 0x45297
movq 0x38(%r12), %rax
xorl %ebx, %ebx
pushq $0x3
popq %r15
pushq $-0x1
popq %rcx
leal -0x3(%rax), %edx
movslq %edx, %rdx
cmpq %rdx, %rbx
jge 0x45d9d
movq 0x20(%r12), %rdx
cmpb $0x4c, (%rdx,%rbx)
jne 0x45d95
cmpb $0x42, 0x1(%rdx,%rbx)
jne 0x45d95
cmpb $0x3a, 0x2(%rdx,%rbx)
jne 0x45d95
testq %rbx, %rbx
je 0x45d65
cmpb $0x3b, -0x1(%rdx,%rbx)
jne 0x45d95
movq %r15, %rbp
movslq %eax, %rcx
cmpq %rcx, %rbp
jge 0x45d92
movq 0x20(%r12), %rcx
movb (%rcx,%rbp), %cl
cmpb $0x3b, %cl
je 0x45d92
movsbl %cl, %esi
movq %r13, %rdi
callq 0x45297
incq %rbp
movq 0x38(%r12), %rax
jmp 0x45d68
leal 0x3(%rbx), %ecx
incq %rbx
incq %r15
jmp 0x45d35
cmpl $-0x1, %ecx
je 0x45dd6
pushq $0xa
popq %rbp
movq 0x98(%rsp), %rbx
cmpb $0x0, 0x90(%rsp)
je 0x45e67
movl %ebp, %r15d
movq %rbx, %rdi
movl %ebp, %esi
callq 0x45ee0
testb %al, %al
jne 0x45e22
testb %r14b, %r14b
je 0x45dfd
xorl %r14d, %r14d
jmp 0x45e08
xorl %ebx, %ebx
cmpq %rax, %rbx
jae 0x45da2
movq 0x20(%r12), %rax
movsbl (%rax,%rbx), %esi
movq %r13, %rdi
callq 0x45297
incq %rbx
movq 0x38(%r12), %rax
jmp 0x45dd8
pushq $0xa
popq %rbp
jmp 0x45dad
movq %r13, %rdi
pushq $0x9
popq %rsi
callq 0x45297
movsbl 0x180(%r12), %eax
movl %eax, 0x4(%rsp)
movq %r13, %rdi
leaq 0x4(%rsp), %rsi
callq 0x452f4
addq $0x2, %rbp
orl $0x1, %r15d
movq %rbx, %rdi
movl %r15d, %esi
callq 0x45ee0
testb %al, %al
jne 0x45e67
testb %r14b, %r14b
je 0x45e43
xorl %r14d, %r14d
jmp 0x45e4e
movq %r13, %rdi
pushq $0x9
popq %rsi
callq 0x45297
movl 0x184(%r12), %eax
movl %eax, 0x4(%rsp)
movq %r13, %rdi
leaq 0x4(%rsp), %rsi
callq 0x452f4
leaq 0x1f2ea(%rip), %rax     # 0x65158
cmpb $0x1, (%rax)
jne 0x45e9e
movq %rbx, %rdi
movl %ebp, %esi
callq 0x45ee0
testb %al, %al
jne 0x45e9e
testb %r14b, %r14b
jne 0x45e91
movq %r13, %rdi
pushq $0x9
popq %rsi
callq 0x45297
movq %r13, %rdi
movq 0x38(%rsp), %rsi
callq 0x452b8
movq %r13, %rdi
pushq $0xa
popq %rsi
callq 0x45297
movl 0x8(%rsp), %r14d
testb $0x1, %r14b
jne 0x45775
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq