// File: /workspace/github_c_makefile_star2_O2/icebert[P]pblat/jkOwnLib/gfBlatLib.c
// Function: gfLongDnaInMem
void gfLongDnaInMem(struct dnaSeq *query, struct genoFind *gf, 
   boolean isRc, int minScore, Bits *qMaskBits, 
   struct gfOutput *out, boolean fastMap, boolean band)
/* Chop up query into pieces, align each, and stitch back
 * together again. */
{
int hitCount;
int maxSize = MAXSINGLEPIECESIZE;
int preferredSize = 4500;
int overlapSize = 250;
struct dnaSeq subQuery = *query;
struct lm *lm = lmInit(0);
int subOffset, subSize, nextOffset;
DNA saveEnd, *endPos;
struct ssBundle *oneBunList = NULL, *bigBunList = NULL, *bun;
struct hash *bunHash = newHash(8);

for (subOffset = 0; subOffset<query->size; subOffset = nextOffset)
    {
    struct gfClump *clumpList;
    struct gfRange *rangeList = NULL;

    /* Figure out size of this piece.  If query is
     * maxSize or less do it all.   Otherwise just
     * do prefered size, and set it up to overlap
     * with surrounding pieces by overlapSize.  */
    if (subOffset == 0 && query->size <= maxSize)
	nextOffset = subSize = query->size;
    else
        {
	subSize = preferredSize;
	if (subSize + subOffset >= query->size)
	    {
	    subSize = query->size - subOffset;
	    nextOffset = query->size;
	    }
	else
	    {
	    nextOffset = subOffset + preferredSize - overlapSize;
	    }
	}
    subQuery.dna = query->dna + subOffset;
    subQuery.size = subSize;
    endPos = &subQuery.dna[subSize];
    saveEnd = *endPos;
    *endPos = 0;
    if (band)
	{
	oneBunList = ffSeedExtInMem(gf, &subQuery, qMaskBits, subOffset, lm, minScore, isRc);
	}
    else
	{
	clumpList = gfFindClumpsWithQmask(gf, &subQuery, qMaskBits, subOffset, lm, &hitCount);
	if (fastMap)
	    {
	    oneBunList = fastMapClumpsToBundles(gf, clumpList, &subQuery);
	    }
	else
	    {
	    oneBunList = gfClumpsToBundles(clumpList, isRc, &subQuery, minScore, &rangeList);
	    gfRangeFreeList(&rangeList);
	    }
	gfClumpFreeList(&clumpList);
	}
    addToBigBundleList(&oneBunList, bunHash, &bigBunList, query);
    *endPos = saveEnd;
    }
#ifdef DEBUG
dumpBunList(bigBunList);
#endif /* DEBUG */
for (bun = bigBunList; bun != NULL; bun = bun->next)
    {
    ssStitch(bun, ffCdna, minScore, ssAliCount);
    if (!fastMap && !band)
	refineSmallExonsInBundle(bun);
    saveAlignments(bun->genoSeq->name, bun->genoSeq->size, 0, 
	bun, NULL, isRc, FALSE, ffCdna, minScore, out);
    }
ssBundleFreeList(&bigBunList);
freeHash(&bunHash);
lmCleanup(&lm);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %r9, 0xa8(%rsp)
movq %r8, 0x40(%rsp)
movq %rcx, 0x28(%rsp)
movq %rdx, 0x68(%rsp)
movq %rsi, 0x38(%rsp)
movq %rdi, %r12
movl 0x148(%rsp), %eax
movl %eax, 0x20(%rsp)
movq 0x20(%rdi), %rax
leaq 0xe0(%rsp), %rbp
movq %rax, 0x20(%rbp)
movups (%rdi), %xmm0
movups 0x10(%rdi), %xmm1
movaps %xmm1, 0x10(%rbp)
movaps %xmm0, (%rbp)
xorl %r14d, %r14d
xorl %edi, %edi
callq 0x26f00
movq %rax, 0x30(%rsp)
movq %rax, 0xd0(%rsp)
leaq 0x58(%rsp), %r13
andq $0x0, (%r13)
leaq 0xa0(%rsp), %rbx
andq $0x0, (%rbx)
pushq $0x8
popq %rdi
pushq $0x1
popq %rsi
callq 0x245c9
movq %rax, 0x48(%rsp)
movq %rax, 0x98(%rsp)
movq %r12, 0x70(%rsp)
movl 0x18(%r12), %esi
movl %esi, %eax
subl %r14d, %eax
jle 0xf9dd
andq $0x0, 0x90(%rsp)
testl %r14d, %r14d
sete %cl
cmpl $0x1389, %esi           # imm = 0x1389
setl %dl
testb %dl, %cl
je 0xf722
movl %esi, 0x18(%rsp)
movl %esi, %eax
jmp 0xf743
leal 0x1194(%r14), %ecx
cmpl %esi, %ecx
jge 0xf73f
leal 0x109a(%r14), %eax
movl %eax, 0x18(%rsp)
movl $0x1194, %eax           # imm = 0x1194
jmp 0xf743
movl %esi, 0x18(%rsp)
movslq %r14d, %r15
addq 0x10(%r12), %r15
movq %r15, 0xf0(%rsp)
movl %eax, 0xf8(%rsp)
cltq
movb (%rax,%r15), %r12b
movq %rax, 0x50(%rsp)
movb $0x0, (%rax,%r15)
cmpl $0x0, 0x148(%rsp)
movb %r12b, 0x78(%rsp)
je 0xf7b4
subq $0x8, %rsp
movq 0x40(%rsp), %rdi
movq %rbp, %rsi
movq 0x48(%rsp), %rdx
movl %r14d, %ecx
movq 0x38(%rsp), %r8
movq 0x30(%rsp), %r9
pushq 0x70(%rsp)
callq 0x13cf1
popq %rcx
popq %rdx
movq %rax, 0x58(%rsp)
movq 0x98(%rsp), %rsi
jmp 0xf9ac
movq 0x38(%rsp), %rbx
movq %rbx, %rdi
movq %rbp, %rsi
movq 0x40(%rsp), %rdx
movl %r14d, %ecx
movq 0x30(%rsp), %r8
leaq 0xdc(%rsp), %r9
callq 0xbd26
movq %rax, %r14
movq %rax, 0xc8(%rsp)
cmpl $0x0, 0x140(%rsp)
je 0xf8a8
andq $0x0, 0x8(%rsp)
testq %r14, %r14
je 0xf820
movl 0xc(%rbx), %edx
movq %r14, %rdi
movq %rbp, %rsi
xorl %ecx, %ecx
xorl %r8d, %r8d
leaq 0x8(%rsp), %r9
pushq $0x1
pushq $0x0
callq 0xe37d
popq %rax
popq %rcx
movq (%r14), %r14
jmp 0xf7f8
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x1c567
movq %rbx, %rdi
leaq -0x2080(%rip), %rsi     # 0xd7b7
callq 0x1c5ab
movq 0x8(%rsp), %rdi
movl $0x100, %esi            # imm = 0x100
callq 0xd8b7
movq %rax, %r14
movq %rax, 0x8(%rsp)
xorl %ebx, %ebx
testq %r14, %r14
je 0xf894
movq 0x18(%r14), %r13
pushq $0x48
popq %rdi
callq 0x28bb0
movq %rax, %r12
movq %rbp, 0x10(%rax)
movq %r13, 0x18(%rax)
movq 0x28(%r14), %rdi
movq %rbp, %rsi
callq 0xdfa8
movq %rax, 0x8(%r12)
andl $0x0, 0x30(%r12)
movq %rbx, (%r12)
movq (%r14), %r14
movq %r12, %rbx
jmp 0xf855
leaq 0x8(%rsp), %rdi
callq 0xd77e
movq %rbx, 0x58(%rsp)
jmp 0xf98d
andq $0x0, 0x8(%rsp)
movq %r14, %rdi
xorl %esi, %esi
callq 0xed3a
movq %rax, 0x60(%rsp)
leaq 0x60(%rsp), %rdi
leaq -0x2112(%rip), %rsi     # 0xd7b7
callq 0x1c5ab
movq 0x60(%rsp), %rdi
movl $0x7d0, %esi            # imm = 0x7D0
callq 0xd8b7
movq %rax, %r14
movq %rax, 0x60(%rsp)
xorl %ebx, %ebx
testq %r14, %r14
je 0xf95f
movq 0x18(%r14), %r13
movl 0xf8(%rsp), %esi
movl 0x18(%r13), %edx
movq %r14, %rdi
xorl %ecx, %ecx
movq 0x68(%rsp), %r8
movl $0x1f4, %r9d            # imm = 0x1F4
callq 0x107a8
andl $0x0, 0x20(%r14)
movl 0x18(%r13), %eax
movl %eax, 0x24(%r14)
pushq $0x48
popq %rdi
callq 0x28bb0
movq %rax, %r12
movq %rbp, 0x10(%rax)
movq %r13, 0x18(%rax)
movq %r14, %rdi
movq %rax, %rsi
callq 0xdcf8
movq %r12, %rdi
pushq $0x1
popq %rsi
movq 0x28(%rsp), %rdx
pushq $0x10
popq %rcx
callq 0x121d7
movq %rbx, (%r12)
movq %r12, 0x8(%rsp)
movq (%r14), %r14
movq %r12, %rbx
jmp 0xf8e7
leaq 0x8(%rsp), %rdi
callq 0x1c567
movq 0x60(%rsp), %rax
movq %rax, 0x90(%rsp)
movq 0x8(%rsp), %rax
movq %rax, 0x58(%rsp)
leaq 0x90(%rsp), %rdi
callq 0xd77e
leaq 0xc8(%rsp), %rdi
callq 0xba5e
leaq 0xa0(%rsp), %rbx
leaq 0x58(%rsp), %r13
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %r14
movq %r13, %rdi
movq %rsi, 0x48(%rsp)
movq %rbx, %rdx
movq 0x70(%rsp), %r12
movq %r12, %rcx
callq 0xfcd0
movb 0x78(%rsp), %al
movb %al, (%r15,%r14)
movl 0x18(%rsp), %eax
movl %eax, %r14d
jmp 0xf6ee
movl 0x140(%rsp), %eax
orl %eax, 0x20(%rsp)
movq (%rbx), %rbx
testq %rbx, %rbx
je 0xfc97
movq %rbx, %rdi
pushq $0x1
popq %rsi
movq 0x28(%rsp), %rdx
pushq $0x10
popq %rcx
callq 0x121d7
cmpl $0x0, 0x20(%rsp)
je 0xfa40
movq 0x18(%rbx), %rax
movq 0x8(%rax), %rdi
movl 0x18(%rax), %esi
xorl %edx, %edx
movq %rbx, %rcx
xorl %r8d, %r8d
movq 0x68(%rsp), %r9
pushq 0xa8(%rsp)
pushq 0x30(%rsp)
pushq $0x1
pushq $0x0
callq 0xdde1
addq $0x20, %rsp
jmp 0xf9e8
leaq 0x8(%rbx), %r14
movq %rbx, 0xb0(%rsp)
movq (%r14), %r14
testq %r14, %r14
je 0xfa0e
movq 0x8(%r14), %r12
movq %r12, %rdi
callq 0x23733
cmpl $0x3, %eax
jl 0xfc8e
movq %r14, 0x88(%rsp)
movq %r12, %rdi
callq 0x23671
movq 0x8(%r12), %rbp
testl %eax, %eax
setns %cl
leaq 0x6fbb2(%rip), %rdx     # 0x7f63c
leaq 0x6fbcb(%rip), %rax     # 0x7f65c
cmovnsq %rax, %rdx
leaq 0x6fbb6(%rip), %rsi     # 0x7f652
leaq 0x6fbb7(%rip), %rax     # 0x7f65a
cmovnsq %rax, %rsi
movq %rsi, 0x38(%rsp)
shlb $0x2, %cl
orb $0x63, %cl
movb %cl, 0x48(%rsp)
movq %rdx, 0x40(%rsp)
movb (%rdx), %al
movb %al, 0x7(%rsp)
movl $0x0, 0x24(%rsp)
movq %r12, 0x80(%rsp)
movq %r12, %rax
movq %rbp, %r12
movq 0x8(%rbp), %rbp
testq %rbp, %rbp
je 0xfc4f
movq 0x18(%r12), %r15
subq 0x10(%r12), %r15
cmpl $0x9, %r15d
jg 0xfad1
movq 0x20(%r12), %rcx
movq 0x28(%rax), %r13
movq %rcx, %rax
subq %r13, %rax
cmpq $0x2, %rax
jl 0xfad1
movq 0x20(%rbp), %r14
movq 0x28(%r12), %rdx
movq %r14, %rax
subq %rdx, %rax
cmpq $0x2, %rax
jl 0xfad1
movslq %r15d, %rax
movq %rax, 0xb8(%rsp)
subl %r13d, %r14d
xorl %esi, %esi
movq %rcx, 0x70(%rsp)
movq %r13, 0x30(%rsp)
movq %rdx, 0xc0(%rsp)
cmpq $0x4, %rsi
je 0xfc42
leaq 0x6d4df(%rip), %rax     # 0x7d030
movslq (%rax,%rsi,8), %rbx
movslq 0x4(%rax,%rsi,8), %rdi
movb 0x48(%rsp), %al
cmpb %al, -0x1(%rcx)
jne 0xfb89
movb 0x7(%rsp), %al
cmpb %al, (%rdx)
jne 0xfb89
cmpl $0x1, %ebx
je 0xfb76
cmpb $0x61, -0x2(%rcx)
jne 0xfb89
cmpl $0x1, %edi
je 0xfc42
cmpb $0x74, 0x1(%rdx)
je 0xfc42
movq %rsi, 0x50(%rsp)
movq 0x38(%rsp), %rsi
subq %rbx, %rsi
leaq 0x8(%rsp), %rax
movq %rdi, 0x78(%rsp)
movq %rax, %rdi
movq %rbx, %rdx
callq 0x6570
leaq (%rsp,%rbx), %r13
addq $0x8, %r13
movq 0x10(%r12), %rsi
movq %r13, %rdi
movq %rbx, 0x18(%rsp)
movq 0xb8(%rsp), %rbx
movq %rbx, %rdx
callq 0x6570
addq %rbx, %r13
movq %r13, %rdi
movq 0x30(%rsp), %r13
movq 0x40(%rsp), %rsi
movq 0x78(%rsp), %rbx
movq %rbx, %rdx
callq 0x6570
movq 0x18(%rsp), %rax
addl %r15d, %eax
leal (%rbx,%rax), %esi
leaq 0x8(%rsp), %rdi
movq %r13, %rdx
movl %r14d, %ecx
callq 0x1def8
movq 0x50(%rsp), %rsi
movq 0xc0(%rsp), %rdx
movq 0x70(%rsp), %rcx
incq %rsi
testq %rax, %rax
je 0xfb40
addq 0x18(%rsp), %rax
movq %rax, 0x20(%r12)
subq %rcx, %rdx
addq %rax, %rdx
movq %rdx, 0x28(%r12)
pushq $0x1
popq %rax
movl %eax, 0x24(%rsp)
movq 0xb0(%rsp), %rbx
jmp 0xfad1
cmpl $0x0, 0x24(%rsp)
je 0xfc7e
movq 0x80(%rsp), %r14
movq %r14, %rdi
callq 0x1362b
movq %r14, %rdi
pushq $0x1
popq %rsi
callq 0x13352
movq %rax, %r12
movq 0x88(%rsp), %r14
jmp 0xfc8e
movq 0x88(%rsp), %r14
movq 0x80(%rsp), %r12
movq %r12, 0x8(%r14)
jmp 0xfa4c
leaq 0xa0(%rsp), %rdi
callq 0x11cd5
leaq 0x98(%rsp), %rdi
callq 0x2494c
leaq 0xd0(%rsp), %rdi
callq 0x26fa2
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq