// File: /workspace/github_c_makefile_star2_O2/icebert[P]pblat/jkOwnLib/fuzzyFind.c
// Function: expandRight
static boolean expandRight(struct ffAli *ali, DNA *needleStart, DNA *needleEnd,
                           DNA *hayStart, DNA *hayEnd, int numSkips, int gapPenalty, int maxSkip,
                           struct lm **ffMemPool)
/* Given a matched segment, try to expand it to the right. */
{
    int score;
    DNA *ne = ali->nEnd;
    DNA *he = ali->hEnd;
    DNA *oldNe = ne;

    for (;;)
    {
        /* Expand as far to the right as you can keeping perfect match */
        while (ne < needleEnd && he < hayEnd && *ne == *he)
        {
            ++he;
            ++ne;
        }

        /* Check to see if have come to the end. */
        if (ne >= needleEnd || he >= hayEnd)
        {
            ali->nEnd = ne;
            ali->hEnd = he;
            return oldNe != ne;
        }

        /* Find fuzzy score to the right. */
        {
            int windowSize = 5;
            int nSize = needleEnd-ne;
            int hSize = hayEnd - he;
            if (windowSize > nSize) windowSize = nSize;
            if (windowSize > hSize) windowSize = hSize;
            if (windowSize > 0)
                score = dnaScoreMatch(ne, he, windowSize);
            else
                score = -1;

            if (score >= windowSize-2)
            {
                he += windowSize;
                ne += windowSize;
            }
            else if (--numSkips >= 0)
            {
                struct ffAli *newAli = ffNeedMem(sizeof(*newAli), ffMemPool);
                ali->nEnd = ne;
                ali->hEnd = he;
                if (needleEnd - ne < 3 ||
                        !rightNextMatch(newAli, ne, needleEnd, he, hayEnd, gapPenalty, maxSkip))
                {
                    return oldNe != ne; /* We did our best... */
                }
                newAli->left = ali;
                newAli->right = ali->right;
                if (ali->right)
                    ali->right->left = newAli;
                ali->right = newAli;
                ali = newAli;
                expandLeft(ali, ne, needleEnd, he, hayEnd, 0, gapPenalty, maxSkip, ffMemPool);
                ne = ali->nEnd;
                he = ali->hEnd;
            }
            else
            {
                ali->nEnd = ne;
                ali->hEnd = he;
                return oldNe != ne;
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movl %r9d, 0x34(%rsp)
movl %r8d, 0x3c(%rsp)
movl %ecx, 0x38(%rsp)
movq %rdx, %r8
movq %rdi, %r15
movabsq $-0x100000000, %rdi     # imm = 0xFFFFFFFF00000000
movq 0x18(%r15), %rdx
movq %rsi, %r9
shlq $0x20, %r9
leal (%r8,%rsi), %r10d
movl %r8d, %eax
negl %eax
movq %rax, 0xc8(%rsp)
movq %r8, %r11
shlq $0x20, %r11
pushq $0x1
popq %rbx
subl %r8d, %ebx
movq %rdx, %rax
movq %rbx, 0x98(%rsp)
movq %r15, 0x68(%rsp)
movq 0x28(%r15), %r14
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
shlq $0x20, %rax
movq %r9, %rcx
subq %rax, %rcx
movq %rcx, 0x78(%rsp)
movl %r10d, %eax
subl %r14d, %eax
subl 0x10(%rsp), %eax
movq %rax, 0x28(%rsp)
movl %r8d, %ecx
subl %r14d, %ecx
movl %esi, %ebp
subl 0x10(%rsp), %ebp
movq %r14, %rax
shlq $0x20, %rax
movq %r11, %r15
subq %rax, %r15
movq 0x10(%rsp), %rax
movq %r15, 0x70(%rsp)
leal (%rbx,%r14), %r12d
movl %ecx, 0x1c(%rsp)
xorl %r13d, %r13d
movq %rax, 0xa0(%rsp)
leaq (%rax,%r13), %rbx
movq %r14, %r15
addq %r13, %r14
cmpq %rsi, %rbx
jae 0xa855
cmpq %r8, %r14
jae 0xa855
movb (%rbx), %al
cmpb (%r14), %al
jne 0xa4fe
incq 0xa0(%rsp)
incq %r13
addq %rdi, 0x78(%rsp)
movq 0x28(%rsp), %rax
addl $-0x2, %eax
movq %rax, 0x28(%rsp)
decl 0x1c(%rsp)
decl %ebp
addq %rdi, 0x70(%rsp)
incl %r12d
movq %r15, %r14
movq 0x10(%rsp), %rax
jmp 0xa4a6
movl %esi, %eax
subl 0x10(%rsp), %eax
subl %r13d, %eax
subl %r13d, %ecx
cmpl %ecx, %eax
cmovll %eax, %ecx
cmpl $0x5, %ecx
pushq $0x5
popq %rax
cmovll %ecx, %eax
movl %eax, 0x48(%rsp)
pushq $-0x1
popq %rax
testl %ecx, %ecx
jle 0xa578
movq %rbx, %rdi
movq %rsi, 0x60(%rsp)
movq %r14, %rsi
movq %rdx, 0x20(%rsp)
movl 0x48(%rsp), %edx
movq %r8, 0x40(%rsp)
movq %r9, 0x58(%rsp)
movl %r10d, 0x18(%rsp)
movq %r11, 0x50(%rsp)
callq 0x21317
movq 0x50(%rsp), %r11
movl 0x18(%rsp), %r10d
movq 0x58(%rsp), %r9
movabsq $-0x100000000, %rdi     # imm = 0xFFFFFFFF00000000
movq 0x60(%rsp), %rsi
movq 0x40(%rsp), %r8
movq 0x20(%rsp), %rdx
movl 0x48(%rsp), %ecx
addl $-0x2, %ecx
cmpl %ecx, %eax
jl 0xa5b3
movslq 0x1c(%rsp), %rax
movslq %ebp, %rcx
cmpq %rcx, %rax
cmovlq %rax, %rcx
cmpq $0x5, %rcx
pushq $0x5
popq %rax
cmovgeq %rax, %rcx
addq %rcx, %r14
addq %rcx, %rbx
movq %rbx, %rax
movq 0x98(%rsp), %rbx
jmp 0xa448
cmpl $0x0, 0x38(%rsp)
movq 0x10(%rsp), %rax
jle 0xa855
movq %r11, 0x50(%rsp)
movl %r10d, 0x18(%rsp)
movq %r9, 0x58(%rsp)
movq %rsi, 0x60(%rsp)
movq %rsi, %rbp
subq %rax, %rbp
subq %r13, %rbp
pushq $0x38
popq %rdi
movq 0x110(%rsp), %rsi
movq %rdx, 0x20(%rsp)
movq %r8, 0x40(%rsp)
callq 0x8e0c
movq 0x40(%rsp), %rcx
movq 0x20(%rsp), %rdx
movq %rax, 0xa8(%rsp)
movq 0x68(%rsp), %rax
movq %rbx, 0x18(%rax)
movq %r14, 0x28(%rax)
cmpq $0x3, %rbp
jl 0xa862
movl %r12d, %esi
decl 0x38(%rsp)
movl %ecx, %eax
movq %r15, %rcx
subl %ecx, %eax
subq %r13, %rax
movq %rax, 0xb0(%rsp)
movl 0x34(%rsp), %eax
movq 0x28(%rsp), %r12
cmpl %eax, %r12d
cmovgel %eax, %r12d
movq 0xc8(%rsp), %rax
addl %r15d, %eax
leal (%rax,%r13), %ecx
sarq $0x20, 0x78(%rsp)
sarq $0x20, 0x70(%rsp)
testl %r12d, %r12d
movl $0x0, %eax
cmovlel %eax, %r12d
incl %r12d
movq %r12, 0x28(%rsp)
pushq $0x1
popq %r12
testl %esi, %esi
movl $0x0, %eax
cmovgl %esi, %eax
cmpq 0x28(%rsp), %r12
je 0xa862
movl %esi, 0x88(%rsp)
addq 0xa0(%rsp), %rax
movq %rax, 0x10(%rsp)
incl %ecx
testl %ecx, %ecx
movl $0x0, %ebp
movl %ecx, 0x84(%rsp)
cmovgl %ecx, %ebp
movq %r12, %rdi
callq 0x2d0c4
movq %rbp, %rdx
movq 0x10(%rsp), %rcx
movl %eax, %esi
addl 0x3c(%rsp), %esi
cmpq 0x70(%rsp), %r12
movq %r12, 0xb8(%rsp)
cmovgl 0xb0(%rsp), %r12d
movslq %esi, %rax
movq 0x78(%rsp), %rdi
movq %rax, 0x90(%rsp)
subq %rax, %rdi
movl 0x1c(%rsp), %ebp
subl %r12d, %ebp
movl %esi, 0x8c(%rsp)
movq %rdi, 0xc0(%rsp)
testl %r12d, %r12d
js 0xa788
cmpq %rdi, %rdx
jg 0xa788
movl %r12d, %r12d
cmpl %ebp, %esi
jg 0xa77b
movb (%rcx), %al
leaq (%r15,%r12), %r8
cmpb (%r13,%r8), %al
jne 0xa77b
leaq (%r14,%r12), %rsi
movq %rcx, 0x10(%rsp)
movq 0x10(%rsp), %rdi
movq %rdx, 0x48(%rsp)
movq 0x90(%rsp), %rdx
movq %r8, 0xd0(%rsp)
callq 0x6710
movq 0xd0(%rsp), %r8
movq 0xc0(%rsp), %rdi
movl 0x8c(%rsp), %esi
movq 0x48(%rsp), %rdx
movq 0x10(%rsp), %rcx
testl %eax, %eax
je 0xa7ad
decl %r12d
incq %rdx
incq %rcx
incl %ebp
jmp 0xa710
movq 0xb8(%rsp), %r12
incq %r12
movl 0x88(%rsp), %esi
incl %esi
movq 0x20(%rsp), %rdx
movl 0x84(%rsp), %ecx
jmp 0xa67f
movq 0xa8(%rsp), %r15
movq %rcx, 0x10(%r15)
movq 0x90(%rsp), %rdx
addq %rdx, %rcx
movq %rcx, 0x18(%r15)
leaq (%r8,%r13), %rax
movq %rax, 0x20(%r15)
addq %rdx, %r8
addq %r13, %r8
movq %r8, 0x28(%r15)
movq 0x68(%rsp), %rcx
movq %rcx, (%r15)
movq 0x8(%rcx), %rax
movq %rax, 0x8(%r15)
testq %rax, %rax
je 0xa7f2
movq %r15, (%rax)
movq %r15, 0x8(%rcx)
movq 0x110(%rsp), %rax
movq %rax, (%rsp)
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
xorl %ecx, %ecx
movl 0x3c(%rsp), %r8d
movl 0x34(%rsp), %r9d
callq 0x9f72
movq 0x18(%r15), %rax
movq 0x20(%rsp), %rdx
movq 0x40(%rsp), %r8
movq 0x60(%rsp), %rsi
movabsq $-0x100000000, %rdi     # imm = 0xFFFFFFFF00000000
movq 0x58(%rsp), %r9
movl 0x18(%rsp), %r10d
movq 0x50(%rsp), %r11
movq 0x98(%rsp), %rbx
jmp 0xa43f
movq 0x68(%rsp), %rax
movq %rbx, 0x18(%rax)
movq %r14, 0x28(%rax)
xorl %eax, %eax
cmpq %rdx, %rbx
setne %al
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq