// File: /workspace/github_cpp_makefile_star2_O2/BenLangmead[P]bowtie/sam.cpp
// Function: SAMHitSink::reportUnOrMax(PatternSourcePerThread&, EList<Hit, 128>*, unsigned long, bool)
void SAMHitSink::reportUnOrMax(
	PatternSourcePerThread& p,
	EList<Hit>* hs,
	size_t threadId,
	bool un)
{
	if(un) {
		HitSink::reportUnaligned(threadId, p);
		if (noUnal) {
			if (reorder_) {
				ptCounts_[threadId]++;
				maybeFlush(threadId);
			}
			return;
		}
	} else {
		HitSink::reportMaxed(*hs, threadId, p);
	}
	bool paired = !p.bufb().empty();
	assert(paired || p.bufa().mate == 0);
	assert(!paired || p.bufa().mate > 0);
	assert(un || hs->size() > 0);
	assert(!un || hs == NULL || hs->size() == 0);
	size_t hssz = 0;
	if(hs != NULL) hssz = hs->size();
	BTString& o = ptBufs_[threadId];
	for(int i = 0; i < (int)p.bufa().name.length() - (paired ? 2 : 0); i++) {
		if(!noQnameTrunc_ && isspace((int)p.bufa().name[i])) break;
		o << p.bufa().name[i];
	}
	o << '\t'
	  << (SAM_FLAG_UNMAPPED | (paired ? (SAM_FLAG_PAIRED | SAM_FLAG_FIRST_IN_PAIR | SAM_FLAG_MATE_UNMAPPED) : 0)) << "\t*"
	  << "\t0\t0\t*\t*\t0\t0\t";
	for(size_t i = 0; i < p.bufa().patFw.length(); i++) {
		o << (char)p.bufa().patFw.toChar(i);
	}
	o << '\t';
	for(size_t i = 0; i < p.bufa().qual.length(); i++) {
		o << (char)p.bufa().qual[i];
	}
	o << "\tXM:i:" << (paired ? (hssz+1)/2 : hssz);
	o << '\n';
	if(paired) {
		// truncate final 2 chars
		for(int i = 0; i < (int)p.bufb().name.length()-2; i++) {
			if(!noQnameTrunc_ && isspace((int)p.bufb().name[i])) break;
			o << p.bufb().name[i];
		}
		o << '\t'
		  << (SAM_FLAG_UNMAPPED | (paired ? (SAM_FLAG_PAIRED | SAM_FLAG_SECOND_IN_PAIR | SAM_FLAG_MATE_UNMAPPED) : 0)) << "\t*"
		  << "\t0\t0\t*\t*\t0\t0\t";
		for(size_t i = 0; i < p.bufb().patFw.length(); i++) {
			o << (char)p.bufb().patFw.toChar(i);
		}
		o << '\t';
		for(size_t i = 0; i < p.bufb().qual.length(); i++) {
			o << (char)p.bufb().qual[i];
		}
		o << "\tXM:i:" << (hssz+1)/2;
		o << '\n';
	}
	ptCounts_[threadId]++;
	if (reorder_ && reorderInfo_[threadId].flushed) {
		reorderInfo_[threadId].batchId = p.batch_id();
		reorderInfo_[threadId].flushed = false;
	}
	maybeFlush(threadId);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r15
movq %rdi, %r14
testl %r8d, %r8d
je 0x44848
movq 0x1e0(%r14), %rax
incq (%rax,%rcx,8)
leaq 0x209ca(%rip), %rax     # 0x651e1
cmpb $0x1, (%rax)
jne 0x44853
cmpb $0x1, 0x78(%r14)
jne 0x44b87
movq 0x50(%r14), %rax
incq (%rax,%rcx,8)
movq %r14, %rdi
movq %rcx, %rsi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1a78a
movq 0x1e8(%r14), %rax
incq (%rax,%rcx,8)
movq 0x38(%r15), %rdi
movq 0x50(%r15), %rax
imulq $0x268, %rax, %rsi      # imm = 0x268
movq 0x20(%rdi,%rsi), %rsi
testq %rdx, %rdx
je 0x44877
movq 0x18(%rdx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x44880
movq $0x0, 0x18(%rsp)
movq %rcx, 0x20(%rsp)
imulq $0x30, %rcx, %r12
addq 0x30(%r14), %r12
testq %rsi, %rsi
movl $0xfffffffe, %ebx       # imm = 0xFFFFFFFE
movq %rsi, 0x8(%rsp)
cmoveq %rsi, %rbx
xorl %r13d, %r13d
movq 0x18(%r15), %rcx
imulq $0x268, %rax, %rax      # imm = 0x268
movl 0x170(%rcx,%rax), %edx
addl %ebx, %edx
movslq %edx, %rdx
cmpq %rdx, %r13
jge 0x448f7
addq %rcx, %rax
addq $0x150, %rax            # imm = 0x150
movq 0x8(%rax), %rax
movsbl (%rax,%r13), %ebp
cmpb $0x0, 0x1f2(%r14)
jne 0x448e4
movl %ebp, %edi
callq 0x9070
testl %eax, %eax
jne 0x448f7
movq %r12, %rdi
movl %ebp, %esi
callq 0x45297
incq %r13
movq 0x50(%r15), %rax
jmp 0x448a1
pushq $0x9
popq %rsi
movq %r12, %rdi
callq 0x45297
movq 0x8(%rsp), %rbp
testq %rbp, %rbp
pushq $0x4
popq %rcx
pushq $0x4d
popq %rdx
cmovel %ecx, %edx
leaq 0x10(%rsp), %rsi
movl %edx, (%rsi)
movq %rax, %rdi
callq 0x452f4
movq %rax, %r13
leaq 0x7c14(%rip), %rsi      # 0x4c540
movq %rax, %rdi
callq 0x453a8
leaq 0x7c08(%rip), %rsi      # 0x4c543
movq %r13, %rdi
callq 0x453a8
xorl %r13d, %r13d
leaq 0x5e55(%rip), %rbx      # 0x4a7a2
movq 0x18(%r15), %rax
imulq $0x268, 0x50(%r15), %rcx # imm = 0x268
cmpq 0x20(%rax,%rcx), %r13
jae 0x4497d
addq %rcx, %rax
movq 0x8(%rax), %rax
movsbq (%rax,%r13), %rax
movsbl (%rax,%rbx), %esi
movq %r12, %rdi
callq 0x45297
incq %r13
jmp 0x4494d
pushq $0x9
popq %rsi
movq %r12, %rdi
callq 0x45297
xorl %r13d, %r13d
movq 0x18(%r15), %rax
imulq $0x268, 0x50(%r15), %rcx # imm = 0x268
cmpq 0x80(%rax,%rcx), %r13
jae 0x449be
addq %rcx, %rax
addq $0x60, %rax
movq 0x8(%rax), %rax
movsbl (%rax,%r13), %esi
movq %r12, %rdi
callq 0x45297
incq %r13
jmp 0x4498b
leaq 0x7b8c(%rip), %rsi      # 0x4c551
movq %r12, %rdi
callq 0x453a8
movq 0x18(%rsp), %rax
leaq 0x1(%rax), %r13
shrq %r13
testq %rbp, %rbp
cmovneq %r13, %rax
leaq 0x10(%rsp), %rsi
movq %rax, (%rsi)
movq %r12, %rdi
callq 0x45259
pushq $0xa
popq %rsi
movq %r12, %rdi
callq 0x45297
testq %rbp, %rbp
je 0x44b40
movq %r13, 0x8(%rsp)
xorl %r13d, %r13d
movq 0x38(%r15), %rax
imulq $0x268, 0x50(%r15), %rcx # imm = 0x268
movl 0x170(%rax,%rcx), %edx
addl $-0x2, %edx
movslq %edx, %rdx
cmpq %rdx, %r13
jge 0x44a60
addq %rcx, %rax
addq $0x150, %rax            # imm = 0x150
movq 0x8(%rax), %rax
movsbl (%rax,%r13), %ebp
cmpb $0x0, 0x1f2(%r14)
jne 0x44a51
movl %ebp, %edi
callq 0x9070
testl %eax, %eax
jne 0x44a60
movq %r12, %rdi
movl %ebp, %esi
callq 0x45297
incq %r13
jmp 0x44a0c
pushq $0x9
popq %rsi
movq %r12, %rdi
callq 0x45297
leaq 0x10(%rsp), %rsi
movl $0x8d, (%rsi)
movq %rax, %rdi
callq 0x452f4
movq %rax, %r13
leaq 0x7ab8(%rip), %rsi      # 0x4c540
movq %rax, %rdi
callq 0x453a8
leaq 0x7aac(%rip), %rsi      # 0x4c543
movq %r13, %rdi
callq 0x453a8
xorl %r13d, %r13d
movq 0x38(%r15), %rax
imulq $0x268, 0x50(%r15), %rcx # imm = 0x268
cmpq 0x20(%rax,%rcx), %r13
jae 0x44ad2
addq %rcx, %rax
movq 0x8(%rax), %rax
movsbq (%rax,%r13), %rax
movsbl (%rax,%rbx), %esi
movq %r12, %rdi
callq 0x45297
incq %r13
jmp 0x44aa2
pushq $0x9
popq %rsi
movq %r12, %rdi
callq 0x45297
xorl %ebx, %ebx
movq 0x8(%rsp), %r13
movq 0x38(%r15), %rax
imulq $0x268, 0x50(%r15), %rcx # imm = 0x268
cmpq 0x80(%rax,%rcx), %rbx
jae 0x44b16
addq %rcx, %rax
addq $0x60, %rax
movq 0x8(%rax), %rax
movsbl (%rax,%rbx), %esi
movq %r12, %rdi
callq 0x45297
incq %rbx
jmp 0x44ae4
leaq 0x7a34(%rip), %rsi      # 0x4c551
movq %r12, %rdi
callq 0x453a8
leaq 0x10(%rsp), %rsi
movq %r13, (%rsi)
movq %r12, %rdi
callq 0x45259
pushq $0xa
popq %rsi
movq %r12, %rdi
callq 0x45297
movq 0x50(%r14), %rax
movq 0x20(%rsp), %rsi
incq (%rax,%rsi,8)
cmpb $0x1, 0x78(%r14)
jne 0x44b7f
movq 0x88(%r14), %rcx
movq %rsi, %rax
shlq $0x4, %rax
cmpb $0x1, 0x8(%rcx,%rax)
jne 0x44b7f
addq %rax, %rcx
movq 0x78(%r15), %rdx
movq %rdx, (%rcx)
movq 0x88(%r14), %rcx
movb $0x0, 0x8(%rcx,%rax)
movq %r14, %rdi
callq 0x1a78a
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq