// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/jkOwnLib/ffAliHelp.c
// Function: slideIntron
static int slideIntron(struct ffAli *left, struct ffAli *right, int orientation)
/* Slides space between alignments if possible to match
 * intron consensus better.  Returns how much it slid intron. */
{
DNA *nLeft = left->nEnd;
DNA *hLeft = left->hEnd;
DNA *nRight = right->nStart;
DNA *hRight = right->hStart;
DNA nl, nr, hl, hr;
DNA *nLeftEnd = left->nStart;
DNA *nRightEnd = right->nEnd;
DNA *nBestLeft = NULL;
int bestScore = -0x7fffffff;
int curScore;
int offset;

if (hRight-hLeft < 4)   /* Too short to be an intron. */
    return 0;
if (nRight-nLeft > 2)   /* Too big of a gap to be an intron. */
    return 0;

/* Slide as far to the left as possible without inserting mismatches. */
while (nLeft > nLeftEnd)
    {
    nl = nLeft[-1];
    hl = hLeft[-1];
    nr = nRight[-1];
    hr = hRight[-1];
    if (!(nl == 'n' && nr == 'n'))  /* N's in needle freely slide. */
        {
        if (nr != hr)
            break;
        }
    nLeft -= 1;
    hLeft -= 1;
    nRight -= 1;
    hRight -= 1;
    }
/* Slide as far to the right as possible computing
   intron score as you go. */
while (nRight < nRightEnd)
    {
    curScore = ffScoreIntron(hLeft[0], hLeft[1], hRight[-2], hRight[-1], orientation);
    if (curScore > bestScore)
        {
        bestScore = curScore;
        nBestLeft = nLeft;
        }
    nl = nLeft[0];
    hl = hLeft[0];
    if (nl != 'n' && nl != hl)
        break;
    nr = nRight[0];
    hr = hRight[0];
    nLeft += 1;
    hLeft += 1;
    nRight += 1;
    hRight += 1;
    }
if (nBestLeft == NULL)
    return 0;
offset = nBestLeft - left->nEnd;
if (offset == 0)
    return offset;
left->nEnd += offset;
left->hEnd += offset;
right->nStart += offset;
right->hStart += offset;
return offset;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x58(%rbp)
movq $0x0, -0x60(%rbp)
movl $0x80000001, -0x64(%rbp) # imm = 0x80000001
movq -0x40(%rbp), %rax
movq -0x30(%rbp), %rcx
subq %rcx, %rax
cmpq $0x4, %rax
jge 0x1b1c7
movl $0x0, -0x4(%rbp)
jmp 0x1b3c4
movq -0x38(%rbp), %rax
movq -0x28(%rbp), %rcx
subq %rcx, %rax
cmpq $0x2, %rax
jle 0x1b1e4
movl $0x0, -0x4(%rbp)
jmp 0x1b3c4
jmp 0x1b1e6
movq -0x28(%rbp), %rax
cmpq -0x50(%rbp), %rax
jbe 0x1b26f
movq -0x28(%rbp), %rax
movb -0x1(%rax), %al
movb %al, -0x41(%rbp)
movq -0x30(%rbp), %rax
movb -0x1(%rax), %al
movb %al, -0x43(%rbp)
movq -0x38(%rbp), %rax
movb -0x1(%rax), %al
movb %al, -0x42(%rbp)
movq -0x40(%rbp), %rax
movb -0x1(%rax), %al
movb %al, -0x44(%rbp)
movsbl -0x41(%rbp), %eax
cmpl $0x6e, %eax
jne 0x1b22a
movsbl -0x42(%rbp), %eax
cmpl $0x6e, %eax
je 0x1b23a
movsbl -0x42(%rbp), %eax
movsbl -0x44(%rbp), %ecx
cmpl %ecx, %eax
je 0x1b238
jmp 0x1b26f
jmp 0x1b23a
movq -0x28(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x28(%rbp)
movq -0x30(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x30(%rbp)
movq -0x38(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x38(%rbp)
movq -0x40(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x1b1e6
jmp 0x1b271
movq -0x38(%rbp), %rax
cmpq -0x58(%rbp), %rax
jae 0x1b33a
movq -0x30(%rbp), %rax
movb (%rax), %sil
movq -0x30(%rbp), %rax
movb 0x1(%rax), %dl
movq -0x40(%rbp), %rax
movb -0x2(%rax), %cl
movq -0x40(%rbp), %rax
movb -0x1(%rax), %al
movl -0x1c(%rbp), %r8d
movsbl %sil, %edi
movsbl %dl, %esi
movsbl %cl, %edx
movsbl %al, %ecx
callq 0x1af90
movl %eax, -0x68(%rbp)
movl -0x68(%rbp), %eax
cmpl -0x64(%rbp), %eax
jle 0x1b2ca
movl -0x68(%rbp), %eax
movl %eax, -0x64(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x28(%rbp), %rax
movb (%rax), %al
movb %al, -0x41(%rbp)
movq -0x30(%rbp), %rax
movb (%rax), %al
movb %al, -0x43(%rbp)
movsbl -0x41(%rbp), %eax
cmpl $0x6e, %eax
je 0x1b2f3
movsbl -0x41(%rbp), %eax
movsbl -0x43(%rbp), %ecx
cmpl %ecx, %eax
je 0x1b2f3
jmp 0x1b33a
movq -0x38(%rbp), %rax
movb (%rax), %al
movb %al, -0x42(%rbp)
movq -0x40(%rbp), %rax
movb (%rax), %al
movb %al, -0x44(%rbp)
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x1b271
cmpq $0x0, -0x60(%rbp)
jne 0x1b34a
movl $0x0, -0x4(%rbp)
jmp 0x1b3c4
movq -0x60(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rcx
subq %rcx, %rax
movl %eax, -0x6c(%rbp)
cmpl $0x0, -0x6c(%rbp)
jne 0x1b36a
movl -0x6c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x1b3c4
movl -0x6c(%rbp), %edx
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rcx
movslq %edx, %rdx
addq %rdx, %rcx
movq %rcx, 0x18(%rax)
movl -0x6c(%rbp), %edx
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rcx
movslq %edx, %rdx
addq %rdx, %rcx
movq %rcx, 0x28(%rax)
movl -0x6c(%rbp), %edx
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rcx
movslq %edx, %rdx
addq %rdx, %rcx
movq %rcx, 0x10(%rax)
movl -0x6c(%rbp), %edx
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rcx
movslq %edx, %rdx
addq %rdx, %rcx
movq %rcx, 0x20(%rax)
movl -0x6c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)