// File: /workspace/github_cpp_makefile_star2_O2/ncbi[P]amr/seq.cpp
// Function: Seq_sp::Dna::getPeptides(char, unsigned char, unsigned long) const
Vector<Peptide> Dna::getPeptides (Frame frame,
                                  Gencode gencode,
                                  size_t len_min) const
{
  ASSERT (isFrame (frame));
  ASSERT (len_min);
  
  Vector<Peptide> peps;  peps. reserve (seq. size () / 300 + 1);  // PAR
  
  string dnaSeq (seq);
  if (frame < 0)
    reverseDna (dnaSeq);
    
  size_t start = (size_t) abs (frame) - 1;
  size_t stop = 0;
  string pepSeq;
  
  const auto proc = [&] () 
    {
      if (pepSeq. size () < len_min)
        return;
      if (frame < 0)
      {
        const size_t start_ = start;
        start = seq. size () - stop;
        stop  = seq. size () - start_;
      }
      // ";partial=11" (Prodigal notation)
      peps << std::move (Peptide (getId () + ":" + to_string (start + 1) + ".." + to_string (stop), pepSeq, false));      
    };
  
  for (size_t i = start; i + 2 < dnaSeq. size (); i += 3)
  {
    const char aa = codon2aa (& dnaSeq [i], gencode, true);
    stop = i;
    if (aa == *terminator)
    {
    //pepSeq += string (1, *terminator);  // Like in GeneMark etc.  // PAR  
      proc ();
      pepSeq. clear ();
    }
    else if (! pepSeq. empty ())
      pepSeq += toUpper (aa);
    else if (Peptide::isStartAa (aa))
    {
      ASSERT (pepSeq. empty ());
      pepSeq = "M";
      start = i;
    }
  }
//proc ();  // Trunc3  // PAR
  
  return peps;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1b8, %rsp            # imm = 0x1B8
movq %r8, 0x80(%rsp)
movl %ecx, %ebx
movl %edx, %r14d
movq %rsi, %r15
movq %rdi, 0x10(%rsp)
callq 0xc070
movq %rax, 0x130(%rsp)
andl $0x0, (%rax)
leal 0x3(%r14), %eax
cmpl $0x6, %eax
ja 0x4bf0a
cmpl $0x3, %eax
je 0x4bf0a
cmpq $0x0, 0x80(%rsp)
je 0x4be2a
xorps %xmm0, %xmm0
movq 0x10(%rsp), %rdi
movups %xmm0, 0x9(%rdi)
movups %xmm0, (%rdi)
movq 0x30(%r15), %rax
movl $0x12c, %ecx            # imm = 0x12C
xorl %edx, %edx
divq %rcx
leaq 0x1(%rax), %rsi
callq 0x5b2a2
leaq 0x28(%r15), %rsi
leaq 0x148(%rsp), %rdi
callq 0xc7e0
movq %r15, 0x140(%rsp)
testb %r14b, %r14b
jns 0x4baba
leaq 0x148(%rsp), %rdi
callq 0x49620
movl %r14d, %eax
sarb $0x7, %al
movl %r14d, %ecx
xorb %al, %cl
subb %al, %cl
leaq 0xa0(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movzbl %cl, %r13d
decq %r13
movb $0x0, (%rax)
movl %r14d, %eax
negb %al
movzbl %r14b, %ecx
movzbl %al, %eax
movq %r14, 0x138(%rsp)
cmpb %al, %r14b
cmovlel %eax, %ecx
movzbl %cl, %eax
pushq $0x1
popq %rcx
subq %rax, %rcx
movq %rcx, 0x88(%rsp)
movzbl %bl, %eax
movl %eax, 0x1c(%rsp)
leaq 0x110(%rsp), %rbp
movq %r13, %r14
leaq 0x2(%r14), %rax
cmpq 0x150(%rsp), %rax
jae 0x4bd1f
movq 0x148(%rsp), %rdi
addq %r14, %rdi
movl 0x1c(%rsp), %esi
pushq $0x1
popq %rdx
callq 0x496cb
movq 0x3e0c1(%rip), %rdx     # 0x89c10
movq 0x98(%rsp), %rcx
cmpb (%rdx), %al
jne 0x4bcb8
cmpq 0x80(%rsp), %rcx
jb 0x4bca2
movq 0x140(%rsp), %rsi
movq 0x30(%rsi), %rbx
movq 0x88(%rsp), %rax
leaq (%rax,%rbx), %r12
subq %r13, %rbx
cmpb $0x0, 0x138(%rsp)
cmovnsq %r13, %r12
cmovnsq %r14, %rbx
leaq 0x20(%rsp), %rdi
callq 0xe516
movq %rbp, %r15
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rsi
leaq 0x16d45(%rip), %rdx     # 0x628fb
callq 0xe24f
leaq 0x1(%r12), %rsi
leaq 0xd0(%rsp), %rbp
movq %rbp, %rdi
callq 0xe83d
leaq 0xf0(%rsp), %r13
movq %r13, %rdi
leaq 0x40(%rsp), %rsi
movq %rbp, %rdx
callq 0xe26e
leaq 0x60(%rsp), %rdi
movq %r13, %rsi
leaq 0x152d8(%rip), %rdx     # 0x60ecf
callq 0xe24f
leaq 0xb0(%rsp), %rbp
movq %rbp, %rdi
movq %rbx, %rsi
callq 0xe83d
movq %r15, %rbx
movq %r15, %rdi
leaq 0x60(%rsp), %rsi
movq %rbp, %rdx
callq 0xe26e
leaq 0x168(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
leaq 0x90(%rsp), %rdx
xorl %ecx, %ecx
callq 0x5b398
movq %rbx, %rbp
movq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0x5bdee
movq %r15, %rdi
callq 0x5bd06
movq %rbp, %rdi
callq 0xcbe8
leaq 0xb0(%rsp), %rdi
callq 0xcbe8
leaq 0x60(%rsp), %rdi
callq 0xcbe8
movq %r13, %rdi
callq 0xcbe8
leaq 0xd0(%rsp), %rdi
callq 0xcbe8
leaq 0x40(%rsp), %rdi
callq 0xcbe8
leaq 0x20(%rsp), %rdi
callq 0xcbe8
movq %r12, %r13
andq $0x0, 0x98(%rsp)
movq 0x90(%rsp), %rax
movb $0x0, (%rax)
jmp 0x4bd0d
movsbl %al, %edi
testq %rcx, %rcx
je 0x4bcd7
callq 0x2a32e
movsbl %al, %esi
leaq 0x90(%rsp), %rdi
callq 0xc510
jmp 0x4bd0d
callq 0x5b344
testb %al, %al
je 0x4bd0d
movq 0x130(%rsp), %rax
andl $0x0, (%rax)
cmpq $0x0, 0x98(%rsp)
jne 0x4bd50
leaq 0x90(%rsp), %rdi
leaq 0x1581d(%rip), %rsi     # 0x61522
callq 0xcb40
movq %r14, %r13
addq $0x3, %r14
addq $-0x3, 0x88(%rsp)
jmp 0x4bb1f
leaq 0x90(%rsp), %rdi
callq 0xcbe8
leaq 0x148(%rsp), %rdi
callq 0xcbe8
movq 0x10(%rsp), %rax
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0xc6d0
testl %eax, %eax
jne 0x4bfea
leaq 0x172ae(%rip), %rsi     # 0x63012
leaq 0x40(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0xdbbe
leaq 0x20(%rsp), %rdi
movl $0x859, %esi            # imm = 0x859
callq 0xe2d5
leaq 0xf0(%rsp), %rdi
leaq 0x40(%rsp), %rsi
leaq 0x20(%rsp), %rdx
callq 0xe26e
leaq 0x12431(%rip), %rdx     # 0x5e1d1
leaq 0x60(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0xe24f
leaq 0x178bc(%rip), %rsi     # 0x63675
leaq 0xb0(%rsp), %rdi
leaq 0xe(%rsp), %rdx
callq 0xdbbe
leaq 0x12afa(%rip), %rdx     # 0x5e8cc
leaq 0xd0(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0xe24f
leaq 0x110(%rsp), %rdi
leaq 0x60(%rsp), %rsi
leaq 0xd0(%rsp), %rdx
callq 0xe26e
leaq 0x178bc(%rip), %rdx     # 0x636c4
leaq 0x168(%rsp), %rdi
leaq 0x110(%rsp), %rsi
callq 0xe24f
leaq 0x168(%rsp), %rdi
callq 0x101d0
callq 0xc6d0
testl %eax, %eax
jne 0x4bfea
leaq 0x171d4(%rip), %rsi     # 0x63012
leaq 0x40(%rsp), %rdi
leaq 0x148(%rsp), %rdx
callq 0xdbbe
leaq 0x20(%rsp), %rdi
movl $0x831, %esi            # imm = 0x831
callq 0xe2d5
leaq 0xf0(%rsp), %rdi
leaq 0x40(%rsp), %rsi
leaq 0x20(%rsp), %rdx
callq 0xe26e
leaq 0x12354(%rip), %rdx     # 0x5e1d1
leaq 0x60(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0xe24f
leaq 0x177df(%rip), %rsi     # 0x63675
leaq 0xb0(%rsp), %rdi
leaq 0x90(%rsp), %rdx
callq 0xdbbe
leaq 0x12a1a(%rip), %rdx     # 0x5e8cc
leaq 0xd0(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0xe24f
leaq 0x110(%rsp), %rdi
leaq 0x60(%rsp), %rsi
leaq 0xd0(%rsp), %rdx
callq 0xe26e
leaq 0x177d4(%rip), %rdx     # 0x636bc
leaq 0x168(%rsp), %rdi
leaq 0x110(%rsp), %rsi
callq 0xe24f
leaq 0x168(%rsp), %rdi
callq 0x101d0
callq 0xc6d0
testl %eax, %eax
jne 0x4bfea
leaq 0x170f4(%rip), %rsi     # 0x63012
leaq 0x40(%rsp), %rdi
leaq 0x148(%rsp), %rdx
callq 0xdbbe
leaq 0x20(%rsp), %rdi
movl $0x830, %esi            # imm = 0x830
callq 0xe2d5
leaq 0xf0(%rsp), %rdi
leaq 0x40(%rsp), %rsi
leaq 0x20(%rsp), %rdx
callq 0xe26e
leaq 0x12274(%rip), %rdx     # 0x5e1d1
leaq 0x60(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0xe24f
leaq 0x176ff(%rip), %rsi     # 0x63675
leaq 0xb0(%rsp), %rdi
leaq 0x90(%rsp), %rdx
callq 0xdbbe
leaq 0x1293a(%rip), %rdx     # 0x5e8cc
leaq 0xd0(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0xe24f
leaq 0x110(%rsp), %rdi
leaq 0x60(%rsp), %rsi
leaq 0xd0(%rsp), %rdx
callq 0xe26e
leaq 0x1752c(%rip), %rdx     # 0x634f4
leaq 0x168(%rsp), %rdi
leaq 0x110(%rsp), %rsi
callq 0xe24f
leaq 0x168(%rsp), %rdi
callq 0x101d0
pushq $0x1
popq %rdi
callq 0xc6f0
jmp 0x4bffa
jmp 0x4c00c
jmp 0x4c020
jmp 0x4c058
movq %rax, %r14
leaq 0x168(%rsp), %rdi
callq 0xcbe8
jmp 0x4c00f
movq %rax, %r14
leaq 0x110(%rsp), %rdi
callq 0xcbe8
jmp 0x4c023
jmp 0x4c07e
movq %rax, %r14
leaq 0xd0(%rsp), %rdi
callq 0xcbe8
jmp 0x4c05b
jmp 0x4c0a1
movq %rax, %r14
leaq 0x168(%rsp), %rdi
callq 0xcbe8
jmp 0x4c049
movq %rax, %r14
leaq 0x110(%rsp), %rdi
callq 0xcbe8
jmp 0x4c06f
movq %rax, %r14
leaq 0xb0(%rsp), %rdi
callq 0xcbe8
jmp 0x4c081
jmp 0x4c0c4
movq %rax, %r14
leaq 0xd0(%rsp), %rdi
callq 0xcbe8
jmp 0x4c092
movq %rax, %r14
leaq 0x60(%rsp), %rdi
callq 0xcbe8
jmp 0x4c0a4
jmp 0x4c0e5
movq %rax, %r14
leaq 0xb0(%rsp), %rdi
callq 0xcbe8
jmp 0x4c0b8
movq %rax, %r14
leaq 0xf0(%rsp), %rdi
callq 0xcbe8
jmp 0x4c0c7
jmp 0x4c106
movq %rax, %r14
leaq 0x60(%rsp), %rdi
callq 0xcbe8
jmp 0x4c0d6
movq %rax, %r14
leaq 0x20(%rsp), %rdi
callq 0xcbe8
jmp 0x4c0e8
movq %rax, %r14
leaq 0xf0(%rsp), %rdi
callq 0xcbe8
jmp 0x4c0fa
movq %rax, %r14
leaq 0x40(%rsp), %rdi
callq 0xcbe8
jmp 0x4c1e0
movq %rax, %r14
leaq 0x20(%rsp), %rdi
callq 0xcbe8
jmp 0x4c111
movq %rax, %r14
jmp 0x4c1e0
movq %rax, %r14
leaq 0x40(%rsp), %rdi
jmp 0x4c1ad
movq %rax, %r14
jmp 0x4c1c9
jmp 0x4c1b9
jmp 0x4c12a
movq %rax, %r14
jmp 0x4c1d6
movq %rax, %r14
jmp 0x4c19e
movq %rax, %r14
jmp 0x4c191
movq %rax, %r14
leaq 0x168(%rsp), %rdi
callq 0x5bd06
jmp 0x4c151
movq %rax, %r14
leaq 0x110(%rsp), %rdi
callq 0xcbe8
jmp 0x4c16d
movq %rax, %r14
jmp 0x4c1a8
movq %rax, %r14
jmp 0x4c17a
movq %rax, %r14
leaq 0xb0(%rsp), %rdi
callq 0xcbe8
leaq 0x60(%rsp), %rdi
callq 0xcbe8
leaq 0xf0(%rsp), %rdi
callq 0xcbe8
leaq 0xd0(%rsp), %rdi
callq 0xcbe8
leaq 0x40(%rsp), %rdi
callq 0xcbe8
leaq 0x20(%rsp), %rdi
callq 0xcbe8
jmp 0x4c1bc
movq %rax, %r14
jmp 0x4c184
movq %rax, %r14
leaq 0x90(%rsp), %rdi
callq 0xcbe8
leaq 0x148(%rsp), %rdi
callq 0xcbe8
movq 0x10(%rsp), %rdi
callq 0x5b356
movq %r14, %rdi
callq 0xcaa0