// File: /workspace/github_c_makefile_star2_O1/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 %ecx, %ebx
movl 0xd0(%rsp), %r11d
movq 0x20(%r8), %r13
xorl %r12d, %r12d
movl %esi, 0x44(%rsp)
movl %esi, %ecx
subl %ebx, %ecx
movl %ecx, %ebp
cmovnsl %r12d, %ebp
movq 0x28(%r8), %rax
movq %rax, 0x58(%rsp)
movl %ecx, 0xc(%rsp)
cmovnsl %ecx, %r12d
movl %r11d, %eax
negl %eax
movl %eax, 0x24(%rsp)
movq 0x10(%r8), %rcx
movq %r8, 0x88(%rsp)
movq 0x18(%r8), %rsi
movq %rsi, 0x78(%rsp)
cmpq %rsi, %rcx
movq %rdi, 0x30(%rsp)
movq %rcx, 0x80(%rsp)
movl %r9d, 0x6c(%rsp)
je 0x112c3
movl %r11d, %eax
movq %rax, 0x48(%rsp)
jmp 0x11300
movq %rdx, %rax
subq %rdi, %rax
je 0x1196f
jae 0x112eb
movslq 0x24(%rsp), %rcx
movl %r11d, %esi
movq %rsi, 0x48(%rsp)
cmpq %rcx, %rax
jl 0x11300
incl %eax
movl %eax, 0x24(%rsp)
jmp 0x112b9
notq %rdi
addq %rdx, %rdi
movl %r11d, %eax
cmpq %rax, %rdi
cmovgel %r11d, %edi
movq %rdi, 0x48(%rsp)
movq -0x10(%r13), %rax
movq -0x8(%r13), %r10
leal -0x1(%rbp), %ecx
leal 0x1(%r12), %esi
cmpl %esi, %ecx
jg 0x11340
movslq %ecx, %rsi
leaq (%r10,%rsi,4), %rcx
leaq (%rax,%rsi,4), %rsi
movl %r12d, %edi
subl %ebp, %edi
addl $0x3, %edi
xorl %r8d, %r8d
movl $0xfffffffe, %r9d       # imm = 0xFFFFFFFE
movl %r9d, (%rcx,%r8,4)
movl %r9d, (%rsi,%r8,4)
incq %r8
cmpl %r8d, %edi
jne 0x11330
movl $0xffffffff, (%r10)     # imm = 0xFFFFFFFF
testl %r11d, %r11d
js 0x11628
decl %r12d
incl %ebp
movslq 0xc(%rsp), %rcx
movq %rcx, 0x28(%rsp)
movslq %ebx, %r8
incl %r11d
movq %r11, 0x90(%rsp)
xorl %r14d, %r14d
movq %rbx, 0x60(%rsp)
movq %r13, 0x50(%rsp)
movq %r10, 0x10(%rsp)
testb $0x1, %r14b
jne 0x1139d
xorl %ecx, %ecx
cmpl 0x24(%rsp), %ebp
setg %cl
subl %ecx, %ebp
xorl %ecx, %ecx
cmpl 0x48(%rsp), %r12d
setl %cl
addl %ecx, %r12d
movq (%r13,%r14,8), %r10
movq 0x58(%rsp), %rcx
movq %r14, 0x18(%rsp)
movq (%rcx,%r14,8), %r15
movq %rbp, 0x38(%rsp)
movslq %ebp, %r13
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
movl %esi, -0x4(%r10,%r13,4)
movq %r12, 0x70(%rsp)
movslq %r12d, %rcx
movl %esi, 0x4(%r10,%rcx,4)
cmpl 0xc(%rsp), %ecx
jle 0x1149a
movl 0x44(%rsp), %esi
subl %ecx, %esi
movq 0x30(%rsp), %rdi
leaq (%rdi,%rcx), %r11
movslq %esi, %rbp
movl $0xfffffffe, %r12d      # imm = 0xFFFFFFFE
leal 0x1(%r12), %edi
movl -0x4(%rax,%rcx,4), %r14d
movq 0x10(%rsp), %rsi
movl (%rsi,%rcx,4), %ebx
leal 0x1(%rbx), %r9d
cmpl %r14d, %r9d
jge 0x11422
xorl %esi, %esi
cmpl %r14d, %edi
setge %sil
leal -0x1(%rsi,%rsi,4), %esi
cmovgl %edi, %r14d
movl %r14d, %r12d
jmp 0x11435
xorl %esi, %esi
cmpl %ebx, %r12d
setge %sil
cmovll %r9d, %edi
shll $0x2, %esi
movl %edi, %r12d
movq 0x60(%rsp), %rbx
movl %esi, (%r15,%rcx,4)
cmpq %r8, %rbp
jle 0x11462
cmpl %ebx, %r12d
jge 0x11482
movslq %r12d, %r12
movb (%rdx,%r12), %sil
cmpb (%r11,%r12), %sil
jne 0x11482
incq %r12
cmpq %r12, %r8
jne 0x1144b
movl %ebx, %r12d
jmp 0x11482
movslq %r12d, %rdi
cmpq %rdi, %rbp
jle 0x11482
movb (%rdx,%rdi), %sil
cmpb (%r11,%rdi), %sil
jne 0x1147f
incq %rdi
cmpq %rbp, %rdi
jl 0x1146a
movq %rbp, %rdi
movl %edi, %r12d
movl %r12d, (%r10,%rcx,4)
decq %rcx
decq %r11
incq %rbp
cmpq 0x28(%rsp), %rcx
jg 0x113f1
movq 0x30(%rsp), %rcx
leaq (%rcx,%r13), %r11
movl 0x44(%rsp), %ecx
movl %ecx, %ebp
subl %r13d, %ebp
movl $0xfffffffe, %ecx       # imm = 0xFFFFFFFE
cmpl 0xc(%rsp), %r13d
jge 0x1155a
movslq %ebp, %rbp
movl $0xfffffffe, %ecx       # imm = 0xFFFFFFFE
movl 0x4(%rax,%r13,4), %r14d
leal 0x1(%r14), %r12d
movq 0x10(%rsp), %rsi
movl (%rsi,%r13,4), %r9d
leal 0x1(%r9), %esi
xorl %edi, %edi
cmpl %ecx, %esi
jge 0x114ef
cmpl %ecx, %r12d
setl %dil
cmovgl %r12d, %ecx
incl %edi
jmp 0x114fc
cmpl %r9d, %r14d
setge %dil
cmovgel %r12d, %esi
movl %esi, %ecx
movl %edi, (%r15,%r13,4)
cmpq %r8, %rbp
jle 0x11522
cmpl %ebx, %ecx
jge 0x11540
movslq %ecx, %rcx
movb (%rdx,%rcx), %sil
cmpb (%r11,%rcx), %sil
jne 0x11540
incq %rcx
cmpq %rcx, %r8
jne 0x1150c
movl %ebx, %ecx
jmp 0x11540
movslq %ecx, %rdi
cmpq %rdi, %rbp
jle 0x11540
movb (%rdx,%rdi), %cl
cmpb (%r11,%rdi), %cl
jne 0x1153e
incq %rdi
cmpq %rbp, %rdi
jl 0x1152a
movq %rbp, %rdi
movl %edi, %ecx
movl %ecx, (%r10,%r13,4)
incq %r13
incq %r11
decq %rbp
cmpq 0x28(%rsp), %r13
jl 0x114c4
jmp 0x1155f
movq 0x38(%rsp), %r13
movq 0x28(%rsp), %rax
movl 0x4(%r10,%rax,4), %r14d
leal 0x1(%r14), %edi
movslq %r13d, %rax
movq 0x10(%rsp), %rsi
movl (%rsi,%rax,4), %ebx
leal 0x1(%rbx), %r9d
cmpl %ecx, %r9d
jge 0x11592
xorl %esi, %esi
cmpl %ecx, %edi
setge %sil
leal 0x2(%rsi,%rsi), %esi
cmovgl %edi, %ecx
jmp 0x115a4
xorl %esi, %esi
cmpl %ebx, %r14d
setge %sil
cmovll %r9d, %edi
shll $0x2, %esi
movl %edi, %ecx
movq 0x50(%rsp), %r13
movq 0x18(%rsp), %r14
movq 0x70(%rsp), %r12
movl %esi, (%r15,%rax,4)
movq 0x60(%rsp), %rbx
cmpl %ebx, %ebp
jle 0x115e1
cmpl %ebx, %ecx
movq 0x38(%rsp), %rbp
jge 0x11600
movslq %ecx, %rcx
movb (%rdx,%rcx), %sil
cmpb (%r11,%rcx), %sil
jne 0x11600
incq %rcx
cmpl %ecx, %ebx
jne 0x115cc
movl %ebx, %ecx
jmp 0x11600
cmpl %ebp, %ecx
jge 0x115fb
movslq %ecx, %rcx
movb (%rdx,%rcx), %sil
cmpb (%r11,%rcx), %sil
jne 0x115fb
incq %rcx
cmpl %ecx, %ebp
jne 0x115e8
movl %ebp, %ecx
movq 0x38(%rsp), %rbp
movl %ecx, (%r10,%rax,4)
movq 0x28(%rsp), %rax
cmpl %ebx, (%r10,%rax,4)
movq 0x90(%rsp), %rcx
jge 0x1162d
incq %r14
movq 0x10(%rsp), %rax
cmpq %rcx, %r14
jne 0x1137a
callq 0x144f
movl 0xc(%rsp), %eax
movl %eax, %r11d
negl %r11d
cmovsl %eax, %r11d
addl %r14d, %r11d
movl %r11d, %r12d
shrl %r12d
movl 0x6c(%rsp), %eax
cmpl $-0x1, %eax
movl %r12d, 0x10(%rsp)
je 0x117af
cmpl $0x1, %eax
jne 0x118ec
testl %r11d, %r11d
je 0x11929
movl 0xc(%rsp), %eax
movl %eax, %ecx
movslq %r14d, %rax
movq 0x58(%rsp), %rsi
movq (%rsi,%rax,8), %rax
movslq %ecx, %r9
movl (%rax,%r9,4), %r10d
leal (%r10,%rcx), %eax
cmpl $0x2, %r10d
jl 0x11690
addl $-0x3, %eax
jmp 0x1169e
testl %r10d, %r10d
je 0x1169b
addl $-0x2, %r14d
jmp 0x1169e
decl %r14d
cmpl %ecx, %eax
jge 0x1174c
movl %ecx, %esi
negl %esi
movl %ecx, %ebp
sarl $0x1f, %ebp
andl %esi, %ebp
movq %r14, 0x18(%rsp)
movslq %r14d, %r12
movq %rbx, %r8
movq (%r13,%r12,8), %rbx
movslq %eax, %r15
movl (%rbx,%r15,4), %esi
leal -0x1(%rsi), %edi
cmpl %r8d, %esi
cmovgl %r8d, %edi
cmpl %ebp, %edi
jl 0x11711
testl %ecx, %ecx
movl $0x0, %r13d
cmovgl %ecx, %r13d
movq 0x30(%rsp), %rsi
leaq (%rsi,%r9), %r14
movl %ecx, %esi
notl %esi
addl %r13d, %esi
movl %edi, %r13d
movb (%r14,%r13), %r8b
cmpb (%rdx,%r13), %r8b
jne 0x1170c
leal -0x1(%rdi), %r8d
cmpl %ebp, %edi
movl %r8d, %edi
jg 0x116f2
movl %esi, %edi
movq 0x50(%rsp), %r13
cmpl $-0x1, %r10d
je 0x11750
movq 0x18(%rsp), %r8
leal -0x2(%r8), %esi
cmpl 0xc(%rsp), %ecx
cmovel %r8d, %esi
movslq %esi, %r8
movq (%r13,%r8,8), %r8
cmpl 0x4(%r8,%r9,4), %edi
jle 0x11771
movq -0x8(%r13,%r12,8), %rsi
cmpl (%rsi,%r9,4), %edi
jne 0x1177a
movq 0x18(%rsp), %r14
decl %r14d
jmp 0x11793
movl %ebx, %edi
jmp 0x1179a
movq 0x10(%r13,%r12,8), %rsi
cmpl 0x4(%rsi,%r9,4), %edi
jle 0x11788
movq 0x8(%r13,%r12,8), %rsi
cmpl (%rsi,%r9,4), %edi
jne 0x1177a
movq 0x18(%rsp), %r14
incl %r14d
jmp 0x11793
incl %ecx
movl %ecx, %eax
movl %esi, %r14d
jmp 0x11795
leal 0x1(%rdi), %ecx
movl %ecx, (%rbx,%r15,4)
movq 0x18(%rsp), %r14
jmp 0x11795
movq 0x18(%rsp), %r14
addl $0x2, %r14d
incl %ecx
movl %ecx, %eax
movl 0x10(%rsp), %r12d
decl %r11d
movl %edi, %ebx
movl %eax, %ecx
cmpl %r12d, %r11d
jg 0x1166e
jmp 0x1192d
testl %r11d, %r11d
je 0x11929
movl 0xc(%rsp), %eax
movl %eax, %ecx
movslq %r14d, %rax
movq 0x58(%rsp), %rsi
movq (%rsi,%rax,8), %rax
movslq %ecx, %rdi
movl (%rax,%rdi,4), %r9d
leal (%r9,%rcx), %eax
cmpl $0x2, %r9d
jl 0x117e0
addl $-0x3, %eax
jmp 0x117ee
testl %r9d, %r9d
je 0x117eb
addl $-0x2, %r14d
jmp 0x117ee
decl %r14d
cmpl %ecx, %eax
jle 0x118dc
movl %ecx, %esi
negl %esi
movl %ecx, %ebp
sarl $0x1f, %ebp
andl %esi, %ebp
movslq %r14d, %r15
movq (%r13,%r15,8), %rsi
movq %rbx, %r8
movslq %eax, %rbx
movq %rsi, 0x28(%rsp)
movl (%rsi,%rbx,4), %esi
cmpl %r8d, %esi
cmovll %esi, %r8d
movq %r8, %r10
cmpl %ebp, %r8d
jl 0x1186d
movq %r14, 0x18(%rsp)
testl %ecx, %ecx
movl $0x0, %r8d
cmovgl %ecx, %r8d
movq 0x30(%rsp), %rsi
leaq (%rsi,%rdi), %r12
movl %ecx, %esi
notl %esi
addl %r8d, %esi
movl %r10d, %r8d
movb (%r12,%r8), %r14b
cmpb (%rdx,%r8), %r14b
jne 0x11863
leal -0x1(%r10), %r8d
cmpl %ebp, %r10d
movl %r8d, %r10d
jg 0x11847
movl %esi, %r10d
movq 0x18(%rsp), %r14
movl 0x10(%rsp), %r12d
cmpl $0x1, %r9d
jne 0x11887
movq 0x10(%r13,%r15,8), %rsi
cmpl -0x4(%rsi,%rdi,4), %r10d
jge 0x118ab
addl $0x2, %r14d
decl %ecx
jmp 0x118c9
leal -0x2(%r14), %esi
cmpl 0xc(%rsp), %ecx
cmovel %r14d, %esi
movslq %esi, %r8
movq (%r13,%r8,8), %r8
cmpl -0x4(%r8,%rdi,4), %r10d
jge 0x118bb
decl %ecx
movl %ecx, %eax
movl %esi, %r14d
jmp 0x118d9
movq 0x8(%r13,%r15,8), %rsi
cmpl (%rsi,%rdi,4), %r10d
jne 0x118cd
incl %r14d
jmp 0x118c9
movq -0x8(%r13,%r15,8), %rsi
cmpl (%rsi,%rdi,4), %r10d
jne 0x118cd
decl %r14d
movl %ecx, %eax
jmp 0x118d9
movq 0x28(%rsp), %rcx
movl %r10d, (%rcx,%rbx,4)
decl %r10d
movq %r10, %rbx
decl %r11d
movl %eax, %ecx
cmpl %r12d, %r11d
jg 0x117be
jmp 0x1192d
testl %r11d, %r11d
je 0x11929
movl 0xc(%rsp), %eax
movq 0x58(%rsp), %rsi
movslq %r14d, %rcx
movq (%rsi,%rcx,8), %rcx
cltq
movl (%rcx,%rax,4), %ecx
addl %ecx, %eax
cmpl $0x2, %ecx
jl 0x11912
addl $-0x3, %eax
jmp 0x1191f
testl %ecx, %ecx
je 0x1191c
addl $-0x2, %r14d
jmp 0x1191f
decl %r14d
decl %r11d
cmpl %r12d, %r11d
jg 0x118fa
jmp 0x1192d
movl 0xc(%rsp), %eax
subl 0x78(%rsp), %edx
movslq %r14d, %rcx
movq (%r13,%rcx,8), %rcx
cltq
addl (%rcx,%rax,4), %edx
movq 0x88(%rsp), %rsi
movl %edx, 0x34(%rsi)
movq 0x30(%rsp), %rdx
subl 0x80(%rsp), %edx
addl %eax, %edx
addl (%rcx,%rax,4), %edx
movl %edx, 0x30(%rsi)
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x1481