// File: /workspace/github_c_makefile_star2_O3/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 $0x58, %rsp
movl %r8d, 0x24(%rsp)
movl %ecx, 0xc(%rsp)
movq %rdi, 0x38(%rsp)
movq $0x0, 0x10(%rsp)
movq 0x10(%rsi), %r12
movq %rsi, 0x28(%rsp)
movslq 0x18(%rsi), %rbx
addq %r12, %rbx
movq $0x0, 0x18(%rsp)
xorl %r13d, %r13d
movq %rbx, 0x30(%rsp)
subl %r12d, %ebx
cmpl $0x2bd, %ebx            # imm = 0x2BD
movl $0x1f4, %eax            # imm = 0x1F4
cmovgel %eax, %ebx
movq 0x38(%rsp), %rdi
movq %r12, %rsi
movl %ebx, %edx
callq 0x18c4e
movq %rax, %r15
movq %rax, 0x50(%rsp)
movslq %ebx, %rax
testq %r15, %r15
movq %rax, 0x40(%rsp)
je 0x15840
addq %r12, %rax
movq %rax, 0x48(%rsp)
movl 0xc(%rsp), %ebx
movq 0x10(%r15), %rbp
movslq 0x18(%r15), %r14
addq 0x10(%rbp), %r14
cmpl $0x0, 0x24(%rsp)
je 0x157a2
movq 0x8(%rbp), %rdi
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rsi
callq 0x6a50
testl %eax, %eax
je 0x15834
movslq 0x1c(%r15), %rcx
addq %r14, %rcx
movq %r12, %rdi
movq 0x48(%rsp), %rsi
movq %r14, %rdx
movl %ebx, %r8d
callq 0xacd1
testq %rax, %rax
je 0x15834
movq %rax, %r14
cmpq %rbp, 0x18(%rsp)
je 0x1581b
movq 0x10(%rsp), %rbx
testq %rbx, %rbx
je 0x157e7
movq %rbx, %r13
cmpq %rbp, 0x18(%r13)
je 0x15812
movq (%r13), %r13
testq %r13, %r13
jne 0x157d8
movl $0x48, %edi
callq 0x2dff4
movq %rax, %r13
movq 0x28(%rsp), %rax
movq %rax, 0x10(%r13)
movq %rbp, 0x18(%r13)
movq 0x8(%r15), %rax
movq %rax, 0x20(%r13)
movq %rbx, (%r13)
movq %r13, 0x10(%rsp)
movq %rbp, 0x18(%rsp)
movl 0xc(%rsp), %ebx
movl $0x10, %edi
callq 0x2dff4
movq %r14, 0x8(%rax)
movq 0x8(%r13), %rcx
movq %rcx, (%rax)
movq %rax, 0x8(%r13)
movq (%r15), %r15
testq %r15, %r15
jne 0x15775
addq 0x40(%rsp), %r12
movq 0x30(%rsp), %rbx
cmpq %rbx, %r12
jae 0x15865
addq $-0xfa, %r12
leaq 0x50(%rsp), %rdi
callq 0x20196
jmp 0x15730
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0x20173
movq (%rbx), %rbx
testq %rbx, %rbx
je 0x158a1
movl 0xc(%rsp), %ebp
movq %rbx, %rdi
movl %ebp, %esi
movl $0x14, %edx
movl $0x10, %ecx
callq 0x14f5d
movq (%rbx), %rbx
testq %rbx, %rbx
jne 0x1587e
movq 0x10(%rsp), %rax
jmp 0x158a3
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq