// File: /workspace/github_c_makefile_star2_O3/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 $0x88, %rsp
movl %ecx, %r15d
movl 0xc0(%rsp), %r11d
movq 0x20(%r8), %r12
xorl %ebp, %ebp
movl %esi, 0x34(%rsp)
movl %esi, %ecx
subl %r15d, %ecx
movl %ecx, %ebx
cmovnsl %ebp, %ebx
movq 0x28(%r8), %rax
movq %rax, 0x40(%rsp)
movl %ecx, 0x4(%rsp)
cmovnsl %ecx, %ebp
movl %r11d, %eax
negl %eax
movl %eax, 0x1c(%rsp)
movq 0x10(%r8), %rcx
movq %r8, 0x70(%rsp)
movq 0x18(%r8), %rsi
cmpq %rsi, %rcx
movq %rdi, 0x28(%rsp)
movq %rcx, 0x68(%rsp)
movq %rsi, 0x60(%rsp)
movl %r9d, 0x5c(%rsp)
je 0x11122
movl %r11d, %eax
movq %rax, 0x38(%rsp)
jmp 0x1115f
movq %rdx, %rax
subq %rdi, %rax
je 0x117bc
jae 0x1114a
movslq 0x1c(%rsp), %rcx
movl %r11d, %esi
movq %rsi, 0x38(%rsp)
cmpq %rcx, %rax
jl 0x1115f
incl %eax
movl %eax, 0x1c(%rsp)
jmp 0x11118
notq %rdi
addq %rdx, %rdi
movl %r11d, %eax
cmpq %rax, %rdi
cmovgel %r11d, %edi
movq %rdi, 0x38(%rsp)
movq -0x10(%r12), %rax
movq -0x8(%r12), %r10
leal -0x1(%rbx), %ecx
movslq %ecx, %rsi
leaq (%r10,%rsi,4), %rcx
leaq (%rax,%rsi,4), %rsi
movl %ebp, %edi
subl %ebx, %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 0x11187
movl $0xffffffff, (%r10)     # imm = 0xFFFFFFFF
testl %r11d, %r11d
js 0x11476
decl %ebp
incl %ebx
movslq 0x4(%rsp), %rcx
movq %rcx, 0x48(%rsp)
movslq %r15d, %r8
incl %r11d
movq %r11, 0x78(%rsp)
xorl %r11d, %r11d
movq %r15, 0x50(%rsp)
movq %r12, 0x20(%rsp)
movq %r10, 0x10(%rsp)
testb $0x1, %r11b
jne 0x111ee
xorl %ecx, %ecx
cmpl 0x1c(%rsp), %ebx
setg %cl
subl %ecx, %ebx
xorl %ecx, %ecx
cmpl 0x38(%rsp), %ebp
setl %cl
addl %ecx, %ebp
movq (%r12,%r11,8), %r10
movq 0x40(%rsp), %rcx
movq %r11, 0x8(%rsp)
movq (%rcx,%r11,8), %rdi
movq %rbx, 0x80(%rsp)
movslq %ebx, %rbx
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
movl %esi, -0x4(%r10,%rbx,4)
movl %ebp, 0x18(%rsp)
movslq %ebp, %rcx
movl %esi, 0x4(%r10,%rcx,4)
cmpl 0x4(%rsp), %ecx
jle 0x112f1
movl 0x34(%rsp), %esi
subl %ecx, %esi
movq 0x28(%rsp), %r9
leaq (%r9,%rcx), %r11
movslq %esi, %rbp
movl $0xfffffffe, %r12d      # imm = 0xFFFFFFFE
leal 0x1(%r12), %esi
movl -0x4(%rax,%rcx,4), %r13d
movq 0x10(%rsp), %r9
movl (%r9,%rcx,4), %r15d
leal 0x1(%r15), %r9d
cmpl %r13d, %r9d
jge 0x11277
xorl %r9d, %r9d
cmpl %r13d, %esi
setge %r9b
leal -0x1(%r9,%r9,4), %r14d
cmovgl %esi, %r13d
movl %r13d, %r12d
jmp 0x1128c
xorl %r14d, %r14d
cmpl %r15d, %r12d
setge %r14b
cmovll %r9d, %esi
shll $0x2, %r14d
movl %esi, %r12d
movq 0x50(%rsp), %r15
movl %r14d, (%rdi,%rcx,4)
cmpq %r8, %rbp
jle 0x112b9
cmpl %r15d, %r12d
jge 0x112d9
movslq %r12d, %r12
movb (%rdx,%r12), %sil
cmpb (%r11,%r12), %sil
jne 0x112d9
incq %r12
cmpq %r12, %r8
jne 0x112a2
movl %r15d, %r12d
jmp 0x112d9
movslq %r12d, %rsi
cmpq %rsi, %rbp
jle 0x112d9
movb (%rdx,%rsi), %r9b
cmpb (%r11,%rsi), %r9b
jne 0x112d6
incq %rsi
cmpq %rbp, %rsi
jl 0x112c1
movq %rbp, %rsi
movl %esi, %r12d
movl %r12d, (%r10,%rcx,4)
decq %rcx
decq %r11
incq %rbp
cmpq 0x48(%rsp), %rcx
jg 0x11243
movq 0x28(%rsp), %rcx
leaq (%rcx,%rbx), %r11
movl 0x34(%rsp), %ecx
movl %ecx, %ebp
subl %ebx, %ebp
movl $0xfffffffe, %ecx       # imm = 0xFFFFFFFE
cmpl 0x4(%rsp), %ebx
jge 0x113b3
movslq %ebp, %rbp
movl $0xfffffffe, %ecx       # imm = 0xFFFFFFFE
movl 0x4(%rax,%rbx,4), %r13d
leal 0x1(%r13), %r12d
movq 0x10(%rsp), %rsi
movl (%rsi,%rbx,4), %r9d
leal 0x1(%r9), %r14d
xorl %esi, %esi
cmpl %ecx, %r14d
jge 0x11345
cmpl %ecx, %r12d
setl %sil
cmovgl %r12d, %ecx
incl %esi
jmp 0x11353
cmpl %r9d, %r13d
setge %sil
cmovgel %r12d, %r14d
movl %r14d, %ecx
movl %esi, (%rdi,%rbx,4)
cmpq %r8, %rbp
jle 0x1137a
cmpl %r15d, %ecx
jge 0x11398
movslq %ecx, %rcx
movb (%rdx,%rcx), %sil
cmpb (%r11,%rcx), %sil
jne 0x11398
incq %rcx
cmpq %rcx, %r8
jne 0x11363
movl %r15d, %ecx
jmp 0x11398
movslq %ecx, %rsi
cmpq %rsi, %rbp
jle 0x11398
movb (%rdx,%rsi), %cl
cmpb (%r11,%rsi), %cl
jne 0x11396
incq %rsi
cmpq %rbp, %rsi
jl 0x11382
movq %rbp, %rsi
movl %esi, %ecx
movl %ecx, (%r10,%rbx,4)
incq %rbx
incq %r11
decq %rbp
cmpq 0x48(%rsp), %rbx
jl 0x11319
movslq %ebx, %rbx
movq 0x48(%rsp), %rax
movl 0x4(%r10,%rax,4), %r14d
leal 0x1(%r14), %eax
movq 0x10(%rsp), %rsi
movl (%rsi,%rbx,4), %r15d
leal 0x1(%r15), %r9d
cmpl %ecx, %r9d
jge 0x113e4
xorl %esi, %esi
cmpl %ecx, %eax
setge %sil
leal 0x2(%rsi,%rsi), %esi
cmovgl %eax, %ecx
jmp 0x113f6
xorl %esi, %esi
cmpl %r15d, %r14d
setge %sil
cmovll %r9d, %eax
shll $0x2, %esi
movl %eax, %ecx
movq 0x20(%rsp), %r12
movl %esi, (%rdi,%rbx,4)
movq 0x50(%rsp), %r15
cmpl %r15d, %ebp
jle 0x1142a
cmpl %r15d, %ecx
movl 0x18(%rsp), %ebp
jge 0x11447
movslq %ecx, %rcx
movb (%rdx,%rcx), %al
cmpb (%r11,%rcx), %al
jne 0x11447
incq %rcx
cmpl %ecx, %r15d
jne 0x11414
movl %r15d, %ecx
jmp 0x11447
cmpl %ebp, %ecx
jge 0x11443
movslq %ecx, %rcx
movb (%rdx,%rcx), %al
cmpb (%r11,%rcx), %al
jne 0x11443
incq %rcx
cmpl %ecx, %ebp
jne 0x11431
movl %ebp, %ecx
movl 0x18(%rsp), %ebp
movl %ecx, (%r10,%rbx,4)
movq 0x48(%rsp), %rax
cmpl %r15d, (%r10,%rax,4)
movq 0x8(%rsp), %r11
jge 0x1147b
incq %r11
movq 0x10(%rsp), %rax
cmpq 0x78(%rsp), %r11
movq 0x80(%rsp), %rbx
jne 0x111cd
callq 0x144f
movl 0x4(%rsp), %eax
movl %eax, %esi
negl %esi
cmovsl %eax, %esi
addl %r11d, %esi
movl %esi, %r13d
shrl %r13d
movl 0x5c(%rsp), %eax
cmpl $-0x1, %eax
movl %r13d, 0x10(%rsp)
je 0x115fc
cmpl $0x1, %eax
jne 0x11742
testl %esi, %esi
je 0x1177d
movl 0x4(%rsp), %eax
movl %eax, %ecx
movslq %r11d, %rax
movq 0x40(%rsp), %rdi
movq (%rdi,%rax,8), %rax
movslq %ecx, %r9
movl (%rax,%r9,4), %r10d
leal (%r10,%rcx), %eax
cmpl $0x2, %r10d
jl 0x114da
addl $-0x3, %eax
jmp 0x114e8
testl %r10d, %r10d
je 0x114e5
addl $-0x2, %r11d
jmp 0x114e8
decl %r11d
cmpl %ecx, %eax
jge 0x1159d
movl %ecx, %edi
negl %edi
movl %ecx, %ebp
sarl $0x1f, %ebp
andl %edi, %ebp
movq %r11, 0x8(%rsp)
movq %r15, %r8
movslq %r11d, %r15
movq (%r12,%r15,8), %r11
movslq %eax, %rbx
movl (%r11,%rbx,4), %r14d
leal -0x1(%r14), %edi
cmpl %r8d, %r14d
cmovgl %r8d, %edi
cmpl %ebp, %edi
jl 0x11563
testl %ecx, %ecx
movl $0x0, %r13d
cmovgl %ecx, %r13d
movq 0x28(%rsp), %r8
leaq (%r8,%r9), %r12
movl %ecx, %r14d
notl %r14d
addl %r13d, %r14d
movl %edi, %r13d
movb (%r12,%r13), %r8b
cmpb (%rdx,%r13), %r8b
jne 0x11559
leal -0x1(%rdi), %r8d
cmpl %ebp, %edi
movl %r8d, %edi
jg 0x1153e
movl %r14d, %edi
movq 0x20(%rsp), %r12
movl 0x10(%rsp), %r13d
cmpl $-0x1, %r10d
je 0x115a2
movq 0x8(%rsp), %r8
leal -0x2(%r8), %r10d
cmpl 0x4(%rsp), %ecx
cmovel %r8d, %r10d
movslq %r10d, %r8
movq (%r12,%r8,8), %r8
cmpl 0x4(%r8,%r9,4), %edi
jle 0x115c3
movq -0x8(%r12,%r15,8), %r8
cmpl (%r8,%r9,4), %edi
jne 0x115cc
movq 0x8(%rsp), %r11
decl %r11d
jmp 0x115e5
movl %r15d, %edi
jmp 0x115e7
movq 0x10(%r12,%r15,8), %r8
cmpl 0x4(%r8,%r9,4), %edi
jle 0x115da
movq 0x8(%r12,%r15,8), %r8
cmpl (%r8,%r9,4), %edi
jne 0x115cc
movq 0x8(%rsp), %r11
incl %r11d
jmp 0x115e5
incl %ecx
movl %ecx, %eax
movl %r10d, %r11d
jmp 0x115e7
leal 0x1(%rdi), %ecx
movl %ecx, (%r11,%rbx,4)
movq 0x8(%rsp), %r11
jmp 0x115e7
movq 0x8(%rsp), %r11
addl $0x2, %r11d
incl %ecx
movl %ecx, %eax
decl %esi
movl %edi, %r15d
movl %eax, %ecx
cmpl %r13d, %esi
jg 0x114b8
jmp 0x11781
testl %esi, %esi
je 0x1177d
movl 0x4(%rsp), %eax
movl %eax, %ecx
movslq %r11d, %rax
movq 0x40(%rsp), %rdi
movq (%rdi,%rax,8), %rax
movslq %ecx, %rdi
movl (%rax,%rdi,4), %r9d
leal (%r9,%rcx), %eax
cmpl $0x2, %r9d
jl 0x1162c
addl $-0x3, %eax
jmp 0x1163a
testl %r9d, %r9d
je 0x11637
addl $-0x2, %r11d
jmp 0x1163a
decl %r11d
cmpl %ecx, %eax
jle 0x11733
movl %ecx, %r8d
negl %r8d
movl %ecx, %ebp
sarl $0x1f, %ebp
andl %r8d, %ebp
movq %r11, 0x8(%rsp)
movslq %r11d, %rbx
movq (%r12,%rbx,8), %r10
movslq %eax, %r11
movl (%r10,%r11,4), %r8d
cmpl %r15d, %r8d
cmovll %r8d, %r15d
cmpl %ebp, %r15d
jl 0x116b4
testl %ecx, %ecx
movl $0x0, %r8d
cmovgl %ecx, %r8d
movq 0x28(%rsp), %r14
leaq (%r14,%rdi), %r13
movl %ecx, %r14d
notl %r14d
addl %r8d, %r14d
movl %r15d, %r8d
movb (%r13,%r8), %r12b
cmpb (%rdx,%r8), %r12b
jne 0x116aa
leal -0x1(%r15), %r8d
cmpl %ebp, %r15d
movl %r8d, %r15d
jg 0x1168d
movl %r14d, %r15d
movq 0x20(%rsp), %r12
movl 0x10(%rsp), %r13d
cmpl $0x1, %r9d
jne 0x116d3
movq 0x10(%r12,%rbx,8), %r8
cmpl -0x4(%r8,%rdi,4), %r15d
jge 0x116fb
movq 0x8(%rsp), %r11
addl $0x2, %r11d
decl %ecx
jmp 0x11723
movq 0x8(%rsp), %r8
leal -0x2(%r8), %r9d
cmpl 0x4(%rsp), %ecx
cmovel %r8d, %r9d
movslq %r9d, %r8
movq (%r12,%r8,8), %r8
cmpl -0x4(%r8,%rdi,4), %r15d
jge 0x11710
decl %ecx
movl %ecx, %eax
movl %r9d, %r11d
jmp 0x11733
movq 0x8(%r12,%rbx,8), %r8
cmpl (%r8,%rdi,4), %r15d
jne 0x11727
movq 0x8(%rsp), %r11
incl %r11d
jmp 0x11723
movq -0x8(%r12,%rbx,8), %r8
cmpl (%r8,%rdi,4), %r15d
jne 0x11727
movq 0x8(%rsp), %r11
decl %r11d
movl %ecx, %eax
jmp 0x11733
movl %r15d, (%r10,%r11,4)
decl %r15d
movq 0x8(%rsp), %r11
decl %esi
movl %eax, %ecx
cmpl %r13d, %esi
jg 0x1160a
jmp 0x11781
testl %esi, %esi
je 0x1177d
movl 0x4(%rsp), %eax
movq 0x40(%rsp), %rdi
movslq %r11d, %rcx
movq (%rdi,%rcx,8), %rcx
cltq
movl (%rcx,%rax,4), %ecx
addl %ecx, %eax
cmpl $0x2, %ecx
jl 0x11767
addl $-0x3, %eax
jmp 0x11774
testl %ecx, %ecx
je 0x11771
addl $-0x2, %r11d
jmp 0x11774
decl %r11d
decl %esi
cmpl %r13d, %esi
jg 0x1174f
jmp 0x11781
movl 0x4(%rsp), %eax
subl 0x60(%rsp), %edx
movslq %r11d, %rcx
movq (%r12,%rcx,8), %rcx
cltq
addl (%rcx,%rax,4), %edx
movq 0x70(%rsp), %rsi
movl %edx, 0x34(%rsi)
movq 0x28(%rsp), %rdx
subl 0x68(%rsp), %edx
addl %eax, %edx
addl (%rcx,%rax,4), %edx
movl %edx, 0x30(%rsi)
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x1481