// File: tedsharpe[P]ORFCall/ORFCall.cc
// Function: (anonymous namespace)::SmithWatermanizer::traceback(__gnu_cxx::__normal_iterator<unsigned char const*, std::vector<unsigned char, std::allocator<unsigned char>>>, __gnu_cxx::__normal_iterator<unsigned char const*, std::vector<unsigned char, std::allocator<unsigned char>>>, __gnu_cxx::__normal_iterator<unsigned char const*, std::vector<unsigned char, std::allocator<unsigned char>>>, __gnu_cxx::__normal_iterator<unsigned char const*, std::vector<unsigned char, std::allocator<unsigned char>>>, std::ostream*)
void SmithWatermanizer::traceback( Sequence::const_iterator bX,
                                   Sequence::const_iterator eX,
                                   Sequence::const_iterator bY,
                                   Sequence::const_iterator eY,
                                   std::ostream* pOS )
{
    using std::distance;
    auto nCols = distance(bX, eX);
    mMatchup.clear();
    if ( pOS )
    {
        mLineX.clear();
        mLineY.clear();
        mLineZ.clear();
    }
    Trace* pTB = mpBestTracebackStart;
    eY -= (&mTraceback.back() - pTB - 1)/(nCols + 1);

    unsigned len = 0;
    while ( *pTB != Trace::DONE )
    {
        Trace trace = *pTB;
        if ( trace == Trace::UP )
        {
            if ( pOS )
            {
                mLineX.push_back(' ');
                mLineY.push_back(charFor(*--eY));
                mLineZ.push_back('|');
            }
            pTB -= nCols + 1;
        }
        else if ( trace == Trace::DIAG )
        {
            if ( pOS )
            {
                mLineX.push_back(charFor(*--eX));
                mLineY.push_back(charFor(*--eY));
                mLineZ.push_back(*eX==*eY?' ':'*');
            }
            pTB -= nCols + 2;
        }
        else
        {
            if ( pOS )
            {
                mLineX.push_back(charFor(*--eX));
                mLineY.push_back(' ');
                mLineZ.push_back('|');
            }
            pTB -= 1;
        }
        len += 1;
        if ( trace != *pTB )
        {
            mMatchup.emplace_back(trace,len);
            len = 0;
        }
    }

    std::reverse(mMatchup.begin(),mMatchup.end());

    if ( pOS )
    {
        if ( bX!=eX || bY!=eY )
            FatalErr("Internal error in traceback.");

        Block const& firstBlock = mMatchup[0];
        if ( firstBlock.mDir == Trace::UP )
        {
            len = mLineX.size() - firstBlock.mLen;
            mLineX.resize(len);
            mLineY.resize(len);
            mLineZ.resize(len);
        }
        std::reverse(mLineX.begin(), mLineX.end());
        *pOS << mLineX << '\n';
        std::reverse(mLineY.begin(), mLineY.end());
        *pOS << mLineY << '\n';
        std::reverse(mLineZ.begin(), mLineZ.end());
        *pOS << mLineZ << '\n';
    }
}

// Assembly:
subq $0xd8, %rsp
movq %rsi, 0xd0(%rsp)
movq %rdx, 0xc8(%rsp)
movq %rcx, 0xc0(%rsp)
movq %r8, 0xb8(%rsp)
movq %rdi, 0xb0(%rsp)
movq %r9, 0xa8(%rsp)
movq 0xb0(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0xd0(%rsp), %rax
movq %rax, 0x98(%rsp)
movq 0xc8(%rsp), %rax
movq %rax, 0x90(%rsp)
movq 0x98(%rsp), %rdi
movq 0x90(%rsp), %rsi
callq 0x1f040
movq 0x30(%rsp), %rdi
movq %rax, 0xa0(%rsp)
addq $0x50, %rdi
callq 0x12220
cmpq $0x0, 0xa8(%rsp)
je 0x110ca
movq 0x30(%rsp), %rdi
addq $0x68, %rdi
callq 0x4330
movq 0x30(%rsp), %rdi
addq $0x88, %rdi
callq 0x4330
movq 0x30(%rsp), %rdi
addq $0xa8, %rdi
callq 0x4330
movq 0x30(%rsp), %rdi
movq 0x48(%rdi), %rax
movq %rax, 0x88(%rsp)
addq $0x30, %rdi
callq 0x12240
movq 0x88(%rsp), %rcx
subq %rcx, %rax
subq $0x1, %rax
movq 0xa0(%rsp), %rcx
addq $0x1, %rcx
cqto
idivq %rcx
movq %rax, %rsi
leaq 0xb8(%rsp), %rdi
callq 0x1fc90
movl $0x0, 0x84(%rsp)
movq 0x88(%rsp), %rax
cmpb $0x0, (%rax)
je 0x113d6
movq 0x88(%rsp), %rax
movb (%rax), %al
movb %al, 0x83(%rsp)
cmpb $0x1, 0x83(%rsp)
jne 0x111e6
cmpq $0x0, 0xa8(%rsp)
je 0x111bd
movq 0x30(%rsp), %rdi
addq $0x68, %rdi
movl $0x20, %esi
callq 0x4220
movq 0x30(%rsp), %rax
addq $0x88, %rax
movq %rax, 0x28(%rsp)
leaq 0xb8(%rsp), %rdi
callq 0x1e5f0
movq %rax, %rdi
callq 0x1a180
movzbl (%rax), %edi
callq 0xddd0
movq 0x28(%rsp), %rdi
movsbl %al, %esi
callq 0x4220
movq 0x30(%rsp), %rdi
addq $0xa8, %rdi
movl $0x7c, %esi
callq 0x4220
movq 0xa0(%rsp), %rdx
addq $0x1, %rdx
movq 0x88(%rsp), %rax
xorl %ecx, %ecx
subq %rdx, %rcx
addq %rcx, %rax
movq %rax, 0x88(%rsp)
jmp 0x11384
cmpb $0x3, 0x83(%rsp)
jne 0x11301
cmpq $0x0, 0xa8(%rsp)
je 0x112d8
movq 0x30(%rsp), %rax
addq $0x68, %rax
movq %rax, 0x8(%rsp)
leaq 0xc8(%rsp), %rdi
callq 0x1e5f0
movq %rax, %rdi
callq 0x1a180
movzbl (%rax), %edi
callq 0xddd0
movq 0x8(%rsp), %rdi
movsbl %al, %esi
callq 0x4220
movq 0x30(%rsp), %rax
addq $0x88, %rax
movq %rax, 0x10(%rsp)
leaq 0xb8(%rsp), %rdi
callq 0x1e5f0
movq %rax, %rdi
callq 0x1a180
movzbl (%rax), %edi
callq 0xddd0
movq 0x10(%rsp), %rdi
movsbl %al, %esi
callq 0x4220
movq 0x30(%rsp), %rax
addq $0xa8, %rax
movq %rax, 0x18(%rsp)
leaq 0xc8(%rsp), %rdi
callq 0x1a180
movzbl (%rax), %eax
movl %eax, 0x20(%rsp)
leaq 0xb8(%rsp), %rdi
callq 0x1a180
movl 0x20(%rsp), %ecx
movzbl (%rax), %edx
movb $0x20, %al
movb $0x2a, %sil
movb %sil, 0x26(%rsp)
cmpl %edx, %ecx
movb %al, 0x27(%rsp)
je 0x112c7
movb 0x26(%rsp), %al
movb %al, 0x27(%rsp)
movq 0x18(%rsp), %rdi
movb 0x27(%rsp), %al
movsbl %al, %esi
callq 0x4220
movq 0xa0(%rsp), %rdx
addq $0x2, %rdx
movq 0x88(%rsp), %rax
xorl %ecx, %ecx
subq %rdx, %rcx
addq %rcx, %rax
movq %rax, 0x88(%rsp)
jmp 0x11382
cmpq $0x0, 0xa8(%rsp)
je 0x1136e
movq 0x30(%rsp), %rax
addq $0x68, %rax
movq %rax, (%rsp)
leaq 0xc8(%rsp), %rdi
callq 0x1e5f0
movq %rax, %rdi
callq 0x1a180
movzbl (%rax), %edi
callq 0xddd0
movq (%rsp), %rdi
movsbl %al, %esi
callq 0x4220
movq 0x30(%rsp), %rdi
addq $0x88, %rdi
movl $0x20, %esi
callq 0x4220
movq 0x30(%rsp), %rdi
addq $0xa8, %rdi
movl $0x7c, %esi
callq 0x4220
movq 0x88(%rsp), %rax
addq $-0x1, %rax
movq %rax, 0x88(%rsp)
jmp 0x11384
movl 0x84(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x84(%rsp)
movb 0x83(%rsp), %al
movq 0x88(%rsp), %rcx
cmpb (%rcx), %al
je 0x113d1
movq 0x30(%rsp), %rdi
addq $0x50, %rdi
leaq 0x83(%rsp), %rsi
leaq 0x84(%rsp), %rdx
callq 0x12280
movl $0x0, 0x84(%rsp)
jmp 0x1111f
movq 0x30(%rsp), %rdi
addq $0x50, %rdi
callq 0x12340
movq 0x30(%rsp), %rdi
movq %rax, 0x78(%rsp)
addq $0x50, %rdi
callq 0x12370
movq %rax, 0x70(%rsp)
movq 0x78(%rsp), %rdi
movq 0x70(%rsp), %rsi
callq 0x12300
cmpq $0x0, 0xa8(%rsp)
je 0x11620
leaq 0xd0(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
callq 0x19f20
testb $0x1, %al
jne 0x1144e
leaq 0xc0(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
callq 0x19f20
testb $0x1, %al
jne 0x1144e
jmp 0x1147a
movq 0x1bb9b(%rip), %rdi     # 0x2cff0
leaq 0x10741(%rip), %rsi     # 0x21b9d
callq 0x4290
movq %rax, %rdi
movq 0x1bb3d(%rip), %rsi     # 0x2cfa8
callq 0x42b0
movl $0x1, %edi
callq 0x42f0
movq 0x30(%rsp), %rdi
addq $0x50, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x123a0
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
cmpb $0x1, (%rax)
jne 0x11506
movq 0x30(%rsp), %rdi
addq $0x68, %rdi
callq 0x41c0
movq 0x30(%rsp), %rdi
movq 0x68(%rsp), %rcx
movl 0x4(%rcx), %ecx
subq %rcx, %rax
movl %eax, 0x84(%rsp)
addq $0x68, %rdi
movl 0x84(%rsp), %eax
movl %eax, %esi
callq 0x4390
movq 0x30(%rsp), %rdi
addq $0x88, %rdi
movl 0x84(%rsp), %eax
movl %eax, %esi
callq 0x4390
movq 0x30(%rsp), %rdi
addq $0xa8, %rdi
movl 0x84(%rsp), %eax
movl %eax, %esi
callq 0x4390
movq 0x30(%rsp), %rdi
addq $0x68, %rdi
callq 0x4230
movq 0x30(%rsp), %rdi
movq %rax, 0x60(%rsp)
addq $0x68, %rdi
callq 0x41a0
movq %rax, 0x58(%rsp)
movq 0x60(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0x1fcc0
movq 0x30(%rsp), %rsi
movq 0xa8(%rsp), %rdi
addq $0x68, %rsi
callq 0x4260
movq %rax, %rdi
movl $0xa, %esi
callq 0x42e0
movq 0x30(%rsp), %rdi
addq $0x88, %rdi
callq 0x4230
movq 0x30(%rsp), %rdi
movq %rax, 0x50(%rsp)
addq $0x88, %rdi
callq 0x41a0
movq %rax, 0x48(%rsp)
movq 0x50(%rsp), %rdi
movq 0x48(%rsp), %rsi
callq 0x1fcc0
movq 0x30(%rsp), %rsi
movq 0xa8(%rsp), %rdi
addq $0x88, %rsi
callq 0x4260
movq %rax, %rdi
movl $0xa, %esi
callq 0x42e0
movq 0x30(%rsp), %rdi
addq $0xa8, %rdi
callq 0x4230
movq 0x30(%rsp), %rdi
movq %rax, 0x40(%rsp)
addq $0xa8, %rdi
callq 0x41a0
movq %rax, 0x38(%rsp)
movq 0x40(%rsp), %rdi
movq 0x38(%rsp), %rsi
callq 0x1fcc0
movq 0x30(%rsp), %rsi
movq 0xa8(%rsp), %rdi
addq $0xa8, %rsi
callq 0x4260
movq %rax, %rdi
movl $0xa, %esi
callq 0x42e0
addq $0xd8, %rsp
retq
nopl (%rax,%rax)