// File: /workspace/github_c_makefile_star2_O1/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 0x30340f
cmpq $0x0, 0x8(%rsp)
je 0x30340f
cmpq $0x0, 0x10(%rsp)
je 0x30340f
movq %rdi, %r13
movq 0x90(%rsp), %rbx
testq %rbx, %rbx
movq %r8, (%rsp)
je 0x303109
movq %rbx, %rdi
callq 0x1797eb
movq %rax, %r14
movq %rbx, %rdi
callq 0x1797fb
movq (%rsp), %r8
movq %rax, %r9
jmp 0x303116
movq 0x80(%rsp), %r9
movq 0x78(%rsp), %r14
movl 0x88(%rsp), %r10d
movabsq $0x7fffffffffffffff, %r15 # imm = 0x7FFFFFFFFFFFFFFF
movq %r14, 0x20(%rsp)
leaq (%r14,%r9), %rbp
xorl %r12d, %r12d
movq %r13, 0x30(%rsp)
xorl %ebx, %ebx
xorl %r14d, %r14d
movq %r14, %rax
orq %r12, %rax
je 0x30318b
testq %r14, %r14
setne %al
testq %r12, %r12
setne %cl
testb %al, %cl
je 0x3031bc
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
je 0x3031ca
movq 0x8(%rsp), %rax
movzbl -0x1(%rax,%r12), %esi
movq 0x10(%rsp), %rax
movzbl -0x1(%rax,%r14), %edx
movq %r9, %r13
callq 0x17982a
movq %r13, %r9
movq 0x30(%rsp), %r13
jmp 0x3031ea
movq (%r13), %rax
cmpl $0x2, %r10d
je 0x303287
cmpl $0x1, %r10d
je 0x303277
testl %r10d, %r10d
jne 0x30329b
movq $0x0, (%rax)
movq %r15, 0x8(%rax)
jmp 0x3033b4
movq (%r13,%r12,8), %rax
movq %r15, (%rax,%rbx)
jmp 0x3032bc
movq 0x8(%rsp), %rax
movb -0x1(%rax,%r12), %cl
movq 0x28(%rsp), %rax
movq 0x10(%rsp), %rdx
cmpb -0x1(%rdx,%r14), %cl
je 0x3031ea
movq 0x70(%rsp), %rax
movq -0x8(%r13,%r12,8), %rsi
movq -0x30(%rsi,%rbx), %rdx
movq -0x28(%rsi,%rbx), %rdi
leaq (%rdx,%rax), %rcx
cmpq %r15, %rdx
cmoveq %r15, %rcx
leaq (%rdi,%rax), %rdx
cmpq %r15, %rdi
cmoveq %r15, %rdx
movq -0x20(%rsi,%rbx), %rsi
addq %rsi, %rax
cmpq %r15, %rsi
cmoveq %r15, %rax
cmpq %rdx, %rcx
movq %rdx, %rsi
cmovbq %rcx, %rsi
cmpq %rax, %rsi
cmovaeq %rax, %rsi
cmpq %r15, %rsi
je 0x30340a
movq (%r13,%r12,8), %rax
movq %rsi, (%rax,%rbx)
cmpq %rsi, %rcx
jne 0x30325c
movl $0x0, 0x20(%rax,%rbx)
movq (%rsp), %r8
movl 0x88(%rsp), %r10d
jmp 0x3032bc
cmpq %rsi, %rdx
movq (%rsp), %r8
movl 0x88(%rsp), %r10d
jne 0x3032b4
movl $0x1, 0x20(%rax,%rbx)
jmp 0x3032bc
movq %r15, (%rax)
movq $0x0, 0x8(%rax)
jmp 0x3033b4
movq %r15, (%rax)
movq %r15, 0x8(%rax)
movq $0x0, 0x10(%rax)
jmp 0x3033b8
movq $0x0, (%rax)
movq 0x20(%rsp), %rcx
movq %rcx, 0x8(%rax)
movq %rcx, 0x10(%rax)
jmp 0x3033b8
movl $0x2, 0x20(%rax,%rbx)
testq %r12, %r12
je 0x303329
movq -0x8(%r13,%r12,8), %rdx
movq (%rdx,%rbx), %rcx
movq 0x8(%rdx,%rbx), %rsi
leaq (%rcx,%rbp), %rax
cmpq %r15, %rcx
cmoveq %r15, %rax
leaq (%rsi,%r9), %rcx
cmpq %r15, %rsi
cmoveq %r15, %rcx
movq 0x10(%rdx,%rbx), %rdx
leaq (%rdx,%rbp), %rsi
cmpq %r15, %rdx
cmoveq %r15, %rsi
cmpq %rcx, %rax
movq %rcx, %rdx
cmovbq %rax, %rdx
cmpq %rsi, %rdx
cmovaeq %rsi, %rdx
cmpq $-0x1, %rdx
je 0x303405
movq (%r13,%r12,8), %rsi
movq %rdx, 0x8(%rsi,%rbx)
cmpq %rdx, %rax
jne 0x303334
movl $0x0, 0x24(%rsi,%rbx)
jmp 0x30334b
movq (%r13), %rax
movq %r15, 0x8(%rax,%rbx)
jmp 0x30334b
cmpq %rdx, %rcx
jne 0x303343
movl $0x1, 0x24(%rsi,%rbx)
jmp 0x30334b
movl $0x2, 0x24(%rsi,%rbx)
testq %r14, %r14
je 0x3033af
movq (%r13,%r12,8), %rax
movq -0x30(%rax,%rbx), %rdx
movq -0x28(%rax,%rbx), %rsi
leaq (%rdx,%rbp), %rcx
cmpq %r15, %rdx
cmoveq %r15, %rcx
leaq (%rsi,%rbp), %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 0x303400
movq %rsi, 0x10(%rax,%rbx)
cmpq %rsi, %rcx
jne 0x3033ca
movl $0x0, 0x28(%rax,%rbx)
jmp 0x3033b8
movq (%r13,%r12,8), %rax
movq %r15, 0x10(%rax)
incq %r14
addq $0x30, %rbx
cmpq %r8, %r14
jbe 0x30313e
jmp 0x3033e3
cmpq %rsi, %rdx
jne 0x3033d9
movl $0x1, 0x28(%rax,%rbx)
jmp 0x3033b8
movl $0x2, 0x28(%rax,%rbx)
jmp 0x3033b8
incq %r12
cmpq 0x18(%rsp), %r12
jbe 0x303139
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x8b301
callq 0x8b338
callq 0x8b36f
callq 0x8b2ca