// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/jkOwnLib/supStitch.c
// Function: ssFindBundles
struct ssBundle *ssFindBundles(struct patSpace *ps, struct dnaSeq *cSeq, 
	char *cName, enum ffStringency stringency, boolean avoidSelfSelf)
/* Find patSpace alignments.  This routine is used by psLayout but not blat. */
{
struct patClump *clumpList, *clump;
struct ssBundle *bundleList = NULL, *bun = NULL;
DNA *cdna = cSeq->dna;
int totalCdnaSize = cSeq->size;
DNA *endCdna = cdna+totalCdnaSize;
struct ssFfItem *ffl;
struct dnaSeq *lastSeq = NULL;
int maxSize = 700;
int preferredSize = 500;
int overlapSize = 250;

for (;;)
    {
    int cSize = endCdna - cdna;
    if (cSize > maxSize)
	cSize = preferredSize;
    clumpList = patSpaceFindOne(ps, cdna, cSize);
    for (clump = clumpList; clump != NULL; clump = clump->next)
	{
	struct ffAli *ff;
	struct dnaSeq *seq = clump->seq;
	DNA *tStart = seq->dna + clump->start;
	if (!avoidSelfSelf || !sameString(seq->name, cSeq->name))
	    {
	    ff = ffFind(cdna, cdna+cSize, tStart, tStart + clump->size, stringency);
	    if (ff != NULL)
		{
		if (lastSeq != seq)
		    {
		    lastSeq = seq;
		    if ((bun = findBundle(bundleList, seq)) == NULL)
			{
			AllocVar(bun);
			bun->qSeq = cSeq;
			bun->genoSeq = seq;
			bun->genoIx = clump->bacIx;
			bun->genoContigIx = clump->seqIx;
			slAddHead(&bundleList, bun);
			}
		    }
		AllocVar(ffl);
		ffl->ff = ff;
		slAddHead(&bun->ffList, ffl);
		}
	    }
	}
    cdna += cSize;
    if (cdna >= endCdna)
	break;
    cdna -= overlapSize;
    slFreeList(&clumpList);
    }
slReverse(&bundleList);
cdna = cSeq->dna;

for (bun = bundleList; bun != NULL; bun = bun->next)
    {
    ssStitch(bun, stringency, 20, 16);
    }
return bundleList;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %r8d, 0x1c(%rsp)
movl %ecx, 0xc(%rsp)
movq %rdi, 0x30(%rsp)
movq $0x0, (%rsp)
movq 0x10(%rsi), %r12
movq %rsi, 0x20(%rsp)
movslq 0x18(%rsi), %r14
addq %r12, %r14
movq $0x0, 0x10(%rsp)
xorl %r13d, %r13d
movq %r14, 0x28(%rsp)
movl %r14d, %ebx
subl %r12d, %ebx
cmpl $0x2bd, %ebx            # imm = 0x2BD
movl $0x1f4, %eax            # imm = 0x1F4
cmovgel %eax, %ebx
movq 0x30(%rsp), %rdi
movq %r12, %rsi
movl %ebx, %edx
callq 0x18acb
movq %rax, %r15
movq %rax, 0x40(%rsp)
movslq %ebx, %rax
testq %r15, %r15
movq %rax, 0x38(%rsp)
je 0x15806
leaq (%r12,%rax), %rbx
movq 0x10(%r15), %rbp
movslq 0x18(%r15), %r14
addq 0x10(%rbp), %r14
cmpl $0x0, 0x1c(%rsp)
je 0x15760
movq 0x8(%rbp), %rdi
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rsi
callq 0x6a50
testl %eax, %eax
je 0x157fa
movslq 0x1c(%r15), %rcx
addq %r14, %rcx
movq %r12, %rdi
movq %rbx, %rsi
movq %r14, %rdx
movl 0xc(%rsp), %r8d
callq 0xad77
testq %rax, %rax
je 0x157fa
movq %rax, %r14
cmpq %rbp, 0x10(%rsp)
je 0x157e1
movq (%rsp), %r13
testq %r13, %r13
je 0x1579e
cmpq %rbp, 0x18(%r13)
je 0x157a1
movq (%r13), %r13
jmp 0x1578d
xorl %r13d, %r13d
testq %r13, %r13
jne 0x157dc
movl $0x48, %edi
callq 0x2dc95
movq %rax, %r13
movq 0x20(%rsp), %rax
movq %rax, 0x10(%r13)
movq %rbp, 0x18(%r13)
movl 0x8(%r15), %eax
movl %eax, 0x20(%r13)
movl 0xc(%r15), %eax
movl %eax, 0x24(%r13)
movq (%rsp), %rax
movq %rax, (%r13)
movq %r13, (%rsp)
movq %rbp, 0x10(%rsp)
movl $0x10, %edi
callq 0x2dc95
movq %r14, 0x8(%rax)
movq 0x8(%r13), %rcx
movq %rcx, (%rax)
movq %rax, 0x8(%r13)
movq (%r15), %r15
testq %r15, %r15
jne 0x15733
addq 0x38(%rsp), %r12
movq %r12, %rbx
movq 0x28(%rsp), %r14
cmpq %r14, %r12
jae 0x1582a
leaq -0xfa(%r12), %rbx
leaq 0x40(%rsp), %rdi
callq 0x1fcd6
cmpq %r14, %r12
movq %rbx, %r12
jb 0x156f3
movq %rsp, %rbx
movq %rbx, %rdi
callq 0x1fcb3
movq (%rbx), %rbx
testq %rbx, %rbx
movl 0xc(%rsp), %ebp
je 0x15869
movq %rbx, %rdi
movl %ebp, %esi
movl $0x14, %edx
movl $0x10, %ecx
callq 0x14ecb
movq (%rbx), %rbx
testq %rbx, %rbx
jne 0x1584d
movq (%rsp), %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq