// File: /workspace/github_cpp_makefile_star2_O2/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, %rbx
addq $0x8, %rdi
movq %rdi, 0x18(%rsp)
callq 0x5b4e4
xorps %xmm0, %xmm0
leaq 0x50(%rsp), %rax
movups %xmm0, 0x9(%rax)
movaps %xmm0, (%rax)
movq 0x10(%rbx), %rax
movq %rbx, 0x28(%rsp)
subq 0x8(%rbx), %rax
pushq $0x70
popq %rcx
cqto
idivq %rcx
movq %rax, 0x158(%rsp)
movq $0x0, 0x10(%rsp)
movq 0x10(%rsp), %rbx
cmpq 0x158(%rsp), %rbx
je 0x52041
movq 0x18(%rsp), %rdi
movq %rbx, %rsi
callq 0x5b4f4
movq %rax, %r15
callq 0xc070
movq %rax, %r13
testq %rbx, %rbx
je 0x51e9e
andl $0x0, (%r13)
movq 0x8(%r15), %rbx
movq 0x10(%r15), %r14
movq 0x10(%rsp), %rax
leaq -0x1(%rax), %rsi
movq 0x18(%rsp), %rdi
callq 0x5b4f4
cmpq %rbx, %r14
cmovbq %r14, %rbx
movq 0x8(%rax), %rcx
movq 0x10(%rax), %rax
cmpq %rcx, %rax
cmovbq %rax, %rcx
cmpq %rcx, %rbx
jb 0x5216b
andl $0x0, (%r13)
cmpq $0x0, 0x60(%r15)
jne 0x5208b
movq 0x8(%r15), %rax
movq 0x10(%r15), %rcx
cmpq %rcx, %rax
movq %rcx, %rdx
cmovaq %rax, %rdx
cmovaq %rcx, %rax
subl %eax, %edx
addl $-0x3c, %edx
movslq %edx, %rax
movq %rax, 0x68(%r15)
movq 0x40(%r15), %rbx
movq 0x48(%r15), %r12
xorl %eax, %eax
cmpq %r12, %rbx
je 0x51f21
movq (%rbx), %r14
movq 0x68(%r14), %rbp
movq %r15, %rdi
movq %r14, %rsi
callq 0x51bb4
cltq
addq %rax, %rbp
cmpq %rbp, 0x68(%r15)
jl 0x51f10
sete %cl
movq 0x60(%r15), %rax
cmpq %rax, %r14
setb %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x51f1b
movq %rbp, 0x68(%r15)
movq %r14, 0x60(%r15)
movq %r14, %rax
addq $0x8, %rbx
jmp 0x51eda
movq 0x40(%r15), %rcx
cmpq 0x48(%r15), %rcx
je 0x51f44
andl $0x0, (%r13)
testq %rax, %rax
je 0x5224b
cmpq $0x0, 0x68(%r15)
jle 0x5224b
movq 0x50(%rsp), %rax
cmpq %rax, 0x58(%rsp)
je 0x51f55
movq %rax, 0x58(%rsp)
movq 0x10(%rsp), %rbx
incq %rbx
movq %rbx, 0x10(%rsp)
movq 0x28(%rsp), %rcx
movq 0x10(%rcx), %rax
subq 0x8(%rcx), %rax
cqto
pushq $0x70
popq %rcx
idivq %rcx
cmpq %rax, %rbx
jae 0x51e2f
movq 0x18(%rsp), %rdi
movq %rbx, %rsi
callq 0x5b4f4
movq %rax, %rbp
movq %r15, %rdi
movq %rax, %rsi
callq 0x5195e
testb %al, %al
je 0x52039
movq %rbx, 0x160(%rsp)
movq %rbp, %rdi
movq %r15, %rsi
callq 0x51bb4
movl %eax, 0x24(%rsp)
movq 0x50(%rsp), %r13
movq 0x58(%rsp), %r14
cmpq %r14, %r13
je 0x52006
movq (%r13), %r12
movq %r12, %rdi
movq %rbp, %rsi
callq 0x5195e
testb %al, %al
je 0x52000
movq %rbp, %rdi
movq %r12, %rsi
callq 0x51bb4
movl %eax, %ebx
movq %r12, %rdi
movq %r15, %rsi
callq 0x51bb4
addl %ebx, %eax
cmpl 0x24(%rsp), %eax
jg 0x51e2f
addq $0x8, %r13
jmp 0x51fc4
movq %rbp, 0x30(%rsp)
leaq 0x50(%rsp), %rdi
leaq 0x30(%rsp), %rbx
movq %rbx, %rsi
callq 0x5b55a
addq $0x40, %rbp
movq %r15, 0x30(%rsp)
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x5b55a
movq 0x160(%rsp), %rbx
incq %rbx
jmp 0x51f62
movq 0x28(%rsp), %rcx
movq 0x8(%rcx), %rax
movq 0x10(%rcx), %rcx
xorl %edx, %edx
xorl %ebx, %ebx
cmpq %rcx, %rax
je 0x5206c
movq 0x68(%rax), %rsi
cmpq %rsi, %rdx
cmovleq %rsi, %rdx
cmovlq %rax, %rbx
addq $0x70, %rax
jmp 0x52052
leaq 0x50(%rsp), %rdi
callq 0x5c16a
movq %rbx, %rax
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0xc6d0
testl %eax, %eax
jne 0x5232b
leaq 0x10f73(%rip), %rsi     # 0x63012
leaq 0xd8(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0xdbbe
leaq 0xb8(%rsp), %rdi
movl $0xf8c, %esi            # imm = 0xF8C
callq 0xe2d5
leaq 0xf8(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
leaq 0xb8(%rsp), %rdx
callq 0xe26e
leaq 0xc0ea(%rip), %rdx      # 0x5e1d1
leaq 0x118(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
callq 0xe24f
leaq 0x11e6d(%rip), %rsi     # 0x63f70
leaq 0x78(%rsp), %rdi
leaq 0xe(%rsp), %rdx
callq 0xdbbe
leaq 0xc7b3(%rip), %rdx      # 0x5e8cc
leaq 0x98(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0xe24f
leaq 0x138(%rsp), %rdi
leaq 0x118(%rsp), %rsi
leaq 0x98(%rsp), %rdx
callq 0xe26e
leaq 0x11e6a(%rip), %rdx     # 0x63fb9
leaq 0x30(%rsp), %rdi
leaq 0x138(%rsp), %rsi
callq 0xe24f
leaq 0x30(%rsp), %rdi
callq 0x101d0
callq 0xc6d0
testl %eax, %eax
jne 0x5232b
leaq 0x10e93(%rip), %rsi     # 0x63012
leaq 0xd8(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0xdbbe
leaq 0xb8(%rsp), %rdi
movl $0xf88, %esi            # imm = 0xF88
callq 0xe2d5
leaq 0xf8(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
leaq 0xb8(%rsp), %rdx
callq 0xe26e
leaq 0xc00a(%rip), %rdx      # 0x5e1d1
leaq 0x118(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
callq 0xe24f
leaq 0x11d8d(%rip), %rsi     # 0x63f70
leaq 0x78(%rsp), %rdi
leaq 0xe(%rsp), %rdx
callq 0xdbbe
leaq 0xc6d3(%rip), %rdx      # 0x5e8cc
leaq 0x98(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0xe24f
leaq 0x138(%rsp), %rdi
leaq 0x118(%rsp), %rsi
leaq 0x98(%rsp), %rdx
callq 0xe26e
leaq 0x11d64(%rip), %rdx     # 0x63f93
leaq 0x30(%rsp), %rdi
leaq 0x138(%rsp), %rsi
callq 0xe24f
leaq 0x30(%rsp), %rdi
callq 0x101d0
callq 0xc6d0
testl %eax, %eax
jne 0x5232b
leaq 0x10db3(%rip), %rsi     # 0x63012
leaq 0xd8(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0xdbbe
leaq 0xb8(%rsp), %rdi
movl $0xfa0, %esi            # imm = 0xFA0
callq 0xe2d5
leaq 0xf8(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
leaq 0xb8(%rsp), %rdx
callq 0xe26e
leaq 0xbf2a(%rip), %rdx      # 0x5e1d1
leaq 0x118(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
callq 0xe24f
leaq 0x11cad(%rip), %rsi     # 0x63f70
leaq 0x78(%rsp), %rdi
leaq 0xe(%rsp), %rdx
callq 0xdbbe
leaq 0xc5f3(%rip), %rdx      # 0x5e8cc
leaq 0x98(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0xe24f
leaq 0x138(%rsp), %rdi
leaq 0x118(%rsp), %rsi
leaq 0x98(%rsp), %rdx
callq 0xe26e
leaq 0x11cba(%rip), %rdx     # 0x63fc9
leaq 0x30(%rsp), %rdi
leaq 0x138(%rsp), %rsi
callq 0xe24f
leaq 0x30(%rsp), %rdi
callq 0x101d0
pushq $0x1
popq %rdi
callq 0xc6f0
jmp 0x5233b
jmp 0x5234a
jmp 0x5233b
jmp 0x5234a
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0xcbe8
jmp 0x5234d
movq %rax, %rbx
leaq 0x138(%rsp), %rdi
callq 0xcbe8
jmp 0x52363
jmp 0x52360
jmp 0x52360
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0xcbe8
jmp 0x52379
jmp 0x52376
jmp 0x52376
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0xcbe8
jmp 0x5238c
jmp 0x52389
jmp 0x52389
movq %rax, %rbx
leaq 0x118(%rsp), %rdi
callq 0xcbe8
jmp 0x523a2
jmp 0x5239f
jmp 0x5239f
movq %rax, %rbx
leaq 0xf8(%rsp), %rdi
callq 0xcbe8
jmp 0x523b8
jmp 0x523b5
jmp 0x523b5
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0xcbe8
jmp 0x523ce
jmp 0x523cb
jmp 0x523cb
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
callq 0xcbe8
jmp 0x523f2
jmp 0x523ef
jmp 0x523ef
jmp 0x523ef
jmp 0x523ef
jmp 0x523ef
jmp 0x523ef
jmp 0x523ef
jmp 0x523ef
jmp 0x523ef
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x5c16a
movq %rbx, %rdi
callq 0xcaa0