// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/jkOwnLib/supStitch.c
// Function: ssGraphMake
static struct ssGraph *ssGraphMake(struct ffAli *ffList, bioSeq *qSeq,
	enum ffStringency stringency, boolean isProt, struct trans3 *t3List)
/* Make a graph corresponding to ffList */
{
int nodeCount = ffAliCount(ffList);
int maxEdgeCount = (nodeCount+1)*(nodeCount)/2;
int edgeCount = 0;
struct ssEdge *edges, *e;
struct ssNode *nodes;
struct ssGraph *graph;
struct ffAli *ff, *mid;
int i, midIx;
int overlap;
boolean canFollow;

if (nodeCount == 1)
    maxEdgeCount = 1;
    
AllocVar(graph);
graph->nodeCount = nodeCount;
graph->nodes = AllocArray(nodes, nodeCount+1);
for (i=1, ff = ffList; i<=nodeCount; ++i, ff = ff->right)
    {
    nodes[i].ff = ff;
    nodes[i].nodeScore = bioScoreMatch(isProt, ff->nStart, ff->hStart, ff->hEnd - ff->hStart);
    }

graph->edges = AllocArray(edges, maxEdgeCount);
for (mid = ffList, midIx=1; mid != NULL; mid = mid->right, ++midIx)
    {
    int midScore;
    struct ssNode *midNode = &nodes[midIx];
    e = &edges[edgeCount++];
    assert(edgeCount <= maxEdgeCount);
    e->nodeIn = &nodes[0];
    e->score = midScore = midNode->nodeScore;
    midNode->waysIn = e;
    for (ff = ffList,i=1; ff != mid; ff = ff->right,++i)
	{
	int mhStart = 0, mhEnd = 0;
	if (t3List)
	    {
	    canFollow = tripleCanFollow(ff, mid, qSeq, t3List);
	    trans3Offsets(t3List, mid->hStart, mid->hEnd, &mhStart, &mhEnd);
	    }
	else 
	    {
	    canFollow = (ff->nStart < mid->nStart && ff->nEnd < mid->nEnd 
			&& ff->hStart < mid->hStart && ff->hEnd < mid->hEnd);
	    }
	if (canFollow)
	    {
	    struct ssNode *ffNode = &nodes[i];
	    int score;
	    int hGap;
	    int nGap;
	    int crossover;

	    nGap = mid->nStart - ff->nEnd;
	    if (t3List)
	        {
		int fhStart, fhEnd;
		trans3Offsets(t3List, ff->hStart, ff->hEnd, &fhStart, &fhEnd);
		hGap = mhStart - fhEnd;
		}
	    else
		{
		hGap = mid->hStart - ff->hEnd;
		}
	    e = &edges[edgeCount++];
	    assert(edgeCount <= maxEdgeCount);
	    e->nodeIn = ffNode;
	    e->overlap = overlap = -nGap;
	    if (overlap > 0)
		{
		int midSize = mid->hEnd - mid->hStart;
		int ffSize = ff->hEnd - ff->hStart;
		int newMidScore, newFfScore;
		e->crossover = crossover = findCrossover(ff, mid, overlap, isProt);
		newMidScore = bioScoreMatch(isProt, mid->nStart, mid->hStart, midSize-overlap+crossover);
		newFfScore = bioScoreMatch(isProt, ff->nStart+crossover, ff->hStart+crossover,
				ffSize-crossover);
		score = newMidScore - ffNode->nodeScore + newFfScore;
		nGap = 0;
		hGap -= overlap;
		}
	    else
		{
		score = midScore;
		}
	    score -= ffCalcGapPenalty(hGap, nGap, stringency);
	    e->score = score;
	    slAddHead(&midNode->waysIn, e);
	    }
	}
    slReverse(&midNode->waysIn);
    }
return graph;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movq -0x8(%rbp), %rdi
callq 0x37d90
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
imull -0x24(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
cmpl $0x1, -0x24(%rbp)
jne 0x19c62
movl $0x1, -0x28(%rbp)
movl $0x20, %edi
callq 0x40c50
movq %rax, -0x50(%rbp)
movl -0x24(%rbp), %ecx
movq -0x50(%rbp), %rax
movl %ecx, (%rax)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdi
shlq $0x5, %rdi
callq 0x409d0
movq %rax, %rcx
movq %rcx, -0x48(%rbp)
movq -0x50(%rbp), %rax
movq %rcx, 0x8(%rax)
movl $0x1, -0x64(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x58(%rbp)
movl -0x64(%rbp), %eax
cmpl -0x24(%rbp), %eax
jg 0x19d20
movq -0x58(%rbp), %rcx
movq -0x48(%rbp), %rax
movslq -0x64(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
movl -0x18(%rbp), %edi
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x58(%rbp), %rax
movq 0x20(%rax), %rdx
movq -0x58(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x58(%rbp), %rcx
movq 0x20(%rcx), %rcx
subq %rcx, %rax
movl %eax, %ecx
callq 0x197b0
movl %eax, %ecx
movq -0x48(%rbp), %rax
movslq -0x64(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movl %ecx, 0x1c(%rax)
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
movq -0x58(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x58(%rbp)
jmp 0x19ca9
movslq -0x28(%rbp), %rdi
shlq $0x5, %rdi
callq 0x409d0
movq %rax, %rcx
movq %rcx, -0x38(%rbp)
movq -0x50(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rax
movq %rax, -0x60(%rbp)
movl $0x1, -0x68(%rbp)
cmpq $0x0, -0x60(%rbp)
je 0x1a148
movq -0x48(%rbp), %rax
movslq -0x68(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movq -0x38(%rbp), %rax
movl -0x2c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x2c(%rbp)
movslq %ecx, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x28(%rbp), %eax
jg 0x19d90
jmp 0x19daf
leaq 0xbe659(%rip), %rdi     # 0xd83f0
leaq 0xbe63d(%rip), %rsi     # 0xd83db
movl $0x169, %edx            # imm = 0x169
leaq 0xbe660(%rip), %rcx     # 0xd840a
callq 0x6450
movq -0x48(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x80(%rbp), %rax
movl 0x1c(%rax), %ecx
movl %ecx, -0x74(%rbp)
movq -0x40(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x40(%rbp), %rcx
movq -0x80(%rbp), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rax
movq %rax, -0x58(%rbp)
movl $0x1, -0x64(%rbp)
movq -0x58(%rbp), %rax
cmpq -0x60(%rbp), %rax
je 0x1a125
movl $0x0, -0x84(%rbp)
movl $0x0, -0x88(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x19e50
movq -0x58(%rbp), %rdi
movq -0x60(%rbp), %rsi
movq -0x10(%rbp), %rdx
movq -0x20(%rbp), %rcx
callq 0x18880
movl %eax, -0x70(%rbp)
movq -0x20(%rbp), %rdi
movq -0x60(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x60(%rbp), %rax
movq 0x28(%rax), %rdx
leaq -0x84(%rbp), %rcx
leaq -0x88(%rbp), %r8
callq 0x18930
jmp 0x19ec5
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x60(%rbp), %rdx
xorl %eax, %eax
cmpq 0x10(%rdx), %rcx
movb %al, -0xb9(%rbp)
jae 0x19eb7
movq -0x58(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x60(%rbp), %rdx
xorl %eax, %eax
cmpq 0x18(%rdx), %rcx
movb %al, -0xb9(%rbp)
jae 0x19eb7
movq -0x58(%rbp), %rax
movq 0x20(%rax), %rcx
movq -0x60(%rbp), %rdx
xorl %eax, %eax
cmpq 0x20(%rdx), %rcx
movb %al, -0xb9(%rbp)
jae 0x19eb7
movq -0x58(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x60(%rbp), %rcx
cmpq 0x28(%rcx), %rax
setb %al
movb %al, -0xb9(%rbp)
movb -0xb9(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x70(%rbp)
cmpl $0x0, -0x70(%rbp)
je 0x1a109
movq -0x48(%rbp), %rax
movslq -0x64(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x90(%rbp)
movq -0x60(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x58(%rbp), %rcx
movq 0x18(%rcx), %rcx
subq %rcx, %rax
movl %eax, -0x9c(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x19f40
movq -0x20(%rbp), %rdi
movq -0x58(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x58(%rbp), %rax
movq 0x28(%rax), %rdx
leaq -0xa4(%rbp), %rcx
leaq -0xa8(%rbp), %r8
callq 0x18930
movl -0x84(%rbp), %eax
subl -0xa8(%rbp), %eax
movl %eax, -0x98(%rbp)
jmp 0x19f59
movq -0x60(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x58(%rbp), %rcx
movq 0x28(%rcx), %rcx
subq %rcx, %rax
movl %eax, -0x98(%rbp)
movq -0x38(%rbp), %rax
movl -0x2c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x2c(%rbp)
movslq %ecx, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x28(%rbp), %eax
jg 0x19f80
jmp 0x19f9f
leaq 0xbe469(%rip), %rdi     # 0xd83f0
leaq 0xbe44d(%rip), %rsi     # 0xd83db
movl $0x18e, %edx            # imm = 0x18E
leaq 0xbe470(%rip), %rcx     # 0xd840a
callq 0x6450
movq -0x90(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x8(%rax)
xorl %ecx, %ecx
subl -0x9c(%rbp), %ecx
movl %ecx, -0x6c(%rbp)
movq -0x40(%rbp), %rax
movl %ecx, 0x14(%rax)
cmpl $0x0, -0x6c(%rbp)
jle 0x1a0c2
movq -0x60(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x60(%rbp), %rcx
movq 0x20(%rcx), %rcx
subq %rcx, %rax
movl %eax, -0xac(%rbp)
movq -0x58(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x58(%rbp), %rcx
movq 0x20(%rcx), %rcx
subq %rcx, %rax
movl %eax, -0xb0(%rbp)
movq -0x58(%rbp), %rdi
movq -0x60(%rbp), %rsi
movl -0x6c(%rbp), %edx
movl -0x18(%rbp), %ecx
callq 0x19a40
movl %eax, %ecx
movl %ecx, -0xa0(%rbp)
movq -0x40(%rbp), %rax
movl %ecx, 0x18(%rax)
movl -0x18(%rbp), %edi
movq -0x60(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x60(%rbp), %rax
movq 0x20(%rax), %rdx
movl -0xac(%rbp), %ecx
subl -0x6c(%rbp), %ecx
addl -0xa0(%rbp), %ecx
callq 0x197b0
movl %eax, -0xb4(%rbp)
movl -0x18(%rbp), %edi
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rsi
movslq -0xa0(%rbp), %rax
addq %rax, %rsi
movq -0x58(%rbp), %rax
movq 0x20(%rax), %rdx
movslq -0xa0(%rbp), %rax
addq %rax, %rdx
movl -0xb0(%rbp), %ecx
subl -0xa0(%rbp), %ecx
callq 0x197b0
movl %eax, -0xb8(%rbp)
movl -0xb4(%rbp), %eax
movq -0x90(%rbp), %rcx
subl 0x1c(%rcx), %eax
addl -0xb8(%rbp), %eax
movl %eax, -0x94(%rbp)
movl $0x0, -0x9c(%rbp)
movl -0x6c(%rbp), %ecx
movl -0x98(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x98(%rbp)
jmp 0x1a0cb
movl -0x74(%rbp), %eax
movl %eax, -0x94(%rbp)
movl -0x98(%rbp), %edi
movl -0x9c(%rbp), %esi
movl -0x14(%rbp), %edx
callq 0x380e0
movl %eax, %ecx
movl -0x94(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x94(%rbp)
movl -0x94(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x80(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x18f00
jmp 0x1a10b
movq -0x58(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x58(%rbp)
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x19de6
movq -0x80(%rbp), %rdi
callq 0x2aad0
movq -0x60(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x60(%rbp)
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0x19d4b
movq -0x50(%rbp), %rax
addq $0xc0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)