// File: 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
movq %rsp, %rbp
subq $0xf0, %rsp
movl 0x18(%rbp), %eax
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movl %r9d, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shll %eax
movl %eax, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movq -0x30(%rbp), %rax
movl 0x14(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
jne 0x147966
movq -0x30(%rbp), %rdi
callq 0xce020
leaq -0xb0(%rbp), %rdi
xorl %esi, %esi
movl $0x68, %edx
callq 0x2100
movl -0x40(%rbp), %eax
movl %eax, %edi
movl $0x1c, %esi
callq 0x2140
movq %rax, -0xb0(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x38(%rbp)
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x38(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
jne 0x147a58
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x38(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movzbl 0x4(%rax,%rcx,8), %eax
cmpl $0x1, %eax
je 0x147a58
movq -0x30(%rbp), %rdi
movl -0x38(%rbp), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x166b50
cmpl $0x2, %eax
jl 0x147a58
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x8(%rbp), %rsi
movl -0x38(%rbp), %edx
movq -0x10(%rbp), %rcx
movl 0x10(%rbp), %r9d
movl 0x18(%rbp), %eax
leaq -0xb0(%rbp), %r8
xorl %r10d, %r10d
xorl %r10d, %r10d
movl %eax, (%rsp)
movl $0x1, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
movq $0x0, 0x20(%rsp)
movl $0x0, 0x28(%rsp)
movl $0x1, 0x30(%rsp)
movq $0x0, 0x38(%rsp)
callq 0xfe040
addq -0x48(%rbp), %rax
movq %rax, -0x48(%rbp)
movl -0x28(%rbp), %eax
xorl $0x1, %eax
movl %eax, -0x38(%rbp)
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x38(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
jne 0x147b24
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x38(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movzbl 0x4(%rax,%rcx,8), %eax
cmpl $0x1, %eax
je 0x147b24
movq -0x30(%rbp), %rdi
movl -0x38(%rbp), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x166b50
cmpl $0x2, %eax
jl 0x147b24
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x8(%rbp), %rsi
movl -0x38(%rbp), %edx
movq -0x10(%rbp), %rcx
movl 0x10(%rbp), %r9d
movl 0x18(%rbp), %eax
leaq -0xb0(%rbp), %r8
xorl %r10d, %r10d
xorl %r10d, %r10d
movl %eax, (%rsp)
movl $0x1, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
movq $0x0, 0x20(%rsp)
movl $0x0, 0x28(%rsp)
movl $0x1, 0x30(%rsp)
movq $0x0, 0x38(%rsp)
callq 0xfe040
addq -0x48(%rbp), %rax
movq %rax, -0x48(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpq -0x20(%rbp), %rax
jae 0x147c45
movq -0x18(%rbp), %rax
movl -0x34(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x38(%rbp)
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x38(%rbp), %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x147b61
jmp 0x147c37
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x38(%rbp), %ecx
movzbl 0x4(%rax,%rcx,8), %eax
cmpl $0x1, %eax
jne 0x147b7b
jmp 0x147c37
movl -0x38(%rbp), %eax
shll %eax
movl %eax, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
cmpl $0x2, -0x3c(%rbp)
jae 0x147c35
movl -0x38(%rbp), %eax
orl -0x3c(%rbp), %eax
movl %eax, -0x38(%rbp)
movq -0x30(%rbp), %rdi
movl -0x38(%rbp), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x166b50
cmpl $0x1, %eax
jg 0x147bb4
jmp 0x147c27
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x8(%rbp), %rsi
movl -0x38(%rbp), %edx
movq -0x10(%rbp), %rcx
movl 0x10(%rbp), %r9d
movl 0x18(%rbp), %eax
leaq -0xb0(%rbp), %r8
xorl %r10d, %r10d
xorl %r10d, %r10d
movl %eax, (%rsp)
movl $0x1, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
movq $0x0, 0x20(%rsp)
movl $0x0, 0x28(%rsp)
movl $0x1, 0x30(%rsp)
movq $0x0, 0x38(%rsp)
callq 0xfe040
addq -0x48(%rbp), %rax
movq %rax, -0x48(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x147b8a
jmp 0x147c37
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x147b2b
movq -0xb0(%rbp), %rdi
callq 0x2210
movq -0x98(%rbp), %rdi
callq 0x2210
movq -0x80(%rbp), %rdi
callq 0x2210
movq -0x68(%rbp), %rdi
callq 0x2210
movq -0x50(%rbp), %rdi
callq 0x2210
movq -0x48(%rbp), %rax
addq $0xf0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)