// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/jkOwnLib/supStitch.c
// Function: ssGraphFindBest
static void ssGraphFindBest(struct ssGraph *graph, struct ffAli **retBestAli, 
   int *retScore, struct ffAli **retLeftovers)
/* Traverse graph and put best alignment in retBestAli.  Return score.
 * Put blocks not part of best alignment in retLeftovers. */
{
struct ssEdge *edge;
struct ssNode *node;
struct ssNode *startNode = &graph->nodes[0];
struct ffAli *bestAli = NULL, *leftovers = NULL;
struct ffAli *ff, *left = NULL;
int i;
int overlap, crossover, crossDif;

/* Find best path and save score. */
node = ssDynamicProgram(graph);
*retScore = node->cumScore;

/* Trace back and trim overlaps. */
while (node != startNode)
    {
    ff = node->ff;
    ff->right = bestAli;
    bestAli = ff;
    node->ff = NULL;
    edge = node->bestWayIn;
    if ((overlap = edge->overlap) > 0)
	{
	left = edge->nodeIn->ff;
	crossover = edge->crossover;
	crossDif = overlap-crossover;
	left->hEnd -= crossDif;
	left->nEnd -= crossDif;
	ff->hStart += crossover;
	ff->nStart += crossover;
	}
    node = node->bestWayIn->nodeIn;
    }

/* Make left links. */
left = NULL;
for (ff = bestAli; ff != NULL; ff = ff->right)
    {
    ff->left = left;
    left = ff;
    }

/* Make leftover list. */
for (i=1, node=graph->nodes+1; i<=graph->nodeCount; ++i,++node)
    {
    if ((ff = node->ff) != NULL)
	{
	ff->left = leftovers;
	leftovers = ff;
	}
    }
leftovers = ffMakeRightLinks(leftovers);

*retBestAli = bestAli;
*retLeftovers = leftovers;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x58(%rbp)
movq -0x8(%rbp), %rdi
callq 0x1a3c0
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movl 0x18(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movq -0x30(%rbp), %rax
cmpq -0x38(%rbp), %rax
je 0x1a2a5
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x40(%rbp), %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x50(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, -0x60(%rbp)
cmpl $0x0, %eax
jle 0x1a290
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x28(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, -0x64(%rbp)
movl -0x60(%rbp), %eax
subl -0x64(%rbp), %eax
movl %eax, -0x68(%rbp)
movl -0x68(%rbp), %edx
movq -0x58(%rbp), %rax
movq 0x28(%rax), %rcx
movslq %edx, %rsi
xorl %edx, %edx
subq %rsi, %rdx
addq %rdx, %rcx
movq %rcx, 0x28(%rax)
movl -0x68(%rbp), %edx
movq -0x58(%rbp), %rax
movq 0x18(%rax), %rcx
movslq %edx, %rsi
xorl %edx, %edx
subq %rsi, %rdx
addq %rdx, %rcx
movq %rcx, 0x18(%rax)
movl -0x64(%rbp), %edx
movq -0x50(%rbp), %rax
movq 0x20(%rax), %rcx
movslq %edx, %rdx
addq %rdx, %rcx
movq %rcx, 0x20(%rax)
movl -0x64(%rbp), %edx
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rcx
movslq %edx, %rdx
addq %rdx, %rcx
movq %rcx, 0x10(%rax)
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x30(%rbp)
jmp 0x1a1b6
movq $0x0, -0x58(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x1a2dd
movq -0x58(%rbp), %rcx
movq -0x50(%rbp), %rax
movq %rcx, (%rax)
movq -0x50(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x50(%rbp)
jmp 0x1a2b5
movl $0x1, -0x5c(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
addq $0x20, %rax
movq %rax, -0x30(%rbp)
movl -0x5c(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl (%rcx), %eax
jg 0x1a33d
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x50(%rbp)
cmpq $0x0, %rax
je 0x1a324
movq -0x48(%rbp), %rcx
movq -0x50(%rbp), %rax
movq %rcx, (%rax)
movq -0x50(%rbp), %rax
movq %rax, -0x48(%rbp)
jmp 0x1a326
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
movq -0x30(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x30(%rbp)
jmp 0x1a2f4
movq -0x48(%rbp), %rdi
callq 0x37bc0
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x48(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)