// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/jkOwnLib/ffSeedExtend.c
// Function: clumpToExactRange
static void clumpToExactRange(struct gfClump *clump, bioSeq *qSeq, int tileSize,
	int frame, struct trans3 *t3, struct gfRange **pRangeList)
/* Covert extend and merge hits in clump->hitList so that
 * you get a list of maximal segments with no gaps or mismatches. */
{
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;

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;
	    extendExactRight(qSeq->size - qEnd, tSeq->size - tEnd,
		&qe, &te);
	    extendExactLeft(qStart, tStart, &qs, &ts);
	    if (qs != lastQs || ts != lastTs || qe != lastQe || qs !=  lastQs)
		{
		lastQs = qs;
		lastTs = ts;
		lastQe = qe;
		// BIOPOL *lastTe = te;  unnecessary
		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;
		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
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movq %r9, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
movl $0x0, -0x64(%rbp)
movl $0x0, -0x68(%rbp)
movl $0x0, -0x6c(%rbp)
movl $0x0, -0x70(%rbp)
movl $0x0, -0x74(%rbp)
movl $0x0, -0x78(%rbp)
movl $0x1, -0x7c(%rbp)
movq $0x0, -0x90(%rbp)
movq $0x0, -0x98(%rbp)
movq $0x0, -0xa0(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x1bebc
leaq 0xbbcc4(%rip), %rdi     # 0xd7b6d
leaq 0xbc5e0(%rip), %rsi     # 0xd8490
movl $0xdc, %edx
movb $0x0, %al
callq 0x35d40
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
je 0x1beea
movq -0x60(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x74(%rbp)
movq -0x60(%rbp), %rax
movl 0xc(%rax), %eax
movq -0x30(%rbp), %rcx
subl 0x18(%rcx), %eax
movl %eax, -0x78(%rbp)
cmpl $0x0, -0x7c(%rbp)
jne 0x1c0db
cmpq $0x0, -0x60(%rbp)
je 0x1bf0f
movl -0x74(%rbp), %eax
cmpl -0x6c(%rbp), %eax
jne 0x1bf0f
movl -0x78(%rbp), %eax
cmpl -0x70(%rbp), %eax
je 0x1c0d9
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x64(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x68(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x6c(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x70(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movl 0x18(%rax), %edi
subl -0x6c(%rbp), %edi
movq -0x38(%rbp), %rax
movl 0x18(%rax), %esi
subl -0x70(%rbp), %esi
leaq -0x50(%rbp), %rdx
leaq -0x58(%rbp), %rcx
callq 0x1cba0
movl -0x64(%rbp), %edi
movl -0x68(%rbp), %esi
leaq -0x40(%rbp), %rdx
leaq -0x48(%rbp), %rcx
callq 0x1cae0
movq -0x40(%rbp), %rax
cmpq -0x90(%rbp), %rax
jne 0x1bfc7
movq -0x48(%rbp), %rax
cmpq -0xa0(%rbp), %rax
jne 0x1bfc7
movq -0x50(%rbp), %rax
cmpq -0x98(%rbp), %rax
jne 0x1bfc7
movq -0x40(%rbp), %rax
cmpq -0x90(%rbp), %rax
je 0x1c0d2
movq -0x40(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x98(%rbp)
movl $0x48, %edi
callq 0x40c50
movq %rax, -0x88(%rbp)
movq -0x40(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x10(%rcx), %rcx
subq %rcx, %rax
movl %eax, %ecx
movq -0x88(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x50(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x10(%rcx), %rcx
subq %rcx, %rax
movl %eax, %ecx
movq -0x88(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x2a450
movq %rax, %rcx
movq -0x88(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x38(%rbp), %rcx
movq -0x88(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x48(%rbp), %rax
movq -0x38(%rbp), %rcx
movq 0x10(%rcx), %rcx
subq %rcx, %rax
movl %eax, %ecx
movq -0x88(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x58(%rbp), %rax
movq -0x38(%rbp), %rcx
movq 0x10(%rcx), %rcx
subq %rcx, %rax
movl %eax, %ecx
movq -0x88(%rbp), %rax
movl %ecx, 0x24(%rax)
movq -0x50(%rbp), %rax
movq -0x40(%rbp), %rcx
subq %rcx, %rax
movl %eax, %ecx
movq -0x88(%rbp), %rax
movl %ecx, 0x30(%rax)
movl -0x18(%rbp), %ecx
movq -0x88(%rbp), %rax
movl %ecx, 0x34(%rax)
movq -0x20(%rbp), %rcx
movq -0x88(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x28(%rbp), %rdi
movq -0x88(%rbp), %rsi
callq 0x1c310
movl $0x1, -0x7c(%rbp)
jmp 0x1c0db
cmpq $0x0, -0x60(%rbp)
jne 0x1c0e4
jmp 0x1c135
cmpl $0x0, -0x7c(%rbp)
je 0x1c111
movl -0x74(%rbp), %eax
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %eax
addl -0x14(%rbp), %eax
movl %eax, -0x6c(%rbp)
movl -0x78(%rbp), %eax
movl %eax, -0x68(%rbp)
movl -0x68(%rbp), %eax
addl -0x14(%rbp), %eax
movl %eax, -0x70(%rbp)
movl $0x0, -0x7c(%rbp)
jmp 0x1c123
movl -0x74(%rbp), %eax
addl -0x14(%rbp), %eax
movl %eax, -0x6c(%rbp)
movl -0x78(%rbp), %eax
addl -0x14(%rbp), %eax
movl %eax, -0x70(%rbp)
jmp 0x1c125
movq -0x60(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x60(%rbp)
jmp 0x1bec8
addq $0xa0, %rsp
popq %rbp
retq
nop