// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/extended/affinealign.c
// Function: affinealign_fill_table
static void affinealign_fill_table(GtAffinealignDPentry **dptable,
                                   const GtUchar *u, GtUword ulen,
                                   const GtUchar *v, GtUword vlen,
                                   GtUword matchcost, GtUword mismatchcost,
                                   GtUword gap_opening, GtUword gap_extension,
                                   GtAffineAlignEdge edge,
                                   const GtScoreHandler *scorehandler)
{
  GtUword i, j, Rvalue, Dvalue, Ivalue, minvalue,rcost;
  gt_assert(dptable && u && v);

  if (scorehandler != NULL)/*else work with given constant values*/
  {
    gap_opening = gt_scorehandler_get_gap_opening(scorehandler);
    gap_extension = gt_scorehandler_get_gapscore(scorehandler);
  }

  for (i = 0; i <= ulen; i++) {
    for (j = 0; j <= vlen; j++) {
      if (!i && !j) {
        switch (edge) {
          case Affine_R:
            dptable[0][0].Rvalue = 0;
            dptable[0][0].Dvalue = GT_WORD_MAX;
            dptable[0][0].Ivalue = GT_WORD_MAX;
            break;
          case Affine_D:
            dptable[0][0].Rvalue = GT_WORD_MAX;
            dptable[0][0].Dvalue = 0;
            dptable[0][0].Ivalue = GT_WORD_MAX;
            break;
          case Affine_I:
            dptable[0][0].Rvalue = GT_WORD_MAX;
            dptable[0][0].Dvalue = GT_WORD_MAX;
            dptable[0][0].Ivalue = 0;
            break;
          default:
            dptable[0][0].Rvalue = 0;
            dptable[0][0].Dvalue = gap_opening;
            dptable[0][0].Ivalue = gap_opening;
        }
      }
      else {
        /* compute A_affine(i,j,R) */
        if (!i || !j)
          dptable[i][j].Rvalue = LONG_MAX;
        else {
          if (scorehandler != NULL)
            rcost = gt_scorehandler_get_replacement(scorehandler,
                                                    u[i-1], v[j-1]);
          else
            rcost  = (u[i-1] == v[j-1]) ? matchcost : mismatchcost;

          Rvalue = add_safe_max(dptable[i-1][j-1].Rvalue, rcost);
          Dvalue = add_safe_max(dptable[i-1][j-1].Dvalue, rcost);
          Ivalue = add_safe_max(dptable[i-1][j-1].Ivalue, rcost);
          minvalue = GT_MIN3(Rvalue, Dvalue, Ivalue);
          gt_assert(minvalue != LONG_MAX);
          dptable[i][j].Rvalue = minvalue;
          /* set backtracing edge */
          if (Rvalue == minvalue)
            dptable[i][j].Redge = Affine_R;
          else if (Dvalue == minvalue)
            dptable[i][j].Redge = Affine_D;
          else /* Ivalue == minvalue */
            dptable[i][j].Redge = Affine_I;
        }
        /* compute A_affine(i,j,D) */
        if (!i)
          dptable[i][j].Dvalue = LONG_MAX;
        else {
          Rvalue = add_safe_max(dptable[i-1][j].Rvalue,
                                gap_opening + gap_extension);
          Dvalue = add_safe_max(dptable[i-1][j].Dvalue, gap_extension);
          Ivalue = add_safe_max(dptable[i-1][j].Ivalue,
                                gap_opening + gap_extension);
          minvalue = GT_MIN3(Rvalue, Dvalue, Ivalue);
          gt_assert(minvalue != ULONG_MAX);
          dptable[i][j].Dvalue = minvalue;
          /* set backtracing edge */
          if (Rvalue == minvalue)
            dptable[i][j].Dedge = Affine_R;
          else if (Dvalue == minvalue)
            dptable[i][j].Dedge = Affine_D;
          else /* Ivalue == minvalue */
            dptable[i][j].Dedge = Affine_I;
        }
        /* compute A_affine(i,j,I) */
        if (!j)
          dptable[i][j].Ivalue = LONG_MAX;
        else {
          Rvalue = add_safe_max(dptable[i][j-1].Rvalue,
                                gap_opening + gap_extension);
          Dvalue = add_safe_max(dptable[i][j-1].Dvalue,
                                gap_opening + gap_extension);
          Ivalue = add_safe_max(dptable[i][j-1].Ivalue, gap_extension);
          minvalue = GT_MIN3(Rvalue, Dvalue, Ivalue);
          gt_assert(minvalue != LONG_MAX);
          dptable[i][j].Ivalue = minvalue;
          /* set backtracing edge */
          if (Rvalue == minvalue)
            dptable[i][j].Iedge = Affine_R;
          else if (Dvalue == minvalue)
            dptable[i][j].Iedge = Affine_D;
          else /* Ivalue == minvalue */
            dptable[i][j].Iedge = Affine_I;
        }
      }
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r9, 0x28(%rsp)
movq %rcx, 0x10(%rsp)
movq %rdx, 0x18(%rsp)
movq %rsi, 0x8(%rsp)
testq %rdi, %rdi
je 0x2f9767
cmpq $0x0, 0x8(%rsp)
je 0x2f9767
cmpq $0x0, 0x10(%rsp)
je 0x2f9767
movq %rdi, %r13
movq 0x90(%rsp), %rbx
testq %rbx, %rbx
movq %r8, (%rsp)
je 0x2f946d
movq %rbx, %rdi
callq 0x171427
movq %rax, %r14
movq %rbx, %rdi
callq 0x171437
movq (%rsp), %r8
movq %rax, %r9
jmp 0x2f947a
movq 0x80(%rsp), %r9
movq 0x78(%rsp), %r14
movl 0x88(%rsp), %r10d
movabsq $0x7fffffffffffffff, %r15 # imm = 0x7FFFFFFFFFFFFFFF
movq %r14, 0x20(%rsp)
leaq (%r14,%r9), %r11
xorl %r12d, %r12d
xorl %ebx, %ebx
xorl %r14d, %r14d
movq %r12, 0x30(%rsp)
movq %r14, %rax
orq %r12, %rax
je 0x2f94f9
testq %r14, %r14
sete %al
testq %r12, %r12
sete %cl
orb %al, %cl
jne 0x2f952a
movq 0x8(%rsp), %rax
movb -0x1(%rax,%r12), %cl
movq 0x10(%rsp), %rax
movb -0x1(%rax,%r14), %dl
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
je 0x2f9546
movzbl %cl, %esi
movzbl %dl, %edx
movq %r9, %rbp
movq %r11, %r12
callq 0x171466
movq %r12, %r11
movq 0x30(%rsp), %r12
movq %rbp, %r9
jmp 0x2f9554
movq (%r13), %rax
cmpl $0x2, %r10d
je 0x2f95ff
cmpl $0x1, %r10d
je 0x2f95ef
testl %r10d, %r10d
jne 0x2f9613
movq $0x0, (%rax)
movq %r15, 0x8(%rax)
jmp 0x2f970c
movq (%r13,%r12,8), %rax
movq %r15, (%rax,%rbx)
testq %r12, %r12
je 0x2f95e1
movq -0x8(%r13,%r12,8), %rcx
jmp 0x2f9634
movq 0x28(%rsp), %rax
cmpb %dl, %cl
je 0x2f9554
movq 0x70(%rsp), %rax
movq -0x8(%r13,%r12,8), %rcx
movq -0x30(%rcx,%rbx), %rsi
movq -0x28(%rcx,%rbx), %rdi
leaq (%rsi,%rax), %rdx
cmpq %r15, %rsi
cmoveq %r15, %rdx
leaq (%rdi,%rax), %rsi
cmpq %r15, %rdi
cmoveq %r15, %rsi
movq -0x20(%rcx,%rbx), %rdi
addq %rdi, %rax
cmpq %r15, %rdi
cmoveq %r15, %rax
cmpq %rsi, %rdx
movq %rsi, %rdi
cmovbq %rdx, %rdi
cmpq %rax, %rdi
cmovaeq %rax, %rdi
cmpq %r15, %rdi
je 0x2f975d
movq (%r13,%r12,8), %rax
movq %rdi, (%rax,%rbx)
cmpq %rdi, %rdx
jne 0x2f95c6
movl $0x0, 0x20(%rax,%rbx)
movq (%rsp), %r8
movl 0x88(%rsp), %r10d
jmp 0x2f9634
cmpq %rdi, %rsi
movq (%rsp), %r8
movl 0x88(%rsp), %r10d
jne 0x2f962c
movl $0x1, 0x20(%rax,%rbx)
jmp 0x2f9634
movq (%r13), %rcx
movq %r15, 0x8(%rcx,%rbx)
jmp 0x2f96ad
movq %r15, (%rax)
movq $0x0, 0x8(%rax)
jmp 0x2f970c
movq %r15, (%rax)
movq %r15, 0x8(%rax)
movq $0x0, 0x10(%rax)
jmp 0x2f9710
movq $0x0, (%rax)
movq 0x20(%rsp), %rcx
movq %rcx, 0x8(%rax)
movq %rcx, 0x10(%rax)
jmp 0x2f9710
movl $0x2, 0x20(%rax,%rbx)
movq (%rcx,%rbx), %rsi
movq 0x8(%rcx,%rbx), %rdi
leaq (%rsi,%r11), %rdx
cmpq %r15, %rsi
cmoveq %r15, %rdx
leaq (%rdi,%r9), %rsi
cmpq %r15, %rdi
cmoveq %r15, %rsi
movq 0x10(%rcx,%rbx), %rdi
leaq (%rdi,%r11), %rcx
cmpq %r15, %rdi
cmoveq %r15, %rcx
cmpq %rsi, %rdx
jae 0x2f9671
cmpq %rcx, %rdx
cmovbq %rdx, %rcx
jmp 0x2f9682
cmpq %rcx, %rsi
cmovbq %rsi, %rcx
cmpq $-0x1, %rcx
je 0x2f9762
movq %rcx, 0x8(%rax,%rbx)
cmpq %rcx, %rdx
jne 0x2f9696
movl $0x0, 0x24(%rax,%rbx)
jmp 0x2f96ad
cmpq %rcx, %rsi
jne 0x2f96a5
movl $0x1, 0x24(%rax,%rbx)
jmp 0x2f96ad
movl $0x2, 0x24(%rax,%rbx)
testq %r14, %r14
je 0x2f970c
movq -0x30(%rax,%rbx), %rdx
movq -0x28(%rax,%rbx), %rsi
leaq (%rdx,%r11), %rcx
cmpq %r15, %rdx
cmoveq %r15, %rcx
leaq (%rsi,%r11), %rdx
cmpq %r15, %rsi
cmoveq %r15, %rdx
movq -0x20(%rax,%rbx), %rsi
leaq (%rsi,%r9), %rdi
cmpq %r15, %rsi
cmoveq %r15, %rdi
cmpq %rdx, %rcx
movq %rdx, %rsi
cmovbq %rcx, %rsi
cmpq %rdi, %rsi
cmovaeq %rdi, %rsi
cmpq %r15, %rsi
je 0x2f9758
movq %rsi, 0x10(%rax,%rbx)
cmpq %rsi, %rcx
jne 0x2f9722
movl $0x0, 0x28(%rax,%rbx)
jmp 0x2f9710
movq %r15, 0x10(%rax)
incq %r14
addq $0x30, %rbx
cmpq %r8, %r14
jbe 0x2f94a2
jmp 0x2f973b
cmpq %rsi, %rdx
jne 0x2f9731
movl $0x1, 0x28(%rax,%rbx)
jmp 0x2f9710
movl $0x2, 0x28(%rax,%rbx)
jmp 0x2f9710
incq %r12
cmpq 0x18(%rsp), %r12
jbe 0x2f9498
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x89655
callq 0x8968c
callq 0x8961e
callq 0x895e7