// File: /workspace/github_cpp_makefile_star2_O1/ncbi[P]amr/seq.cpp
// Function: Seq_sp::DnaAnnot::run()
const Cds* DnaAnnot::run ()
{
  sort (cdss);
  
  
  // Dynamic programming
  Vector<const Cds*> nexts;
  FFOR (size_t, i, cdss. size ())
  {
  	// cdss[j] are optimized for all j < i
  	
  	Cds& cds = cdss [i];
  	IMPLY (i, cds. left () >= cdss [i - 1]. left ());

  	// Optimization of cdss[i]
    // cds.{sumLen,bestPrev}    	
  	ASSERT (! cds. bestPrev);
  	cds. sumLen = cds. sizeEffective ();
  	for (const Cds* prev : cds. prevs)
  	{
  	  const long sumLen_new = prev->sumLen  + cds. getLenIncrease (*prev);
  	  if (   cds. sumLen < sumLen_new
  	      || (   cds. sumLen == sumLen_new   // tie resolution
  	        #if 1
  	          && prev < cds. bestPrev
  	        #else
  	          && cds. bestPrev 
  	          && prev->refProt < cds. bestPrev->refProt
  	        #endif
  	         )
  	     )  
  	  {
  	    cds. sumLen = sumLen_new;
  	  	cds. bestPrev = prev;
  	  }
  	}
  	IMPLY (! cds. prevs. empty (), cds. bestPrev && cds. sumLen > 0);
  	

    // Cds::prevs
  	nexts. clear ();  // Cds::coexists(cds)
  	FOR_START (size_t, j, i + 1, cdss. size ())
  	{
  		Cds& next = cdss [j];
  		if (! cds. coexists (next))
  			continue;
  		
  		bool tooFar = false;
  	  const int nextLenIncrease = next. getLenIncrease (cds);
  	  for (const Cds* next_old : nexts)
  	    if (   next_old->coexists (next)
  	    	  && next. getLenIncrease (*next_old) + next_old->getLenIncrease (cds) > nextLenIncrease
  	    	 )
  	    {
  	    	tooFar = true;
  	    	break;
  	    }
  	  if (tooFar)
  	  	break;
  	  	
  	  nexts << & next;
  		next. prevs << & cds;
  	}
  }


  const Cds* cds_last = nullptr;
  long sumLen_max = 0;
  for (const Cds& cds : cdss)
    if (maximize (sumLen_max, cds. sumLen))
    	cds_last = & cds;


  return cds_last;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x168, %rsp            # imm = 0x168
movq %rdi, %r12
movq 0x8(%rdi), %r14
movq 0x10(%rdi), %r15
movabsq $0x6db6db6db6db6db7, %rbp # imm = 0x6DB6DB6DB6DB6DB7
cmpq %r15, %r14
je 0x7df2c
movq %r15, %rax
subq %r14, %rax
sarq $0x4, %rax
imulq %rbp, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r14, %rdi
movq %r15, %rsi
callq 0x908ee
movq %r14, %rdi
movq %r15, %rsi
callq 0x909ca
xorps %xmm0, %xmm0
movups %xmm0, 0x99(%rsp)
movaps %xmm0, 0x90(%rsp)
movq 0x10(%r12), %rax
subq 0x8(%r12), %rax
je 0x7e26d
sarq $0x4, %rax
imulq %rbp, %rax
cmpq $0x1, %rax
adcq $0x0, %rax
movq %rax, 0x160(%rsp)
leaq 0x8(%r12), %rbx
xorl %r15d, %r15d
movq %r12, 0xf8(%rsp)
movq %rbx, 0x70(%rsp)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x8efa4
movq %rax, 0x8(%rsp)
testq %r15, %r15
je 0x7dfd6
callq 0xb070
movl $0x0, (%rax)
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rbx
movq 0x10(%rax), %r14
leaq -0x1(%r15), %rsi
movq 0x70(%rsp), %rdi
callq 0x8efa4
cmpq %rbx, %r14
cmovbq %r14, %rbx
movq 0x8(%rax), %rcx
movq 0x10(%rax), %rax
cmpq %rcx, %rax
cmovbq %rax, %rcx
cmpq %rcx, %rbx
jb 0x7e369
movq %r15, 0x78(%rsp)
callq 0xb070
movq %rax, 0x88(%rsp)
movl $0x0, (%rax)
movq 0x8(%rsp), %rcx
cmpq $0x0, 0x60(%rcx)
jne 0x7e2ca
movq 0x8(%rcx), %rax
movq 0x10(%rcx), %rcx
cmpq %rcx, %rax
movq %rcx, %rdx
cmovaq %rax, %rdx
cmovaq %rcx, %rax
subl %eax, %edx
addl $-0x3c, %edx
movslq %edx, %rax
movq 0x8(%rsp), %r15
movq %rax, 0x68(%r15)
movq 0x40(%r15), %rbx
movq 0x48(%r15), %r14
cmpq %r14, %rbx
je 0x7e066
movq (%rbx), %r12
movq 0x68(%r12), %r13
movq %r15, %rdi
movq %r12, %rsi
callq 0x7db3e
cltq
addq %rax, %r13
cmpq %r13, 0x68(%r15)
jl 0x7e058
jne 0x7e060
cmpq 0x60(%r15), %r12
jae 0x7e060
movq %r13, 0x68(%r15)
movq %r12, 0x60(%r15)
addq $0x8, %rbx
jmp 0x7e02d
movq 0x40(%r15), %rax
cmpq 0x48(%r15), %rax
je 0x7e094
movq 0x88(%rsp), %rax
movl $0x0, (%rax)
cmpq $0x0, 0x60(%r15)
je 0x7e408
cmpq $0x0, 0x68(%r15)
jle 0x7e408
movq 0x90(%rsp), %rax
cmpq %rax, 0x98(%rsp)
movq 0xf8(%rsp), %r12
movq 0x70(%rsp), %rbx
je 0x7e0bb
movq %rax, 0x98(%rsp)
movq 0x10(%r12), %rax
subq 0x8(%r12), %rax
movq 0x78(%rsp), %r15
incq %r15
sarq $0x4, %rax
imulq %rbp, %rax
cmpq %rax, %r15
jae 0x7e25f
movq %r15, 0x80(%rsp)
movq %r15, 0x78(%rsp)
movq %rbx, %rdi
movq 0x80(%rsp), %rsi
callq 0x8efa4
movq %rax, %r13
movq 0x8(%rsp), %rdi
movq %rax, %rsi
callq 0x7d77a
movl $0x9, %edx
testb %al, %al
je 0x7e219
movq %r13, %rdi
movq 0x8(%rsp), %rsi
callq 0x7db3e
movl %eax, 0x88(%rsp)
movq 0x90(%rsp), %rbp
movq 0x98(%rsp), %r15
cmpq %r15, %rbp
je 0x7e1b3
addq $0x8, %rbp
xorl %r12d, %r12d
movq -0x8(%rbp), %r14
movq %r14, %rdi
movq %r13, %rsi
callq 0x7d77a
testb %al, %al
je 0x7e184
movq %r13, %rdi
movq %r14, %rsi
callq 0x7db3e
movl %eax, %ebx
movq %r14, %rdi
movq 0x8(%rsp), %rsi
callq 0x7db3e
addl %ebx, %eax
movb $0x1, %cl
movb $0x1, %dl
cmpl 0x88(%rsp), %eax
jg 0x7e189
xorl %edx, %edx
movl %r12d, %ecx
testb %dl, %dl
jne 0x7e19c
leaq 0x8(%rbp), %rax
movl %ecx, %r12d
cmpq %r15, %rbp
movq %rax, %rbp
jne 0x7e148
movl $0x7, %edx
testb $0x1, %cl
movq 0xf8(%rsp), %r12
movq 0x70(%rsp), %rbx
jne 0x7e219
movq %r13, 0x30(%rsp)
leaq 0x90(%rsp), %rdi
leaq 0x30(%rsp), %r14
movq %r14, %rsi
callq 0x91b94
movq 0x98(%rsp), %rax
subq 0x90(%rsp), %rax
cmpq $0x9, %rax
movq 0x8(%rsp), %rax
jb 0x7e1f0
movb $0x0, 0xa8(%rsp)
movq %r13, %rdi
addq $0x40, %rdi
movq %rax, 0x30(%rsp)
movq %r14, %rsi
callq 0x91b94
movq 0x48(%r13), %rax
subq 0x40(%r13), %rax
cmpq $0x9, %rax
jb 0x7e217
movb $0x0, 0x58(%r13)
xorl %edx, %edx
cmpl $0x9, %edx
movabsq $0x6db6db6db6db6db7, %rbp # imm = 0x6DB6DB6DB6DB6DB7
movq 0x78(%rsp), %r15
je 0x7e231
testl %edx, %edx
jne 0x7e25f
movq 0x10(%r12), %rax
subq 0x8(%r12), %rax
movq 0x80(%rsp), %rcx
incq %rcx
sarq $0x4, %rax
imulq %rbp, %rax
movq %rcx, 0x80(%rsp)
cmpq %rax, %rcx
jb 0x7e0eb
cmpq 0x160(%rsp), %r15
jne 0x7df7c
movq 0x8(%r12), %rax
movq 0x10(%r12), %rcx
xorl %ebx, %ebx
cmpq %rcx, %rax
je 0x7e298
xorl %edx, %edx
movq 0x68(%rax), %rsi
cmpq %rsi, %rdx
cmovleq %rsi, %rdx
cmovlq %rax, %rbx
addq $0x70, %rax
cmpq %rcx, %rax
jne 0x7e280
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
je 0x7e2b5
movq 0xa0(%rsp), %rsi
subq %rdi, %rsi
callq 0xb5a0
movq %rbx, %rax
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0xb6b0
testl %eax, %eax
jne 0x7e4a7
leaq 0xe8(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x19d78(%rip), %rsi     # 0x98062
leaq 0x19d81(%rip), %rdx     # 0x98072
leaq 0xd8(%rsp), %rdi
callq 0xdc76
leaq 0x100(%rsp), %rdi
movl $0xf8c, %esi            # imm = 0xF8C
callq 0xe1a8
leaq 0x120(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
leaq 0x100(%rsp), %rdx
callq 0xe100
leaq 0x14e9d(%rip), %rsi     # 0x931d1
leaq 0x120(%rsp), %rdi
callq 0xbb10
leaq 0x20(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x7e4b1
movups (%rcx), %xmm0
movups %xmm0, (%r15)
jmp 0x7e4be
callq 0xb6b0
testl %eax, %eax
jne 0x7e4a7
leaq 0xe8(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x19cd9(%rip), %rsi     # 0x98062
leaq 0x19ce2(%rip), %rdx     # 0x98072
leaq 0xd8(%rsp), %rdi
callq 0xdc76
leaq 0x100(%rsp), %rdi
movl $0xf88, %esi            # imm = 0xF88
callq 0xe1a8
leaq 0x120(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
leaq 0x100(%rsp), %rdx
callq 0xe100
leaq 0x14dfe(%rip), %rsi     # 0x931d1
leaq 0x120(%rsp), %rdi
callq 0xbb10
leaq 0x20(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x7e53b
movups (%rcx), %xmm0
movups %xmm0, (%r15)
jmp 0x7e548
callq 0xb6b0
testl %eax, %eax
jne 0x7e4a7
leaq 0xe8(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x19c3a(%rip), %rsi     # 0x98062
leaq 0x19c43(%rip), %rdx     # 0x98072
leaq 0xd8(%rsp), %rdi
callq 0xdc76
leaq 0x100(%rsp), %rdi
movl $0xfa0, %esi            # imm = 0xFA0
callq 0xe1a8
leaq 0x120(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
leaq 0x100(%rsp), %rdx
callq 0xe100
leaq 0x14d5f(%rip), %rsi     # 0x931d1
leaq 0x120(%rsp), %rdi
callq 0xbb10
leaq 0x20(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x7e5c5
movups (%rcx), %xmm0
movups %xmm0, (%r15)
jmp 0x7e5d2
movl $0x1, %edi
callq 0xb6d0
movq %rdx, 0x10(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x20(%rsp)
movq 0x8(%rax), %rdx
movq %rdx, 0x18(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0xc8(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x1aac5(%rip), %rsi     # 0x98faf
leaq 0x1aae0(%rip), %rdx     # 0x98fd1
leaq 0xb8(%rsp), %rdi
callq 0xdc76
leaq 0x153ac(%rip), %rsi     # 0x938b1
leaq 0xb8(%rsp), %rdi
callq 0xbb10
leaq 0x60(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x7e64f
movups (%rcx), %xmm0
movups %xmm0, (%r13)
jmp 0x7e65c
movq %rdx, 0x10(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x20(%rsp)
movq 0x8(%rax), %rdx
movq %rdx, 0x18(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0xc8(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x1aa3b(%rip), %rsi     # 0x98faf
leaq 0x1aa56(%rip), %rdx     # 0x98fd1
leaq 0xb8(%rsp), %rdi
callq 0xdc76
leaq 0x15322(%rip), %rsi     # 0x938b1
leaq 0xb8(%rsp), %rdi
callq 0xbb10
leaq 0x60(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x7e6c6
movups (%rcx), %xmm0
movups %xmm0, (%r13)
jmp 0x7e6d3
movq %rdx, 0x10(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x20(%rsp)
movq 0x8(%rax), %rdx
movq %rdx, 0x18(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0xc8(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x1a9b1(%rip), %rsi     # 0x98faf
leaq 0x1a9cc(%rip), %rdx     # 0x98fd1
leaq 0xb8(%rsp), %rdi
callq 0xdc76
leaq 0x15298(%rip), %rsi     # 0x938b1
leaq 0xb8(%rsp), %rdi
callq 0xbb10
leaq 0x60(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x7e73d
movups (%rcx), %xmm0
movups %xmm0, (%r13)
jmp 0x7e74a
movq %rdx, 0x50(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x60(%rsp)
movq 0x8(%rax), %rsi
leaq 0x50(%rsp), %rdx
movq %rsi, 0x8(%rdx)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x140(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xe100
leaq 0x1a967(%rip), %rsi     # 0x98ff8
leaq 0x140(%rsp), %rdi
callq 0xbb10
leaq 0x40(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x7e7ad
movups (%rcx), %xmm0
movups %xmm0, (%rbp)
jmp 0x7e7ba
movq %rdx, 0x50(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x60(%rsp)
movq 0x8(%rax), %rsi
leaq 0x50(%rsp), %rdx
movq %rsi, 0x8(%rdx)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x140(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xe100
leaq 0x1a8ca(%rip), %rsi     # 0x98fd2
leaq 0x140(%rsp), %rdi
callq 0xbb10
leaq 0x40(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x7e7db
movups (%rcx), %xmm0
movups %xmm0, (%rbp)
jmp 0x7e7e8
movq %rdx, 0x50(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x60(%rsp)
movq 0x8(%rax), %rsi
leaq 0x50(%rsp), %rdx
movq %rsi, 0x8(%rdx)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x140(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xe100
leaq 0x1a889(%rip), %rsi     # 0x99008
leaq 0x140(%rsp), %rdi
callq 0xbb10
leaq 0x40(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x7e809
movups (%rcx), %xmm0
movups %xmm0, (%rbp)
jmp 0x7e816
movq %rdx, 0x30(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x40(%rsp)
movq 0x8(%rax), %rdx
leaq 0x30(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
callq 0x1151b
movq %rdx, 0x30(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x40(%rsp)
movq 0x8(%rax), %rdx
leaq 0x30(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
callq 0x1151b
movq %rdx, 0x30(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x40(%rsp)
movq 0x8(%rax), %rdx
leaq 0x30(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
callq 0x1151b
jmp 0x7e83f
jmp 0x7e85b
jmp 0x7e83f
jmp 0x7e85b
movq %rax, %rbx
movq 0x30(%rsp), %rdi
cmpq %rbp, %rdi
je 0x7e85e
movq 0x40(%rsp), %rsi
incq %rsi
callq 0xb5a0
jmp 0x7e85e
movq %rax, %rbx
leaq 0x150(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7e888
movq 0x150(%rsp), %rsi
incq %rsi
callq 0xb5a0
jmp 0x7e888
jmp 0x7e885
jmp 0x7e885
movq %rax, %rbx
movq 0x50(%rsp), %rdi
cmpq %r13, %rdi
je 0x7e8a8
movq 0x60(%rsp), %rsi
incq %rsi
callq 0xb5a0
jmp 0x7e8a8
jmp 0x7e8a5
jmp 0x7e8a5
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
cmpq %r12, %rdi
je 0x7e8ce
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0xb5a0
jmp 0x7e8ce
jmp 0x7e8cb
jmp 0x7e8cb
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0x7e8ee
movq 0x20(%rsp), %rsi
incq %rsi
callq 0xb5a0
jmp 0x7e8ee
jmp 0x7e8eb
jmp 0x7e8eb
movq %rax, %rbx
leaq 0x130(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7e918
movq 0x130(%rsp), %rsi
incq %rsi
callq 0xb5a0
jmp 0x7e918
jmp 0x7e915
jmp 0x7e915
movq %rax, %rbx
leaq 0x110(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7e942
movq 0x110(%rsp), %rsi
incq %rsi
callq 0xb5a0
jmp 0x7e942
jmp 0x7e93f
jmp 0x7e93f
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
cmpq %r14, %rdi
je 0x7e976
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0xb5a0
jmp 0x7e976
jmp 0x7e973
jmp 0x7e973
jmp 0x7e973
jmp 0x7e973
jmp 0x7e973
jmp 0x7e973
jmp 0x7e973
jmp 0x7e973
jmp 0x7e973
movq %rax, %rbx
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
je 0x7e993
movq 0xa0(%rsp), %rsi
subq %rdi, %rsi
callq 0xb5a0
movq %rbx, %rdi
callq 0xba60
nop