// File: /workspace/github_cpp_makefile_star2_O1/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 0x503ee
movq 0x1e0(%r14), %rax
incq (%rax,%rcx,8)
leaq 0x1de00(%rip), %rax     # 0x6e1d1
cmpb $0x1, (%rax)
jne 0x503f9
cmpb $0x1, 0x78(%r14)
jne 0x5086b
movq 0x50(%r14), %rax
incq (%rax,%rcx,8)
jmp 0x50850
movq 0x1e8(%r14), %rax
incq (%rax,%rcx,8)
movq 0x38(%r15), %rax
imulq $0x268, 0x50(%r15), %rsi # imm = 0x268
movq 0x20(%rax,%rsi), %rsi
testq %rdx, %rdx
je 0x5041a
movq 0x18(%rdx), %rax
movq %rax, 0x18(%rsp)
jmp 0x50423
movq $0x0, 0x18(%rsp)
xorl %eax, %eax
movq %rsi, 0x8(%rsp)
testq %rsi, %rsi
sete %al
movq %rcx, 0x20(%rsp)
leaq (%rcx,%rcx,2), %r12
shlq $0x4, %r12
movq %r14, 0x10(%rsp)
addq 0x30(%r14), %r12
leal -0x2(,%rax,2), %ebp
imulq $0x268, 0x50(%r15), %rax # imm = 0x268
movq 0x18(%r15), %rcx
movl 0x170(%rcx,%rax), %edx
addl %ebp, %edx
testl %edx, %edx
jle 0x504d1
leaq (%rcx,%rax), %r14
addq $0x150, %r14            # imm = 0x150
xorl %ebx, %ebx
movq %rsp, %r13
movq 0x10(%rsp), %rax
cmpb $0x0, 0x1f2(%rax)
jne 0x50495
movq 0x8(%r14), %rax
movsbl (%rax,%rbx), %edi
callq 0x9080
testl %eax, %eax
jne 0x504d1
movq 0x8(%r14), %rax
movb (%rax,%rbx), %al
movb %al, (%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x4f02e
incq %rbx
movq 0x18(%r15), %rax
imulq $0x268, 0x50(%r15), %rcx # imm = 0x268
leaq (%rax,%rcx), %r14
addq $0x150, %r14            # imm = 0x150
movl 0x20(%r14), %eax
addl %ebp, %eax
cltq
cmpq %rax, %rbx
jl 0x50476
movq %rsp, %r13
movb $0x9, (%r13)
movq %r12, %rdi
movq %r13, %rsi
callq 0x4f02e
movq 0x8(%rsp), %rbp
testq %rbp, %rbp
movl $0x4, %eax
movl $0x4d, %ecx
cmovel %eax, %ecx
movl %ecx, (%r13)
movq %rsp, %rsi
movq %r12, %rdi
callq 0x511ff
movq %rax, %r13
leaq 0x800e(%rip), %rsi      # 0x58520
movl $0x2, %edx
movq %rax, %rdi
callq 0x512bc
leaq 0x7ffd(%rip), %rsi      # 0x58523
movl $0xd, %edx
movq %r13, %rdi
callq 0x512bc
movq 0x18(%r15), %rax
imulq $0x268, 0x50(%r15), %rcx # imm = 0x268
cmpq $0x0, 0x20(%rax,%rcx)
je 0x5058b
addq %rcx, %rax
xorl %ebx, %ebx
leaq 0x6204(%rip), %r14      # 0x56757
movq %rsp, %r13
movq 0x8(%rax), %rax
movsbq (%rax,%rbx), %rax
movb (%rax,%r14), %al
movb %al, (%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x4f02e
incq %rbx
imulq $0x268, 0x50(%r15), %rcx # imm = 0x268
movq 0x18(%r15), %rdx
leaq (%rdx,%rcx), %rax
cmpq 0x20(%rdx,%rcx), %rbx
jb 0x50556
movq %rsp, %rsi
movb $0x9, (%rsi)
movq %r12, %rdi
callq 0x4f02e
movq 0x18(%r15), %rax
imulq $0x268, 0x50(%r15), %rcx # imm = 0x268
cmpq $0x0, 0x80(%rax,%rcx)
je 0x505ed
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 0x4f02e
incq %rbx
imulq $0x268, 0x50(%r15), %rax # imm = 0x268
movq 0x18(%r15), %rcx
addq %rcx, %rax
addq $0x60, %rax
cmpq 0x20(%rax), %rbx
jb 0x505bc
leaq 0x7f3d(%rip), %rsi      # 0x58531
movl $0x6, %edx
movq %r12, %rdi
callq 0x512bc
movq 0x18(%rsp), %rax
leaq 0x1(%rax), %rbx
shrq %rbx
testq %rbp, %rbp
cmovneq %rbx, %rax
movq %rsp, %r13
movq %rax, (%r13)
movq %r12, %rdi
movq %r13, %rsi
callq 0x510b6
movb $0xa, (%r13)
movq %rsp, %rsi
movq %r12, %rdi
callq 0x4f02e
testq %rbp, %rbp
movq 0x10(%rsp), %r14
je 0x50811
movq %rbx, 0x8(%rsp)
movq 0x38(%r15), %rax
imulq $0x268, 0x50(%r15), %rcx # imm = 0x268
cmpl $0x3, 0x170(%rax,%rcx)
jl 0x506c6
leaq (%rax,%rcx), %rbp
addq $0x150, %rbp            # imm = 0x150
xorl %ebx, %ebx
movq %rsp, %r13
cmpb $0x0, 0x1f2(%r14)
jne 0x5068a
movq 0x8(%rbp), %rax
movsbl (%rax,%rbx), %edi
callq 0x9080
testl %eax, %eax
jne 0x506c6
movq 0x8(%rbp), %rax
movb (%rax,%rbx), %al
movb %al, (%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x4f02e
incq %rbx
movq 0x38(%r15), %rax
imulq $0x268, 0x50(%r15), %rcx # imm = 0x268
leaq (%rax,%rcx), %rbp
addq $0x150, %rbp            # imm = 0x150
movl 0x20(%rbp), %eax
addl $-0x2, %eax
cltq
cmpq %rax, %rbx
jl 0x5066f
movq %rsp, %r13
movb $0x9, (%r13)
movq %r12, %rdi
movq %r13, %rsi
callq 0x4f02e
movl $0x8d, (%r13)
movq %rsp, %rsi
movq %r12, %rdi
callq 0x511ff
movq %rax, %r13
leaq 0x7e2a(%rip), %rsi      # 0x58520
movl $0x2, %edx
movq %rax, %rdi
callq 0x512bc
leaq 0x7e19(%rip), %rsi      # 0x58523
movl $0xd, %edx
movq %r13, %rdi
callq 0x512bc
movq 0x38(%r15), %rax
imulq $0x268, 0x50(%r15), %rcx # imm = 0x268
cmpq $0x0, 0x20(%rax,%rcx)
je 0x5076f
addq %rcx, %rax
xorl %ebx, %ebx
leaq 0x6020(%rip), %r14      # 0x56757
movq %rsp, %r13
movq 0x8(%rax), %rax
movsbq (%rax,%rbx), %rax
movb (%rax,%r14), %al
movb %al, (%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x4f02e
incq %rbx
imulq $0x268, 0x50(%r15), %rcx # imm = 0x268
movq 0x38(%r15), %rdx
leaq (%rdx,%rcx), %rax
cmpq 0x20(%rdx,%rcx), %rbx
jb 0x5073a
movq %rsp, %rsi
movb $0x9, (%rsi)
movq %r12, %rdi
callq 0x4f02e
movq 0x38(%r15), %rax
imulq $0x268, 0x50(%r15), %rcx # imm = 0x268
cmpq $0x0, 0x80(%rax,%rcx)
je 0x507d1
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 0x4f02e
incq %rbx
imulq $0x268, 0x50(%r15), %rax # imm = 0x268
movq 0x38(%r15), %rcx
addq %rcx, %rax
addq $0x60, %rax
cmpq 0x20(%rax), %rbx
jb 0x507a0
leaq 0x7d59(%rip), %rsi      # 0x58531
movl $0x6, %edx
movq %r12, %rdi
callq 0x512bc
movq %rsp, %r13
movq 0x8(%rsp), %rax
movq %rax, (%r13)
movq %r12, %rdi
movq %r13, %rsi
callq 0x510b6
movb $0xa, (%r13)
movq %rsp, %rsi
movq %r12, %rdi
callq 0x4f02e
movq 0x10(%rsp), %r14
movq 0x50(%r14), %rax
movq 0x20(%rsp), %rcx
incq (%rax,%rcx,8)
cmpb $0x1, 0x78(%r14)
jne 0x50850
movq 0x88(%r14), %rsi
movq %rcx, %rax
shlq $0x4, %rax
cmpb $0x1, 0x8(%rsi,%rax)
jne 0x50850
addq %rax, %rsi
movq 0x78(%r15), %rdx
movq %rdx, (%rsi)
movq 0x88(%r14), %rdx
movb $0x0, 0x8(%rdx,%rax)
movq 0x50(%r14), %rax
movq (%rax,%rcx,8), %rax
cmpq 0x68(%r14), %rax
jb 0x5086b
movq %r14, %rdi
movq %rcx, %rsi
xorl %edx, %edx
callq 0x20ff0
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq