// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/extended/diagonalbandalign_affinegapcost.c
// Function: diagonalband_fillDPtab_affine
static void diagonalband_fillDPtab_affine(GtAffinealignDPentry **Atabcolumn,
                                          const GtUchar *useq,
                                          GtUword ustart,
                                          GtUword ulen,
                                          const GtUchar *vseq,
                                          GtUword vstart,
                                          GtUword vlen,
                                          GtWord left_dist,
                                          GtWord right_dist,
                                          GtAffineAlignEdge from_edge,
                                          GtAffineAlignEdge edge,
                                          const GtScoreHandler *scorehandler)
{
  GtUword i,j, low_row, high_row, gap_opening, gap_extension;
  GtWord rcost, r_dist, d_dist, i_dist, minvalue;

  gt_assert(Atabcolumn && scorehandler);
  if ((left_dist > GT_MIN(0, (GtWord)vlen-(GtWord)ulen))||
      (right_dist < GT_MAX(0, (GtWord)vlen-(GtWord)ulen)))
  {
    gt_assert(false);
  }

  gap_opening = gt_scorehandler_get_gap_opening(scorehandler);
  gap_extension = gt_scorehandler_get_gapscore(scorehandler);
  low_row = 0;
  high_row = -left_dist;

  /* first entry */
   switch (edge) {
    case Affine_R:
      Atabcolumn[0][0].Rvalue = 0;
      Atabcolumn[0][0].Redge = from_edge;
      Atabcolumn[0][0].Dvalue = GT_WORD_MAX;
      Atabcolumn[0][0].Ivalue = GT_WORD_MAX;
      break;
    case Affine_D:
      Atabcolumn[0][0].Rvalue = GT_WORD_MAX;
      Atabcolumn[0][0].Dvalue = 0;
      Atabcolumn[0][0].Dedge = from_edge;
      Atabcolumn[0][0].Ivalue = GT_WORD_MAX;
      break;
    case Affine_I:
      Atabcolumn[0][0].Rvalue = GT_WORD_MAX;
      Atabcolumn[0][0].Dvalue = GT_WORD_MAX;
      Atabcolumn[0][0].Ivalue = 0;
      Atabcolumn[0][0].Iedge = from_edge;
      break;
    default:
      Atabcolumn[0][0].Rvalue = 0;
      Atabcolumn[0][0].Dvalue = gap_opening;
      Atabcolumn[0][0].Ivalue = gap_opening;
    }
  /* first column */
  for (i = 1; i <= high_row; i++)
  {
    Atabcolumn[i][0].Rvalue = GT_WORD_MAX;
    r_dist = add_safe_max(Atabcolumn[i-1][0].Rvalue,
                         gap_opening + gap_extension);
    d_dist = add_safe_max(Atabcolumn[i-1][0].Dvalue, gap_extension);
    i_dist = add_safe_max(Atabcolumn[i-1][0].Ivalue,
                         gap_opening + gap_extension);
    Atabcolumn[i][0].Dvalue = GT_MIN3(r_dist, d_dist, i_dist);
    Atabcolumn[i][0].Ivalue = GT_WORD_MAX;

    Atabcolumn[i][0].Redge = Affine_X;
    Atabcolumn[i][0].Dedge = gt_linearalign_affinegapcost_set_edge(r_dist,
                                                                   d_dist,
                                                                   i_dist);
    Atabcolumn[i][0].Iedge = Affine_X;
  }
  for (; i <= ulen; i++)
  {
    /* invalid values */
    Atabcolumn[i][0].Rvalue = GT_WORD_MAX;
    Atabcolumn[i][0].Dvalue = GT_WORD_MAX;
    Atabcolumn[i][0].Ivalue = GT_WORD_MAX;
  }

  /* next columns */
  for (j = 1; j <= vlen; j++)
  {
    /* below diagonal band*/
    for (i = 0; i <= low_row; i++)
    {
      if (j <= right_dist)
      {
        Atabcolumn[i][j].Redge = Affine_X;
        Atabcolumn[i][j].Dedge = Affine_X;
        r_dist = add_safe_max(Atabcolumn[i][j-1].Rvalue,
                               gap_extension + gap_opening);
        d_dist = add_safe_max(Atabcolumn[i][j-1].Dvalue,
                               gap_extension + gap_opening);
        i_dist = add_safe_max(Atabcolumn[i][j-1].Ivalue,gap_extension);

        minvalue = GT_MIN3(r_dist, d_dist, i_dist);
        Atabcolumn[i][j].Ivalue = minvalue;
        Atabcolumn[i][j].Rvalue = GT_WORD_MAX;
        Atabcolumn[i][j].Dvalue = GT_WORD_MAX;

        Atabcolumn[i][j].Iedge = gt_linearalign_affinegapcost_set_edge(r_dist,
                                                         d_dist,
                                                         i_dist);
      }
      else{
        Atabcolumn[i][j].Rvalue = GT_WORD_MAX;
        Atabcolumn[i][j].Dvalue = GT_WORD_MAX;
        Atabcolumn[i][j].Ivalue = GT_WORD_MAX;
        Atabcolumn[i][j].Iedge = Affine_X;
      }
    }
    if ( j > right_dist)
      low_row++;
    if (high_row < ulen)
      high_row ++;

    /* diagonalband */
    for (; i <= high_row; i++)
    {
      /* compute A_affine(i,j,I) */
      r_dist=add_safe_max(Atabcolumn[i][j-1].Rvalue,gap_extension+gap_opening);
      d_dist=add_safe_max(Atabcolumn[i][j-1].Dvalue,gap_extension+gap_opening);
      i_dist=add_safe_max(Atabcolumn[i][j-1].Ivalue,gap_extension);
      minvalue = GT_MIN3(r_dist, d_dist, i_dist);
      Atabcolumn[i][j].Ivalue = minvalue;
      Atabcolumn[i][j].Iedge = gt_linearalign_affinegapcost_set_edge(
                                                        r_dist, d_dist, i_dist);

      /* compute A_affine(i,j,R) */
      rcost = gt_scorehandler_get_replacement(scorehandler,
                                            useq[ustart+i-1], vseq[vstart+j-1]);
      r_dist = add_safe_max(Atabcolumn[i-1][j-1].Rvalue, rcost);
      d_dist = add_safe_max(Atabcolumn[i-1][j-1].Dvalue, rcost);
      i_dist = add_safe_max(Atabcolumn[i-1][j-1].Ivalue, rcost);
      minvalue = GT_MIN3(r_dist, d_dist, i_dist);
      Atabcolumn[i][j].Rvalue = minvalue;
      Atabcolumn[i][j].Redge = gt_linearalign_affinegapcost_set_edge(
                                                        r_dist, d_dist, i_dist);

      /* compute A_affine(i,j,D) */
      r_dist = add_safe_max(Atabcolumn[i-1][j].Rvalue,
                         gap_extension+gap_opening);
      d_dist = add_safe_max(Atabcolumn[i-1][j].Dvalue,gap_extension);
      i_dist = add_safe_max(Atabcolumn[i-1][j].Ivalue,
                          gap_extension+gap_opening);
      minvalue = GT_MIN3(r_dist, d_dist, i_dist);
      Atabcolumn[i][j].Dvalue = minvalue;
      Atabcolumn[i][j].Dedge = gt_linearalign_affinegapcost_set_edge(
                                                        r_dist, d_dist, i_dist);

    }
    /* above diagonal band */
    for (; i <= ulen; i++)
    {
      Atabcolumn[i][j].Rvalue = GT_WORD_MAX;
      Atabcolumn[i][j].Dvalue = GT_WORD_MAX;
      Atabcolumn[i][j].Ivalue = GT_WORD_MAX;
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
testq %rdi, %rdi
je 0xcb50b
movq %rcx, %r12
movq %rsi, 0x20(%rsp)
movq %rdx, 0x28(%rsp)
movq %r8, 0x30(%rsp)
movq %r9, 0x10(%rsp)
movq 0x88(%rsp), %rsi
movq 0x80(%rsp), %rcx
subq %r12, %rcx
movq %rcx, %rdx
sarq $0x3f, %rdx
andq %rcx, %rdx
xorl %eax, %eax
testq %rcx, %rcx
cmovgq %rcx, %rax
movq %rsi, (%rsp)
cmpq %rsi, %rdx
jl 0xcb535
movq 0x90(%rsp), %r13
cmpq %r13, %rax
jg 0xcb535
movq %rdi, %r14
movq 0xa8(%rsp), %rbx
movl 0xa0(%rsp), %ebp
movabsq $0x7fffffffffffffff, %r15 # imm = 0x7FFFFFFFFFFFFFFF
movq %rbx, %rdi
callq 0x114a29
movq %rax, 0x8(%rsp)
movq %rbx, %rdi
callq 0x114a6a
movq %rax, 0x18(%rsp)
movq (%r14), %rax
cmpl $0x2, %ebp
je 0xcb165
cmpl $0x1, %ebp
jne 0xcb17d
movq %r15, (%rax)
andq $0x0, 0x8(%rax)
movl 0x98(%rsp), %ecx
movl %ecx, 0x24(%rax)
movq %r15, 0x10(%rax)
jmp 0xcb18e
movq %r15, (%rax)
movq %r15, 0x8(%rax)
andq $0x0, 0x10(%rax)
movl 0x98(%rsp), %ecx
movl %ecx, 0x28(%rax)
jmp 0xcb18e
andq $0x0, (%rax)
movq 0x8(%rsp), %rcx
movq %rcx, 0x8(%rax)
movq %rcx, 0x10(%rax)
negq (%rsp)
movq 0x18(%rsp), %rax
addq %rax, 0x8(%rsp)
pushq $0x1
popq %rbx
pushq $0x3
popq %rbp
cmpq (%rsp), %rbx
ja 0xcb230
movq (%r14,%rbx,8), %rax
movq %r15, (%rax)
movq -0x8(%r14,%rbx,8), %rcx
movq (%rcx), %rdx
movq 0x8(%rcx), %r8
movq 0x8(%rsp), %r9
leaq (%rdx,%r9), %rdi
cmpq %r15, %rdx
cmoveq %r15, %rdi
movq 0x18(%rsp), %rdx
leaq (%r8,%rdx), %rsi
cmpq %r15, %r8
cmoveq %r15, %rsi
movq 0x10(%rcx), %rcx
leaq (%rcx,%r9), %rdx
cmpq %r15, %rcx
cmoveq %r15, %rdx
cmpq %rsi, %rdi
movq %rsi, %rcx
cmovlq %rdi, %rcx
cmpq %rdx, %rcx
cmovgeq %rdx, %rcx
movq %rcx, 0x8(%rax)
movq %r15, 0x10(%rax)
movl %ebp, 0x20(%rax)
callq 0xf7854
movq (%r14,%rbx,8), %rcx
movl %eax, 0x24(%rcx)
movl %ebp, 0x28(%rcx)
incq %rbx
jmp 0xcb1a2
movq (%r14,%rbx,8), %rax
movq %r15, (%rax)
movq %r15, 0x8(%rax)
movq %r15, 0x10(%rax)
incq %rbx
cmpq %r12, %rbx
jbe 0xcb21e
movq 0x10(%rsp), %rax
movq 0x30(%rsp), %rcx
addq %rcx, %rax
decq %rax
movq %rax, 0x30(%rsp)
movq 0x28(%rsp), %rax
movq 0x20(%rsp), %rcx
leaq -0x1(%rcx,%rax), %rax
movq %rax, 0x28(%rsp)
pushq $0x1
popq %rsi
xorl %edi, %edi
pushq $0x3
popq %rbx
movq %r12, 0x38(%rsp)
cmpq 0x80(%rsp), %rsi
ja 0xcb4fc
leaq -0x1(%rsi), %r12
xorl %ebp, %ebp
movq %rsi, 0x10(%rsp)
movq %rdi, 0x20(%rsp)
cmpq %rdi, %rbp
ja 0xcb345
movq (%r14,%rbp,8), %rcx
cmpq %r13, %rsi
jbe 0xcb2b4
imulq $0x30, %rsi, %rax
movq %r15, (%rcx,%rax)
movq %r15, 0x8(%rcx,%rax)
movq %r15, 0x10(%rcx,%rax)
movl %ebx, %eax
jmp 0xcb335
imulq $0x30, %rsi, %rax
movabsq $0x300000003, %rdx      # imm = 0x300000003
movq %rdx, 0x20(%rcx,%rax)
imulq $0x30, %r12, %rdx
movq (%rcx,%rdx), %rsi
movq 0x8(%rcx,%rdx), %r8
movq 0x8(%rsp), %r9
leaq (%rsi,%r9), %rdi
cmpq %r15, %rsi
cmoveq %r15, %rdi
leaq (%r8,%r9), %rsi
cmpq %r15, %r8
cmoveq %r15, %rsi
movq 0x10(%rcx,%rdx), %r8
movq 0x18(%rsp), %rdx
addq %r8, %rdx
cmpq %r15, %r8
cmoveq %r15, %rdx
cmpq %rsi, %rdi
movq %rsi, %r8
cmovlq %rdi, %r8
cmpq %rdx, %r8
cmovgeq %rdx, %r8
movq %r8, 0x10(%rcx,%rax)
movq %r15, (%rcx,%rax)
movq %r15, 0x8(%rcx,%rax)
callq 0xf7854
movq 0x20(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq (%r14,%rbp,8), %rcx
imulq $0x30, %rsi, %rdx
movl %eax, 0x28(%rcx,%rdx)
incq %rbp
jmp 0xcb289
xorl %eax, %eax
cmpq %r13, %rsi
seta %al
movq %rax, 0x40(%rsp)
movq (%rsp), %rax
cmpq 0x38(%rsp), %rax
adcq $0x0, %rax
movq %rax, (%rsp)
imulq $0x30, %r12, %r12
imulq $0x30, %rsi, %r13
cmpq (%rsp), %rbp
ja 0xcb4b9
movq (%r14,%rbp,8), %rax
movq (%rax,%r12), %rcx
movq 0x8(%rax,%r12), %rdx
movq 0x8(%rsp), %rbx
leaq (%rcx,%rbx), %rdi
cmpq %r15, %rcx
cmoveq %r15, %rdi
leaq (%rdx,%rbx), %rsi
cmpq %r15, %rdx
cmoveq %r15, %rsi
movq 0x10(%rax,%r12), %rcx
movq 0x18(%rsp), %rdx
addq %rcx, %rdx
cmpq %r15, %rcx
cmoveq %r15, %rdx
cmpq %rsi, %rdi
movq %rsi, %rcx
cmovlq %rdi, %rcx
cmpq %rdx, %rcx
cmovgeq %rdx, %rcx
movq %rcx, 0x10(%rax,%r13)
callq 0xf7854
movq (%r14,%rbp,8), %rcx
movl %eax, 0x28(%rcx,%r13)
movq 0x28(%rsp), %rax
movzbl (%rax,%rbp), %esi
movq 0x30(%rsp), %rax
movq 0x10(%rsp), %rcx
movzbl (%rax,%rcx), %edx
movq 0xa8(%rsp), %rdi
callq 0x114b2c
movq -0x8(%r14,%rbp,8), %rcx
movq (%r14,%rbp,8), %r8
movq (%rcx,%r12), %rdx
movq 0x8(%rcx,%r12), %r9
leaq (%rdx,%rax), %rdi
cmpq %r15, %rdx
cmoveq %r15, %rdi
leaq (%r9,%rax), %rsi
cmpq %r15, %r9
cmoveq %r15, %rsi
movq 0x10(%rcx,%r12), %rcx
leaq (%rax,%rcx), %rdx
cmpq %r15, %rcx
cmoveq %r15, %rdx
cmpq %rsi, %rdi
movq %rsi, %rax
cmovlq %rdi, %rax
cmpq %rdx, %rax
cmovgeq %rdx, %rax
movq %rax, (%r8,%r13)
callq 0xf7854
movq (%r14,%rbp,8), %rcx
movl %eax, 0x20(%rcx,%r13)
movq -0x8(%r14,%rbp,8), %rax
movq (%rax,%r13), %rdx
movq 0x8(%rax,%r13), %r8
leaq (%rdx,%rbx), %rdi
cmpq %r15, %rdx
cmoveq %r15, %rdi
movq 0x18(%rsp), %rdx
leaq (%r8,%rdx), %rsi
cmpq %r15, %r8
cmoveq %r15, %rsi
movq 0x10(%rax,%r13), %rax
leaq (%rax,%rbx), %rdx
cmpq %r15, %rax
cmoveq %r15, %rdx
cmpq %rsi, %rdi
movq %rsi, %rax
cmovlq %rdi, %rax
cmpq %rdx, %rax
cmovgeq %rdx, %rax
movq %rax, 0x8(%rcx,%r13)
callq 0xf7854
movq (%r14,%rbp,8), %rcx
movl %eax, 0x24(%rcx,%r13)
incq %rbp
jmp 0xcb36b
movq 0x38(%rsp), %r12
pushq $0x3
popq %rbx
movq 0x10(%rsp), %rsi
movq 0x20(%rsp), %rdi
cmpq %r12, %rbp
ja 0xcb4e7
movq (%r14,%rbp,8), %rax
movq %r15, (%rax,%r13)
movq %r15, 0x8(%rax,%r13)
movq %r15, 0x10(%rax,%r13)
incq %rbp
jmp 0xcb4cb
addq 0x40(%rsp), %rdi
incq %rsi
movq 0x90(%rsp), %r13
jmp 0xcb26b
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x36ca56(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x219af7(%rip), %rsi    # 0x2e5013
leaq 0x24ff32(%rip), %rdx    # 0x31b455
leaq 0x24ff46(%rip), %rcx    # 0x31b470
leaq 0x24fd29(%rip), %r8     # 0x31b25a
pushq $0x32
jmp 0xcb55d
movq 0x36ca2c(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x219acd(%rip), %rsi    # 0x2e5013
leaq 0x25b49f(%rip), %rdx    # 0x3269ec
leaq 0x24ff1c(%rip), %rcx    # 0x31b470
leaq 0x24fcff(%rip), %r8     # 0x31b25a
pushq $0x36
popq %r9
xorl %eax, %eax
callq 0x17a50
callq 0x17390