// File: /workspace/github_cpp_makefile_star2_O3/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, %r15d
movl %r8d, %ebx
movq %rcx, 0x50(%rsp)
movq %rdx, 0x58(%rsp)
movq %rsi, 0x48(%rsp)
movq %rdi, 0x40(%rsp)
movq 0x18(%rdi), %r13
movl 0x14(%r13), %eax
leal (%rax,%rax), %ebp
testl %eax, %eax
js 0xee46a
movq %r13, %rdi
callq 0xa0ab6
movq %r13, %rdi
callq 0xa0b79
orb $-0x80, 0x17(%r13)
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
movl $0x1c, %esi
callq 0x2120
movq %rax, 0x60(%rsp)
movq 0x20(%r13), %rax
movl %ebx, %ecx
shrl %ecx
cmpl $0x0, (%rax,%rcx,8)
js 0xee576
cmpb $0x1, 0x4(%rax,%rcx,8)
je 0xee576
movq 0x28(%r13), %rcx
movl %ebx, %edx
movq (%rcx,%rdx,8), %rcx
xorl %r14d, %r14d
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
andq %rcx, %rdx
je 0xee579
movq 0x8(%r13), %rsi
shrq $0x20, %rcx
leaq (%rcx,%rcx,2), %rcx
leaq (%rsi,%rcx,8), %rcx
addq $0xc, %rcx
shlq $0x3, %rdx
leaq (%rdx,%rdx,2), %rdx
xorl %esi, %esi
movl (%rcx,%rsi), %edi
notl %edi
shrl $0x1f, %edi
addl %edi, %r14d
addq $0x18, %rsi
cmpq %rsi, %rdx
jne 0xee4fe
cmpl $0x2, %r14d
jl 0xee576
movq 0x40(%rsp), %rsi
movq 0x18(%rsi), %rdi
xorl %eax, %eax
movq %rax, 0x38(%rsp)
movl $0x1, %ecx
movl %ecx, 0x30(%rsp)
movq %rax, 0x20(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rsp)
movl %ecx, 0x8(%rsp)
movl 0x108(%rsp), %eax
movl %eax, (%rsp)
movl $0x0, 0x28(%rsp)
leaq 0x60(%rsp), %r8
movl %ebx, %edx
movq 0x48(%rsp), %rcx
movl 0x100(%rsp), %r9d
callq 0xc02d6
movq %rax, %r14
movq 0x20(%r13), %rax
jmp 0xee579
xorl %r14d, %r14d
movl %r15d, %ecx
shrl %ecx
cmpl $0x0, (%rax,%rcx,8)
js 0xee641
cmpb $0x1, 0x4(%rax,%rcx,8)
je 0xee641
xorl $0x1, %r15d
movq 0x28(%r13), %rax
movl %r15d, %ecx
movq (%rax,%rcx,8), %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
andq %rax, %rcx
je 0xee641
movq 0x8(%r13), %rdx
shrq $0x20, %rax
leaq (%rax,%rax,2), %rax
leaq (%rdx,%rax,8), %rax
addq $0xc, %rax
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %rcx
xorl %edx, %edx
xorl %esi, %esi
movl (%rax,%rdx), %edi
notl %edi
shrl $0x1f, %edi
addl %edi, %esi
addq $0x18, %rdx
cmpq %rdx, %rcx
jne 0xee5d0
cmpl $0x2, %esi
jl 0xee641
movq 0x40(%rsp), %rsi
movq 0x18(%rsi), %rdi
xorl %eax, %eax
movq %rax, 0x38(%rsp)
movl $0x1, %ecx
movl %ecx, 0x30(%rsp)
movq %rax, 0x20(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rsp)
movl %ecx, 0x8(%rsp)
movl 0x108(%rsp), %eax
movl %eax, (%rsp)
movl $0x0, 0x28(%rsp)
leaq 0x60(%rsp), %r8
movl %r15d, %edx
movq 0x48(%rsp), %rcx
movl 0x100(%rsp), %r9d
callq 0xc02d6
addq %rax, %r14
cmpq $0x0, 0x50(%rsp)
je 0xee752
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
xorl %eax, %eax
xorl %r15d, %r15d
movq 0x58(%rsp), %rcx
movq (%rcx,%rax,8), %rbp
movl %ebp, %eax
movq 0x20(%r13), %rcx
cmpl $0x0, (%rcx,%rax,8)
js 0xee741
cmpb $0x1, 0x4(%rcx,%rax,8)
je 0xee741
addl %ebp, %ebp
xorl %eax, %eax
movb $0x1, %r12b
movl %ebp, %ecx
movl %eax, %ebp
orl %ecx, %ebp
movq 0x28(%r13), %rax
movq (%rax,%rbp,8), %rax
movq %rax, %rcx
andq %rbx, %rcx
je 0xee72c
movq 0x8(%r13), %rdx
shrq $0x20, %rax
leaq (%rax,%rax,2), %rax
leaq (%rdx,%rax,8), %rax
addq $0xc, %rax
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %rcx
xorl %edx, %edx
xorl %esi, %esi
movl (%rax,%rdx), %edi
notl %edi
shrl $0x1f, %edi
addl %edi, %esi
addq $0x18, %rdx
cmpq %rdx, %rcx
jne 0xee6bc
cmpl $0x2, %esi
jl 0xee72c
movq 0x40(%rsp), %rsi
movq 0x18(%rsi), %rdi
xorl %eax, %eax
movq %rax, 0x38(%rsp)
movl $0x1, %ecx
movl %ecx, 0x30(%rsp)
movq %rax, 0x20(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rsp)
movl %ecx, 0x8(%rsp)
movl 0x108(%rsp), %eax
movl %eax, (%rsp)
movl $0x0, 0x28(%rsp)
movl %ebp, %edx
movq 0x48(%rsp), %rcx
leaq 0x60(%rsp), %r8
movl 0x100(%rsp), %r9d
callq 0xc02d6
addq %rax, %r14
movl $0x1, %eax
testb $0x1, %r12b
movl $0x0, %r12d
jne 0xee682
incl %r15d
movq %r15, %rax
cmpq 0x50(%rsp), %r15
jb 0xee657
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