// File: /workspace/github_cpp_makefile_star2_O3/schneebergerlab[P]GameteBinning/asPollinator_1.0.cpp
// Function: cluster_pollens(std::map<int, POLLEN, std::less<int>, std::allocator<std::pair<int const, POLLEN>>>, std::map<int, POLLEN, std::less<int>, std::allocator<std::pair<int const, POLLEN>>>*, std::map<int, POLLEN, std::less<int>, std::allocator<std::pair<int const, POLLEN>>>*, std::map<int, POLLEN, std::less<int>, std::allocator<std::pair<int const, POLLEN>>>*, std::map<int, POLLEN, std::less<int>, std::allocator<std::pair<int const, POLLEN>>>*)
bool cluster_pollens(map<int, POLLEN>  pollens, 
                     map<int, POLLEN>* maCluster,
                     map<int, POLLEN>* paCluster,
                     map<int, POLLEN>* unCluster,
                     map<int, POLLEN>* pollens_updated)
{
    // idea: using initial haplotypes related to a contig as backbone, 
    //       1.color   pollen genotypes
    //       2.cluster pollen genotypes
    //       3.correct haplotypes
    assert(pollens.find(0) != pollens.end());
    string matGT = pollens[0].poSeq; // maternal backbone
    string patGT = pollens[0].poAll; // paternal backbone
    //
    // map<int, POLLEN> maCluster; // close to maternal GT
    // map<int, POLLEN> paCluster; // close to paternal GT
    // map<int, POLLEN> unCluster; // not informative 
    //
    map<int, POLLEN>::iterator pollenitr;
    map<int, POLLEN>::iterator pollenitr_end;
    pollenitr        = pollens.begin();
    pollenitr_end    = pollens.end();
    while(pollenitr != pollenitr_end)
    {
        int     pid  = (*pollenitr).first;
        POLLEN ptmp  = (*pollenitr).second;
        if(pid>0)
        {
            string        pollenGT = ((*pollenitr).second).poSeq;
            string        pattern  = "";                   
            unsigned long matscore = 0; 
            unsigned long patscore = 0;
            if( !get_similarty(matGT,
                               patGT,
                               pollenGT,
                               &pattern,
                               &matscore,
                               &patscore) )
            {
                return false;
            }
            // updating attribute pattern of pollen
            ((*pollenitr).second).poPat = pattern;
            // setting  attribute pattern of pollen
            ptmp.poPat = pattern;  
            //
            if(matscore  > patscore)
            {
                (*maCluster).insert(std::pair<int, POLLEN>(pid, ptmp));
            }
            else
            if(matscore  < patscore)
            {
                (*paCluster).insert(std::pair<int, POLLEN>(pid, ptmp));
            }else
            if(matscore == patscore)
            {
                (*unCluster).insert(std::pair<int, POLLEN>(pid, ptmp));
            }else ;
        }
        pollenitr ++;
    }
    // get pattern inserted in pollen data - new
    (*pollens_updated) = pollens;
    //
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x218, %rsp            # imm = 0x218
movq %rcx, 0x190(%rsp)
movq %rdx, 0x188(%rsp)
movq %rsi, 0x198(%rsp)
movq 0x10(%rdi), %rax
testq %rax, %rax
je 0xee86
movq %rdi, %r15
leaq 0x8(%rdi), %rcx
movq %rcx, (%rsp)
movl 0x20(%rax), %edx
testl %edx, %edx
cmovnsq %rax, %rcx
shrl $0x1f, %edx
movq 0x10(%rax,%rdx,8), %rax
testq %rax, %rax
jne 0xe8f1
cmpq (%rsp), %rcx
je 0xee86
cmpl $0x0, 0x20(%rcx)
jg 0xee86
movq %r8, 0x180(%rsp)
xorl %ebp, %ebp
leaq 0x58(%rsp), %rbx
movl %ebp, (%rbx)
movq %r15, %rdi
movq %rbx, %rsi
callq 0x14730
leaq 0x128(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x118(%rsp), %rdi
callq 0x164ba
movl %ebp, (%rbx)
leaq 0x58(%rsp), %rsi
movq %r15, %rdi
callq 0x14730
leaq 0x108(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq 0x20(%rax), %rsi
movq 0x28(%rax), %rdx
addq %rsi, %rdx
leaq 0xf8(%rsp), %rdi
callq 0x164ba
movq %r15, 0x178(%rsp)
movq 0x18(%r15), %rbp
cmpq (%rsp), %rbp
je 0xed46
leaq 0x38(%rsp), %rbx
leaq 0x158(%rsp), %r12
leaq 0x138(%rsp), %r15
movl 0x20(%rbp), %r13d
leaq 0x28(%rbp), %rsi
leaq 0x1a0(%rsp), %rdi
callq 0x14816
testl %r13d, %r13d
jle 0xeca5
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x28(%rbp), %rsi
movq 0x30(%rbp), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %rdi
callq 0x164ba
leaq 0x48(%rsp), %rax
movq %rax, 0x38(%rsp)
movq %rbx, %rdi
leaq 0xb4c0(%rip), %rdx      # 0x19ec9
movq %rdx, %rsi
callq 0x16550
xorl %eax, %eax
movq %rax, 0x30(%rsp)
movq %rax, 0x28(%rsp)
leaq 0x168(%rsp), %rax
movq %rax, 0x158(%rsp)
movq 0x118(%rsp), %rsi
movq 0x120(%rsp), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x164ba
leaq 0xe8(%rsp), %rax
movq %rax, 0xd8(%rsp)
movq 0xf8(%rsp), %rsi
movq 0x100(%rsp), %rdx
addq %rsi, %rdx
leaq 0xd8(%rsp), %rdi
callq 0x164ba
leaq 0x148(%rsp), %rax
movq %rax, 0x138(%rsp)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0x164ba
movq %r15, %rdx
movq %r12, %r14
movq %r12, %rdi
leaq 0xd8(%rsp), %rsi
movq %rdx, %r15
movq %rbx, %rcx
leaq 0x30(%rsp), %r8
leaq 0x28(%rsp), %r9
callq 0x14336
movl %eax, %r12d
movq 0x138(%rsp), %rdi
leaq 0x148(%rsp), %rax
cmpq %rax, %rdi
je 0xeaeb
movq 0x148(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0xd8(%rsp), %rdi
leaq 0xe8(%rsp), %rax
cmpq %rax, %rdi
je 0xeb10
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0x158(%rsp), %rdi
leaq 0x168(%rsp), %rax
cmpq %rax, %rdi
je 0xeb35
movq 0x168(%rsp), %rsi
incq %rsi
callq 0x3290
testb %r12b, %r12b
je 0xed62
leaq 0x68(%rbp), %rdi
movq %rbx, %rsi
callq 0x3160
movq %r14, %r12
leaq 0x1e0(%rsp), %rdi
movq %rbx, %rsi
callq 0x3160
movq 0x28(%rsp), %rax
cmpq %rax, 0x30(%rsp)
jbe 0xeb94
movl %r13d, 0x58(%rsp)
leaq 0x60(%rsp), %rdi
leaq 0x1a0(%rsp), %rsi
callq 0x14816
movq 0x198(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x167ac
jmp 0xebea
jae 0xebc1
movl %r13d, 0x58(%rsp)
leaq 0x60(%rsp), %rdi
leaq 0x1a0(%rsp), %rsi
callq 0x14816
movq 0x188(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x167ac
jmp 0xebea
movl %r13d, 0x58(%rsp)
leaq 0x60(%rsp), %rdi
leaq 0x1a0(%rsp), %rsi
callq 0x14816
movq 0x190(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x167ac
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0xec07
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x3290
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0xec2c
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0xec51
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0xec6d
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0xec89
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0xeca5
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3290
movq %rbp, %rdi
callq 0x31c0
movq %rax, %rbp
movq 0x200(%rsp), %rdi
testq %rdi, %rdi
je 0xeccd
movq 0x210(%rsp), %rsi
subq %rdi, %rsi
callq 0x3290
movq 0x1e0(%rsp), %rdi
leaq 0x1f0(%rsp), %rax
cmpq %rax, %rdi
je 0xecf2
movq 0x1f0(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0x1c0(%rsp), %rdi
leaq 0x1d0(%rsp), %rax
cmpq %rax, %rdi
je 0xed17
movq 0x1d0(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0x1a0(%rsp), %rdi
leaq 0x1b0(%rsp), %rax
cmpq %rax, %rdi
je 0xed3c
movq 0x1b0(%rsp), %rsi
incq %rsi
callq 0x3290
cmpq (%rsp), %rbp
jne 0xe9b8
movb $0x1, %bl
movq 0x180(%rsp), %rdi
movq 0x178(%rsp), %rsi
callq 0x153ea
jmp 0xee28
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0xed7e
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0xed9a
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0x200(%rsp), %rdi
testq %rdi, %rdi
je 0xedb7
movq 0x210(%rsp), %rsi
subq %rdi, %rsi
callq 0x3290
movq 0x1e0(%rsp), %rdi
leaq 0x1f0(%rsp), %rax
cmpq %rax, %rdi
je 0xeddc
movq 0x1f0(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0x1c0(%rsp), %rdi
leaq 0x1d0(%rsp), %rax
cmpq %rax, %rdi
je 0xee01
movq 0x1d0(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0x1a0(%rsp), %rdi
leaq 0x1b0(%rsp), %rax
cmpq %rax, %rdi
je 0xee26
movq 0x1b0(%rsp), %rsi
incq %rsi
callq 0x3290
xorl %ebx, %ebx
movq 0xf8(%rsp), %rdi
leaq 0x108(%rsp), %rax
cmpq %rax, %rdi
je 0xee4d
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0x118(%rsp), %rdi
leaq 0x128(%rsp), %rax
cmpq %rax, %rdi
je 0xee72
movq 0x128(%rsp), %rsi
incq %rsi
callq 0x3290
movl %ebx, %eax
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xb1b1(%rip), %rdi      # 0x1a03e
leaq 0xac37(%rip), %rsi      # 0x19acb
leaq 0xb1c4(%rip), %rcx      # 0x1a05f
movl $0x98e, %edx            # imm = 0x98E
callq 0x3180
jmp 0xef65
jmp 0xeec0
jmp 0xef6a
jmp 0xeec0
jmp 0xef6a
movq %rax, %rbx
jmp 0xefd7
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x1458e
jmp 0xef6d
jmp 0xef6a
movq %rax, %rbx
jmp 0xef89
movq %rax, %rbx
movq 0x138(%rsp), %rdi
leaq 0x148(%rsp), %rax
cmpq %rax, %rdi
je 0xef14
movq 0x148(%rsp), %rsi
incq %rsi
callq 0x3290
jmp 0xef14
movq %rax, %rbx
jmp 0xefa5
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
leaq 0xe8(%rsp), %rax
cmpq %rax, %rdi
je 0xef3e
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x3290
jmp 0xef3e
movq %rax, %rbx
movq 0x158(%rsp), %rdi
leaq 0x168(%rsp), %rax
cmpq %rax, %rdi
je 0xef6d
movq 0x168(%rsp), %rsi
incq %rsi
callq 0x3290
jmp 0xef6d
movq %rax, %rbx
jmp 0xefb2
movq %rax, %rbx
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0xef89
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0xefa5
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3290
leaq 0x1a0(%rsp), %rdi
callq 0x1466e
movq 0xf8(%rsp), %rdi
leaq 0x108(%rsp), %rax
cmpq %rax, %rdi
je 0xefd7
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0x118(%rsp), %rdi
leaq 0x128(%rsp), %rax
cmpq %rax, %rdi
je 0xeffc
movq 0x128(%rsp), %rsi
incq %rsi
callq 0x3290
movq %rbx, %rdi
callq 0x3460