// File: zeeev[P]DASVC/src/varcall.cpp
// Function: alignmentInternalPrint(BamTools::BamAlignment&, FastaReference&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&)
void alignmentInternalPrint(BamAlignment & al,
                            FastaReference & targetFa,
                            std::string & refName )
{

    long int qPos = 0;
    long int rPos = al.Position;

    float pctA;
    int mbA;
    int qStart;
    int qEnd;

    al.GetTag<float>("PI", pctA);
    al.GetTag<int>("MB", mbA   );
    al.GetTag<int>("QE", qStart);
    al.GetTag<int>("QS", qEnd  );


    for(std::vector< CigarOp >::iterator it = al.CigarData.begin();
        it != al.CigarData.end(); it++){

        if(it->Length > 20){

            if(it->Type == 'I'){
                std::cout << refName
                          << "\t" << rPos
                          << "\t" << rPos
                          << "\t" << "INS:INTERNAL"
                          << "\t" << it->Length
                          << "\t" << pctA
                          << "\t" << mbA
                          << "\t" << al.Name
                          << "\t" << qStart
                          << "\t" << qEnd
                          << "\t" << al.QueryBases.substr(qPos, it->Length)
                          << std::endl;
            }
            if(it->Type == 'D'){
                std::cout << refName
                          << "\t" << rPos
                          << "\t" << (rPos + it->Length)
                          << "\t" << "DEL:INTERNAL"
                          << "\t" << it->Length
                          << "\t" << pctA
                          << "\t" << mbA
                          << "\t" << al.Name
                          << "\t" << qStart
                          << "\t" << qEnd
                          << "\t" << targetFa.getSubSequence(refName,
                                                             rPos, it->Length)
                          << std::endl;
            }
        }
        advanceQuery(it->Type,     it->Length, &qPos);
        advanceReference(it->Type, it->Length, &rPos);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x240, %rsp            # imm = 0x240
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x8(%rbp), %rax
movslq 0xac(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x170(%rbp)
leaq -0x59(%rbp), %rdi
movq %rdi, -0x168(%rbp)
callq 0x6a20
movq -0x168(%rbp), %rdx
leaq 0x5e627(%rip), %rsi     # 0x8016e
leaq -0x58(%rbp), %rdi
callq 0x11570
jmp 0x21b52
movq -0x170(%rbp), %rdi
leaq -0x58(%rbp), %rsi
leaq -0x2c(%rbp), %rdx
callq 0x23c20
jmp 0x21b68
leaq -0x58(%rbp), %rdi
callq 0x6ba8
leaq -0x59(%rbp), %rdi
callq 0x6600
movq -0x8(%rbp), %rax
movq %rax, -0x180(%rbp)
leaq -0x91(%rbp), %rdi
movq %rdi, -0x178(%rbp)
callq 0x6a20
movq -0x178(%rbp), %rdx
leaq 0x5e538(%rip), %rsi     # 0x800de
leaq -0x90(%rbp), %rdi
callq 0x11570
jmp 0x21bb4
movq -0x180(%rbp), %rdi
leaq -0x90(%rbp), %rsi
leaq -0x30(%rbp), %rdx
callq 0x111c0
jmp 0x21bcd
leaq -0x90(%rbp), %rdi
callq 0x6ba8
leaq -0x91(%rbp), %rdi
callq 0x6600
movq -0x8(%rbp), %rax
movq %rax, -0x190(%rbp)
leaq -0xb9(%rbp), %rdi
movq %rdi, -0x188(%rbp)
callq 0x6a20
movq -0x188(%rbp), %rdx
leaq 0x5e4d0(%rip), %rsi     # 0x800e1
leaq -0xb8(%rbp), %rdi
callq 0x11570
jmp 0x21c1f
movq -0x190(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
leaq -0x34(%rbp), %rdx
callq 0x111c0
jmp 0x21c38
leaq -0xb8(%rbp), %rdi
callq 0x6ba8
leaq -0xb9(%rbp), %rdi
callq 0x6600
movq -0x8(%rbp), %rax
movq %rax, -0x1a0(%rbp)
leaq -0xe1(%rbp), %rdi
movq %rdi, -0x198(%rbp)
callq 0x6a20
movq -0x198(%rbp), %rdx
leaq 0x5e45c(%rip), %rsi     # 0x800d8
leaq -0xe0(%rbp), %rdi
callq 0x11570
jmp 0x21c8a
movq -0x1a0(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
leaq -0x38(%rbp), %rdx
callq 0x111c0
jmp 0x21ca3
leaq -0xe0(%rbp), %rdi
callq 0x6ba8
leaq -0xe1(%rbp), %rdi
callq 0x6600
movq -0x8(%rbp), %rdi
addq $0xb8, %rdi
callq 0x11d30
movq %rax, -0xf0(%rbp)
movq -0x8(%rbp), %rdi
addq $0xb8, %rdi
callq 0x11da0
movq %rax, -0xf8(%rbp)
leaq -0xf0(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x11d60
testb $0x1, %al
jne 0x21d05
jmp 0x222de
leaq -0xf0(%rbp), %rdi
callq 0x11dd0
cmpl $0x14, 0x4(%rax)
jbe 0x22254
leaq -0xf0(%rbp), %rdi
callq 0x11dd0
movsbl (%rax), %eax
cmpl $0x49, %eax
jne 0x21ff2
movq -0x18(%rbp), %rsi
movq 0x8c292(%rip), %rdi     # 0xadfd0
callq 0x64c0
movq %rax, %rdi
leaq 0x5f02a(%rip), %rsi     # 0x80d77
movq %rsi, -0x1d8(%rbp)
callq 0x6560
movq %rax, %rdi
movq -0x28(%rbp), %rsi
callq 0x6a70
movq -0x1d8(%rbp), %rsi
movq %rax, %rdi
callq 0x6560
movq %rax, %rdi
movq -0x28(%rbp), %rsi
callq 0x6a70
movq -0x1d8(%rbp), %rsi
movq %rax, %rdi
callq 0x6560
movq %rax, %rdi
leaq 0x5e7fb(%rip), %rsi     # 0x80594
callq 0x6560
movq -0x1d8(%rbp), %rsi
movq %rax, %rdi
callq 0x6560
movq %rax, -0x1e0(%rbp)
leaq -0xf0(%rbp), %rdi
movq %rdi, -0x1d0(%rbp)
callq 0x11dd0
movq -0x1e0(%rbp), %rdi
movl 0x4(%rax), %esi
callq 0x67d0
movq -0x1d8(%rbp), %rsi
movq %rax, %rdi
callq 0x6560
movq %rax, %rdi
movss -0x2c(%rbp), %xmm0
callq 0x63e0
movq -0x1d8(%rbp), %rsi
movq %rax, %rdi
callq 0x6560
movq %rax, %rdi
movl -0x30(%rbp), %esi
callq 0x6a00
movq -0x1d8(%rbp), %rsi
movq %rax, %rdi
callq 0x6560
movq %rax, %rdi
movq -0x8(%rbp), %rsi
callq 0x64c0
movq -0x1d8(%rbp), %rsi
movq %rax, %rdi
callq 0x6560
movq %rax, %rdi
movl -0x34(%rbp), %esi
callq 0x6a00
movq -0x1d8(%rbp), %rsi
movq %rax, %rdi
callq 0x6560
movq %rax, %rdi
movl -0x38(%rbp), %esi
callq 0x6a00
movq -0x1d8(%rbp), %rsi
movq %rax, %rdi
callq 0x6560
movq -0x1d0(%rbp), %rdi
movq %rax, -0x1b8(%rbp)
movq -0x8(%rbp), %rax
addq $0x28, %rax
movq %rax, -0x1c8(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x1c0(%rbp)
callq 0x11dd0
movq -0x1c8(%rbp), %rsi
movq -0x1c0(%rbp), %rdx
movl 0x4(%rax), %eax
movl %eax, %ecx
leaq -0x118(%rbp), %rdi
movq %rdi, -0x1b0(%rbp)
callq 0x65a0
movq -0x1b8(%rbp), %rdi
movq -0x1b0(%rbp), %rsi
callq 0x64c0
movq %rax, -0x1a8(%rbp)
jmp 0x21ed9
movq -0x1a8(%rbp), %rdi
movq 0x8c0c1(%rip), %rsi     # 0xadfa8
callq 0x65c0
jmp 0x21eee
leaq -0x118(%rbp), %rdi
callq 0x6ba8
jmp 0x21ff2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x21f22
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x6ba8
leaq -0x59(%rbp), %rdi
callq 0x6600
jmp 0x222e7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x21f56
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x6ba8
leaq -0x91(%rbp), %rdi
callq 0x6600
jmp 0x222e7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x21f8d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x6ba8
leaq -0xb9(%rbp), %rdi
callq 0x6600
jmp 0x222e7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x21fc4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x6ba8
leaq -0xe1(%rbp), %rdi
callq 0x6600
jmp 0x222e7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x118(%rbp), %rdi
callq 0x6ba8
jmp 0x222e7
leaq -0xf0(%rbp), %rdi
callq 0x11dd0
movsbl (%rax), %eax
cmpl $0x44, %eax
jne 0x22252
movq -0x18(%rbp), %rsi
movq 0x8bfbb(%rip), %rdi     # 0xadfd0
callq 0x64c0
movq %rax, %rdi
leaq 0x5ed53(%rip), %rsi     # 0x80d77
movq %rsi, -0x210(%rbp)
callq 0x6560
movq %rax, %rdi
movq -0x28(%rbp), %rsi
callq 0x6a70
movq -0x210(%rbp), %rsi
movq %rax, %rdi
callq 0x6560
movq %rax, -0x220(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x228(%rbp)
leaq -0xf0(%rbp), %rdi
movq %rdi, -0x200(%rbp)
callq 0x11dd0
movq -0x228(%rbp), %rsi
movq -0x220(%rbp), %rdi
movl 0x4(%rax), %eax
addq %rax, %rsi
callq 0x6a70
movq -0x210(%rbp), %rsi
movq %rax, %rdi
callq 0x6560
movq %rax, %rdi
leaq 0x5e4ff(%rip), %rsi     # 0x805a1
callq 0x6560
movq -0x210(%rbp), %rsi
movq %rax, %rdi
callq 0x6560
movq -0x200(%rbp), %rdi
movq %rax, -0x218(%rbp)
callq 0x11dd0
movq -0x218(%rbp), %rdi
movl 0x4(%rax), %esi
callq 0x67d0
movq -0x210(%rbp), %rsi
movq %rax, %rdi
callq 0x6560
movq %rax, %rdi
movss -0x2c(%rbp), %xmm0
callq 0x63e0
movq -0x210(%rbp), %rsi
movq %rax, %rdi
callq 0x6560
movq %rax, %rdi
movl -0x30(%rbp), %esi
callq 0x6a00
movq -0x210(%rbp), %rsi
movq %rax, %rdi
callq 0x6560
movq %rax, %rdi
movq -0x8(%rbp), %rsi
callq 0x64c0
movq -0x210(%rbp), %rsi
movq %rax, %rdi
callq 0x6560
movq %rax, %rdi
movl -0x34(%rbp), %esi
callq 0x6a00
movq -0x210(%rbp), %rsi
movq %rax, %rdi
callq 0x6560
movq %rax, %rdi
movl -0x38(%rbp), %esi
callq 0x6a00
movq -0x210(%rbp), %rsi
movq %rax, %rdi
callq 0x6560
movq %rax, -0x208(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x1f8(%rbp)
movq -0x18(%rbp), %rsi
leaq -0x158(%rbp), %rdi
movq %rdi, -0x1f0(%rbp)
callq 0x6200
movq -0x200(%rbp), %rdi
movl -0x28(%rbp), %eax
movl %eax, -0x1e4(%rbp)
callq 0x11dd0
movq -0x1f8(%rbp), %rsi
movq -0x1f0(%rbp), %rdx
movl -0x1e4(%rbp), %ecx
movl 0x4(%rax), %r8d
leaq -0x138(%rbp), %rdi
callq 0x26340
jmp 0x221d0
movq -0x208(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0x64c0
movq %rax, -0x230(%rbp)
jmp 0x221ec
movq -0x230(%rbp), %rdi
movq 0x8bdae(%rip), %rsi     # 0xadfa8
callq 0x65c0
jmp 0x22201
leaq -0x138(%rbp), %rdi
callq 0x6ba8
leaq -0x158(%rbp), %rdi
callq 0x6ba8
jmp 0x22252
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x22241
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x138(%rbp), %rdi
callq 0x6ba8
leaq -0x158(%rbp), %rdi
callq 0x6ba8
jmp 0x222e7
jmp 0x22254
leaq -0xf0(%rbp), %rdi
callq 0x11dd0
movb (%rax), %al
movb %al, -0x232(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x11dd0
movq %rax, %rcx
movb -0x232(%rbp), %al
movl 0x4(%rcx), %esi
leaq -0x20(%rbp), %rdx
movsbl %al, %edi
callq 0x1e0f0
leaq -0xf0(%rbp), %rdi
callq 0x11dd0
movb (%rax), %al
movb %al, -0x231(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x11dd0
movq %rax, %rcx
movb -0x231(%rbp), %al
movl 0x4(%rcx), %esi
leaq -0x28(%rbp), %rdx
movsbl %al, %edi
callq 0x1e1b0
leaq -0xf0(%rbp), %rdi
xorl %esi, %esi
callq 0x11df0
movq %rax, -0x160(%rbp)
jmp 0x21cd2
addq $0x240, %rsp            # imm = 0x240
popq %rbp
retq
movq -0x68(%rbp), %rdi
callq 0x6a10