// File: /workspace/github_cpp_makefile_star2_O2/ncbi[P]amr/seq.cpp
// Function: Seq_sp::Dna::cds2prot(unsigned char, bool, bool, bool, bool) const
Peptide Dna::cds2prot (Gencode gencode,
                       bool trunc5,
                       bool trunc3,
	                     bool hasStopCodon,
	                     bool allowExtraStopCodon) const
{
  size_t translationStart = 0;
  Peptide pep (makePeptide (1 /*frame*/, gencode, true, true, translationStart));
  
  EXEC_ASSERT (trimSuffix (pep. name, ".fr1"));
  
  if (pep. seq. empty ())
    throw runtime_error (FUNC "empty sequence");
  if (! trunc5 && ! trunc3 && pep. seq. size () * 3 != seq. size ())
    throw runtime_error (FUNC "incomplete codon");  
  if (! trunc5 && pep. seq [0] != 'm')
    throw runtime_error (FUNC "no start codon");
    
  const size_t starPos = pep. seq. find ("*");
  if (hasStopCodon)
  {
  	if (starPos == string::npos)
  	{
  	  if (! trunc3)
        throw runtime_error (FUNC "no stop codon");
    }
    else
    {
  	  if (starPos == pep. seq. size () - 1)
  	  {
    	  EXEC_ASSERT (trimSuffix (pep. seq, "*"));
    	}
    	else
    	{
        if (allowExtraStopCodon)
          pep. seq. erase (starPos);
        else
          throw runtime_error (FUNC "stop codon at peptide position " + to_string (starPos + 1) + "\n" + seq. substr (starPos * 3));
      }
  	}
  }
  else
	  if (starPos != string::npos)
	    throw runtime_error (FUNC "has a stop codon");
  
  return pep;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movl %r9d, %r15d
movl %r8d, %ebp
movl %ecx, %r12d
movl %edx, %ecx
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x110(%rsp), %rax
andq $0x0, (%rax)
movq %rax, (%rsp)
pushq $0x1
popq %rdx
movl %edx, %r8d
movl %edx, %r9d
callq 0x4aa08
leaq 0x18290(%rip), %rsi     # 0x63577
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0xdbbe
leaq 0x8(%rbx), %rdi
leaq 0x10(%rsp), %rsi
callq 0x111f5
movl %eax, %r13d
leaq 0x10(%rsp), %rdi
callq 0xcbe8
testb %r13b, %r13b
je 0x4b5a2
movq 0x30(%rbx), %rax
testq %rax, %rax
je 0x4b676
movl %r12d, %ecx
orb %bpl, %cl
jne 0x4b33d
leaq (%rax,%rax,2), %rax
cmpq 0x30(%r14), %rax
jne 0x4b6e2
leaq 0x28(%rbx), %r13
testb %r12b, %r12b
jne 0x4b353
movq (%r13), %rax
cmpb $0x6d, (%rax)
jne 0x4b746
leaq 0x1352a(%rip), %rsi     # 0x5e884
movq %r13, %rdi
xorl %edx, %edx
callq 0xcba0
movq %rax, %r12
testb %r15b, %r15b
je 0x4b496
cmpq $-0x1, %r12
je 0x4b504
movq 0x30(%rbx), %rax
decq %rax
cmpq %rax, %r12
jne 0x4b571
leaq 0x134f3(%rip), %rsi     # 0x5e884
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0xdbbe
leaq 0x10(%rsp), %rsi
movq %r13, %rdi
callq 0x111f5
movl %eax, %ebp
leaq 0x10(%rsp), %rdi
callq 0xcbe8
testb %bpl, %bpl
jne 0x4b58d
callq 0xc6d0
testl %eax, %eax
jne 0x4b6da
leaq 0x17c3c(%rip), %rsi     # 0x63012
leaq 0xb0(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0xdbbe
leaq 0x90(%rsp), %rdi
movl $0x818, %esi            # imm = 0x818
callq 0xe2d5
leaq 0xd0(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
leaq 0x90(%rsp), %rdx
callq 0xe26e
leaq 0x12db3(%rip), %rdx     # 0x5e1d1
leaq 0x50(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
callq 0xe24f
leaq 0x18145(%rip), %rsi     # 0x6357c
leaq 0xf0(%rsp), %rdi
leaq 0xe(%rsp), %rdx
callq 0xdbbe
leaq 0x1347c(%rip), %rdx     # 0x5e8cc
leaq 0x70(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0xe24f
leaq 0x30(%rsp), %rdi
leaq 0x50(%rsp), %rsi
leaq 0x70(%rsp), %rdx
callq 0xe26e
leaq 0x181a8(%rip), %rdx     # 0x63625
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0xe24f
leaq 0x10(%rsp), %rdi
callq 0x101d0
cmpq $-0x1, %r12
je 0x4b58d
pushq $0x10
popq %rdi
callq 0xc310
movq %rax, %r15
leaq 0x180ca(%rip), %rsi     # 0x6357c
leaq 0x30(%rsp), %rdi
leaq 0x50(%rsp), %rdx
callq 0xdbbe
leaq 0x1819a(%rip), %rdx     # 0x63662
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0xe24f
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %r15, %rdi
callq 0xc990
xorl %ebp, %ebp
movq 0x3db00(%rip), %rsi     # 0x88ff0
movq 0x3da71(%rip), %rdx     # 0x88f68
movq %r15, %rdi
callq 0xca40
jmp 0x4b883
testb %bpl, %bpl
jne 0x4b58d
pushq $0x10
popq %rdi
callq 0xc310
movq %rax, %r15
leaq 0x1805d(%rip), %rsi     # 0x6357c
leaq 0x30(%rsp), %rdi
leaq 0x50(%rsp), %rdx
callq 0xdbbe
leaq 0x180e0(%rip), %rdx     # 0x63615
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0xe24f
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %r15, %rdi
callq 0xc990
xorl %ebp, %ebp
movq 0x3da93(%rip), %rsi     # 0x88ff0
movq 0x3da04(%rip), %rdx     # 0x88f68
movq %r15, %rdi
callq 0xca40
jmp 0x4b883
cmpb $0x0, 0x150(%rsp)
je 0x4b7aa
pushq $-0x1
popq %rdx
movq %r13, %rdi
movq %r12, %rsi
callq 0xc120
movq %rbx, %rax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0xc6d0
testl %eax, %eax
jne 0x4b6da
leaq 0x17a5c(%rip), %rsi     # 0x63012
leaq 0xb0(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0xdbbe
leaq 0x90(%rsp), %rdi
movl $0x803, %esi            # imm = 0x803
callq 0xe2d5
leaq 0xd0(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
leaq 0x90(%rsp), %rdx
callq 0xe26e
leaq 0x12bd3(%rip), %rdx     # 0x5e1d1
leaq 0x50(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
callq 0xe24f
leaq 0x17f65(%rip), %rsi     # 0x6357c
leaq 0xf0(%rsp), %rdi
leaq 0xe(%rsp), %rdx
callq 0xdbbe
leaq 0x1329c(%rip), %rdx     # 0x5e8cc
leaq 0x70(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0xe24f
leaq 0x30(%rsp), %rdi
leaq 0x50(%rsp), %rsi
leaq 0x70(%rsp), %rdx
callq 0xe26e
leaq 0x17f64(%rip), %rdx     # 0x635c1
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0xe24f
leaq 0x10(%rsp), %rdi
callq 0x101d0
pushq $0x10
popq %rdi
callq 0xc310
movq %rax, %r15
leaq 0x17ef4(%rip), %rsi     # 0x6357c
leaq 0x30(%rsp), %rdi
leaq 0x50(%rsp), %rdx
callq 0xdbbe
leaq 0x17f42(%rip), %rdx     # 0x635e0
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0xe24f
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %r15, %rdi
callq 0xc990
xorl %ebp, %ebp
movq 0x3d92a(%rip), %rsi     # 0x88ff0
movq 0x3d89b(%rip), %rdx     # 0x88f68
movq %r15, %rdi
callq 0xca40
jmp 0x4b883
pushq $0x1
popq %rdi
callq 0xc6f0
pushq $0x10
popq %rdi
callq 0xc310
movq %rax, %r15
leaq 0x17e88(%rip), %rsi     # 0x6357c
leaq 0x30(%rsp), %rdi
leaq 0x50(%rsp), %rdx
callq 0xdbbe
leaq 0x17ee7(%rip), %rdx     # 0x635f1
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0xe24f
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %r15, %rdi
callq 0xc990
xorl %ebp, %ebp
movq 0x3d8be(%rip), %rsi     # 0x88ff0
movq 0x3d82f(%rip), %rdx     # 0x88f68
movq %r15, %rdi
callq 0xca40
jmp 0x4b883
pushq $0x10
popq %rdi
callq 0xc310
movq %rax, %r15
leaq 0x17e24(%rip), %rsi     # 0x6357c
leaq 0x30(%rsp), %rdi
leaq 0x50(%rsp), %rdx
callq 0xdbbe
leaq 0x17e96(%rip), %rdx     # 0x63604
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0xe24f
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %r15, %rdi
callq 0xc990
xorl %ebp, %ebp
movq 0x3d85a(%rip), %rsi     # 0x88ff0
movq 0x3d7cb(%rip), %rdx     # 0x88f68
movq %r15, %rdi
callq 0xca40
jmp 0x4b883
pushq $0x10
popq %rdi
callq 0xc310
movq %rax, %r15
leaq 0x17dc0(%rip), %rsi     # 0x6357c
leaq 0xb0(%rsp), %rdi
leaq 0xf0(%rsp), %rdx
callq 0xdbbe
leaq 0x17e68(%rip), %rdx     # 0x63640
leaq 0xd0(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0xe24f
leaq 0x1(%r12), %rsi
leaq 0x90(%rsp), %rdi
callq 0xe83d
leaq 0x50(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
leaq 0x90(%rsp), %rdx
callq 0xe26e
leaq 0x15076(%rip), %rdx     # 0x60896
leaq 0x30(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0xe24f
addq $0x28, %r14
leaq (%r12,%r12,2), %rdx
leaq 0x70(%rsp), %rdi
pushq $-0x1
popq %rcx
movq %r14, %rsi
callq 0xc5f0
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0x70(%rsp), %rdx
callq 0xe26e
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %r15, %rdi
callq 0xc990
xorl %ebp, %ebp
movq 0x3d77c(%rip), %rsi     # 0x88ff0
movq 0x3d6ed(%rip), %rdx     # 0x88f68
movq %r15, %rdi
callq 0xca40
jmp 0x4b8ac
jmp 0x4b8bb
jmp 0x4b8de
jmp 0x4b901
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0xcbe8
jmp 0x4b8a0
movq %rax, %r14
movb $0x1, %bpl
leaq 0x70(%rsp), %rdi
callq 0xcbe8
jmp 0x4b8d2
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0xcbe8
jmp 0x4b8be
movq %rax, %r14
leaq 0x30(%rsp), %rdi
callq 0xcbe8
jmp 0x4b8e1
jmp 0x4b92a
movq %rax, %r14
movb $0x1, %bpl
leaq 0x30(%rsp), %rdi
callq 0xcbe8
jmp 0x4b8f5
movq %rax, %r14
leaq 0x70(%rsp), %rdi
callq 0xcbe8
jmp 0x4b904
jmp 0x4b950
movq %rax, %r14
movb $0x1, %bpl
leaq 0x50(%rsp), %rdi
callq 0xcbe8
jmp 0x4b91b
movq %rax, %r14
leaq 0xf0(%rsp), %rdi
callq 0xcbe8
jmp 0x4b92d
jmp 0x4b97b
movq %rax, %r14
movb $0x1, %bpl
leaq 0x90(%rsp), %rdi
callq 0xcbe8
jmp 0x4b941
movq %rax, %r14
leaq 0x50(%rsp), %rdi
callq 0xcbe8
jmp 0x4b953
jmp 0x4b99d
movq %rax, %r14
movb $0x1, %bpl
leaq 0xd0(%rsp), %rdi
callq 0xcbe8
jmp 0x4b96d
movq %rax, %r14
leaq 0xd0(%rsp), %rdi
callq 0xcbe8
jmp 0x4b97e
jmp 0x4b9fa
movq %rax, %r14
movb $0x1, %bpl
leaq 0xb0(%rsp), %rdi
jmp 0x4b9d0
jmp 0x4b9b6
jmp 0x4b9c5
movq %rax, %r14
leaq 0x90(%rsp), %rdi
callq 0xcbe8
jmp 0x4b9a0
jmp 0x4b9de
jmp 0x4b9de
jmp 0x4b9b6
jmp 0x4b9c5
jmp 0x4b9b6
jmp 0x4b9c5
jmp 0x4b9b6
jmp 0x4b9c5
movq %rax, %r14
leaq 0xb0(%rsp), %rdi
jmp 0x4b9f3
jmp 0x4b9fa
jmp 0x4b9eb
jmp 0x4b9fa
jmp 0x4b9de
jmp 0x4b9de
jmp 0x4b9de
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0xcbe8
jmp 0x4b9cb
movq %rax, %r14
movb $0x1, %bpl
leaq 0x30(%rsp), %rdi
callq 0xcbe8
testb %bpl, %bpl
jne 0x4b9e1
jmp 0x4b9fd
jmp 0x4b9fa
movq %rax, %r14
movq %r15, %rdi
callq 0xc470
jmp 0x4b9fd
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0xcbe8
jmp 0x4b9fd
movq %rax, %r14
movq %rbx, %rdi
callq 0x5bd06
movq %r14, %rdi
callq 0xcaa0
nop