// File: zeeev[P]DASVC/src/varcall.cpp
// Function: largeInsertionPrint(std::__cxx11::list<BamTools::BamAlignment, std::allocator<BamTools::BamAlignment>>&, FastaReference&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&)
bool largeInsertionPrint(std::list<BamAlignment> & twoReads,
                           FastaReference & queryFasta,
                           std::string & refName )
{
    if(twoReads.front().RefID != twoReads.back().RefID){
        return false;
    }


    /* start and end of the SV relative to query */

    int qStartA ;
    int qStartB ;
    int qEndA   ;
    int qEndB   ;

    int alA ;
    int alB ;

    float pctA;
    float pctB;

    int mbA;
    int mbB;

    twoReads.front().GetTag<int>("QS", qStartA);
    twoReads.front().GetTag<int>("QE",   qEndA);
    twoReads.back().GetTag<int>("QS",  qStartB);
    twoReads.back().GetTag<int>("QE",    qEndB);

    twoReads.front().GetTag<int>("AI", alA);
    twoReads.back().GetTag<int>("AI",  alB);

    twoReads.front().GetTag<float>("PI", pctA);
    twoReads.back().GetTag<float>("PI",  pctB);

    twoReads.front().GetTag<int>("MB", mbA);
    twoReads.back().GetTag<int>("MB",  mbB);

    /* next alignment block needs to be the next query block.
    */

    if(abs(alA - alB) > 1){
        return false;
    }

    long int istart = qEndA   ;
    long int iend   = qStartB ;

    if(alA > alB){
        istart = qEndB        ;
        iend   = qStartA      ;
    }

    int insertionL = iend - istart;

    if(insertionL < 20){
        return false;
    }

    std::cout << refName
              << "\t" << twoReads.front().GetEndPosition()
              << "\t" << twoReads.front().GetEndPosition()
              << "\t" << "INS:BETWEEN"
              << "\t" << insertionL
              << "\t" << pctA << "," << pctB
              << "\t" << mbA << "," << mbB
              << "\t" << twoReads.front().Name
              << "\t" << istart
              << "\t" << iend
              << "\t" << queryFasta.getSubSequence(twoReads.front().Name,
                                                   istart,
                                                   insertionL)

              << std::endl;

    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x340, %rsp            # imm = 0x340
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rdi
callq 0x23fd0
movl 0xa8(%rax), %eax
movl %eax, -0x244(%rbp)
movq -0x10(%rbp), %rdi
callq 0x128a0
movq %rax, %rcx
movl -0x244(%rbp), %eax
cmpl 0xa8(%rcx), %eax
je 0x22c0f
movb $0x0, -0x1(%rbp)
jmp 0x23590
movq -0x10(%rbp), %rdi
callq 0x23fd0
movq %rax, -0x258(%rbp)
leaq -0x69(%rbp), %rdi
movq %rdi, -0x250(%rbp)
callq 0x6a20
movq -0x250(%rbp), %rdx
leaq 0x5d49b(%rip), %rsi     # 0x800d8
leaq -0x68(%rbp), %rdi
callq 0x11570
jmp 0x22c48
movq -0x258(%rbp), %rdi
leaq -0x68(%rbp), %rsi
leaq -0x24(%rbp), %rdx
callq 0x111c0
jmp 0x22c5e
leaq -0x68(%rbp), %rdi
callq 0x6ba8
leaq -0x69(%rbp), %rdi
callq 0x6600
movq -0x10(%rbp), %rdi
callq 0x23fd0
movq %rax, -0x268(%rbp)
leaq -0xa1(%rbp), %rdi
movq %rdi, -0x260(%rbp)
callq 0x6a20
movq -0x260(%rbp), %rdx
leaq 0x5d440(%rip), %rsi     # 0x800e1
leaq -0xa0(%rbp), %rdi
callq 0x11570
jmp 0x22caf
movq -0x268(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
leaq -0x2c(%rbp), %rdx
callq 0x111c0
jmp 0x22cc8
leaq -0xa0(%rbp), %rdi
callq 0x6ba8
leaq -0xa1(%rbp), %rdi
callq 0x6600
movq -0x10(%rbp), %rdi
callq 0x128a0
movq %rax, -0x278(%rbp)
leaq -0xc9(%rbp), %rdi
movq %rdi, -0x270(%rbp)
callq 0x6a20
movq -0x270(%rbp), %rdx
leaq 0x5d3c7(%rip), %rsi     # 0x800d8
leaq -0xc8(%rbp), %rdi
callq 0x11570
jmp 0x22d1f
movq -0x278(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
leaq -0x28(%rbp), %rdx
callq 0x111c0
jmp 0x22d38
leaq -0xc8(%rbp), %rdi
callq 0x6ba8
leaq -0xc9(%rbp), %rdi
callq 0x6600
movq -0x10(%rbp), %rdi
callq 0x128a0
movq %rax, -0x288(%rbp)
leaq -0xf1(%rbp), %rdi
movq %rdi, -0x280(%rbp)
callq 0x6a20
movq -0x280(%rbp), %rdx
leaq 0x5d360(%rip), %rsi     # 0x800e1
leaq -0xf0(%rbp), %rdi
callq 0x11570
jmp 0x22d8f
movq -0x288(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
leaq -0x30(%rbp), %rdx
callq 0x111c0
jmp 0x22da8
leaq -0xf0(%rbp), %rdi
callq 0x6ba8
leaq -0xf1(%rbp), %rdi
callq 0x6600
movq -0x10(%rbp), %rdi
callq 0x23fd0
movq %rax, -0x298(%rbp)
leaq -0x119(%rbp), %rdi
movq %rdi, -0x290(%rbp)
callq 0x6a20
movq -0x290(%rbp), %rdx
leaq 0x5d32a(%rip), %rsi     # 0x8011b
leaq -0x118(%rbp), %rdi
callq 0x11570
jmp 0x22dff
movq -0x298(%rbp), %rdi
leaq -0x118(%rbp), %rsi
leaq -0x34(%rbp), %rdx
callq 0x111c0
jmp 0x22e18
leaq -0x118(%rbp), %rdi
callq 0x6ba8
leaq -0x119(%rbp), %rdi
callq 0x6600
movq -0x10(%rbp), %rdi
callq 0x128a0
movq %rax, -0x2a8(%rbp)
leaq -0x141(%rbp), %rdi
movq %rdi, -0x2a0(%rbp)
callq 0x6a20
movq -0x2a0(%rbp), %rdx
leaq 0x5d2ba(%rip), %rsi     # 0x8011b
leaq -0x140(%rbp), %rdi
callq 0x11570
jmp 0x22e6f
movq -0x2a8(%rbp), %rdi
leaq -0x140(%rbp), %rsi
leaq -0x38(%rbp), %rdx
callq 0x111c0
jmp 0x22e88
leaq -0x140(%rbp), %rdi
callq 0x6ba8
leaq -0x141(%rbp), %rdi
callq 0x6600
movq -0x10(%rbp), %rdi
callq 0x23fd0
movq %rax, -0x2b8(%rbp)
leaq -0x169(%rbp), %rdi
movq %rdi, -0x2b0(%rbp)
callq 0x6a20
movq -0x2b0(%rbp), %rdx
leaq 0x5d29d(%rip), %rsi     # 0x8016e
leaq -0x168(%rbp), %rdi
callq 0x11570
jmp 0x22edf
movq -0x2b8(%rbp), %rdi
leaq -0x168(%rbp), %rsi
leaq -0x3c(%rbp), %rdx
callq 0x23c20
jmp 0x22ef8
leaq -0x168(%rbp), %rdi
callq 0x6ba8
leaq -0x169(%rbp), %rdi
callq 0x6600
movq -0x10(%rbp), %rdi
callq 0x128a0
movq %rax, -0x2c8(%rbp)
leaq -0x191(%rbp), %rdi
movq %rdi, -0x2c0(%rbp)
callq 0x6a20
movq -0x2c0(%rbp), %rdx
leaq 0x5d22d(%rip), %rsi     # 0x8016e
leaq -0x190(%rbp), %rdi
callq 0x11570
jmp 0x22f4f
movq -0x2c8(%rbp), %rdi
leaq -0x190(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x23c20
jmp 0x22f68
leaq -0x190(%rbp), %rdi
callq 0x6ba8
leaq -0x191(%rbp), %rdi
callq 0x6600
movq -0x10(%rbp), %rdi
callq 0x23fd0
movq %rax, -0x2d8(%rbp)
leaq -0x1b9(%rbp), %rdi
movq %rdi, -0x2d0(%rbp)
callq 0x6a20
movq -0x2d0(%rbp), %rdx
leaq 0x5d12d(%rip), %rsi     # 0x800de
leaq -0x1b8(%rbp), %rdi
callq 0x11570
jmp 0x22fbf
movq -0x2d8(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
leaq -0x44(%rbp), %rdx
callq 0x111c0
jmp 0x22fd8
leaq -0x1b8(%rbp), %rdi
callq 0x6ba8
leaq -0x1b9(%rbp), %rdi
callq 0x6600
movq -0x10(%rbp), %rdi
callq 0x128a0
movq %rax, -0x2e8(%rbp)
leaq -0x1e1(%rbp), %rdi
movq %rdi, -0x2e0(%rbp)
callq 0x6a20
movq -0x2e0(%rbp), %rdx
leaq 0x5d0bd(%rip), %rsi     # 0x800de
leaq -0x1e0(%rbp), %rdi
callq 0x11570
jmp 0x2302f
movq -0x2e8(%rbp), %rdi
leaq -0x1e0(%rbp), %rsi
leaq -0x48(%rbp), %rdx
callq 0x111c0
jmp 0x23048
leaq -0x1e0(%rbp), %rdi
callq 0x6ba8
leaq -0x1e1(%rbp), %rdi
callq 0x6600
movl -0x34(%rbp), %eax
subl -0x38(%rbp), %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
cmpl $0x1, %eax
jle 0x2329f
movb $0x0, -0x1(%rbp)
jmp 0x23590
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x230a2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x6ba8
leaq -0x69(%rbp), %rdi
callq 0x6600
jmp 0x2359e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x230d6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x6ba8
leaq -0xa1(%rbp), %rdi
callq 0x6600
jmp 0x2359e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x2310d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x6ba8
leaq -0xc9(%rbp), %rdi
callq 0x6600
jmp 0x2359e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x23144
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x6ba8
leaq -0xf1(%rbp), %rdi
callq 0x6600
jmp 0x2359e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x2317b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x118(%rbp), %rdi
callq 0x6ba8
leaq -0x119(%rbp), %rdi
callq 0x6600
jmp 0x2359e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x231b2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x140(%rbp), %rdi
callq 0x6ba8
leaq -0x141(%rbp), %rdi
callq 0x6600
jmp 0x2359e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x231e9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x168(%rbp), %rdi
callq 0x6ba8
leaq -0x169(%rbp), %rdi
callq 0x6600
jmp 0x2359e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x23220
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x190(%rbp), %rdi
callq 0x6ba8
leaq -0x191(%rbp), %rdi
callq 0x6600
jmp 0x2359e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x23257
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x1b8(%rbp), %rdi
callq 0x6ba8
leaq -0x1b9(%rbp), %rdi
callq 0x6600
jmp 0x2359e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x2328e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x1e0(%rbp), %rdi
callq 0x6ba8
leaq -0x1e1(%rbp), %rdi
callq 0x6600
jmp 0x2359e
movslq -0x2c(%rbp), %rax
movq %rax, -0x1f0(%rbp)
movslq -0x28(%rbp), %rax
movq %rax, -0x1f8(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x38(%rbp), %eax
jle 0x232d3
movslq -0x30(%rbp), %rax
movq %rax, -0x1f0(%rbp)
movslq -0x24(%rbp), %rax
movq %rax, -0x1f8(%rbp)
movq -0x1f8(%rbp), %rax
subq -0x1f0(%rbp), %rax
movl %eax, -0x1fc(%rbp)
cmpl $0x14, -0x1fc(%rbp)
jge 0x232f9
movb $0x0, -0x1(%rbp)
jmp 0x23590
movq -0x20(%rbp), %rsi
movq 0x8accc(%rip), %rdi     # 0xadfd0
callq 0x64c0
movq %rax, %rdi
leaq 0x5da64(%rip), %rsi     # 0x80d77
movq %rsi, -0x308(%rbp)
callq 0x6560
movq %rax, -0x330(%rbp)
movq -0x10(%rbp), %rdi
callq 0x23fd0
movq %rax, %rdi
xorl %edx, %edx
movl %edx, -0x324(%rbp)
movl %edx, %esi
callq 0x2cdf0
movq -0x330(%rbp), %rdi
movl %eax, %esi
callq 0x6a00
movq -0x308(%rbp), %rsi
movq %rax, %rdi
callq 0x6560
movq %rax, -0x320(%rbp)
movq -0x10(%rbp), %rdi
callq 0x23fd0
movl -0x324(%rbp), %edx
movq %rax, %rdi
movl %edx, %esi
callq 0x2cdf0
movq -0x320(%rbp), %rdi
movl %eax, %esi
callq 0x6a00
movq -0x308(%rbp), %rsi
movq %rax, %rdi
callq 0x6560
movq %rax, %rdi
leaq 0x5d217(%rip), %rsi     # 0x805bc
callq 0x6560
movq -0x308(%rbp), %rsi
movq %rax, %rdi
callq 0x6560
movq %rax, %rdi
movl -0x1fc(%rbp), %esi
callq 0x6a00
movq -0x308(%rbp), %rsi
movq %rax, %rdi
callq 0x6560
movq %rax, %rdi
movss -0x3c(%rbp), %xmm0
callq 0x63e0
movq %rax, %rdi
leaq 0x5d1cd(%rip), %rsi     # 0x805ba
movq %rsi, -0x318(%rbp)
callq 0x6560
movq %rax, %rdi
movss -0x40(%rbp), %xmm0
callq 0x63e0
movq -0x308(%rbp), %rsi
movq %rax, %rdi
callq 0x6560
movq %rax, %rdi
movl -0x44(%rbp), %esi
callq 0x6a00
movq -0x318(%rbp), %rsi
movq %rax, %rdi
callq 0x6560
movq %rax, %rdi
movl -0x48(%rbp), %esi
callq 0x6a00
movq -0x308(%rbp), %rsi
movq %rax, %rdi
callq 0x6560
movq %rax, -0x310(%rbp)
movq -0x10(%rbp), %rdi
callq 0x23fd0
movq -0x310(%rbp), %rdi
movq %rax, %rsi
callq 0x64c0
movq -0x308(%rbp), %rsi
movq %rax, %rdi
callq 0x6560
movq %rax, %rdi
movq -0x1f0(%rbp), %rsi
callq 0x6a70
movq -0x308(%rbp), %rsi
movq %rax, %rdi
callq 0x6560
movq %rax, %rdi
movq -0x1f8(%rbp), %rsi
callq 0x6a70
movq -0x308(%rbp), %rsi
movq %rax, %rdi
callq 0x6560
movq %rax, -0x300(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x2f8(%rbp)
movq -0x10(%rbp), %rdi
callq 0x23fd0
movq %rax, %rsi
leaq -0x240(%rbp), %rdi
movq %rdi, -0x2f0(%rbp)
callq 0x6200
movq -0x2f8(%rbp), %rsi
movq -0x2f0(%rbp), %rdx
movl -0x1f0(%rbp), %ecx
movl -0x1fc(%rbp), %r8d
leaq -0x220(%rbp), %rdi
callq 0x26340
jmp 0x2350d
movq -0x300(%rbp), %rdi
leaq -0x220(%rbp), %rsi
callq 0x64c0
movq %rax, -0x338(%rbp)
jmp 0x23529
movq -0x338(%rbp), %rdi
movq 0x8aa71(%rip), %rsi     # 0xadfa8
callq 0x65c0
jmp 0x2353e
leaq -0x220(%rbp), %rdi
callq 0x6ba8
leaq -0x240(%rbp), %rdi
callq 0x6ba8
movb $0x1, -0x1(%rbp)
jmp 0x23590
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x23582
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x220(%rbp), %rdi
callq 0x6ba8
leaq -0x240(%rbp), %rdi
callq 0x6ba8
jmp 0x2359e
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x340, %rsp            # imm = 0x340
popq %rbp
retq
movq -0x78(%rbp), %rdi
callq 0x6a10
nopw (%rax,%rax)