// File: /workspace/github_c_makefile_star2_O3/icebert[P]pblat/jkOwnLib/gfBlatLib.c
// Function: gfAlignTransTrans
void gfAlignTransTrans(int *pConn, char *tSeqDir, struct dnaSeq *qSeq, 
	boolean qIsRc, int minMatch, struct hash *tFileCache, 
	struct gfOutput *out, boolean isRna)
/* Search indexed translated genome on server with an dna sequence.  Translate
 * this sequence in three frames. Load homologous bits of genome locally
 * and do detailed alignment.  Call 'outFunction' with each alignment
 * that is found. */
{
struct gfClump *clumps[2][3][3], *clump;
char targetName[PATH_LEN];
int qFrame, tFrame, tIsRc;
struct gfSeqSource *ssList = NULL, *ss;
struct lm *lm = lmInit(0);
int tileSize;
struct gfRange *rangeList = NULL, *rl, *range;
struct trans3 *qTrans = trans3New(qSeq), *t3;
struct slRef *t3RefList = NULL, *t3Ref;
struct hash *t3Hash = NULL;
struct dnaSeq *tSeqList = NULL;
enum ffStringency stringency = (isRna ? ffCdna : ffLoose);

/* Query server for clumps. */
gfQuerySeqTransTrans(*pConn, qSeq, clumps, lm, &ssList, &tileSize);
close(*pConn);
*pConn = -1;

for (tIsRc=0; tIsRc <= 1; ++tIsRc)
    {
    /* Figure out which ranges need to be loaded and load them. */
    for (qFrame = 0; qFrame < 3; ++qFrame)
        {
        for (tFrame = 0; tFrame < 3; ++tFrame)
            {
	    rl = seqClumpToRangeList(clumps[tIsRc][qFrame][tFrame], tFrame);
	    rangeList = slCat(rangeList, rl);
	    }
	}
    rangeCoorTimes3(rangeList);
    slSort(&rangeList, gfRangeCmpTarget);
    rangeList = gfRangesBundle(rangeList, ffIntronMax);
    loadHashT3Ranges(rangeList, tSeqDir, tFileCache,
    	qSeq->size/3, tIsRc, &t3Hash, &tSeqList, &t3RefList);

    /* The old range list was not very precise - it was just to get
     * the DNA loaded.  */
    gfRangeFreeList(&rangeList);

    /* Patch up clump list and associated sequence source to refer
     * to bits of genome loaded into memory.  Create new range list
     * by extending hits in clumps. */
    for (qFrame = 0; qFrame < 3; ++qFrame)
	{
	for (tFrame = 0; tFrame < 3; ++tFrame)
	    {
	    for (clump = clumps[tIsRc][qFrame][tFrame]; clump != NULL; clump = clump->next)
		{
		struct gfSeqSource *ss = clump->target;
		struct gfRange *rangeSet = NULL;
		t3 = trans3Find(t3Hash, clumpTargetName(clump), clump->tStart*3, clump->tEnd*3);
		ss->seq = t3->trans[tFrame];
		ss->start = t3->start/3;
		ss->end = t3->end/3;
		clumpToHspRange(clump, qTrans->trans[qFrame], tileSize, tFrame, t3, &rangeSet, TRUE, FALSE);
		untranslateRangeList(rangeSet, qFrame, tFrame, NULL, t3, t3->start);
		rangeList = slCat(rangeSet, rangeList);
		}
	    }
	}
    slReverse(&rangeList);
    slSort(&rangeList, gfRangeCmpTarget);
    rangeList = gfRangesBundle(rangeList, ffIntronMax);

    for (range = rangeList; range != NULL; range = range->next)
	{
	struct dnaSeq *targetSeq = range->tSeq;
	struct ssBundle *bun;

	AllocVar(bun);
	bun->qSeq = qSeq;
	bun->genoSeq = targetSeq;
	bun->ffList = gfRangesToFfItem(range->components, qSeq);
	ssStitch(bun, stringency, minMatch, ssAliCount);
	getTargetName(range->tName, out->includeTargetFile, targetName);
	t3 = range->t3;
	saveAlignments(targetName, t3->nibSize, t3->start, 
	    bun, NULL, qIsRc, tIsRc, stringency, minMatch, out);
	ssBundleFree(&bun);
	}

    /* Cleanup for this strand of database. */
    gfRangeFreeList(&rangeList);
    freeHash(&t3Hash);
    for (t3Ref = t3RefList; t3Ref != NULL; t3Ref = t3Ref->next)
        {
	struct trans3 *t3 = t3Ref->val;
	trans3Free(&t3);
	}
    slFreeList(&t3RefList);
    freeDnaSeqList(&tSeqList);
    }
trans3Free(&qTrans);
for (ss = ssList; ss != NULL; ss = ss->next)
    freeMem(ss->fileName);
slFreeList(&ssList);
lmCleanup(&lm);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x398, %rsp            # imm = 0x398
movq %r9, 0xe0(%rsp)
movq %r8, 0xd8(%rsp)
movl %ecx, 0x3c(%rsp)
movq %rdx, %r13
movq %rsi, 0xd0(%rsp)
movq %rdi, %r15
xorl %ebx, %ebx
movq %rbx, 0x58(%rsp)
xorl %edi, %edi
callq 0x2c220
movq %rax, 0x20(%rsp)
movq %rax, 0xf8(%rsp)
movq %rbx, 0x8(%rsp)
movq %r13, %rdi
callq 0x15dc0
movq %rax, 0xe8(%rsp)
movq %rax, 0xf0(%rsp)
movq %rbx, 0x30(%rsp)
movq %rbx, 0x28(%rsp)
movq $0x0, 0x48(%rsp)
movq %rbx, 0x50(%rsp)
xorl %ebx, %ebx
cmpl $0x0, 0x3d8(%rsp)
sete %r12b
movl (%r15), %ebp
leaq 0x100(%rsp), %rdi
movl $0x90, %edx
xorl %esi, %esi
callq 0x63b0
leaq 0x7c7e0(%rip), %rdx     # 0x8dfe3
movl %ebp, %edi
movq %r13, %rsi
callq 0x12b22
leaq 0x190(%rsp), %rsi
movl %ebp, %edi
callq 0x311c3
movq %rax, %r14
leaq 0x7c5ed(%rip), %rdi     # 0x8de13
movq %rax, %rsi
callq 0x21b23
testl %eax, %eax
movq %r13, 0x40(%rsp)
je 0x11858
movq 0x8(%r13), %rsi
leaq 0x7c646(%rip), %rdi     # 0x8de88
leaq 0x190(%rsp), %rdx
xorl %eax, %eax
callq 0x26bea
xorl %ebp, %ebp
jmp 0x11a58
movb %r12b, 0x10(%rsp)
movq %r15, 0x18(%rsp)
movq %r14, %rdi
callq 0x12bd8
movq %rax, 0x48(%rsp)
leaq 0x190(%rsp), %r12
xorl %ebx, %ebx
movl %ebp, %edi
movq %r12, %rsi
callq 0x311c3
cmpl $0x646e65, 0x190(%rsp) # imm = 0x646E65
je 0x11a01
leaq 0x7c578(%rip), %rdi     # 0x8de13
movq %r12, %rsi
callq 0x21b23
testl %eax, %eax
jne 0x119e7
movq %r12, %rdi
leaq 0x60(%rsp), %rsi
movl $0xc, %edx
callq 0x226f5
cmpl $0x8, %eax
jg 0x118d2
leaq 0x7c725(%rip), %rdi     # 0x8dfee
movl %eax, %esi
xorl %eax, %eax
callq 0x26e94
movl $0x38, %edi
callq 0x2dff4
movq %rax, %r14
movq 0x60(%rsp), %rdi
callq 0x3bc10
movl %eax, 0x8(%r14)
movq 0x68(%rsp), %rdi
callq 0x3bc10
movl %eax, 0xc(%r14)
movl $0x28, %edi
callq 0x2dff4
movq %rax, %r15
movq 0x70(%rsp), %rdi
callq 0x1feba
movq %rax, 0x8(%r15)
movq %rbx, (%r15)
movq %r15, 0x10(%r14)
movq 0x78(%rsp), %rdi
callq 0x3bc10
movl %eax, 0x18(%r14)
movq 0x80(%rsp), %rdi
callq 0x3bc10
movl %eax, 0x1c(%r14)
movq 0x88(%rsp), %rdi
callq 0x3bc10
movl %eax, 0x20(%r14)
movq 0x90(%rsp), %rax
movq 0x98(%rsp), %rdi
xorl %ebx, %ebx
cmpb $0x2d, (%rax)
sete %bl
callq 0x3bc10
movl %eax, %r13d
movq 0xa0(%rsp), %rdi
callq 0x3bc10
movslq %r13d, %rcx
cltq
leaq (%rcx,%rcx,2), %rcx
leaq (%rbx,%rbx,8), %rdx
leaq 0x100(%rsp,%rdx,8), %rdx
leaq (%rdx,%rcx,8), %rcx
movq (%rcx,%rax,8), %rdx
movq %rdx, (%r14)
movq %r14, (%rcx,%rax,8)
movl %ebp, %edi
movq 0x20(%rsp), %rsi
callq 0xfc90
movq %rax, 0x28(%r14)
movq %rax, %rdi
callq 0x200ac
movq %r15, %rbx
cmpl 0x20(%r14), %eax
movq 0x40(%rsp), %r13
je 0x11879
leaq 0x7c583(%rip), %rdi     # 0x8df52
leaq 0x7c422(%rip), %rsi     # 0x8ddf8
leaq 0x7c636(%rip), %rcx     # 0x8e013
movl $0x152, %edx            # imm = 0x152
callq 0x6460
movq 0x8(%r13), %rsi
leaq 0x7c496(%rip), %rdi     # 0x8de88
leaq 0x190(%rsp), %rdx
xorl %eax, %eax
callq 0x26bea
movq %rbx, %rbp
movb $0x1, %bl
xorl %eax, %eax
leaq (%rax,%rax,8), %rax
leaq (%rsp,%rax,8), %r14
addq $0x100, %r14            # imm = 0x100
xorl %r15d, %r15d
xorl %r12d, %r12d
leaq (%r14,%r12), %rdi
callq 0x20173
addq $0x8, %r12
cmpq $0x18, %r12
jne 0x11a1d
incq %r15
addq $0x18, %r14
cmpq $0x3, %r15
jne 0x11a1a
movl $0x1, %eax
testb $0x1, %bl
movl $0x0, %ebx
jne 0x11a08
movq 0x18(%rsp), %r15
xorl %ebx, %ebx
movb 0x10(%rsp), %r12b
movb %r12b, %bl
leal 0x1(,%rbx,2), %r14d
movq %rbp, 0xc0(%rsp)
movq %rbp, 0x58(%rsp)
movl (%r15), %edi
callq 0x6e80
movl $0xffffffff, (%r15)     # imm = 0xFFFFFFFF
movb $0x1, %al
leaq 0x30(%rsp), %rbp
xorl %ecx, %ecx
movq %r14, 0xc8(%rsp)
movl %eax, 0x38(%rsp)
movq %rcx, 0x10(%rsp)
leaq (%rcx,%rcx,8), %r15
leaq (%rsp,%r15,8), %rbx
addq $0x100, %rbx            # imm = 0x100
xorl %r12d, %r12d
xorl %r14d, %r14d
movq (%rbx,%r14,8), %rdi
movl %r14d, %esi
callq 0x114a9
movq 0x8(%rsp), %rdi
movq %rax, %rsi
callq 0x20155
movq %rax, 0x8(%rsp)
incq %r14
cmpq $0x3, %r14
jne 0x11aae
incq %r12
addq $0x18, %rbx
cmpq $0x3, %r12
jne 0x11aab
movq %rax, %rdi
callq 0x10dc2
leaq 0x8(%rsp), %rdi
leaq -0x1eaa(%rip), %rsi     # 0xfc4c
callq 0x201c4
movq 0x8(%rsp), %rdi
leaq 0xaf069(%rip), %rax     # 0xc0b70
movl (%rax), %esi
callq 0xfd63
movq %rax, 0x8(%rsp)
movslq 0x18(%r13), %rcx
imulq $0x55555556, %rcx, %rcx # imm = 0x55555556
movq %rcx, %rdx
shrq $0x3f, %rdx
shrq $0x20, %rcx
addl %edx, %ecx
movq %rax, %rdi
movq 0xd0(%rsp), %rsi
movq 0xe0(%rsp), %rdx
movq 0x10(%rsp), %r8
leaq 0x28(%rsp), %r9
pushq %rbp
leaq 0x58(%rsp), %rax
pushq %rax
callq 0x11586
addq $0x10, %rsp
movq 0x8(%rsp), %rbx
movq %rbx, 0x60(%rsp)
testq %rbx, %rbx
leaq 0x60(%rsp), %r14
je 0x11b81
movq (%rbx), %rbx
movq %r14, %rdi
callq 0xfbac
movq %rbx, 0x60(%rsp)
testq %rbx, %rbx
jne 0x11b6c
movq $0x0, 0x8(%rsp)
leaq (%rsp,%r15,8), %rax
addq $0x100, %rax            # imm = 0x100
movq %rax, 0x18(%rsp)
xorl %r12d, %r12d
leaq (%r12,%r12,2), %rax
movq 0x18(%rsp), %rcx
leaq (%rcx,%rax,8), %rax
movq %rax, 0x20(%rsp)
xorl %r14d, %r14d
movq 0x20(%rsp), %rax
movq (%rax,%r14,8), %r15
testq %r15, %r15
je 0x11cc1
movq 0x10(%r15), %rbx
movq $0x0, 0x60(%rsp)
movq 0x28(%rsp), %rbp
movq 0x10(%rbx), %rax
testq %rax, %rax
cmoveq %rbx, %rax
movq 0x8(%rax), %r13
testq %r13, %r13
jne 0x11c03
leaq 0x7c01b(%rip), %rdi     # 0x8dc0b
leaq 0x7c201(%rip), %rsi     # 0x8ddf8
movl $0x251, %edx            # imm = 0x251
xorl %eax, %eax
callq 0x26e94
movl 0x18(%r15), %eax
movl 0x1c(%r15), %ecx
leal (%rax,%rax,2), %edx
leal (%rcx,%rcx,2), %ecx
movq %rbp, %rdi
movq %r13, %rsi
callq 0x15eab
movq %rax, %rbp
movq 0x18(%rax,%r14,8), %rax
movq %rax, 0x10(%rbx)
movslq 0x30(%rbp), %rax
imulq $0x55555556, %rax, %rax # imm = 0x55555556
movq %rax, %rcx
shrq $0x3f, %rcx
shrq $0x20, %rax
addl %ecx, %eax
movl %eax, 0x18(%rbx)
movslq 0x34(%rbp), %rax
imulq $0x55555556, %rax, %rax # imm = 0x55555556
movq %rax, %rcx
shrq $0x3f, %rcx
shrq $0x20, %rax
addl %ecx, %eax
movl %eax, 0x1c(%rbx)
movq 0xe8(%rsp), %rax
movq 0x18(%rax,%r12,8), %rsi
movq %r15, %rdi
movq 0x48(%rsp), %rdx
movl %r14d, %ecx
movq %rbp, %r8
leaq 0x60(%rsp), %r9
pushq $0x0
pushq $0x1
callq 0x1098c
addq $0x10, %rsp
movq 0x60(%rsp), %r13
movl 0x30(%rbp), %r9d
movq %r13, %rdi
movl %r12d, %esi
movl %r14d, %edx
xorl %ecx, %ecx
movq %rbp, %r8
callq 0x116ba
movq 0x8(%rsp), %rsi
movq %r13, %rdi
callq 0x20155
movq %rax, 0x8(%rsp)
movq (%r15), %r15
jmp 0x11bba
incq %r14
cmpq $0x3, %r14
jne 0x11bb1
incq %r12
cmpq $0x3, %r12
jne 0x11b9c
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x20173
movq %rbx, %rdi
leaq -0x20a6(%rip), %rsi     # 0xfc4c
callq 0x201c4
movq 0x8(%rsp), %rdi
leaq 0xaee6d(%rip), %rax     # 0xc0b70
movl (%rax), %esi
callq 0xfd63
movq %rax, %r14
movq %rax, 0x8(%rsp)
testq %rax, %rax
movq 0xd8(%rsp), %r15
movq 0x40(%rsp), %rbp
movq 0xc8(%rsp), %r13
leaq 0x190(%rsp), %r12
je 0x11dfc
movq 0x18(%r14), %rbx
movl $0x48, %edi
callq 0x2dff4
movq %rax, 0x60(%rsp)
movq %rbp, 0x10(%rax)
movq %rbx, 0x18(%rax)
movq 0x28(%r14), %rdi
movq %rbp, %rsi
callq 0x10529
movq 0x60(%rsp), %rdi
movq %rax, 0x8(%rdi)
movl %r13d, %esi
movl %r15d, %edx
movl $0x10, %ecx
callq 0x14f5d
movq 0x10(%r14), %rdi
movq 0x3d0(%rsp), %rbx
movl 0x48(%rbx), %esi
movq %r12, %rdx
callq 0x101f3
movq 0x38(%r14), %rax
movl 0x30(%rax), %edx
movl 0x38(%rax), %esi
movq 0x60(%rsp), %rcx
movq %r12, %rdi
xorl %r8d, %r8d
movl 0x3c(%rsp), %r9d
pushq %rbx
pushq %r15
pushq %r13
pushq 0x28(%rsp)
callq 0x10352
addq $0x20, %rsp
leaq 0x60(%rsp), %rdi
callq 0x149ec
movq (%r14), %r14
testq %r14, %r14
jne 0x11d38
movq 0x8(%rsp), %rbx
movq %rbx, 0x60(%rsp)
testq %rbx, %rbx
leaq 0x60(%rsp), %r12
je 0x11e01
movq (%rbx), %rbx
movq %r12, %rdi
callq 0xfbac
movq %rbx, 0x60(%rsp)
testq %rbx, %rbx
jne 0x11de5
jmp 0x11e01
leaq 0x60(%rsp), %r12
movq $0x0, 0x8(%rsp)
leaq 0x28(%rsp), %rdi
callq 0x298bd
movq 0x30(%rsp), %rbx
testq %rbx, %rbx
movq %rbp, %r13
leaq 0x30(%rsp), %rbp
je 0x11e3f
movq 0x8(%rbx), %rax
movq %rax, 0x60(%rsp)
movq %r12, %rdi
callq 0x15e23
movq (%rbx), %rbx
testq %rbx, %rbx
jne 0x11e26
movq %rbp, %rdi
callq 0x20196
leaq 0x50(%rsp), %rdi
callq 0x24df5
movl $0x1, %ecx
testb $0x1, 0x38(%rsp)
movl $0x0, %eax
jne 0x11a90
leaq 0xf0(%rsp), %rdi
callq 0x15e23
movq 0xc0(%rsp), %rbx
testq %rbx, %rbx
je 0x11e8e
movq 0x8(%rbx), %rdi
callq 0x2e0a0
movq (%rbx), %rbx
jmp 0x11e7b
leaq 0x58(%rsp), %rdi
callq 0x20196
leaq 0xf8(%rsp), %rdi
callq 0x2c2c7
addq $0x398, %rsp            # imm = 0x398
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq