// File: /workspace/github_c_makefile_star2_O3/icebert[P]pblat/jkOwnLib/supStitch.c
// Function: ssStitch
void ssStitch(struct ssBundle *bundle, enum ffStringency stringency, 
	int minScore, int maxToReturn)
/* Glue together mrnas in bundle as much as possible. Returns number of
 * alignments after stitching. Updates bundle->ffList with stitched
 * together version. */
{
struct dnaSeq *qSeq =  bundle->qSeq;
struct dnaSeq *genoSeq = bundle->genoSeq;
struct ffAli *ffList = NULL;
struct ssFfItem *ffl;
struct ffAli *bestPath;
int score;
boolean firstTime = TRUE;

if (bundle->ffList == NULL)
    return;

/* The score may improve when we stitch together more alignments,
 * so don't let minScore be too harsh at this stage. */
if (minScore > 20)
    minScore = 20;

/* Create ffAlis for all in bundle and move to one big list. */
for (ffl = bundle->ffList; ffl != NULL; ffl = ffl->next)
    {
    ffCat(&ffList, &ffl->ff);
    }
slFreeList(&bundle->ffList);

ffAliSort(&ffList, ffCmpHitsNeedleFirst);
ffList = ffMergeClose(ffList, qSeq->dna, genoSeq->dna);

while (ffList != NULL)
    {

    ssFindBest(ffList, qSeq, genoSeq, stringency, 
    	bundle->isProt, bundle->t3List,
    	&bestPath, &score, &ffList);


    bestPath = ffMergeNeedleAlis(bestPath, TRUE);
    bestPath = ffRemoveEmptyAlis(bestPath, TRUE);
    if (!bestPath)
	{
	ffFreeAli(&ffList);
	break;
	}
    bestPath = ffMergeHayOverlaps(bestPath);
    bestPath = ffRemoveEmptyAlis(bestPath, TRUE);
    bestPath = forceMonotonic(bestPath, qSeq, genoSeq, stringency,
    	bundle->isProt, bundle->t3List);

    if (firstTime && stringency == ffCdna && bundle->avoidFuzzyFindKludge == FALSE)
	{
	/* Only look for middle exons the first time.  Next times
	 * this might regenerate most of the first alignment... */
	bestPath = smallMiddleExons(bestPath, bundle, stringency);
	}
    bestPath = ffMergeNeedleAlis(bestPath, TRUE);
    if (ffIntronMax != ffIntronMaxDefault)
	{
	bestPath = cutAtBigIntrons(bestPath, ffIntronMax, &score, stringency, 
		bundle->isProt, genoSeq, bundle->t3List,
		&ffList);
	}
    if (!bundle->isProt)
	ffSlideIntrons(bestPath);
    bestPath = ffRemoveEmptyAlis(bestPath, TRUE);
    if (score >= minScore)
	{
	AllocVar(ffl);
	ffl->ff = bestPath;
	slAddHead(&bundle->ffList, ffl);
	}
    else
	{
	ffFreeAli(&bestPath);
	ffFreeAli(&ffList);
	break;
	}
    firstTime = FALSE;
    if (--maxToReturn <= 0)
	{
	ffFreeAli(&ffList);
	break;
	}
    }
slReverse(&bundle->ffList);
return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movl %esi, (%rsp)
movq 0x10(%rdi), %rax
movq %rax, 0x38(%rsp)
movq 0x18(%rdi), %rax
movq %rax, 0x20(%rsp)
movq $0x0, 0x10(%rsp)
movq 0x8(%rdi), %r15
testq %r15, %r15
je 0x1569a
movl %edx, %ebx
movl %ecx, %r13d
movq %rdi, 0x48(%rsp)
leaq 0x8(%rdi), %r12
leaq 0x10(%rsp), %r14
leaq 0x8(%r15), %rsi
movq %r14, %rdi
callq 0x1600c
movq (%r15), %r15
testq %r15, %r15
jne 0x14fac
cmpl $0x14, %ebx
movl $0x14, %eax
cmovll %ebx, %eax
movl %eax, 0x6c(%rsp)
movq %r12, %rdi
callq 0x20196
leaq 0x10b6(%rip), %rsi      # 0x16094
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0x1603a
movq (%rbx), %rdi
movq 0x38(%rsp), %rax
movq 0x10(%rax), %rsi
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rdx
callq 0x16127
movq %rax, (%rbx)
testq %rax, %rax
movq 0x48(%rsp), %r15
je 0x15692
movq %rax, %rbp
movl %r13d, %r14d
movb $0x1, %al
movq %r12, 0x88(%rsp)
movl %eax, 0x70(%rsp)
movl 0x30(%r15), %r13d
movq 0x38(%r15), %rbx
movq %rbp, %rdi
callq 0x2831c
cmpl $0xa, %eax
jl 0x1507f
subq $0x8, %rsp
movq %rbp, %rdi
movq 0x40(%rsp), %rsi
movq 0x28(%rsp), %rdx
movl 0x8(%rsp), %ecx
movl %r13d, %r8d
movq %rbx, %r9
leaq 0x18(%rsp), %rax
pushq %rax
leaq 0x2c(%rsp), %rax
pushq %rax
leaq 0x40(%rsp), %rax
pushq %rax
callq 0x158b2
addq $0x20, %rsp
movq 0x28(%rsp), %rbx
jmp 0x15545
movq %rbx, 0x60(%rsp)
movl %r14d, 0x30(%rsp)
movq %rbp, 0x58(%rsp)
movq %rbp, %rdi
callq 0x2831c
movl %eax, %r15d
leal 0x1(%r15), %ebx
movl $0x20, %edi
callq 0x2dff4
movq %rax, %r14
movl %r15d, (%rax)
movslq %ebx, %rdi
shlq $0x5, %rdi
callq 0x2de63
movq %rax, %rbp
movq %r14, 0x50(%rsp)
movq %rax, 0x8(%r14)
movq %r15, 0x8(%rsp)
testl %r15d, %r15d
jle 0x15113
movl %ebx, %r14d
shlq $0x5, %r14
addq $-0x20, %r14
xorl %r15d, %r15d
movq 0x58(%rsp), %r12
movq %r12, 0x28(%rbp,%r15)
movq 0x10(%r12), %rsi
movq 0x20(%r12), %rdx
movl 0x28(%r12), %ecx
subl %edx, %ecx
movl %r13d, %edi
callq 0x15b80
movl %eax, 0x3c(%rbp,%r15)
movq 0x8(%r12), %r12
addq $0x20, %r15
cmpq %r15, %r14
jne 0x150e2
movl %r13d, 0x4(%rsp)
imull 0x8(%rsp), %ebx
movl %ebx, %eax
shrl $0x1f, %eax
addl %ebx, %eax
sarl %eax
movl %eax, 0x34(%rsp)
movslq %eax, %rdi
shlq $0x5, %rdi
callq 0x2de63
movq %rax, %rcx
movq 0x50(%rsp), %rax
movq %rcx, 0x90(%rsp)
movq %rcx, 0x18(%rax)
leaq 0x20(%rbp), %rax
movq %rax, 0xa0(%rsp)
xorl %ecx, %ecx
movl $0x1, %eax
movq 0x58(%rsp), %r14
movq %r14, %rbx
movq 0x60(%rsp), %r15
movq %rbp, 0xa8(%rsp)
cmpl 0x34(%rsp), %ecx
jge 0x156cb
movq %rax, 0xb0(%rsp)
movq %rax, %rsi
shlq $0x5, %rsi
addq %rbp, %rsi
movslq %ecx, %rax
incl %ecx
movl %ecx, 0x8(%rsp)
shlq $0x5, %rax
movq 0x90(%rsp), %rdx
leaq (%rdx,%rax), %rcx
movq %rbp, 0x8(%rdx,%rax)
movl 0x1c(%rsi), %edi
movl %edi, 0x74(%rsp)
movl %edi, 0x10(%rdx,%rax)
movq %rsi, 0x98(%rsp)
movq %rcx, (%rsi)
cmpq %r14, %rbx
je 0x1539c
movq 0xa0(%rsp), %r12
movl $0x0, 0x40(%rsp)
testq %r15, %r15
je 0x15289
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rcx
callq 0x14d94
movl %eax, %ebp
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rdx
movq %r15, %rdi
leaq 0x40(%rsp), %rcx
leaq 0xc4(%rsp), %r8
callq 0x14e0e
testl %ebp, %ebp
je 0x1538b
movq 0x10(%rbx), %r13
subq 0x18(%r14), %r13
movq 0x20(%r14), %rsi
movq 0x28(%r14), %rdx
movq %r15, %rdi
leaq 0xc0(%rsp), %rcx
leaq 0x84(%rsp), %r8
callq 0x14e0e
movl 0x40(%rsp), %edi
subl 0x84(%rsp), %edi
movl 0x4(%rsp), %r8d
movl 0x8(%rsp), %edx
cmpl 0x34(%rsp), %edx
jge 0x156ac
movslq %edx, %r15
shlq $0x5, %r15
addq 0x90(%rsp), %r15
movq %r12, 0x8(%r15)
movl %r13d, %ecx
negl %ecx
movl %ecx, 0x14(%r15)
testl %r13d, %r13d
js 0x152c8
movl 0x74(%rsp), %ebp
jmp 0x1535e
movq 0x10(%rbx), %r13
cmpq %r13, 0x10(%r14)
jae 0x1538b
movq 0x18(%r14), %rax
cmpq 0x18(%rbx), %rax
jae 0x1538b
movq 0x20(%rbx), %rdi
cmpq %rdi, 0x20(%r14)
jae 0x1538b
movq 0x28(%r14), %rcx
cmpq 0x28(%rbx), %rcx
jae 0x1538b
subq %rax, %r13
subl %ecx, %edi
jmp 0x1524c
movl 0x28(%rbx), %ebp
movq 0x10(%rbx), %rsi
movq 0x20(%rbx), %rdx
subl %edx, %ebp
movq %rdi, 0xb8(%rsp)
movq 0x28(%r14), %rdi
movl 0x20(%r14), %eax
movl %edi, %r9d
subl %eax, %r9d
movl %r9d, 0x80(%rsp)
callq 0x15ce4
movl %eax, 0x78(%rsp)
movl %eax, 0x18(%r15)
movq 0x10(%rbx), %rsi
movq 0x20(%rbx), %rdx
addl %r13d, %ebp
addl %eax, %ebp
movl 0x4(%rsp), %edi
movl %ebp, %ecx
callq 0x15b80
movl %eax, 0x7c(%rsp)
movslq 0x78(%rsp), %rax
movq 0x10(%r14), %rsi
addq %rax, %rsi
movq 0x20(%r14), %rdx
addq %rax, %rdx
movl 0x80(%rsp), %ecx
subl %eax, %ecx
movl 0x4(%rsp), %edi
callq 0x15b80
movq 0xb8(%rsp), %rdi
movl 0x8(%rsp), %edx
movl %eax, %ebp
addl 0x7c(%rsp), %ebp
subl 0x1c(%r12), %ebp
addl %r13d, %edi
xorl %r13d, %r13d
incl %edx
movl %edx, 0x8(%rsp)
movl %r13d, %esi
movl (%rsp), %edx
callq 0x28548
subl %eax, %ebp
movl %ebp, 0x10(%r15)
movq 0x98(%rsp), %rcx
movq (%rcx), %rax
movq %rax, (%r15)
movq %r15, (%rcx)
movq 0x60(%rsp), %r15
movq 0x8(%r14), %r14
addq $0x20, %r12
cmpq %rbx, %r14
jne 0x151d3
movq 0x98(%rsp), %rdi
callq 0x20173
movq 0x8(%rbx), %rbx
movq 0xb0(%rsp), %rax
incq %rax
testq %rbx, %rbx
movq 0x58(%rsp), %r14
movq 0xa8(%rsp), %rbp
movl 0x8(%rsp), %ecx
jne 0x15172
movq 0x50(%rsp), %rcx
movq %rcx, 0x40(%rsp)
movq 0x8(%rcx), %rax
movl (%rcx), %ecx
movq %rcx, %rsi
incq %rsi
movl $0xc0000001, %edi       # imm = 0xC0000001
movl $0x1, %r8d
xorl %edx, %edx
movq %r8, %r9
shlq $0x5, %r9
movq (%rax,%r9), %rbx
movl $0xc0000001, %r10d      # imm = 0xC0000001
xorl %r11d, %r11d
testq %rbx, %rbx
je 0x1542f
movq 0x8(%rbx), %r14
movl 0x18(%r14), %ebp
addl 0x10(%rbx), %ebp
cmpl %r10d, %ebp
cmovgq %rbx, %r11
movq (%rbx), %r14
cmovgl %ebp, %r10d
movq %r14, %rbx
testq %r14, %r14
jne 0x1540e
addq %rax, %r9
movq %r11, 0x10(%r9)
movl %r10d, 0x18(%r9)
cmpl %edi, %r10d
cmovgeq %r9, %rdx
cmovgl %r10d, %edi
incq %r8
cmpq %rsi, %r8
jne 0x153f5
movl 0x18(%rdx), %esi
movl %esi, 0x1c(%rsp)
xorl %ebx, %ebx
cmpq %rax, %rdx
je 0x154ca
movq %rbx, %rsi
movq 0x8(%rdx), %rbx
movq %rsi, 0x8(%rbx)
movq $0x0, 0x8(%rdx)
movq 0x10(%rdx), %rdi
movslq 0x14(%rdi), %rsi
movq 0x8(%rdi), %rdx
testq %rsi, %rsi
jle 0x1549a
movq 0x8(%rdx), %r8
movslq 0x18(%rdi), %rdi
subq %rdi, %rsi
subq %rsi, 0x28(%r8)
subq %rsi, 0x18(%r8)
addq %rdi, 0x20(%rbx)
addq %rdi, 0x10(%rbx)
cmpq %rax, %rdx
jne 0x1545b
xorl %esi, %esi
movq %rbx, %rdx
movq 0x88(%rsp), %r12
movl 0x30(%rsp), %r14d
movq 0x48(%rsp), %r15
movq %rsi, (%rdx)
movq %rdx, %rsi
movq 0x8(%rdx), %rdi
movq %rdi, %rdx
testq %rdi, %rdi
jne 0x154b6
jmp 0x154dc
movq 0x88(%rsp), %r12
movl 0x30(%rsp), %r14d
movq 0x48(%rsp), %r15
addq $0x28, %rax
xorl %edi, %edi
movq (%rax), %rdx
testq %rdx, %rdx
je 0x154f0
movq %rdi, (%rdx)
movq %rdx, %rdi
addq $0x20, %rax
decl %ecx
jne 0x154e2
callq 0x28293
movq %rax, 0x10(%rsp)
movq %rbx, %rdi
movq 0x38(%rsp), %rsi
movq 0x20(%rsp), %rdx
movl (%rsp), %ecx
movl 0x4(%rsp), %r8d
movq 0x60(%rsp), %r9
callq 0x14cc9
movq %rax, %rbx
movq 0x50(%rsp), %r13
movq 0x8(%r13), %rdi
callq 0x2e0a0
movq 0x18(%r13), %rdi
callq 0x2e0a0
leaq 0x40(%rsp), %rdi
callq 0x2e0b0
movq %rbx, %rdi
movl $0x1, %esi
callq 0x165c9
movq %rax, %rdi
movl $0x1, %esi
callq 0x1620c
movq %rax, 0x28(%rsp)
testq %rax, %rax
je 0x15688
movl (%rsp), %ebx
cmpl $0x1, %ebx
setne %bpl
movq %rax, %rdi
callq 0x16566
movq %rax, 0x28(%rsp)
movq %rax, %rdi
movl $0x1, %esi
callq 0x1620c
movl 0x30(%r15), %r8d
movq 0x38(%r15), %r9
movq %rax, %rdi
movq 0x38(%rsp), %rsi
movq 0x20(%rsp), %rdx
movl %ebx, %ecx
callq 0x14cc9
movq %rax, %rbx
movl 0x70(%rsp), %eax
notb %al
orb %bpl, %al
testb $0x1, %al
jne 0x155d4
cmpl $0x0, 0x40(%r15)
jne 0x155d4
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x14bda
movq %rbx, %rdi
movl $0x1, %esi
callq 0x165c9
movq %rax, %rbx
leaq 0xab585(%rip), %rax     # 0xc0b70
movl (%rax), %esi
cmpl $0xb71b0, %esi          # imm = 0xB71B0
je 0x1561c
movl 0x30(%r15), %r8d
movq %rbx, %rdi
leaq 0x1c(%rsp), %rdx
movl (%rsp), %ecx
movq 0x20(%rsp), %r9
leaq 0x10(%rsp), %rax
pushq %rax
pushq 0x38(%r15)
callq 0x14e95
addq $0x10, %rsp
cmpl $0x0, 0x30(%r15)
jne 0x1562b
movq %rbx, %rdi
callq 0x16552
movq %rbx, %rdi
movl $0x1, %esi
callq 0x1620c
movq %rax, %rbx
movq %rax, 0x28(%rsp)
movl 0x6c(%rsp), %eax
cmpl %eax, 0x1c(%rsp)
jl 0x1567e
movl $0x10, %edi
callq 0x2dff4
movq %rbx, 0x8(%rax)
movq (%r12), %rcx
movq %rcx, (%rax)
movq %rax, (%r12)
cmpl $0x2, %r14d
jl 0x15688
decl %r14d
movq 0x10(%rsp), %rbp
xorl %eax, %eax
testq %rbp, %rbp
jne 0x15026
jmp 0x15692
leaq 0x28(%rsp), %rdi
callq 0x281f8
leaq 0x10(%rsp), %rdi
callq 0x281f8
movq %r12, %rdi
callq 0x20173
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x78e45(%rip), %rdi     # 0x8e4f8
leaq 0x78e29(%rip), %rsi     # 0x8e4e3
leaq 0x78e51(%rip), %rcx     # 0x8e512
movl $0x18e, %edx            # imm = 0x18E
callq 0x6460
leaq 0x78e26(%rip), %rdi     # 0x8e4f8
leaq 0x78e0a(%rip), %rsi     # 0x8e4e3
leaq 0x78e32(%rip), %rcx     # 0x8e512
movl $0x169, %edx            # imm = 0x169
callq 0x6460