// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/extended/squarealign.c
// Function: gt_squarealign_calculate_local_generic
GtWord gt_squarealign_calculate_local_generic(GtLinspaceManagement
                                              *spacemanager,
                                              GtAlignment *align,
                                              const GtUchar *useq,
                                              GtUword ustart,
                                              GtUword ulen,
                                              const GtUchar *vseq,
                                              GtUword vstart,
                                              GtUword vlen,
                                              const GtScoreHandler
                                              *scorehandler)
{
  GtWord score = 0, **Ltabcolumn;
  GtMaxcoordvalue *max;

  gt_assert(align != NULL);
  if (spacemanager == NULL)
  {
    /*use it in normally case*/
    gt_array2dim_malloc(Ltabcolumn, (ulen+1), (vlen+1));
    max = gt_maxcoordvalue_new();
  }
  else
  {
    /*use it in lineraspace context*/
    Ltabcolumn = (GtWord **)
                 gt_linspace_management_change_to_square(spacemanager,
                                                         ulen, vlen);
    max = gt_linspace_management_get_maxspace(spacemanager);
  }

  score = fillDPtab_in_square_space_local(Ltabcolumn, max, useq, ustart, ulen,
                                          vseq, vstart, vlen, scorehandler);

  /* reconstruct local alignment from 2dimarray Ltabcolumn */
  gt_reconstructalignment_from_Ltab(align, Ltabcolumn, max,
                                    useq, ustart, ulen,
                                    vseq, vstart, vlen,
                                    scorehandler);

  if (gt_maxcoordvalue_get_length_safe(max))
  {
    ustart = ustart + (gt_maxcoordvalue_get_start(max)).a;
    vstart = vstart + (gt_maxcoordvalue_get_start(max)).b;
    ulen = gt_maxcoordvalue_get_row_length(max);
    vlen = gt_maxcoordvalue_get_col_length(max);

    gt_alignment_set_seqs(align, &useq[ustart], ulen,
                                 &vseq[vstart], vlen);
  }

  if (spacemanager == NULL)
  {
    gt_array2dim_delete(Ltabcolumn);
    gt_maxcoordvalue_delete(max);
  }
  return score;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, 0x28(%rsp)
testq %rsi, %rsi
je 0x17a168
movq %r9, %r12
movq %r8, %r15
movq %rcx, %r14
movq %rdx, %r13
movq %rdi, %rbx
movq 0x88(%rsp), %rdx
testq %rdi, %rdi
movq %r15, (%rsp)
movq %rdi, 0x40(%rsp)
movq %rcx, 0x18(%rsp)
je 0x179e7d
movq %rbx, %rdi
movq %r15, %rsi
callq 0x15be6b
movq %rax, %rbp
movq %rbx, %rdi
callq 0x15be5e
movq %rax, 0x8(%rsp)
jmp 0x179f0e
movq (%rsp), %rax
leaq 0x1(%rax), %r15
movq (%rsp), %rax
leaq 0x8(,%rax,8), %rbx
leaq 0x21a78f(%rip), %r14    # 0x394627
movq %rbx, %rdi
movq %r14, %rsi
movl $0x13c, %edx            # imm = 0x13C
callq 0x104226
movq %rax, %rbp
movq 0x88(%rsp), %rax
leaq 0x1(%rax), %rdi
imulq %rbx, %rdi
movq %r14, %rsi
movl $0x13c, %edx            # imm = 0x13C
callq 0x104226
movq %rax, (%rbp)
cmpq $0x2, %r15
movq (%rsp), %r15
jb 0x179eff
movq 0x88(%rsp), %rax
leaq 0x8(,%rax,8), %rax
movq (%rbp), %rcx
addq %rax, %rcx
xorl %edx, %edx
movq %rcx, 0x8(%rbp,%rdx,8)
addq %rax, %rcx
incq %rdx
cmpq %rdx, %r15
jne 0x179eef
callq 0x160590
movq %rax, 0x8(%rsp)
movq 0x18(%rsp), %r14
movq 0x90(%rsp), %rdi
callq 0x171437
movq %rax, %rbx
movq (%rbp), %rax
movq $0x0, (%rax)
testq %r15, %r15
je 0x179f58
leaq 0x1(%r15), %rcx
cmpq $0x3, %rcx
movl $0x2, %eax
cmovaeq %rcx, %rax
movl $0x1, %ecx
movq (%rbp,%rcx,8), %rdx
movq $0x0, (%rdx)
incq %rcx
cmpq %rcx, %rax
jne 0x179f44
movq 0x80(%rsp), %rcx
movq 0x88(%rsp), %rax
testq %rax, %rax
movq %r12, 0x38(%rsp)
movq %r13, 0x30(%rsp)
je 0x17a068
leaq (%r12,%rcx), %rax
decq %rax
movq %rax, 0x20(%rsp)
addq %r14, %r13
movl $0x1, %r14d
movq $0x0, 0x10(%rsp)
movq (%rbp), %rax
movq $0x0, (%rax,%r14,8)
testq %r15, %r15
je 0x17a052
movl $0x1, %r12d
movq (%rbp,%r12,8), %rax
movq -0x8(%rax,%r14,8), %rcx
addq %rbx, %rcx
movq %rcx, (%rax,%r14,8)
movq -0x8(%rbp,%r12,8), %rax
movq -0x8(%rax,%r14,8), %r15
movzbl -0x1(%r13,%r12), %esi
movq 0x20(%rsp), %rax
movzbl (%rax,%r14), %edx
movq 0x90(%rsp), %rdi
callq 0x171466
addq %r15, %rax
movq (%rbp,%r12,8), %rcx
movq (%rcx,%r14,8), %rdx
cmpq %rdx, %rax
jl 0x17a004
movq %rax, (%rcx,%r14,8)
movq %rax, %rdx
movq -0x8(%rbp,%r12,8), %rax
movq (%rax,%r14,8), %r15
addq %rbx, %r15
cmpq %rdx, %r15
cmovleq %rdx, %r15
testq %r15, %r15
jg 0x17a01f
xorl %r15d, %r15d
movq %r15, (%rcx,%r14,8)
cmpq 0x10(%rsp), %r15
jle 0x17a042
movq 0x8(%rsp), %rdi
movq %r15, %rsi
movq %r12, %rdx
movq %r14, %rcx
callq 0x160655
movq %r15, 0x10(%rsp)
incq %r12
movq (%rsp), %r15
cmpq %r15, %r12
jbe 0x179fb4
incq %r14
movq 0x88(%rsp), %rax
cmpq %rax, %r14
jbe 0x179f99
jmp 0x17a071
movq $0x0, 0x10(%rsp)
movq 0x28(%rsp), %rdi
movq %rbp, %rsi
movq 0x8(%rsp), %r14
movq %r14, %rdx
movq 0x30(%rsp), %r13
movq %r13, %rcx
movq 0x18(%rsp), %r8
movq %r15, %r9
pushq 0x90(%rsp)
pushq %rax
movq 0x90(%rsp), %r15
pushq %r15
movq 0x50(%rsp), %r12
pushq %r12
callq 0x16cee9
addq $0x20, %rsp
movq %r14, %rdi
callq 0x1606a4
testb %al, %al
je 0x17a11a
movq %r15, %r14
movq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x1605fa
movq %rax, (%rsp)
movq %r15, %rdi
callq 0x1605fa
movq %rdx, %rbx
movq %r15, %rdi
callq 0x16066c
movq %rax, 0x20(%rsp)
movq %r15, %rdi
callq 0x160688
addq 0x18(%rsp), %r13
addq (%rsp), %r13
addq %rbx, %r12
addq %r14, %r12
movq 0x28(%rsp), %rdi
movq %r13, %rsi
movq 0x20(%rsp), %rdx
movq %r12, %rcx
movq %rax, %r8
callq 0x120e01
cmpq $0x0, 0x40(%rsp)
jne 0x17a154
movq (%rbp), %rdi
leaq 0x21a4fa(%rip), %rbx    # 0x394627
movq %rbx, %rsi
movl $0x15e, %edx            # imm = 0x15E
callq 0x1045eb
movq %rbp, %rdi
movq %rbx, %rsi
movl $0x15e, %edx            # imm = 0x15E
callq 0x1045eb
movq 0x8(%rsp), %rdi
callq 0x1605c0
movq 0x10(%rsp), %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x55e28