// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/extended/diagonalbandalign.c
// Function: diagonalband_fillDPtab_in_square_space
static void diagonalband_fillDPtab_in_square_space(GtUword **EDtabcolumn,
                                                   const GtUchar *useq,
                                                   GtUword ustart,
                                                   GtUword ulen,
                                                   const GtUchar *vseq,
                                                   GtUword vstart,
                                                   GtUword vlen,
                                                   GtWord left_dist,
                                                   GtWord right_dist,
                                                   const GtScoreHandler
                                                   *scorehandler)
{
  GtUword i,j, val, low_row, high_row, gapcost;
  gt_assert(EDtabcolumn && scorehandler);

  low_row = 0;
  high_row = -left_dist;
  gapcost = gt_scorehandler_get_gapscore(scorehandler);

  /* first column */
  EDtabcolumn[0][0] = 0;

  for (i = 1; i <= high_row; i++)
  {
      EDtabcolumn[i][0] = add_safe_umax(EDtabcolumn[i-1][0], gapcost);
  }
  for (; i <= ulen; i++)
  {
      EDtabcolumn[i][0] = GT_UWORD_MAX; /* invalid value */
  }

  /* next columns */
  for (j = 1; j <= vlen; j++)
  {
    /* below diagonal band*/
    for (i = 0; i <= low_row; i++)
    {
      if (j <= right_dist)
      {
        EDtabcolumn[i][j] = add_safe_umax(EDtabcolumn[i][j-1], gapcost);
      }
      else{
        EDtabcolumn[i][j] = GT_UWORD_MAX;
      }
    }
    if (j > right_dist)
      low_row ++;
    if (high_row < ulen)
      high_row ++;

    /* diagonaldband */
    for (; i <= high_row; i++)
    {
      EDtabcolumn[i][j] = add_safe_umax(EDtabcolumn[i][j-1], gapcost);

      val = add_safe_umax(EDtabcolumn[i-1][j-1],
                          gt_scorehandler_get_replacement(scorehandler,
                                    useq[ustart+i-1],vseq[vstart+j-1]));
      if (val <= EDtabcolumn[i][j])
      {
        EDtabcolumn[i][j] = val;
      }

      if ((val = add_safe_umax(EDtabcolumn[i-1][j],gapcost))
                                        < EDtabcolumn[i][j])
      {
        EDtabcolumn[i][j] = val;
      }
    }
    /* above diagonal band */
    for (; i <= ulen; i++)
      EDtabcolumn[i][j] = GT_UWORD_MAX;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, 0x8(%rsp)
testq %rdi, %rdi
je 0x13916c
movq %rdi, %r14
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x13916c
movq %r9, %r15
movq %r8, %r12
movq %rdx, %r13
movq %rsi, %rbp
movq 0x68(%rsp), %rbx
callq 0x1797fb
movq %rbx, %rdi
movq %rax, %r9
movq (%r14), %rax
movq $0x0, (%rax)
movl $0x1, %eax
testq %rbx, %rbx
je 0x138fdd
movl $0x1, %edx
subq %rdi, %rdx
cmpq $0x3, %rdx
movl $0x2, %ecx
cmovaeq %rdx, %rcx
movq -0x8(%r14,%rax,8), %rdx
movq (%rdx), %rdx
leaq (%rdx,%r9), %rsi
cmpq $-0x1, %rdx
cmoveq %rdx, %rsi
movq (%r14,%rax,8), %rdx
movq %rsi, (%rdx)
incq %rax
cmpq %rax, %rcx
jne 0x138fba
movq 0x8(%rsp), %rdx
cmpq %rdx, %rax
ja 0x138ff7
movq (%r14,%rax,8), %rcx
movq $-0x1, (%rcx)
incq %rax
jmp 0x138fe2
cmpq $0x0, 0x60(%rsp)
je 0x13915d
movq 0x70(%rsp), %r8
negq %rdi
leaq (%r12,%r15), %rax
decq %rax
movq %rax, 0x20(%rsp)
leaq -0x1(,%r13), %rax
addq %rbp, %rax
movq %rax, 0x18(%rsp)
movl $0x1, %r15d
movq $0x0, 0x10(%rsp)
movq 0x10(%rsp), %rcx
leaq 0x1(%rcx), %rax
cmpq $0x1, %rax
movq %rcx, %rax
adcq $0x1, %rax
xorl %ebx, %ebx
movq (%r14,%rbx,8), %rcx
movq $-0x1, %rdx
cmpq %r8, %r15
ja 0x13906d
movq -0x8(%rcx,%r15,8), %rsi
leaq (%rsi,%r9), %rdx
cmpq $-0x1, %rsi
cmoveq %rsi, %rdx
movq %rdx, (%rcx,%r15,8)
incq %rbx
cmpq %rbx, %rax
jne 0x13904c
cmpq %r15, %r8
adcq $0x0, 0x10(%rsp)
cmpq 0x8(%rsp), %rdi
adcq $0x0, %rdi
leaq -0x1(%rbx), %rax
cmpq %rdi, %rax
jae 0x139134
movq (%r14,%rbx,8), %rax
movq -0x8(%rax,%r15,8), %rcx
leaq (%rcx,%r9), %rdx
cmpq $-0x1, %rcx
cmoveq %rcx, %rdx
movq %rdx, (%rax,%r15,8)
movq -0x8(%r14,%rbx,8), %rax
movq -0x8(%rax,%r15,8), %r13
cmpq $-0x1, %r13
je 0x1390ef
movq 0x18(%rsp), %rax
movzbl (%rax,%rbx), %esi
movq 0x20(%rsp), %rax
movzbl (%rax,%r15), %edx
movq %rdi, %rbp
movq 0x78(%rsp), %rdi
movq %r9, %r12
callq 0x17982a
movq %r12, %r9
movq %rbp, %rdi
addq %r13, %rax
jmp 0x1390f6
movq $-0x1, %rax
movq (%r14,%rbx,8), %rcx
cmpq (%rcx,%r15,8), %rax
ja 0x139104
movq %rax, (%rcx,%r15,8)
movq -0x8(%r14,%rbx,8), %rax
movq (%rax,%r15,8), %rdx
leaq (%rdx,%r9), %rax
cmpq $-0x1, %rdx
cmoveq %rdx, %rax
cmpq (%rcx,%r15,8), %rax
movq 0x70(%rsp), %r8
jae 0x139128
movq %rax, (%rcx,%r15,8)
incq %rbx
cmpq %rdi, %rbx
jbe 0x139098
movq 0x8(%rsp), %rcx
cmpq %rcx, %rbx
ja 0x13914f
movq (%r14,%rbx,8), %rax
movq $-0x1, (%rax,%r15,8)
incq %rbx
jmp 0x139139
incq %r15
cmpq 0x60(%rsp), %r15
jbe 0x139036
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x3fa38