// File: /workspace/github_c_makefile_star2_O3/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 $0xc8, %rsp
movq %r9, 0xa0(%rsp)
movq %r8, 0xa8(%rsp)
movl %ecx, 0x64(%rsp)
movl %edx, %r12d
movq %rsi, 0x70(%rsp)
movq %rdi, %r13
movq 0x10(%rdi), %r14
movq 0x10(%r14), %rax
movq %rax, 0x28(%rsp)
cmpl $0x0, 0x100(%rsp)
jne 0x109dc
leaq 0x15142(%rip), %rax     # 0x25b1c
jmp 0x109e3
leaq 0x151c8(%rip), %rax     # 0x25bab
movq %rax, 0x58(%rsp)
xorl %r15d, %r15d
xorl %ebx, %ebx
cmpl $0x0, 0x108(%rsp)
sete %bl
movl $0x14, %eax
cmoveq %r15, %rax
movq %rax, 0xb0(%rsp)
cmpq $0x0, 0x28(%rsp)
jne 0x10a2b
leaq 0x7d1f3(%rip), %rdi     # 0x8dc0b
leaq 0x7d3d9(%rip), %rsi     # 0x8ddf8
movl $0x2e9, %edx            # imm = 0x2E9
xorl %eax, %eax
callq 0x26e94
leal 0x2(,%rbx,8), %eax
movq %rax, 0x88(%rsp)
addq $0x28, %r13
xorl %ecx, %ecx
xorl %eax, %eax
xorl %esi, %esi
xorl %edi, %edi
xorl %edx, %edx
xorl %r10d, %r10d
movq $0x0, 0x38(%rsp)
movq $0x0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
movq %r12, 0x68(%rsp)
movq %r14, 0x40(%rsp)
movq (%r13), %r13
testq %r13, %r13
je 0x10a85
movl 0x8(%r13), %esi
movl 0xc(%r13), %edi
subl 0x18(%r14), %edi
testb $0x1, %dl
je 0x10d77
testq %r13, %r13
je 0x10a9f
cmpl %ecx, %esi
jne 0x10a9f
cmpl %eax, %edi
je 0x10d82
movq %rsi, 0x78(%rsp)
movq 0x70(%rsp), %rdx
movq 0x10(%rdx), %rbp
movq 0x28(%rsp), %rsi
movq 0x10(%rsi), %r8
movslq %ecx, %r9
addq %rbp, %r9
movq %r9, 0x98(%rsp)
movslq %eax, %r9
addq %r8, %r9
movq %r9, 0x90(%rsp)
movl 0x18(%rdx), %edx
subl %ecx, %edx
movl 0x18(%rsi), %ecx
subl %eax, %ecx
cmpl %ecx, %edx
cmovll %edx, %ecx
testl %ecx, %ecx
movq %rdi, 0x48(%rsp)
movq %r13, 0x80(%rsp)
movq %r8, 0x10(%rsp)
movq %rbp, 0x8(%rsp)
jle 0x10b8d
movl %r10d, 0x18(%rsp)
movq %r15, 0x50(%rsp)
movl %ecx, %r15d
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
xorl %r13d, %r13d
xorl %ebx, %ebx
xorl %eax, %eax
movl %eax, %r14d
movq 0x98(%rsp), %rax
movsbl (%rax,%r13), %edi
movq 0x90(%rsp), %rax
movsbl (%rax,%r13), %esi
callq *0x58(%rsp)
addl %r14d, %eax
cmpl %ebx, %eax
jle 0x10b48
movl %r13d, %ebp
movl %eax, %ebx
jmp 0x10b5a
movq 0x88(%rsp), %rcx
addl %ebp, %ecx
movslq %ecx, %rcx
cmpq %rcx, %r13
jg 0x10b62
incq %r13
cmpq %r13, %r15
jne 0x10b19
movslq %ebp, %rdx
movq 0x80(%rsp), %r13
movq 0x40(%rsp), %r14
movq 0x48(%rsp), %rdi
movq 0x10(%rsp), %r8
movq 0x8(%rsp), %rbp
movq 0x50(%rsp), %r15
movl 0x18(%rsp), %r10d
jmp 0x10b94
movq $-0x1, %rdx
movslq %r10d, %rsi
movslq %r15d, %rcx
cmpl %ecx, %esi
movl %ecx, %eax
cmovll %esi, %eax
testl %eax, %eax
jle 0x10c55
movq %rdx, 0x18(%rsp)
negl %eax
cltq
movq %rax, 0x50(%rsp)
movq %rcx, 0xc0(%rsp)
leaq (%r8,%rcx), %r15
decq %r15
movq %rsi, 0xb8(%rsp)
leaq (%rsi,%rbp), %r13
decq %r13
xorl %r12d, %r12d
xorl %r14d, %r14d
xorl %eax, %eax
xorl %ebx, %ebx
movl %eax, %ebp
movsbl (%r13,%r12), %edi
movsbl (%r15,%r12), %esi
decq %r12
callq *0x58(%rsp)
addl %ebp, %eax
cmpl %r14d, %eax
jle 0x10c02
movl %r12d, %ebx
movl %eax, %r14d
jmp 0x10c13
movl %ebx, %ecx
subl 0x88(%rsp), %ecx
movslq %ecx, %rcx
cmpq %rcx, %r12
jl 0x10c1a
cmpq 0x50(%rsp), %r12
jg 0x10bdf
movslq %ebx, %rax
movq 0x68(%rsp), %r12
movq 0x80(%rsp), %r13
movq 0x40(%rsp), %r14
movq 0x48(%rsp), %rdi
movq 0x10(%rsp), %r8
movq 0x8(%rsp), %rbp
movq 0x18(%rsp), %rdx
movq 0xc0(%rsp), %rcx
movq 0xb8(%rsp), %rsi
jmp 0x10c57
xorl %eax, %eax
addq %rsi, %rbp
addq %rcx, %r8
movq 0x98(%rsp), %rcx
leaq (%rcx,%rdx), %r15
incq %r15
addq %rax, %rbp
addq %rax, %r8
cmpq 0x38(%rsp), %rbp
movq 0x78(%rsp), %rsi
jne 0x10c90
cmpq 0x30(%rsp), %r8
jne 0x10c90
cmpq 0x20(%rsp), %r15
je 0x10d77
movq %r15, %rbx
subq %rbp, %rbx
cmpq 0xb0(%rsp), %rbx
jge 0x10cb4
movq %rbp, 0x38(%rsp)
movq %r15, 0x20(%rsp)
movq %r8, 0x30(%rsp)
jmp 0x10d77
movq 0x90(%rsp), %rax
leaq (%rax,%rdx), %r12
incq %r12
movl $0x48, %edi
movq %r8, 0x10(%rsp)
callq 0x2dff4
movq %rax, %r14
movq 0x70(%rsp), %rax
movl 0x10(%rax), %eax
movl %ebp, %ecx
subl %eax, %ecx
movl %ecx, 0x8(%r14)
movl %r15d, %ecx
subl %eax, %ecx
movl %ecx, 0xc(%r14)
movq %rbp, 0x8(%rsp)
movq 0x28(%rsp), %rbp
movq 0x8(%rbp), %rdi
callq 0x1feba
movq 0x10(%rsp), %rdx
movq %rax, 0x10(%r14)
movq %rbp, 0x18(%r14)
movl 0x10(%rbp), %eax
movl %edx, %ecx
subl %eax, %ecx
movl %ecx, 0x20(%r14)
subl %eax, %r12d
movl %r12d, 0x24(%r14)
movl %ebx, 0x30(%r14)
movl 0x64(%rsp), %eax
movl %eax, 0x34(%r14)
movq 0xa8(%rsp), %rax
movq %rax, 0x38(%r14)
cmpl %r12d, 0x18(%rbp)
jl 0x10da3
movq 0xa0(%rsp), %rcx
movq (%rcx), %rax
movq %rax, (%r14)
movq %r14, (%rcx)
movq 0x8(%rsp), %rax
movq %rax, 0x38(%rsp)
movq %r15, 0x20(%rsp)
movq %rdx, 0x30(%rsp)
movq 0x68(%rsp), %r12
movq 0x78(%rsp), %rsi
movq 0x48(%rsp), %rdi
movq 0x40(%rsp), %r14
movl %edi, %r15d
movl %esi, %r10d
testq %r13, %r13
je 0x10d91
leal (%rdi,%r12), %eax
leal (%rsi,%r12), %ecx
movb $0x1, %dl
jmp 0x10a70
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x7d0f6(%rip), %rdi     # 0x8dea0
leaq 0x7d047(%rip), %rsi     # 0x8ddf8
leaq 0x7d102(%rip), %rcx     # 0x8deba
movl $0x319, %edx            # imm = 0x319
callq 0x6460