// File: /workspace/github_cpp_makefile_star2_O1/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), %ebp
addl %ebp, %ebp
cmpl $0x0, 0x14(%r13)
js 0xecb41
movq %r13, %rdi
callq 0xa0333
movq %r13, %rdi
callq 0xa03e9
orb $-0x80, 0x17(%r13)
xorps %xmm0, %xmm0
movaps %xmm0, 0xb0(%rsp)
movaps %xmm0, 0xa0(%rsp)
movaps %xmm0, 0x90(%rsp)
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movq $0x0, 0xc0(%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 0xecc55
cmpb $0x1, 0x4(%rax,%rcx,8)
je 0xecc55
movq 0x28(%r13), %rax
movl %ebx, %ecx
movq (%rax,%rcx,8), %rax
xorl %r14d, %r14d
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
andq %rax, %rcx
je 0xecc58
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
movl (%rax,%rdx), %esi
notl %esi
shrl $0x1f, %esi
addl %esi, %r14d
addq $0x18, %rdx
cmpq %rdx, %rcx
jne 0xecbe1
cmpl $0x2, %r14d
jl 0xecc55
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 0xbf39f
movq %rax, %r14
jmp 0xecc58
xorl %r14d, %r14d
movq 0x20(%r13), %rax
movl %r15d, %ecx
shrl %ecx
cmpl $0x0, (%rax,%rcx,8)
js 0xecd24
cmpb $0x1, 0x4(%rax,%rcx,8)
je 0xecd24
xorl $0x1, %r15d
movq 0x28(%r13), %rax
movl %r15d, %ecx
movq (%rax,%rcx,8), %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
andq %rax, %rcx
je 0xecd24
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 0xeccb3
cmpl $0x2, %esi
jl 0xecd24
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 0xbf39f
addq %rax, %r14
cmpq $0x0, 0x50(%rsp)
je 0xece2c
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 0xece1b
cmpb $0x1, 0x4(%rcx,%rax,8)
je 0xece1b
addl %ebp, %ebp
xorl %r12d, %r12d
orl %r12d, %ebp
movq 0x28(%r13), %rax
movq (%rax,%rbp,8), %rax
movq %rax, %rcx
andq %rbx, %rcx
je 0xece0a
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 0xecd9a
cmpl $0x2, %esi
jl 0xece0a
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 0xbf39f
addq %rax, %r14
leal 0x1(%r12), %eax
testl %r12d, %r12d
movl %eax, %r12d
je 0xecd63
incl %r15d
movq %r15, %rax
cmpq 0x50(%rsp), %r15
jb 0xecd3a
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