// File: /workspace/github_c_makefile_star2_O2/thegenemyers[P]DASCRUBBER/align.c
// Function: middle_np
static int middle_np(char *A, int M, char *B, int N, Trace_Waves *wave, int mode, int dmax)
{ int  **PVF = wave->PVF; 
  int  **PHF = wave->PHF;
  int    D;
  int    del = M-N;

  { int  *F0, *F1, *F2;
    int  *HF;
    int   low, hgh;
    int   posl, posh;

#ifdef DEBUG_ALIGN
    printf("\n%*s BASE %ld,%ld: %d vs %d\n",depth,"",A-wave->Aabs,B-wave->Babs,M,N);
    printf("%*s A = ",depth,"");
    for (D = 0; D < M; D++)
      printf("%c",ToA[(int) A[D]]);
    printf("\n");
    printf("%*s B = ",depth,"");
    for (D = 0; D < N; D++)
      printf("%c",ToA[(int) B[D]]);
    printf("\n");
#endif

    if (del >= 0)
      { low = 0;
        hgh = del;
      }
    else
      { low = del;
        hgh = 0;
      }

    posl = -dmax;
    posh =  dmax;
    if (wave->Aabs == wave->Babs)
      { if (B == A)
          { EPRINTF(EPLACE,"%s: self comparison starts on diagonal 0 (Compute_Trace)\n",Prog_Name);
            EXIT(1);
          }
        else if (B < A)
          { if ((B-A)+1 > posl)
              posl = (B-A)+1;
          }
        else
          { if ((B-A)-1 < posh)
              posh = (B-A)-1;
          }
      }

    F1 = PVF[-2];
    F0 = PVF[-1];

    for (D = low-1; D <= hgh+1; D++)
      F1[D] = F0[D] = -2;
    F0[0] = -1;

    low += 1;
    hgh -= 1;

    for (D = 0; 1; D += 1)
      { int   k, i, j;
        int   am, ac, ap;
        char *a;

        if (D > dmax)
          { EPRINTF(EPLACE,"%s: %s\n",Prog_Name,TP_Align);
            EXIT(-1);
          }

        F2 = F1;
        F1 = F0;
        F0 = PVF[D];
        HF = PHF[D];

        if ((D & 0x1) == 0)
          { if (low > posl)
              low -= 1;
            if (hgh < posh)
              hgh += 1;
          }
        F0[hgh+1] = F0[low-1] = -2;

        j = -2;
        a = A + hgh;
        i = M - hgh;
        for (k = hgh; k > del; k--)
          { ap = j+1;
            am = F2[k-1];
            FS_MOVE(-1,4)
            a -= 1;
            i += 1;
          }

        j = -2;
        a = A + low;
        i = M - low;
        for (k = low; k < del; k++)
          { ap = F2[k+1]+1;
            am = j;
            FS_MOVE(2,1)
            a += 1;
            i -= 1;
          }

        ap = F0[del+1]+1;
        am = j;
        FS_MOVE(2,4)

#ifdef DEBUG_AWAVE
        print_awave(F0,low,hgh);
        print_awave(HF,low,hgh);
#endif

        if (F0[del] >= N)
          break;
      }
  }

  { int   k, h, m, e, c;
    int   d, f;

    d = D + abs(del);
    c = N;
    k = del;

    if (mode == UPPERMOST)

      for (f = d/2; d > f; d--)
        { e = PHF[D][k];
          h = k+e;
          if (e > 1)
            h -= 3;
          else if (e == 0)
            D -= 1;
          else
            D -= 2;

          if (h < k)       // => e = -1 or 2,  UPPERMOST
            { char *a;
  
              a = A + k;
              if (k < 0)
                m = -k;
              else
                m = 0;
              if (PVF[D][h] <= c)
                c = PVF[D][h]-1;
              while (c >= m && a[c] == B[c])
                c -= 1;
              if (e == -1)  //  => edge is 2, others are 1, and 0
                { if (c <= PVF[D+2][k+1])
                    { e = 4;
                      h = k+1;
                      D = D+2;
                    }
                  else if (c == PVF[D+1][k])
                    { e = 0;
                      h = k;
                      D = D+1;
                    }
                  else
                    PVF[D][h] = c+1;
                }
              else      //   => edge is 0, others are 1, and 2 (if k != del), 0 (otherwise)
                { if (k == del)
                    m = D;
                  else
                    m = D-2;
                  if (c <= PVF[m][k+1])
                    { if (k == del)
                        e = 4;
                      else
                        e = 1;
                      h = k+1;
                      D = m;
                    }
                  else if (c == PVF[D-1][k])
                    { e = 0;
                      h = k;
                      D = D-1;
                    }
                  else
                    PVF[D][h] = c+1;
                }
            }

          k = h;
        }

    else if (mode == LOWERMOST)

      for (f = d/2; d > f; d--)
        { e = PHF[D][k];
          h = k+e;
          if (e > 1)
            h -= 3;
          else if (e == 0)
            D -= 1;
          else
            D -= 2;

          if (h > k)       // => e = 1 or 4,   LOWERMOST
            { char *a;
  
              a = A + k;
              if (k < 0)
                m = -k;
              else
                m = 0;
              if (PVF[D][h] < c)
                c = PVF[D][h];
              while (c >= m && a[c] == B[c])
                c -= 1;
              if (e == 1)  //  => edge is 2, others are 1, and 0
                { if (c < PVF[D+2][k-1])
                    { e = 2;
                      h = k-1;
                      D = D+2;
                    }
                  else if (c == PVF[D+1][k])
                    { e = 0;
                      h = k;
                      D = D+1;
                    }
                  else
                    PVF[D][h] = c--;
                }
              else      //   => edge is 0, others are 1, and 2 (if k != del), 0 (otherwise)
                { if (k == del)
                    m = D;
                  else
                    m = D-2;
                  if (c < PVF[m][k-1])
                    { if (k == del)
                        e = 2;
                      else
                        e = -1;
                      h = k-1;
                      D = m;
                    }
                  else if (c == PVF[D-1][k])
                    { e = 0;
                      h = k;
                      D = D-1;
                    }
                  else
                    PVF[D][h] = c--;
                }
            }

          k = h;
        }

    else //  mode == GREEDIEST

      for (f = d/2; d > f; d--)
        { e = PHF[D][k];
          h = k+e;
          if (e > 1)
            h -= 3;
          else if (e == 0)
            D -= 1;
          else
            D -= 2;
          k = h;
        }

    wave->midb = (B-wave->Babs) + PVF[D][k];
    wave->mida = (A-wave->Aabs) + k + PVF[D][k];
  }

  return (0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movl %r9d, 0x64(%rsp)
movl 0xd0(%rsp), %r10d
movq 0x20(%r8), %r12
xorl %r11d, %r11d
movl %esi, 0x2c(%rsp)
movl %esi, %eax
movq %rcx, 0x8(%rsp)
subl %ecx, %eax
movq %rax, 0x30(%rsp)
movl %eax, %r15d
cmovnsl %r11d, %r15d
movq 0x28(%r8), %rcx
movq %rcx, 0x40(%rsp)
cmovnsl %eax, %r11d
movl %r10d, %eax
negl %eax
movl %eax, 0x28(%rsp)
movq 0x10(%r8), %rcx
movq 0x18(%r8), %r9
cmpq %r9, %rcx
movq %rdi, 0x18(%rsp)
movq %rcx, 0x78(%rsp)
je 0xfb6d
movl %r10d, %eax
movq %rax, 0x38(%rsp)
jmp 0xfbaa
movq %rdx, %rax
subq %rdi, %rax
je 0x1023c
jae 0xfb95
movslq 0x28(%rsp), %rcx
movl %r10d, %esi
movq %rsi, 0x38(%rsp)
cmpq %rcx, %rax
jl 0xfbaa
incl %eax
movl %eax, 0x28(%rsp)
jmp 0xfb63
notq %rdi
addq %rdx, %rdi
movl %r10d, %eax
cmpq %rax, %rdi
cmovgel %r10d, %edi
movq %rdi, 0x38(%rsp)
movq -0x10(%r12), %r14
movq -0x8(%r12), %rax
leal -0x1(%r15), %edi
leal 0x1(%r11), %ecx
movslq %edi, %rdi
pushq $-0x2
popq %rsi
cmpq %rcx, %rdi
jg 0xfbd3
movl %esi, (%rax,%rdi,4)
movl %esi, (%r14,%rdi,4)
incq %rdi
jmp 0xfbc2
movq %r9, 0x48(%rsp)
movq %r8, 0x50(%rsp)
orl $-0x1, (%rax)
incl %r15d
decl %r11d
movslq 0x30(%rsp), %rcx
movq %rcx, 0x58(%rsp)
movslq 0x8(%rsp), %r9
movslq %r10d, %rcx
movq %rcx, 0x88(%rsp)
xorl %r10d, %r10d
movq %r12, 0x20(%rsp)
movq %rax, 0x10(%rsp)
cmpq 0x88(%rsp), %r10
jg 0x1020b
testb $0x1, %r10b
jne 0xfc3b
xorl %eax, %eax
cmpl 0x28(%rsp), %r15d
setg %al
subl %eax, %r15d
xorl %eax, %eax
cmpl 0x38(%rsp), %r11d
setl %al
addl %eax, %r11d
movq (%r12,%r10,8), %rax
movq 0x40(%rsp), %rcx
movq (%rcx,%r10,8), %rbx
movq %r10, 0x68(%rsp)
movl %r10d, %ecx
movq %rcx, 0x80(%rsp)
movq %r15, 0x70(%rsp)
movslq %r15d, %rbp
pushq $-0x2
popq %r8
movl %r8d, -0x4(%rax,%rbp,4)
movq %r11, 0x90(%rsp)
movslq %r11d, %rsi
movl %r8d, 0x4(%rax,%rsi,4)
movq 0x18(%rsp), %rcx
leaq (%rcx,%rsi), %rdi
movl 0x2c(%rsp), %ecx
subl %esi, %ecx
movslq %ecx, %r12
movl %r8d, %r11d
movq 0x58(%rsp), %r8
cmpq %r8, %rsi
jle 0xfd43
leal 0x1(%r11), %r13d
movl -0x4(%r14,%rsi,4), %r10d
movq 0x10(%rsp), %rcx
movl (%rcx,%rsi,4), %r8d
leal 0x1(%r8), %ecx
cmpl %r10d, %ecx
jge 0xfccd
xorl %ecx, %ecx
cmpl %r10d, %r13d
setge %cl
leal -0x1(%rcx,%rcx,4), %r15d
cmovgl %r13d, %r10d
movl %r10d, %r11d
jmp 0xfce2
xorl %r15d, %r15d
cmpl %r8d, %r11d
setge %r15b
cmovll %ecx, %r13d
shll $0x2, %r15d
movl %r13d, %r11d
movl %r15d, (%rbx,%rsi,4)
movslq %r11d, %r13
cmpq %r9, %r12
movq 0x58(%rsp), %r8
jle 0xfd13
movq 0x8(%rsp), %rcx
cmpl %ecx, %r11d
cmovlel %ecx, %r11d
cmpq %r9, %r13
jge 0xfd31
movb (%rdx,%r13), %cl
cmpb (%rdi,%r13), %cl
jne 0xfd2e
incq %r13
jmp 0xfcff
cmpl %r12d, %r11d
cmovlel %r12d, %r11d
cmpq %r12, %r13
jge 0xfd31
movb (%rdx,%r13), %cl
cmpb (%rdi,%r13), %cl
jne 0xfd2e
incq %r13
jmp 0xfd1a
movl %r13d, %r11d
movl %r11d, (%rax,%rsi,4)
decq %rsi
decq %rdi
incq %r12
jmp 0xfc93
movq 0x18(%rsp), %rcx
leaq (%rcx,%rbp), %rdi
movl 0x2c(%rsp), %ecx
subl %ebp, %ecx
movslq %ecx, %rsi
pushq $-0x2
popq %rcx
movl %ecx, %r12d
cmpq %r8, %rbp
jge 0xfdf4
movl 0x4(%r14,%rbp,4), %r10d
leal 0x1(%r10), %r15d
movq 0x10(%rsp), %rcx
movl (%rcx,%rbp,4), %ecx
leal 0x1(%rcx), %r11d
xorl %r13d, %r13d
cmpl %r12d, %r11d
jge 0xfd94
cmpl %r12d, %r15d
setl %r13b
cmovgl %r15d, %r12d
incl %r13d
movl %r12d, %r11d
jmp 0xfd9f
cmpl %ecx, %r10d
setge %r13b
cmovgel %r15d, %r11d
movl %r13d, (%rbx,%rbp,4)
movslq %r11d, %r12
cmpq %r9, %rsi
jle 0xfdcb
movq 0x8(%rsp), %rcx
cmpl %ecx, %r11d
cmovlel %ecx, %r11d
cmpq %r9, %r12
jge 0xfddf
movb (%rdx,%r12), %cl
cmpb (%rdi,%r12), %cl
jne 0xfde2
incq %r12
jmp 0xfdb7
cmpq %rsi, %r12
jge 0xfde2
movb (%rdx,%r12), %cl
cmpb (%rdi,%r12), %cl
jne 0xfde2
incq %r12
jmp 0xfdcb
movl %r11d, %r12d
movl %r12d, (%rax,%rbp,4)
incq %rbp
incq %rdi
decq %rsi
jmp 0xfd5b
movl 0x4(%rax,%r8,4), %r10d
leal 0x1(%r10), %r11d
movslq %ebp, %r14
movq 0x10(%rsp), %rcx
movl (%rcx,%r14,4), %r8d
leal 0x1(%r8), %ecx
cmpl %r12d, %ecx
jge 0xfe24
xorl %ecx, %ecx
cmpl %r12d, %r11d
setge %cl
leal 0x2(%rcx,%rcx), %ebp
cmovgl %r11d, %r12d
jmp 0xfe37
xorl %ebp, %ebp
cmpl %r8d, %r10d
setge %bpl
cmovll %ecx, %r11d
shll $0x2, %ebp
movl %r11d, %r12d
movl %ebp, (%rbx,%r14,4)
movslq %r12d, %rbx
movq 0x8(%rsp), %rcx
cmpl %ecx, %esi
movq 0x90(%rsp), %r11
movq 0x58(%rsp), %r8
jle 0xfe77
cmpl %ecx, %r12d
cmovlel %ecx, %r12d
movq 0x70(%rsp), %r15
movq 0x68(%rsp), %r10
cmpq %r9, %rbx
jge 0xfe9b
movb (%rdx,%rbx), %cl
cmpb (%rdi,%rbx), %cl
jne 0xfe9e
incq %rbx
jmp 0xfe65
movslq %esi, %rsi
movq 0x20(%rsp), %r12
movq 0x70(%rsp), %r15
movq 0x68(%rsp), %r10
cmpq %rsi, %rbx
jge 0xfea3
movb (%rdx,%rbx), %cl
cmpb (%rdi,%rbx), %cl
jne 0xfea3
incq %rbx
jmp 0xfe89
movl %r12d, %ebx
movq 0x20(%rsp), %r12
movl %ebx, (%rax,%r14,4)
incq %r10
movq 0x10(%rsp), %r14
movq 0x8(%rsp), %rcx
cmpl %ecx, (%rax,%r8,4)
jl 0xfc08
movq 0x30(%rsp), %r8
movl %r8d, %eax
negl %eax
cmovsl %r8d, %eax
movq 0x80(%rsp), %r14
addl %r14d, %eax
movl %eax, %edi
shrl %edi
movl 0x64(%rsp), %ecx
cmpl $0x1, %ecx
movl %edi, 0x10(%rsp)
je 0x1004a
cmpl $-0x1, %ecx
movq 0x18(%rsp), %r11
jne 0x10196
cmpl %edi, %eax
jle 0x1018a
movslq %r14d, %rcx
movq 0x40(%rsp), %rsi
movq (%rsi,%rcx,8), %rcx
movslq %r8d, %r9
movl (%rcx,%r9,4), %r10d
leal (%r10,%r8), %esi
cmpl $0x2, %r10d
jl 0xff24
addl $-0x3, %esi
jmp 0xff32
testl %r10d, %r10d
je 0xff2f
addl $-0x2, %r14d
jmp 0xff32
decl %r14d
cmpl %r8d, %esi
jle 0x10040
movq %r12, %rbx
leaq (%r11,%r9), %r12
movl %r8d, %ecx
negl %ecx
movl %r8d, %ebp
sarl $0x1f, %ebp
andl %ecx, %ebp
movq %r14, %rdi
movslq %r14d, %r15
movq (%rbx,%r15,8), %rbx
movslq %esi, %r14
movl (%rbx,%r14,4), %ecx
movq 0x8(%rsp), %r11
cmpl %r11d, %ecx
cmovll %ecx, %r11d
decl %r11d
movq %r11, 0x8(%rsp)
incl %r11d
cmpl %ebp, %r11d
jl 0xff90
movl %r11d, %ecx
movb (%r12,%rcx), %r13b
cmpb (%rdx,%rcx), %r13b
jne 0xff90
movq 0x8(%rsp), %r11
jmp 0xff6c
cmpl $0x1, %r10d
jne 0xffb3
movq 0x20(%rsp), %r12
movq 0x10(%r12,%r15,8), %rcx
cmpl -0x4(%rcx,%r9,4), %r11d
jge 0xffe8
movq %rdi, %r14
addl $0x2, %r14d
decl %r8d
jmp 0x1002c
movq %rdi, %r10
leal -0x2(%rdi), %ecx
cmpl 0x30(%rsp), %r8d
cmovel %r10d, %ecx
movslq %ecx, %r10
movq 0x20(%rsp), %r12
movq (%r12,%r10,8), %r10
cmpl -0x4(%r10,%r9,4), %r11d
jge 0x10004
decl %r8d
movl %r8d, %esi
movl %r11d, %r8d
movq %r8, 0x8(%rsp)
movl %ecx, %r14d
jmp 0x10037
movq 0x8(%r12,%r15,8), %rcx
movq 0x8(%rsp), %r10
subl (%rcx,%r9,4), %r10d
cmpl $-0x1, %r10d
jne 0x10018
movq %rdi, %r14
incl %r14d
jmp 0x1002c
movq -0x8(%r12,%r15,8), %rcx
movq 0x8(%rsp), %r10
subl (%rcx,%r9,4), %r10d
cmpl $-0x1, %r10d
je 0x10026
movl %r11d, (%rbx,%r14,4)
movq 0x18(%rsp), %r11
movq %rdi, %r14
jmp 0x1003c
movq %rdi, %r14
decl %r14d
movl %r8d, %esi
movl %r11d, %ecx
movq %rcx, 0x8(%rsp)
movq 0x18(%rsp), %r11
movl 0x10(%rsp), %edi
decl %eax
movl %esi, %r8d
jmp 0xfefa
movq 0x18(%rsp), %r11
cmpl %edi, %eax
jle 0x1018a
movslq %r14d, %rcx
movq 0x40(%rsp), %rsi
movq (%rsi,%rcx,8), %rcx
movslq %r8d, %r9
movl (%rcx,%r9,4), %r10d
leal (%r10,%r8), %esi
cmpl $0x2, %r10d
jl 0x10079
addl $-0x3, %esi
jmp 0x10087
testl %r10d, %r10d
je 0x10084
addl $-0x2, %r14d
jmp 0x10087
decl %r14d
cmpl %r8d, %esi
jge 0x10180
leaq (%r11,%r9), %r15
movl %r8d, %ecx
negl %ecx
movl %r8d, %ebp
sarl $0x1f, %ebp
andl %ecx, %ebp
movq %r14, %rdi
movslq %r14d, %r14
movq (%r12,%r14,8), %r11
movslq %esi, %rbx
movl (%r11,%rbx,4), %ecx
leal -0x1(%rcx), %r12d
movq 0x8(%rsp), %r13
cmpl %r13d, %ecx
cmovgl %r13d, %r12d
cmpl %ebp, %r12d
jl 0x100df
movl %r12d, %ecx
movq %r12, %r13
movb (%r15,%rcx), %r12b
cmpb (%rdx,%rcx), %r12b
movq %r13, %r12
jne 0x100df
decl %r12d
jmp 0x100c2
movq %r12, 0x8(%rsp)
cmpl $-0x1, %r10d
je 0x10124
movq %rdi, %r10
leal -0x2(%rdi), %ecx
cmpl 0x30(%rsp), %r8d
cmovel %r10d, %ecx
movslq %ecx, %r10
movq 0x20(%rsp), %r12
movq (%r12,%r10,8), %r10
movq 0x8(%rsp), %r15
cmpl 0x4(%r10,%r9,4), %r15d
jle 0x1014d
movq -0x8(%r12,%r14,8), %rcx
cmpl %r15d, (%rcx,%r9,4)
jne 0x10158
movq %rdi, %r14
decl %r14d
jmp 0x10174
movq 0x20(%rsp), %r12
movq 0x10(%r12,%r14,8), %rcx
movq 0x8(%rsp), %r15
cmpl 0x4(%rcx,%r9,4), %r15d
jle 0x1016a
movq 0x8(%r12,%r14,8), %rcx
cmpl %r15d, (%rcx,%r9,4)
jne 0x10158
movq %rdi, %r14
incl %r14d
jmp 0x10174
incl %r8d
movl %r8d, %esi
movl %ecx, %r14d
jmp 0x10177
leal 0x1(%r15), %ecx
movl %ecx, (%r11,%rbx,4)
movq 0x18(%rsp), %r11
movq %rdi, %r14
jmp 0x1017c
movq %rdi, %r14
addl $0x2, %r14d
incl %r8d
movl %r8d, %esi
movq 0x18(%rsp), %r11
movl 0x10(%rsp), %edi
decl %eax
movl %esi, %r8d
jmp 0x1004f
movq 0x50(%rsp), %rsi
movq 0x48(%rsp), %r9
jmp 0x101d6
movq 0x50(%rsp), %rsi
movq 0x48(%rsp), %r9
movq 0x40(%rsp), %r10
cmpl %edi, %eax
jle 0x101d6
movslq %r14d, %rcx
movq (%r10,%rcx,8), %rcx
movslq %r8d, %r8
movl (%rcx,%r8,4), %ecx
addl %ecx, %r8d
cmpl $0x2, %ecx
jl 0x101c5
addl $-0x3, %r8d
jmp 0x101d2
testl %ecx, %ecx
je 0x101cf
addl $-0x2, %r14d
jmp 0x101d2
decl %r14d
decl %eax
jmp 0x101a5
subl %r9d, %edx
movslq %r14d, %rax
movq (%r12,%rax,8), %rax
movslq %r8d, %rcx
addl (%rax,%rcx,4), %edx
movl %edx, 0x34(%rsi)
subl 0x78(%rsp), %r11d
addl %ecx, %r11d
addl (%rax,%rcx,4), %r11d
movl %r11d, 0x30(%rsi)
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xdde6(%rip), %rax      # 0x1dff8
movq (%rax), %rdi
leaq 0xe0d4(%rip), %rax      # 0x1e2f0
movq (%rax), %rdx
leaq 0x8436(%rip), %rsi      # 0x1865c
leaq 0x8512(%rip), %rcx      # 0x1873f
xorl %eax, %eax
callq 0x11a0
pushq $0x1
popq %rdi
callq 0x1280
movq 0xddb5(%rip), %rax      # 0x1dff8
movq (%rax), %rdi
leaq 0xe0a3(%rip), %rax      # 0x1e2f0
movq (%rax), %rdx
leaq 0x84ae(%rip), %rsi      # 0x18705
xorl %eax, %eax
callq 0x11a0
jmp 0x10234