// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/jkOwnLib/ffAliHelp.c
// Function: ffMergeNeedleAlis
struct ffAli *ffMergeNeedleAlis(struct ffAli *ali, boolean doFree)
/* Remove overlapping areas needle in alignment. Assumes ali is sorted on
 * ascending nStart field. Also merge perfectly abutting neighbors.*/
{
struct ffAli *a = NULL;
struct ffAli *leftA = NULL;
struct ffAli *rightA;

if (ali == NULL)
    return NULL;
rightA = ali;
for (;;)
    {
    /* Advance to next ali */
    leftA = a;
    a = rightA;
    if (a == NULL)
        break;
    rightA = a->right;
    

    /* See if can merge current alignment into left one. */
    if (leftA != NULL)
        {
        int overlap = leftA->nEnd - a->nStart;

        /* Deal with overlaps in needle */
        if (overlap > 0)
            {
            /* See if left encompasses current segment. */
            if (leftA->nStart <= a->nStart && leftA->nEnd >= a->nEnd)
                {
                /* Eliminate current segment. */
                leftA->right = rightA;
                if (rightA != NULL)
                    rightA->left = leftA;
		if (doFree) freeMem(a);
                a = leftA;
                }
            else
                {
                /* Remove overlapping area from current segment, leave
                 * it in left segment. */
                a->hStart += overlap;
                a->nStart += overlap;
                }
            }
        else if (overlap == 0 && leftA->hEnd == a->hStart)
            {
            /* Remove current segment from list. */
            leftA->right = rightA;
            if (rightA != NULL)
                rightA->left = leftA;
            /* Fold data from current segment into left segment */
            leftA->nEnd = a->nEnd;
            leftA->hEnd = a->hEnd;
	    if (doFree) freeMem(a); 
	    a = leftA;
            }
        }
    }
return ali;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x1b523
movq $0x0, -0x8(%rbp)
jmp 0x1b683
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x1b547
jmp 0x1b67b
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x1b676
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x20(%rbp), %rcx
movq 0x10(%rcx), %rcx
subq %rcx, %rax
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jle 0x1b605
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x20(%rbp), %rcx
cmpq 0x10(%rcx), %rax
ja 0x1b5d9
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x20(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jb 0x1b5d9
movq -0x30(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
cmpq $0x0, -0x30(%rbp)
je 0x1b5c0
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
cmpl $0x0, -0x14(%rbp)
je 0x1b5cf
movq -0x20(%rbp), %rdi
callq 0x40d40
movq -0x28(%rbp), %rax
movq %rax, -0x20(%rbp)
jmp 0x1b603
movl -0x34(%rbp), %edx
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rcx
movslq %edx, %rdx
addq %rdx, %rcx
movq %rcx, 0x20(%rax)
movl -0x34(%rbp), %edx
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rcx
movslq %edx, %rdx
addq %rdx, %rcx
movq %rcx, 0x10(%rax)
jmp 0x1b674
cmpl $0x0, -0x34(%rbp)
jne 0x1b672
movq -0x28(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x20(%rbp), %rcx
cmpq 0x20(%rcx), %rax
jne 0x1b672
movq -0x30(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
cmpq $0x0, -0x30(%rbp)
je 0x1b63b
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x28(%rax)
cmpl $0x0, -0x14(%rbp)
je 0x1b66a
movq -0x20(%rbp), %rdi
callq 0x40d40
movq -0x28(%rbp), %rax
movq %rax, -0x20(%rbp)
jmp 0x1b674
jmp 0x1b676
jmp 0x1b52b
movq -0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)