// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/Overlaps.cpp
// Function: pop_bubble_at_tangle(ma_ug_t*, unsigned long, unsigned long*, unsigned long, unsigned int, unsigned int, unsigned int, unsigned int)
int pop_bubble_at_tangle(ma_ug_t *ug, uint64_t max_dist, uint64_t* nodes, uint64_t n, uint32_t beg, uint32_t end,
uint32_t positive_flag, uint32_t negative_flag)
{
    asg_t *g = ug->g;
    uint32_t i, v, k, n_vtx = g->n_seq*2;
    uint64_t n_pop = 0;
    buf_t b;
    if (!g->is_symm) asg_symm(g);
    memset(&b, 0, sizeof(buf_t));
    b.a = (binfo_t*)calloc(n_vtx, sizeof(binfo_t));

    v = beg;
    if((!g->seq[v>>1].del)&&(g->seq[v>>1].c!=ALTER_LABLE)&&get_real_length(g, v, NULL)>=2)
    {
        n_pop += asg_bub_pop1_primary_trio(ug->g, ug, v, max_dist, &b, positive_flag, negative_flag, 1, NULL, NULL, NULL, 0, 1, NULL);
    }

    v = end^1;
    if((!g->seq[v>>1].del)&&(g->seq[v>>1].c!=ALTER_LABLE)&&get_real_length(g, v, NULL)>=2)
    {
        n_pop += asg_bub_pop1_primary_trio(ug->g, ug, v, max_dist, &b, positive_flag, negative_flag, 1, NULL, NULL, NULL, 0, 1, NULL);
    }


    for (i = 0; i < n; i++)
    {
        v = (uint32_t)nodes[i];
        if(g->seq[v].del) continue;
        if(g->seq[v].c == ALTER_LABLE) continue;
        v = v<<1;

        for (k = 0; k < 2; k++)
        {
            v = v|k;
            if(get_real_length(g, v, NULL)<=1) continue;
            n_pop += asg_bub_pop1_primary_trio(ug->g, ug, v, max_dist, &b, positive_flag, negative_flag, 1, NULL, NULL, NULL, 0, 1, NULL);
        }
    }

    free(b.a); free(b.S.a); free(b.T.a); free(b.b.a); free(b.e.a);
    ///if (n_pop) asg_cleanup(g);
    return n_pop;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movl %r9d, 0x4c(%rsp)
movl %r8d, %ebx
movq %rcx, %r15
movq %rdx, 0x58(%rsp)
movq %rsi, 0x40(%rsp)
movq %rdi, %r12
movq 0x18(%rdi), %r13
movl 0x14(%r13), %eax
leal (%rax,%rax), %ebp
testl %eax, %eax
js 0xaf42c
movq %r13, %rdi
callq 0x69638
xorps %xmm0, %xmm0
movups %xmm0, 0xb8(%rsp)
movups %xmm0, 0xa8(%rsp)
movups %xmm0, 0x98(%rsp)
movups %xmm0, 0x88(%rsp)
movups %xmm0, 0x78(%rsp)
movups %xmm0, 0x68(%rsp)
movl %ebp, %edi
pushq $0x1c
popq %rsi
callq 0x2120
movq %rax, 0x60(%rsp)
movq 0x20(%r13), %rax
movl %ebx, %ecx
shrl %ecx
cmpl $0x0, (%rax,%rcx,8)
js 0xaf481
cmpb $0x1, 0x4(%rax,%rcx,8)
jne 0xaf607
xorl %r14d, %r14d
movq 0x20(%r13), %rax
movl 0x4c(%rsp), %ebx
movl %ebx, %ecx
shrl %ecx
cmpl $0x0, (%rax,%rcx,8)
js 0xaf503
cmpb $0x1, 0x4(%rax,%rcx,8)
je 0xaf503
xorl $0x1, %ebx
movq %r13, %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0xc2e7a
cmpl $0x2, %eax
jl 0xaf503
movq 0x18(%r12), %rdi
pushq $0x1
popq %rax
movl %eax, 0x30(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rsp)
andq $0x0, 0x38(%rsp)
andl $0x0, 0x28(%rsp)
movl %eax, 0x8(%rsp)
andq $0x0, 0x20(%rsp)
movl 0x108(%rsp), %eax
movl %eax, (%rsp)
leaq 0x60(%rsp), %r8
movq %r12, %rsi
movl %ebx, %edx
movq 0x40(%rsp), %rcx
movl 0x100(%rsp), %r9d
callq 0x84a86
addq %rax, %r14
xorl %ebx, %ebx
movq %r15, 0x50(%rsp)
movl %ebx, %ebx
cmpq %r15, %rbx
jae 0xaf5b7
movq 0x58(%rsp), %rax
movq (%rax,%rbx,8), %rbp
movl %ebp, %eax
movq 0x20(%r13), %rcx
cmpl $0x0, (%rcx,%rax,8)
js 0xaf5b0
cmpb $0x1, 0x4(%rcx,%rax,8)
je 0xaf5b0
addl %ebp, %ebp
xorl %r15d, %r15d
cmpl $0x2, %r15d
je 0xaf5ab
orl %r15d, %ebp
movq %r13, %rdi
movl %ebp, %esi
xorl %edx, %edx
callq 0xc2e7a
cmpl $0x2, %eax
jl 0xaf5a6
movq 0x18(%r12), %rdi
pushq $0x1
popq %rax
movl %eax, 0x30(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rsp)
andq $0x0, 0x38(%rsp)
andl $0x0, 0x28(%rsp)
andq $0x0, 0x20(%rsp)
movl %eax, 0x8(%rsp)
movl 0x108(%rsp), %eax
movl %eax, (%rsp)
movq %r12, %rsi
movl %ebp, %edx
movq 0x40(%rsp), %rcx
leaq 0x60(%rsp), %r8
movl 0x100(%rsp), %r9d
callq 0x84a86
addq %rax, %r14
incl %r15d
jmp 0xaf53a
movq 0x50(%rsp), %r15
incl %ebx
jmp 0xaf50a
movq 0x60(%rsp), %rdi
callq 0x2220
movq 0x78(%rsp), %rdi
callq 0x2220
movq 0x90(%rsp), %rdi
callq 0x2220
movq 0xa8(%rsp), %rdi
callq 0x2220
movq 0xc0(%rsp), %rdi
callq 0x2220
movl %r14d, %eax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r14d, %r14d
movq %r13, %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0xc2e7a
cmpl $0x2, %eax
jl 0xaf484
movq 0x18(%r12), %rdi
pushq $0x1
popq %rax
movl %eax, 0x30(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rsp)
andq $0x0, 0x38(%rsp)
andl $0x0, 0x28(%rsp)
movl %eax, 0x8(%rsp)
andq $0x0, 0x20(%rsp)
movl 0x108(%rsp), %eax
movl %eax, (%rsp)
leaq 0x60(%rsp), %r8
movq %r12, %rsi
movl %ebx, %edx
movq 0x40(%rsp), %rcx
movl 0x100(%rsp), %r9d
callq 0x84a86
movq %rax, %r14
jmp 0xaf484