// File: /workspace/github_c_makefile_star2_O2/icebert[P]pblat/jkOwnLib/gfBlatLib.c
// Function: clumpToHspRange
static void clumpToHspRange(struct gfClump *clump, bioSeq *qSeq, int tileSize,
	int frame, struct trans3 *t3, struct gfRange **pRangeList, 
	boolean isProt, boolean fastMap)
/* Covert clump->hitList to HSPs (high scoring local sequence pair,
 * that is longest alignment without gaps) and add resulting HSPs to
 * rangeList. */
{
struct gfSeqSource *target = clump->target;
aaSeq *tSeq = target->seq;
BIOPOL *qs, *ts, *qe, *te;
struct gfHit *hit;
int qStart = 0, tStart = 0, qEnd = 0, tEnd = 0, newQ = 0, newT = 0;
boolean outOfIt = TRUE;		/* Logically outside of a clump. */
struct gfRange *range;
BIOPOL *lastQs = NULL, *lastQe = NULL, *lastTs = NULL;
int (*scoreMatch)(char a, char b) = (isProt ? aaScore2 : dnaScore2);
int maxDown, minSpan;

if (fastMap)
    {
    maxDown = 2;
    minSpan = 20;
    }
else
    {
    maxDown = 10;
    minSpan = 0;
    }


if (tSeq == NULL)
    internalErr();

/* The termination condition of this loop is a little complicated.
 * We want to output something either when the next hit can't be
 * merged into the previous, or at the end of the list.  To avoid
 * duplicating the output code we're forced to complicate the loop
 * termination logic.  Hence the check for hit == NULL to break
 * the loop is not until near the end of the loop. */
for (hit = clump->hitList; ; hit = hit->next)
    {
    if (hit != NULL)
        {
	newQ = hit->qStart;
	newT = hit->tStart - target->start;
	}

    /* See if it's time to output merged (diagonally adjacent) hits. */
    if (!outOfIt)	/* Not first time through. */
        {
	/* As a micro-optimization handle strings of adjacent hits
	 * specially.  Don't do the extensions until we've merged
	 * all adjacent hits. */
	if (hit == NULL || newQ != qEnd || newT != tEnd)
	    {
	    qs = qSeq->dna + qStart;
	    ts = tSeq->dna + tStart;
	    qe = qSeq->dna + qEnd;
	    te = tSeq->dna + tEnd;
	    extendHitRight(qSeq->size - qEnd, tSeq->size - tEnd,
		&qe, &te, scoreMatch, maxDown);
	    extendHitLeft(qStart, tStart, &qs, &ts, scoreMatch, maxDown);
	    if (qs != lastQs || ts != lastTs || qe != lastQe || qs !=  lastQs)
		{
		lastQs = qs;
		lastTs = ts;
		lastQe = qe;
		if (qe - qs >= minSpan)
		    {
		    AllocVar(range);
		    range->qStart = qs - qSeq->dna;
		    range->qEnd = qe - qSeq->dna;
		    range->tName = cloneString(tSeq->name);
		    range->tSeq = tSeq;
		    range->tStart = ts - tSeq->dna;
		    range->tEnd = te - tSeq->dna;
		    range->hitCount = qe - qs;
		    range->frame = frame;
		    range->t3 = t3;
		    assert(range->tEnd <= tSeq->size);
		    slAddHead(pRangeList, range);
		    }
		}
	    outOfIt = TRUE;
	    }
	}
    if (hit == NULL)
        break;

    if (outOfIt)
        {
	qStart = newQ;
	qEnd = qStart + tileSize;
	tStart = newT;
	tEnd = tStart + tileSize;
	outOfIt = FALSE;
	}
    else
        {
	qEnd = newQ + tileSize;
	tEnd = newT + tileSize;
	}
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %r9, 0x70(%rsp)
movq %r8, 0x78(%rsp)
movl %ecx, 0x40(%rsp)
movl %edx, %r14d
movq %rsi, 0x50(%rsp)
movq %rdi, %r12
movq 0x10(%rdi), %r13
movq 0x10(%r13), %rax
movq %rax, 0x20(%rsp)
cmpl $0x0, 0xe0(%rsp)
jne 0xe3c7
leaq 0x12efe(%rip), %rax     # 0x212c3
jmp 0xe3ce
leaq 0x12f59(%rip), %rax     # 0x21327
movq %rax, 0x38(%rsp)
xorl %r15d, %r15d
xorl %ebx, %ebx
cmpl $0x0, 0xe8(%rsp)
sete %bl
pushq $0x14
popq %rax
cmoveq %r15, %rax
movq %rax, 0x80(%rsp)
cmpq $0x0, 0x20(%rsp)
jne 0xe414
leaq 0x6e79a(%rip), %rdi     # 0x7cb9b
leaq 0x6e990(%rip), %rsi     # 0x7cd98
movl $0x2e9, %edx            # imm = 0x2E9
xorl %eax, %eax
callq 0x223fb
leal 0x2(,%rbx,8), %eax
movq %rax, 0x68(%rsp)
addq $0x28, %r12
xorl %ecx, %ecx
xorl %eax, %eax
xorl %esi, %esi
xorl %edi, %edi
xorl %edx, %edx
xorl %r8d, %r8d
movq $0x0, 0x30(%rsp)
movq $0x0, 0x18(%rsp)
movq $0x0, 0x28(%rsp)
movq %r14, 0x88(%rsp)
movq %r13, 0x48(%rsp)
movq (%r12), %r12
testq %r12, %r12
je 0xe470
movl 0x8(%r12), %esi
movl 0xc(%r12), %edi
subl 0x18(%r13), %edi
testb $0x1, %dl
je 0xe6e4
testq %r12, %r12
je 0xe48a
cmpl %ecx, %esi
jne 0xe48a
cmpl %eax, %edi
je 0xe6ef
movq %rdi, 0x58(%rsp)
movq %rsi, 0x60(%rsp)
movq %r12, 0xa0(%rsp)
movq 0x50(%rsp), %rdi
movq 0x10(%rdi), %rdx
movl %r8d, 0x44(%rsp)
movslq %r8d, %rsi
addq %rdx, %rsi
movq %rsi, 0x10(%rsp)
movq 0x20(%rsp), %r8
movq 0x10(%r8), %rsi
movq %r15, 0x98(%rsp)
movslq %r15d, %r9
addq %rsi, %r9
movq %r9, 0x8(%rsp)
movslq %ecx, %r9
addq %rdx, %r9
movq %r9, (%rsp)
movslq %eax, %r13
addq %rsi, %r13
movl 0x18(%rdi), %edx
subl %ecx, %edx
movl 0x18(%r8), %r15d
subl %eax, %r15d
cmpl %r15d, %edx
cmovll %edx, %r15d
xorl %r12d, %r12d
testl %r15d, %r15d
cmovlel %r12d, %r15d
pushq $-0x1
popq %rax
movl %eax, %r14d
xorl %ebx, %ebx
xorl %ebp, %ebp
cmpq %r12, %r15
je 0xe541
movq (%rsp), %rax
movsbl (%rax,%r12), %edi
movsbl (%r13,%r12), %esi
callq *0x38(%rsp)
addl %eax, %ebx
cmpl %ebp, %ebx
jle 0xe52d
movl %r12d, %r14d
movl %ebx, %ebp
jmp 0xe53c
movq 0x68(%rsp), %rax
addl %r14d, %eax
cltq
cmpq %rax, %r12
jg 0xe541
incq %r12
jmp 0xe508
movslq %r14d, %rax
movq (%rsp), %rcx
addq %rax, %rcx
incq %rcx
movq %rcx, (%rsp)
leaq 0x1(%r13,%rax), %rax
movq %rax, 0x90(%rsp)
movq 0x98(%rsp), %rax
movl 0x44(%rsp), %ecx
cmpl %eax, %ecx
cmovll %ecx, %eax
negl %eax
movslq %eax, %r15
xorl %ebp, %ebp
pushq $-0x1
popq %r12
xorl %ebx, %ebx
xorl %r14d, %r14d
movq 0x48(%rsp), %r13
cmpq %r15, %r12
jl 0xe5c3
movq 0x10(%rsp), %rax
movsbl (%rax,%r12), %edi
movq 0x8(%rsp), %rax
movsbl (%rax,%r12), %esi
callq *0x38(%rsp)
addl %eax, %ebx
cmpl %r14d, %ebx
jle 0xe5b1
movl %r12d, %ebp
movl %ebx, %r14d
jmp 0xe5be
movl %ebp, %eax
subl 0x68(%rsp), %eax
cltq
cmpq %rax, %r12
jl 0xe5c3
decq %r12
jmp 0xe585
movslq %ebp, %rax
movq 0x10(%rsp), %rbp
addq %rax, %rbp
movq 0x8(%rsp), %rcx
addq %rax, %rcx
movq %rcx, %rax
cmpq 0x30(%rsp), %rbp
movq 0x88(%rsp), %r14
movq 0xa0(%rsp), %r12
movq 0x60(%rsp), %rsi
movq 0x58(%rsp), %rdi
movq (%rsp), %rcx
jne 0xe610
cmpq 0x28(%rsp), %rax
jne 0xe610
cmpq 0x18(%rsp), %rcx
je 0xe6e4
movq %rcx, %rbx
subq %rbp, %rbx
cmpq 0x80(%rsp), %rbx
jge 0xe634
movq %rbp, 0x30(%rsp)
movq %rcx, 0x18(%rsp)
movq %rax, 0x28(%rsp)
jmp 0xe6e4
pushq $0x48
popq %rdi
movq %rax, 0x8(%rsp)
movq %rcx, %r13
callq 0x28bb0
movq %rax, %r15
movq 0x50(%rsp), %rax
movl 0x10(%rax), %eax
movl %ebp, %ecx
subl %eax, %ecx
movl %ecx, 0x8(%r15)
movl %r13d, %ecx
subl %eax, %ecx
movl %ecx, 0xc(%r15)
movq %rbp, 0x10(%rsp)
movq 0x20(%rsp), %rbp
movq 0x8(%rbp), %rdi
callq 0x1c306
movq 0x8(%rsp), %rdx
movq %rax, 0x10(%r15)
movq %rbp, 0x18(%r15)
movl 0x10(%rbp), %eax
movl %edx, %ecx
subl %eax, %ecx
movl %ecx, 0x20(%r15)
movq 0x90(%rsp), %rcx
subl %eax, %ecx
movl %ecx, 0x24(%r15)
movl %ebx, 0x30(%r15)
movl 0x40(%rsp), %eax
movl %eax, 0x34(%r15)
movq 0x78(%rsp), %rax
movq %rax, 0x38(%r15)
cmpl %ecx, 0x18(%rbp)
jl 0xe710
movq 0x70(%rsp), %rcx
movq (%rcx), %rax
movq %rax, (%r15)
movq %r15, (%rcx)
movq 0x10(%rsp), %rax
movq %rax, 0x30(%rsp)
movq %r13, 0x18(%rsp)
movq %rdx, 0x28(%rsp)
movq 0x60(%rsp), %rsi
movq 0x58(%rsp), %rdi
movq 0x48(%rsp), %r13
movl %edi, %r15d
movl %esi, %r8d
testq %r12, %r12
je 0xe6fe
leal (%rdi,%r14), %eax
leal (%rsi,%r14), %ecx
movb $0x1, %dl
jmp 0xe459
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6e729(%rip), %rdi     # 0x7ce40
leaq 0x6e67a(%rip), %rsi     # 0x7cd98
leaq 0x6e735(%rip), %rcx     # 0x7ce5a
movl $0x319, %edx            # imm = 0x319
callq 0x6460