// File: /workspace/github_c_makefile_star2_O2/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, 0x24(%rsp)
movl %ecx, 0x14(%rsp)
movq %rdi, 0x38(%rsp)
leaq 0x8(%rsp), %rax
andq $0x0, (%rax)
movq 0x10(%rsi), %r15
movq %rsi, 0x28(%rsp)
movslq 0x18(%rsi), %rbx
addq %r15, %rbx
movq $0x0, 0x18(%rsp)
xorl %r12d, %r12d
movq %rbx, 0x30(%rsp)
movl %ebx, %r14d
subl %r15d, %r14d
cmpl $0x2bd, %r14d           # imm = 0x2BD
movl $0x1f4, %eax            # imm = 0x1F4
cmovgel %eax, %r14d
movq 0x38(%rsp), %rdi
movq %r15, %rsi
movl %r14d, %edx
callq 0x15a88
movq %rax, %rbx
movq %rax, 0x40(%rsp)
movq %r15, %rax
movslq %r14d, %r15
movq %rax, %rbp
addq %rax, %r15
testq %rbx, %rbx
je 0x12a9c
movq 0x10(%rbx), %r13
movslq 0x18(%rbx), %r14
addq 0x10(%r13), %r14
cmpl $0x0, 0x24(%rsp)
je 0x12a05
movq 0x8(%r13), %rdi
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rsi
callq 0x6a50
testl %eax, %eax
je 0x12a94
movslq 0x1c(%rbx), %rcx
addq %r14, %rcx
movq %rbp, %rdi
movq %r15, %rsi
movq %r14, %rdx
movl 0x14(%rsp), %r8d
callq 0x9254
testq %rax, %rax
je 0x12a94
movq %rax, %r14
cmpq %r13, 0x18(%rsp)
je 0x12a7b
leaq 0x8(%rsp), %r12
movq (%r12), %r12
testq %r12, %r12
je 0x12a45
cmpq %r13, 0x18(%r12)
jne 0x12a33
jmp 0x12a76
pushq $0x48
popq %rdi
callq 0x28bb0
movq %rax, %r12
movq 0x28(%rsp), %rax
movq %rax, 0x10(%r12)
movq %r13, 0x18(%r12)
movq 0x8(%rbx), %rax
movq %rax, 0x20(%r12)
movq 0x8(%rsp), %rax
movq %rax, (%r12)
movq %r12, 0x8(%rsp)
movq %r13, 0x18(%rsp)
pushq $0x10
popq %rdi
callq 0x28bb0
movq %r14, 0x8(%rax)
movq 0x8(%r12), %rcx
movq %rcx, (%rax)
movq %rax, 0x8(%r12)
movq (%rbx), %rbx
jmp 0x129cf
movq 0x30(%rsp), %rbx
cmpq %rbx, %r15
jae 0x12abc
addq $-0xfa, %r15
leaq 0x40(%rsp), %rdi
callq 0x1c583
jmp 0x12995
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x1c567
pushq $0x14
popq %rbp
pushq $0x10
popq %r14
movq (%rbx), %rbx
testq %rbx, %rbx
je 0x12aeb
movq %rbx, %rdi
movl 0x14(%rsp), %esi
movl %ebp, %edx
movl %r14d, %ecx
callq 0x121d7
jmp 0x12ad0
movq 0x8(%rsp), %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq