// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/extended/linearalign_affinegapcost.c
// Function: gt_linearalign_affinegapcost_compute_local_generic
GtWord gt_linearalign_affinegapcost_compute_local_generic(
                                            GtLinspaceManagement *spacemanager,
                                            const GtScoreHandler *scorehandler,
                                            GtAlignment *align,
                                            const GtUchar *useq,
                                            GtUword ustart,
                                            GtUword ulen,
                                            const GtUchar *vseq,
                                            GtUword vstart,
                                            GtUword vlen)
{
  GtUword ulen_part, ustart_part, vlen_part, vstart_part;
  GtWord score;
  GtAffinealignDPentry *Atabcolumn;
  Starttabentry *Starttabcolumn;
  GtMaxcoordvalue *max;

  gt_linspace_management_set_ulen(spacemanager, ulen);
  if (ulen == 0UL || vlen == 0UL)
  {
     /* empty alignment */
    return 0;
  }
  else if (vlen == 1UL)
  {
    gt_linspace_management_check_local(spacemanager,
                                       (ulen+1)*(vlen+1)-1, ulen,
                                       sizeof (*Atabcolumn),
                                       sizeof (Atabcolumn));
    return gt_affinealign_calculate_local_generic(spacemanager,scorehandler,
                                                  align,
                                                  useq, ustart, ulen,
                                                  vseq, vstart, vlen);
  }
  else if (gt_linspace_management_checksquare_local(spacemanager, ulen, vlen,
                                                    sizeof (*Atabcolumn),
                                                    sizeof (*Starttabcolumn)))
  {
    /* call alignment function for square space */
    return gt_affinealign_calculate_local_generic(spacemanager, scorehandler,
                                                  align, useq, ustart, ulen,
                                                  vseq, vstart, vlen);
  }

  gt_linspace_management_check_local(spacemanager, ulen, vlen,
                                     sizeof (*Atabcolumn),
                                     sizeof (*Starttabcolumn));

  max = evaluateallAStabcolumns(spacemanager, scorehandler,
                                useq, ustart, ulen,
                                vseq, vstart, vlen);

  score = gt_maxcoordvalue_get_value(max);

  if (gt_maxcoordvalue_get_length_safe(max))
  {
    GtScoreHandler *costhandler = gt_scorehandler2costhandler(scorehandler);

    ustart_part = ustart+(gt_maxcoordvalue_get_start(max)).a;
    vstart_part = vstart+(gt_maxcoordvalue_get_start(max)).b;
    ulen_part = gt_maxcoordvalue_get_row_length(max);
    vlen_part = gt_maxcoordvalue_get_col_length(max);

    gt_alignment_set_seqs(align,useq + ustart_part,ulen_part,
                                vseq + vstart_part,vlen_part);

    /* change score to cost, from maximizing to minimizing */

    gt_calc_affinealign_linear(spacemanager,
                               costhandler,
                               align,
                               useq, ustart_part, ulen_part,
                               vseq, vstart_part, vlen_part);
    gt_scorehandler_delete(costhandler);
  } else
  {
     /* empty alignment */
     return 0;
  }
  return score;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq %r9, %rbp
movq %r8, %rbx
movq %rcx, %r15
movq %rdx, %r12
movq %rsi, 0x10(%rsp)
movq %rdi, %r13
movq 0x180(%rsp), %r14
movq 0x178(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x170(%rsp), %rax
movq %rax, 0x28(%rsp)
movq %r9, %rsi
callq 0x15be18
testq %rbp, %rbp
sete %al
testq %r14, %r14
sete %cl
orb %al, %cl
je 0x15afb6
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x138, %rsp            # imm = 0x138
jmp 0x15b008
cmpq $0x1, %r14
jne 0x15b013
leaq 0x1(,%rbp,2), %rsi
movl $0x30, %ecx
movl $0x8, %r8d
movq %r13, %rdi
movq %rbp, %rdx
callq 0x15bd68
subq $0x8, %rsp
movq %r13, %rdi
movq 0x18(%rsp), %rsi
movq %r12, %rdx
movq %r15, %rcx
movq %rbx, %r8
movq %rbp, %r9
pushq $0x1
pushq 0x50(%rsp)
pushq 0x40(%rsp)
callq 0x2f9ac3
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, 0x38(%rsp)
movl $0x30, %r15d
movl $0x30, %ecx
movl $0x30, %r8d
movq %r13, %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0x15be0d
testb %al, %al
je 0x15b067
movq %r13, %rdi
movq 0x10(%rsp), %rsi
movq %r12, %rdx
movq 0x38(%rsp), %rcx
movq %rbx, %r8
movq %rbp, %r9
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2f9ac3
movq %r12, 0x90(%rsp)
movq %rbx, 0x60(%rsp)
movl $0x30, %ecx
movl $0x30, %r8d
movq %r13, %rdi
movq %rbp, %rsi
movq %r14, 0xb0(%rsp)
movq %r14, %rdx
callq 0x15bd68
movq %r13, %rdi
callq 0x15be28
movq %rax, %r14
movq %r13, %rdi
callq 0x15be34
movq %rax, %rbx
movq %rbp, 0x68(%rsp)
movq 0x10(%rsp), %rbp
movq %rbp, %rdi
callq 0x171427
movq %rax, %r12
movq %rbp, %rdi
callq 0x171437
movabsq $-0x8000000000000000, %rdi # imm = 0x8000000000000000
movq %rdi, (%r14)
movq %rdi, 0x8(%r14)
movq %rdi, 0x10(%r14)
movq $0x0, 0x18(%r14)
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movups %xmm0, 0x10(%rbx)
movups %xmm0, 0x20(%rbx)
addq %r12, %rax
movq 0x68(%rsp), %rcx
leaq 0x1(%rcx), %rdx
cmpq $0x3, %rdx
movl $0x2, %ecx
cmovaeq %rdx, %rcx
movl $0x1, %edx
xorl %esi, %esi
movq %rdi, (%r14,%r15)
movq %rax, 0x8(%r14,%r15)
movq %rdi, 0x10(%r14,%r15)
movq %rsi, 0x18(%r14,%r15)
movq %rdx, (%rbx,%r15)
movq %rsi, 0x8(%rbx,%r15)
movq %rdx, 0x10(%rbx,%r15)
movq %rsi, 0x18(%rbx,%r15)
movq %rdx, 0x20(%rbx,%r15)
movq %rsi, 0x28(%rbx,%r15)
incq %rdx
addq $0x30, %r15
cmpq %rdx, %rcx
jne 0x15b113
movq %r13, %rdi
callq 0x15be5e
movq %rax, %r12
movq 0x28(%rsp), %rax
movq 0x40(%rsp), %rcx
addq %rcx, %rax
decq %rax
movq %rax, 0xa8(%rsp)
leaq 0x10(%rbx), %rax
movq %rax, 0xa0(%rsp)
leaq 0x20(%rbx), %rax
movq %rax, 0x98(%rsp)
movq 0x60(%rsp), %rax
movq 0x38(%rsp), %rcx
addq %rcx, %rax
movq %rax, 0xb8(%rsp)
movl $0x1, %ecx
movq %r13, 0x88(%rsp)
movq %r12, 0x58(%rsp)
movq 0xa8(%rsp), %rax
movq %rcx, 0x8(%rsp)
movb (%rax,%rcx), %al
movb %al, 0x7(%rsp)
movq 0x10(%rsp), %r15
movq %r15, %rdi
callq 0x171427
movq %rax, %r13
movq %r15, %rdi
callq 0x171437
movq %rax, %rcx
movq (%r14), %rax
movq %rax, 0x20(%rsp)
movq 0x8(%r14), %rax
movq %rax, 0x70(%rsp)
movq 0x10(%r14), %rbp
movq 0x18(%r14), %rax
movq %rax, 0x18(%rsp)
movups (%rbx), %xmm0
movups 0x10(%rbx), %xmm1
movups 0x20(%rbx), %xmm2
movaps %xmm2, 0x120(%rsp)
movaps %xmm1, 0x110(%rsp)
movaps %xmm0, 0x100(%rsp)
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
movq %rax, (%r14)
movq %rax, 0x8(%r14)
movq %rcx, 0x78(%rsp)
addq %rcx, %r13
movq %r13, 0x10(%r14)
movl $0x0, %r15d
testq %r13, %r13
cmovgq %r13, %r15
movq %r15, 0x18(%r14)
jg 0x15b26f
xorl %ecx, %ecx
movq %rcx, (%rbx)
movq 0x8(%rsp), %rax
movq %rax, 0x8(%rbx)
movq %rcx, 0x10(%rbx)
movq %rax, 0x18(%rbx)
movq %rcx, 0x20(%rbx)
movq %rax, 0x28(%rbx)
movq %r12, %rdi
callq 0x1605d7
cmpq %rax, %r15
movq %r13, 0xc0(%rsp)
jle 0x15b2e2
movq 0x18(%r14), %rsi
movl $0x8, %eax
movq %rbx, %rcx
cmpq (%r14), %rsi
je 0x15b2bf
movl $0x18, %eax
movq 0xa0(%rsp), %rcx
cmpq 0x8(%r14), %rsi
je 0x15b2bf
movl $0x28, %eax
movq 0x98(%rsp), %rcx
cmpq 0x10(%r14), %rsi
jne 0x15b684
movq (%rcx), %rdx
movq (%rbx,%rax), %rcx
movq 0x8(%rsp), %r9
movq %r12, %rdi
movq %rdx, 0x50(%rsp)
movq %rcx, 0x48(%rsp)
xorl %r8d, %r8d
callq 0x160636
jmp 0x15b2f4
movq $0x0, 0x50(%rsp)
movq $0x0, 0x48(%rsp)
movl $0x1, %r12d
xorl %r15d, %r15d
movq %rbp, 0xc8(%rsp)
movq 0x20(%rsp), %rbp
movq 0x18(%rsp), %r13
movq 0x30(%r14,%r15), %rax
movq %rax, 0x20(%rsp)
movq 0x38(%r14,%r15), %rax
movq %rax, 0x80(%rsp)
movq 0x40(%r14,%r15), %rax
movq %rax, 0x30(%rsp)
movq 0x48(%r14,%r15), %rax
movq %rax, 0x18(%rsp)
movups 0x30(%rbx,%r15), %xmm0
movups 0x40(%rbx,%r15), %xmm1
movups 0x50(%rbx,%r15), %xmm2
movaps %xmm2, 0xf0(%rsp)
movaps %xmm1, 0xe0(%rsp)
movaps %xmm0, 0xd0(%rsp)
movq 0xb8(%rsp), %rax
movzbl -0x1(%rax,%r12), %esi
movzbl 0x7(%rsp), %edx
movq 0x10(%rsp), %rdi
callq 0x171466
leaq (%rax,%r13), %rsi
movabsq $-0x8000000000000000, %r9 # imm = 0x8000000000000000
cmpq %r9, %r13
cmoveq %r9, %rsi
movq %rsi, 0x30(%r14,%r15)
addq %rax, %rbp
movl $0x8, %ecx
movl $0x8, %edx
leaq 0x100(%rsp), %rdi
cmpq %rsi, %rbp
je 0x15b3f1
movq 0x70(%rsp), %r8
addq %rax, %r8
movl $0x18, %edx
leaq 0x110(%rsp), %rdi
cmpq %rsi, %r8
je 0x15b3f1
addq 0xc8(%rsp), %rax
xorl %edx, %edx
cmpq %rsi, %rax
sete %dl
shll $0x5, %edx
leaq (%rsp,%rdx), %rdi
addq $0x100, %rdi            # imm = 0x100
orq $0x8, %rdx
leaq (%r12,%r12,2), %rbp
shlq $0x4, %rbp
movq 0x100(%rsp,%rdx), %rdx
movq (%rdi), %rsi
leaq (%rbx,%r15), %rax
movq %rsi, 0x30(%rbx,%r15)
movq %rdx, 0x38(%rbx,%r15)
movq 0x8(%r14,%r15), %rdx
movq 0x18(%r14,%r15), %r8
movq 0x78(%rsp), %rsi
leaq (%rdx,%rsi), %rdi
cmpq %r9, %rdx
movq %rdi, %rdx
cmoveq %r9, %rdx
movq 0xc0(%rsp), %r10
leaq (%r8,%r10), %rsi
cmpq %r9, %r8
cmoveq %r9, %rsi
cmpq %rsi, %rdx
cmovgq %rdx, %rsi
movq %rsi, 0x38(%r14,%r15)
movq (%r14,%r15), %r8
addq %r10, %r8
movq %rax, %rdx
cmpq %rsi, %r8
je 0x15b48f
leaq (%rbx,%rbp), %rdx
addq $-0x30, %rdx
cmpq %rsi, %rdi
jne 0x15b475
addq $0x10, %rdx
movl $0x18, %ecx
jmp 0x15b48f
movq 0x10(%r14,%r15), %rdi
addq %r10, %rdi
xorl %ecx, %ecx
cmpq %rsi, %rdi
sete %cl
shll $0x5, %ecx
addq %rcx, %rdx
orq $0x8, %rcx
movq (%rcx,%rax), %rax
movq (%rdx), %rcx
movq %rcx, 0x40(%rbx,%r15)
movq %rax, 0x48(%rbx,%r15)
movq 0x78(%rsp), %rax
movq 0x30(%rsp), %rcx
addq %rcx, %rax
cmpq %r9, %rcx
movq %rax, %rcx
cmoveq %r9, %rcx
movq 0x18(%rsp), %rsi
leaq (%rsi,%r10), %rdx
cmpq %r9, %rsi
cmoveq %r9, %rdx
cmpq %rdx, %rcx
cmovgq %rcx, %rdx
movq %rdx, 0x40(%r14,%r15)
movq 0x20(%rsp), %rcx
leaq (%rcx,%r10), %rdi
movl $0x8, %ecx
leaq 0xd0(%rsp), %rsi
cmpq %rdx, %rdi
je 0x15b526
movq 0x80(%rsp), %rcx
leaq (%rcx,%r10), %rdi
movl $0x18, %ecx
leaq 0xe0(%rsp), %rsi
cmpq %rdx, %rdi
je 0x15b526
xorl %ecx, %ecx
cmpq %rdx, %rax
sete %cl
shll $0x5, %ecx
leaq (%rsp,%rcx), %rsi
addq $0xd0, %rsi
orq $0x8, %rcx
movq 0xd0(%rsp,%rcx), %rax
movq (%rsi), %rcx
movq %rcx, 0x50(%rbx,%r15)
movq %rax, 0x58(%rbx,%r15)
movq 0x30(%r14,%r15), %rax
movq 0x38(%r14,%r15), %r13
cmpq %r13, %rax
cmovgq %rax, %r13
movq 0x40(%r14,%r15), %rax
cmpq %rax, %r13
cmovleq %rax, %r13
testq %r13, %r13
movl $0x0, %eax
cmovleq %rax, %r13
movq %r13, 0x48(%r14,%r15)
jg 0x15b58e
movq %r12, 0x30(%rbx,%r15)
movq 0x8(%rsp), %rax
movq %rax, 0x38(%rbx,%r15)
movq %r12, 0x40(%rbx,%r15)
movq %rax, 0x48(%rbx,%r15)
movq %r12, 0x50(%rbx,%r15)
movq %rax, 0x58(%rbx,%r15)
movq 0x58(%rsp), %rdi
callq 0x1605d7
cmpq %rax, %r13
jle 0x15b613
addq %rbx, %rbp
movq 0x48(%r14,%r15), %rsi
cmpq 0x30(%r14,%r15), %rsi
jne 0x15b5bf
leaq (%rbx,%r15), %rax
addq $0x30, %rax
addq $0x8, %rbp
movq 0x8(%rsp), %r9
jmp 0x15b5f5
cmpq 0x38(%r14,%r15), %rsi
movq 0x8(%rsp), %r9
jne 0x15b5d5
leaq 0x10(%rbp), %rax
addq $0x18, %rbp
jmp 0x15b5f5
cmpq 0x40(%r14,%r15), %rsi
movq 0x50(%rsp), %rdx
movq 0x48(%rsp), %rcx
jne 0x15b5fc
addq $0x20, %rbp
movq %rbp, %rax
leaq (%rbx,%r15), %rbp
addq $0x58, %rbp
movq (%rax), %rdx
movq (%rbp), %rcx
movq 0x58(%rsp), %rdi
movq %rdx, 0x50(%rsp)
movq %rcx, 0x48(%rsp)
movq %r12, %r8
callq 0x160636
movaps 0xd0(%rsp), %xmm0
movaps 0xe0(%rsp), %xmm1
movaps 0xf0(%rsp), %xmm2
movaps %xmm2, 0x120(%rsp)
movaps %xmm1, 0x110(%rsp)
movaps %xmm0, 0x100(%rsp)
incq %r12
addq $0x30, %r15
movq 0x30(%rsp), %rbp
movq 0x80(%rsp), %rax
movq %rax, 0x70(%rsp)
cmpq 0x68(%rsp), %r12
jbe 0x15b2fd
movq 0x8(%rsp), %rcx
incq %rcx
cmpq 0xb0(%rsp), %rcx
movq 0x58(%rsp), %r12
jbe 0x15b1b1
jmp 0x15b68d
xorl %ecx, %ecx
xorl %edx, %edx
jmp 0x15b2c6
movq %r12, %rdi
callq 0x1605d7
movq %rax, %rbx
movq %r12, %rdi
callq 0x1606a4
testb %al, %al
je 0x15afa8
movq 0x10(%rsp), %rdi
callq 0x1714fe
movq %rax, 0x20(%rsp)
movq %r12, %rdi
callq 0x1605fa
movq 0x60(%rsp), %rbp
addq %rax, %rbp
movq %r12, %rdi
callq 0x1605fa
movq %rdx, %r15
addq 0x40(%rsp), %r15
movq %r12, %rdi
callq 0x16066c
movq %rax, %r13
movq %rax, 0x18(%rsp)
movq %r12, %rdi
callq 0x160688
movq %rax, %r8
movq %rax, 0x30(%rsp)
movq 0x38(%rsp), %r12
leaq (%r12,%rbp), %rsi
movq 0x28(%rsp), %rax
leaq (%rax,%r15), %rcx
movq 0x90(%rsp), %r14
movq %r14, %rdi
movq %r13, %rdx
callq 0x120e01
subq $0x8, %rsp
movq 0x90(%rsp), %rdi
movq 0x28(%rsp), %r13
movq %r13, %rsi
movq %r14, %rdx
movq %r12, %rcx
movq %rbp, %r8
movq 0x20(%rsp), %r9
pushq 0x38(%rsp)
pushq %r15
pushq 0x40(%rsp)
callq 0x159e73
addq $0x20, %rsp
movq %r13, %rdi
callq 0x1713ff
jmp 0x15afaa