// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/extended/diagonalbandalign_affinegapcost.c
// Function: gt_diagonalbandalign_affinegapcost_in_square_space_generic
GtWord gt_diagonalbandalign_affinegapcost_in_square_space_generic(
                                             GtLinspaceManagement *space,
                                             const GtScoreHandler *scorehandler,
                                             GtAlignment *align,
                                             const GtUchar *useq,
                                             GtUword ustart,
                                             GtUword ulen,
                                             const GtUchar *vseq,
                                             GtUword vstart,
                                             GtUword vlen,
                                             GtWord left_dist,
                                             GtWord right_dist)
{
  GtWord distance;
  GtUword idx;
  GtAffinealignDPentry **Atabcolumn;

  gt_assert(align && scorehandler);
  if (space == NULL)
  {
    gt_array2dim_malloc(Atabcolumn, (ulen+1), (vlen+1));
  }
  else
  {
    gt_assert((ulen+1)*(vlen+1)*sizeof(**Atabcolumn) <=
               gt_linspace_management_get_valueTabsize(space));

    Atabcolumn = gt_linspace_management_get_rTabspace(space);
    *Atabcolumn = gt_linspace_management_get_valueTabspace(space);

    for (idx=1; idx<ulen+1; idx++)
      Atabcolumn[idx]=Atabcolumn[idx-1]+vlen+1;
  }

  diagonalband_fillDPtab_affine(Atabcolumn, useq, ustart, ulen, vseq, vstart,
                                vlen, left_dist, right_dist,
                                Affine_X, Affine_X, scorehandler);

  distance = GT_MIN3(Atabcolumn[ulen][vlen].Rvalue,
                  Atabcolumn[ulen][vlen].Dvalue,
                  Atabcolumn[ulen][vlen].Ivalue);

  /* reconstruct alignment from 2dimarray Atabcolumn */
  gt_affinealign_traceback(align, Atabcolumn, ulen, vlen);

  if (space == NULL)
  {
    gt_array2dim_delete(Atabcolumn);
  }
  return distance;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
testq %rsi, %rsi
je 0x13ab00
movq %rdx, %r15
testq %rdx, %rdx
je 0x13ab00
movq %r9, %rbx
movq %rsi, %r13
movq %rdi, %rbp
movq %rcx, 0x10(%rsp)
movq %r8, 0x8(%rsp)
movq 0x70(%rsp), %r14
leaq 0x1(%r9), %r12
testq %rdi, %rdi
movq %r15, 0x20(%rsp)
movq %rdi, 0x18(%rsp)
je 0x13a9c1
leaq 0x1(%r14), %rax
imulq %r12, %rax
shlq $0x4, %rax
leaq (%rax,%rax,2), %r15
movq %rbp, %rdi
callq 0x163bba
cmpq %rax, %r15
ja 0x13ab05
movq %rbp, %rdi
callq 0x163ba0
movq %rbp, %rdi
movq %rax, %rbp
callq 0x163b94
movq %rax, (%rbp)
cmpq $0x2, %r12
jb 0x13aa3e
movq 0x70(%rsp), %rax
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
addq $0x30, %rax
movq (%rbp), %rcx
addq %rax, %rcx
xorl %edi, %edi
movq 0x8(%rsp), %rdx
movq 0x10(%rsp), %rsi
movq %rcx, 0x8(%rbp,%rdi,8)
addq %rax, %rcx
incq %rdi
cmpq %rdi, %rbx
jne 0x13a9ac
jmp 0x13aa48
leaq (,%r12,8), %rdi
leaq 0x2498a3(%rip), %rsi    # 0x384273
movl $0xd9, %edx
callq 0x1092b2
movq %rax, %rbp
leaq 0x1(%r14), %rax
imulq %r12, %rax
shlq $0x4, %rax
leaq (%rax,%rax,2), %rdi
leaq 0x24987f(%rip), %rsi    # 0x384273
movl $0xd9, %edx
callq 0x1092b2
movq %rax, (%rbp)
cmpq $0x2, %r12
jb 0x13aa3e
movq 0x70(%rsp), %rax
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
addq $0x30, %rax
movq (%rbp), %rcx
addq %rax, %rcx
xorl %edi, %edi
movq 0x8(%rsp), %rdx
movq 0x10(%rsp), %rsi
movq %rcx, 0x8(%rbp,%rdi,8)
addq %rax, %rcx
incq %rdi
cmpq %rdi, %rbx
jne 0x13aa2c
jmp 0x13aa48
movq 0x8(%rsp), %rdx
movq 0x10(%rsp), %rsi
movq 0x68(%rsp), %r9
movq 0x60(%rsp), %r8
movl $0x3, %eax
movq %rbp, %rdi
movq %rbx, %rcx
pushq %r13
pushq %rax
pushq %rax
pushq 0x98(%rsp)
pushq 0x98(%rsp)
movq 0x98(%rsp), %r14
pushq %r14
callq 0x13ab0a
addq $0x30, %rsp
movq (%rbp,%rbx,8), %rax
leaq (%r14,%r14,2), %rcx
shlq $0x4, %rcx
movq (%rax,%rcx), %r15
movq 0x8(%rax,%rcx), %r13
movq 0x10(%rax,%rcx), %r12
movq 0x20(%rsp), %rdi
movq %rbp, %rsi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x302dd4
cmpq $0x0, 0x18(%rsp)
jne 0x13aae0
movq (%rbp), %rdi
leaq 0x2497b0(%rip), %rbx    # 0x384273
movq %rbx, %rsi
movl $0xf4, %edx
callq 0x109670
movq %rbp, %rdi
movq %rbx, %rsi
movl $0xf4, %edx
callq 0x109670
cmpq %r13, %r15
cmovlq %r15, %r13
cmpq %r12, %r13
cmovgeq %r12, %r13
movq %r13, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x3fe2b
callq 0x3fe64