// File: /workspace/github_cpp_makefile_star2_O3/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
testl %r8d, %r8d
je 0x4f08f
movq 0x1e0(%rdi), %rax
incq (%rax,%rcx,8)
leaq 0x1e183(%rip), %rax     # 0x6d1d1
cmpb $0x1, (%rax)
jne 0x4f09a
cmpb $0x1, 0x78(%rdi)
jne 0x4f4f5
movq 0x50(%rdi), %rax
incq (%rax,%rcx,8)
movq 0x50(%rdi), %rax
movq (%rax,%rcx,8), %rax
cmpq 0x68(%rdi), %rax
jb 0x4f4f5
movq %rcx, %rsi
xorl %edx, %edx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x20cb8
movq 0x1e8(%rdi), %rax
incq (%rax,%rcx,8)
movq 0x38(%r15), %rsi
imulq $0x268, 0x50(%r15), %rax # imm = 0x268
movq 0x20(%rsi,%rax), %rsi
movq %rsi, 0x8(%rsp)
testq %rdx, %rdx
je 0x4f0c0
movq 0x18(%rdx), %rdx
movq %rdx, 0x10(%rsp)
jmp 0x4f0c9
movq $0x0, 0x10(%rsp)
xorl %edx, %edx
cmpq $0x0, 0x8(%rsp)
sete %dl
movq %rcx, 0x20(%rsp)
leaq (%rcx,%rcx,2), %r12
shlq $0x4, %r12
movq %rdi, 0x18(%rsp)
addq 0x30(%rdi), %r12
leal -0x2(,%rdx,2), %ebp
movq 0x18(%r15), %rcx
movl 0x170(%rcx,%rax), %edx
addl %ebp, %edx
testl %edx, %edx
jle 0x4f167
addq %rcx, %rax
addq $0x150, %rax            # imm = 0x150
xorl %ebx, %ebx
movq %rsp, %r13
movq 0x8(%rax), %rax
movb (%rax,%rbx), %r14b
movq 0x18(%rsp), %rax
cmpb $0x0, 0x1f2(%rax)
jne 0x4f133
movsbl %r14b, %edi
callq 0x9080
testl %eax, %eax
jne 0x4f167
movb %r14b, (%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x4dc0a
incq %rbx
movq 0x18(%r15), %rax
imulq $0x268, 0x50(%r15), %rcx # imm = 0x268
addq %rcx, %rax
addq $0x150, %rax            # imm = 0x150
movl 0x20(%rax), %ecx
addl %ebp, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rbx
jl 0x4f110
movq %rsp, %r13
movb $0x9, (%r13)
movq %r12, %rdi
movq %r13, %rsi
callq 0x4dc0a
cmpq $0x0, 0x8(%rsp)
movl $0x4, %eax
movl $0x4d, %ecx
cmovel %eax, %ecx
movl %ecx, (%r13)
movq %rsp, %rsi
movq %r12, %rdi
callq 0x4fe23
movq %rax, %r13
leaq 0x845c(%rip), %rsi      # 0x57602
movl $0x2, %edx
movq %rax, %rdi
callq 0x4fee0
leaq 0x844b(%rip), %rsi      # 0x57605
movl $0xd, %edx
movq %r13, %rdi
callq 0x4fee0
movq 0x18(%r15), %rax
imulq $0x268, 0x50(%r15), %rcx # imm = 0x268
cmpq $0x0, 0x20(%rax,%rcx)
je 0x4f21e
addq %rcx, %rax
xorl %ebx, %ebx
leaq 0x6650(%rip), %rbp      # 0x55837
movq %rsp, %r13
movq 0x8(%rax), %rax
movsbq (%rax,%rbx), %rax
movb (%rax,%rbp), %al
movb %al, (%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x4dc0a
incq %rbx
imulq $0x268, 0x50(%r15), %rcx # imm = 0x268
movq 0x18(%r15), %rdx
leaq (%rdx,%rcx), %rax
cmpq 0x20(%rdx,%rcx), %rbx
jb 0x4f1ea
movq %rsp, %rsi
movb $0x9, (%rsi)
movq %r12, %rdi
callq 0x4dc0a
movq 0x18(%r15), %rax
imulq $0x268, 0x50(%r15), %rcx # imm = 0x268
cmpq $0x0, 0x80(%rax,%rcx)
movq 0x18(%rsp), %r14
je 0x4f285
addq %rcx, %rax
addq $0x60, %rax
xorl %ebx, %ebx
movq %rsp, %r13
movq 0x8(%rax), %rax
movb (%rax,%rbx), %al
movb %al, (%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x4dc0a
incq %rbx
imulq $0x268, 0x50(%r15), %rax # imm = 0x268
movq 0x18(%r15), %rcx
addq %rcx, %rax
addq $0x60, %rax
cmpq 0x20(%rax), %rbx
jb 0x4f254
leaq 0x8387(%rip), %rsi      # 0x57613
movl $0x6, %edx
movq %r12, %rdi
callq 0x4fee0
movq 0x10(%rsp), %rax
leaq 0x1(%rax), %rbp
shrq %rbp
movq 0x8(%rsp), %rbx
testq %rbx, %rbx
cmovneq %rbp, %rax
movq %rsp, %r13
movq %rax, (%r13)
movq %r12, %rdi
movq %r13, %rsi
callq 0x4fcda
movb $0xa, (%r13)
movq %rsp, %rsi
movq %r12, %rdi
callq 0x4dc0a
testq %rbx, %rbx
je 0x4f49e
movq %rbp, 0x8(%rsp)
movq 0x38(%r15), %rax
imulq $0x268, 0x50(%r15), %rcx # imm = 0x268
cmpl $0x3, 0x170(%rax,%rcx)
jl 0x4f359
addq %rcx, %rax
addq $0x150, %rax            # imm = 0x150
xorl %ebx, %ebx
movq %rsp, %r13
movq 0x8(%rax), %rax
movb (%rax,%rbx), %bpl
cmpb $0x0, 0x1f2(%r14)
jne 0x4f324
movsbl %bpl, %edi
callq 0x9080
testl %eax, %eax
jne 0x4f359
movb %bpl, (%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x4dc0a
incq %rbx
movq 0x38(%r15), %rax
imulq $0x268, 0x50(%r15), %rcx # imm = 0x268
addq %rcx, %rax
addq $0x150, %rax            # imm = 0x150
movl 0x20(%rax), %ecx
addl $-0x2, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rbx
jl 0x4f305
movq %rsp, %r13
movb $0x9, (%r13)
movq %r12, %rdi
movq %r13, %rsi
callq 0x4dc0a
movl $0x8d, (%r13)
movq %rsp, %rsi
movq %r12, %rdi
callq 0x4fe23
movq %rax, %r13
leaq 0x8279(%rip), %rsi      # 0x57602
movl $0x2, %edx
movq %rax, %rdi
callq 0x4fee0
leaq 0x8268(%rip), %rsi      # 0x57605
movl $0xd, %edx
movq %r13, %rdi
callq 0x4fee0
movq 0x38(%r15), %rax
imulq $0x268, 0x50(%r15), %rcx # imm = 0x268
cmpq $0x0, 0x20(%rax,%rcx)
je 0x4f401
addq %rcx, %rax
xorl %ebx, %ebx
leaq 0x646d(%rip), %rbp      # 0x55837
movq %rsp, %r13
movq 0x8(%rax), %rax
movsbq (%rax,%rbx), %rax
movb (%rax,%rbp), %al
movb %al, (%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x4dc0a
incq %rbx
imulq $0x268, 0x50(%r15), %rcx # imm = 0x268
movq 0x38(%r15), %rdx
leaq (%rdx,%rcx), %rax
cmpq 0x20(%rdx,%rcx), %rbx
jb 0x4f3cd
movq %rsp, %rsi
movb $0x9, (%rsi)
movq %r12, %rdi
callq 0x4dc0a
movq 0x38(%r15), %rax
imulq $0x268, 0x50(%r15), %rcx # imm = 0x268
cmpq $0x0, 0x80(%rax,%rcx)
je 0x4f463
addq %rcx, %rax
addq $0x60, %rax
xorl %ebx, %ebx
movq %rsp, %r13
movq 0x8(%rax), %rax
movb (%rax,%rbx), %al
movb %al, (%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x4dc0a
incq %rbx
imulq $0x268, 0x50(%r15), %rax # imm = 0x268
movq 0x38(%r15), %rcx
addq %rcx, %rax
addq $0x60, %rax
cmpq 0x20(%rax), %rbx
jb 0x4f432
leaq 0x81a9(%rip), %rsi      # 0x57613
movl $0x6, %edx
movq %r12, %rdi
callq 0x4fee0
movq %rsp, %r13
movq 0x8(%rsp), %rax
movq %rax, (%r13)
movq %r12, %rdi
movq %r13, %rsi
callq 0x4fcda
movb $0xa, (%r13)
movq %rsp, %rsi
movq %r12, %rdi
callq 0x4dc0a
movq 0x50(%r14), %rax
movq 0x20(%rsp), %rsi
incq (%rax,%rsi,8)
cmpb $0x1, 0x78(%r14)
jne 0x4f4dd
movq 0x88(%r14), %rcx
movq %rsi, %rax
shlq $0x4, %rax
cmpb $0x1, 0x8(%rcx,%rax)
jne 0x4f4dd
addq %rax, %rcx
movq 0x78(%r15), %rdx
movq %rdx, (%rcx)
movq 0x88(%r14), %rcx
movb $0x0, 0x8(%rcx,%rax)
movq 0x50(%r14), %rax
movq (%rax,%rsi,8), %rax
cmpq 0x68(%r14), %rax
jb 0x4f4f5
movq %r14, %rdi
xorl %edx, %edx
callq 0x20cb8
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq