// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/extended/diagonalbandalign.c
// Function: gt_calc_diagonalbandalign
static void gt_calc_diagonalbandalign(GtLinspaceManagement *spacemanager,
                                      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)
{
  GtDiagAlignentry *Diagcolumn;
  GtUword idx, gapcost, *EDtabcolumn, *Rtabcolumn;

  gt_assert(align && spacemanager && scorehandler);

  if ((left_dist > GT_MIN(0, (GtWord)vlen-(GtWord)ulen))||
      (right_dist < GT_MAX(0, (GtWord)vlen-(GtWord)ulen)))
  {
    gt_assert(false); /* no global alignment */
  }

  gt_linspace_management_set_ulen(spacemanager,ulen);
  gapcost = gt_scorehandler_get_gapscore(scorehandler);
  if (ulen == 0UL)
  {
    (void) gt_reconstructalignment_trivial_insertion(align, vlen, gapcost);
    return;
  }
  else if (vlen == 0UL)
  {
    (void) gt_reconstructalignment_trivial_deletion(align, ulen, gapcost);
    return;
  }
  else if (gt_linspace_management_checksquare(spacemanager, ulen, vlen,
                                              sizeof (*EDtabcolumn),
                                              sizeof (*Rtabcolumn)))
  {
    (void) gt_diagonalbandalignment_in_square_space_generic(spacemanager,align,
                                                            useq, ustart, ulen,
                                                            vseq, vstart, vlen,
                                                            left_dist,
                                                            right_dist,
                                                            scorehandler);
    return;
  }

  gt_linspace_management_check(spacemanager, GT_MIN(right_dist-left_dist,ulen),
                               vlen,
                               sizeof (*EDtabcolumn),
                               sizeof (*Rtabcolumn),
                               sizeof (*Diagcolumn));

  Diagcolumn = gt_linspace_management_get_crosspointTabspace(spacemanager);
  /* initialize Diagcolumn */
  for (idx = 0; idx <= vlen; idx++)
  {
    Diagcolumn[idx].lastcpoint = GT_UWORD_MAX;
    Diagcolumn[idx].currentrowindex = GT_UWORD_MAX;
  }

  evaluateDBcrosspoints(spacemanager, Diagcolumn, scorehandler,
                        Linear_X, 0, 0,  useq, ustart, ulen,
                        vseq, vstart, vlen, left_dist, right_dist);

  gt_reconstructalignment_from_Dtab(align, Diagcolumn, ulen, vlen);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
testq %rsi, %rsi
je 0x133136
movq %rdi, %r12
testq %rdi, %rdi
je 0x133136
movq %rdx, %r14
testq %rdx, %rdx
je 0x133136
movq %r9, %rbx
movq %rsi, %rbp
movq %r8, 0x18(%rsp)
movq %rcx, 0x20(%rsp)
movq 0x78(%rsp), %rsi
movq 0x70(%rsp), %r15
movq %r15, %rcx
subq %r9, %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 0x13313b
movq 0x80(%rsp), %r13
cmpq %r13, %rax
jg 0x13313b
movq 0x68(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x60(%rsp), %rax
movq %rax, 0x8(%rsp)
movq %r12, %rdi
movq %rbx, %rsi
callq 0x15be18
movq %rbp, %rdi
callq 0x171437
testq %rbx, %rbx
je 0x133051
testq %r15, %r15
je 0x13306d
movl $0x8, %ecx
movl $0x8, %r8d
movq %r12, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x15bd8d
testb %al, %al
je 0x133089
subq $0x8, %rsp
movq %r12, %rdi
movq %r14, %rsi
movq 0x28(%rsp), %rdx
movq 0x20(%rsp), %rcx
movq %rbx, %r8
movq 0x10(%rsp), %r9
pushq %rbp
pushq %r13
pushq 0x18(%rsp)
pushq %r15
pushq 0x38(%rsp)
callq 0x1329cc
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rdx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x16cd21
movq %r14, %rdi
movq %rbx, %rsi
movq %rax, %rdx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x16cce8
movq %r13, %rsi
subq (%rsp), %rsi
cmpq %rbx, %rsi
cmovaeq %rbx, %rsi
movl $0x8, %ecx
movl $0x8, %r8d
movl $0x18, %r9d
movq %r12, %rdi
movq %r15, %rdx
callq 0x15bc3e
movq %r12, %rdi
callq 0x15be41
leaq 0x1(%r15), %rcx
cmpq $0x1, %rcx
movq %r15, %rdx
adcq $0x1, %rdx
pcmpeqd %xmm0, %xmm0
movq %rax, %rcx
movdqu %xmm0, (%rcx)
addq $0x18, %rcx
decq %rdx
jne 0x1330d1
movq %r12, %rdi
movq %rax, %r12
movq %rax, %rsi
movq %rbp, %rdx
movl $0x3, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
pushq %r13
pushq 0x8(%rsp)
pushq %r15
pushq 0x28(%rsp)
pushq 0x28(%rsp)
pushq %rbx
pushq 0x48(%rsp)
pushq 0x58(%rsp)
callq 0x1337af
addq $0x40, %rsp
movq %r14, %rdi
movq %r12, %rsi
movq %rbx, %rdx
movq %r15, %rcx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x16d27d
callq 0x3efbf
callq 0x3eff8