// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/Overlaps.cpp
// Function: bub_pop_merge(ma_ug_t*, ma_ug_t*, unsigned int, unsigned int, unsigned long, buf_t*, unsigned int, unsigned int, hap_cov_t*, unsigned int, utg_trans_t*, kvec_asg_arc_t_warp*, ma_hit_t_alloc*, ma_sub_t*, int, int, int, unsigned int*)
uint32_t bub_pop_merge(ma_ug_t *raw_ug, ma_ug_t *new_ug, uint32_t v0, uint32_t v1, uint64_t max_dist, buf_t *b, 
uint32_t positive_flag, uint32_t negative_flag, hap_cov_t *cov, uint32_t is_update_chain, utg_trans_t *o, kvec_asg_arc_t_warp *ae, 
ma_hit_t_alloc* src, ma_sub_t *sub, int32_t max_hang, int32_t min_ovlp, int32_t gap_fuzz, uint32_t *n_insert)
{
    ///do not pop bubble within new_ug; 
    uint32_t is_pop = asg_bub_pop1_primary_trio(new_ug->g, new_ug, v0, max_dist, b, positive_flag, negative_flag, 0, NULL, NULL, cov, is_update_chain, 1/**0**/, o);
    assert(is_pop); assert(b->S.a[0] == v1);

    ///b->S.a[0] is the sink of this bubble
    uint32_t i, v, qn, tn, tmp_c, u; asg_arc_t *a;
    asg_t *g = raw_ug->g; tmp_c = g->seq[b->S.a[0]>>1].c;
    
    ///assert(b->S.n == 1);
    ///first remove all nodes in this bubble
    for (i = 0; i < b->b.n; ++i) g->seq[b->b.a[i]>>1].c = ALTER_LABLE;
    

    ///v is the sink of this bubble
    v = b->S.a[0];
    ///recover node
    do {
        u = b->a[v].p; // u->v
        /****************************may have hap bugs********************************/
        ////g->seq[v>>1].c = PRIMARY_LABLE;
        g->seq[v>>1].c = HAP_LABLE;
        /****************************may have hap bugs********************************/
        v = u;
    } while (v != v0);
    ///especially for unitig graph, don't label beg and sink node of a bubble as HAP_LABLE
    ///since in unitig graph, a node may consist of a lot of reads
    g->seq[b->S.a[0]>>1].c = tmp_c;

    ///remove all edges (self/reverse for each edge) in this bubble
    for (i = 0; i < b->e.n; ++i) {
        a = &(new_ug->g->arc[b->e.a[i]]);///note:: new_ug->g here
        qn = a->ul>>33;
        tn = a->v>>1;
        if(g->seq[qn].c == ALTER_LABLE && g->seq[tn].c == ALTER_LABLE) continue;
        ///remove this edge self
        asg_arc_del(g, a->ul>>32, a->v, 1);
        ///remove the reverse direction
        asg_arc_del(g, a->v^1, a->ul>>32^1, 1);
    }

    ///v is the sink of this bubble
    v = b->S.a[0];
    ///recover node
    do {
        u = b->a[v].p; // u->v
        g->seq[v>>1].del = 0;
        asg_arc_rest(g, new_ug->g, u, v, raw_ug, ae, src, sub, max_hang, min_ovlp, gap_fuzz, n_insert);
        v = u;
    } while (v != v0);
    return is_pop;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r9, %rbx
movl %ecx, %ebp
movl %edx, %r12d
movq %rsi, %r13
movq %rdi, 0x8(%rsp)
movl 0x80(%rsp), %r9d
movl 0x88(%rsp), %eax
movq 0x90(%rsp), %rcx
movl 0x98(%rsp), %edx
movq 0xa0(%rsp), %rsi
movq 0x18(%r13), %rdi
subq $0x40, %rsp
movq %rsi, 0x38(%rsp)
movl %edx, 0x28(%rsp)
movq %rcx, 0x20(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rsp)
movl %eax, (%rsp)
movl $0x1, 0x30(%rsp)
movl $0x0, 0x8(%rsp)
movq %r13, %rsi
movl %r12d, %edx
movq %r8, %rcx
movq %rbx, %r8
callq 0xbf39f
addq $0x40, %rsp
testl %eax, %eax
je 0xe60dd
movq 0x18(%rbx), %rcx
movl (%rcx), %r11d
cmpl %ebp, %r11d
jne 0xe60e6
movq 0x8(%rsp), %rcx
movq 0x18(%rcx), %r15
movq 0x20(%r15), %rcx
movl %r11d, %edx
shrl %edx
movb 0x4(%rcx,%rdx,8), %sil
movq 0x38(%rbx), %rdi
testq %rdi, %rdi
je 0xe59b1
movq 0x48(%rbx), %r8
xorl %r9d, %r9d
movl (%r8,%r9,4), %r10d
shrl %r10d
movb $0x1, 0x4(%rcx,%r10,8)
incq %r9
movl %r9d, %r10d
cmpq %r10, %rdi
ja 0xe5999
movq %rax, 0x18(%rsp)
movq (%rbx), %rdi
movl %r11d, %r8d
leaq (%r8,%r8,8), %r9
leaq (%r9,%r9,2), %r9
addq %r8, %r9
movl (%rdi,%r9), %r8d
shrl %r11d
movb $0x2, 0x4(%rcx,%r11,8)
movl %r8d, %r11d
cmpl %r12d, %r8d
jne 0xe59b9
movb %sil, 0x4(%rcx,%rdx,8)
cmpq $0x0, 0x50(%rbx)
je 0xe5ae1
xorl %eax, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movq 0x18(%r13), %rdx
movq 0x8(%rdx), %rdx
movq 0x60(%rbx), %rsi
movl (%rsi,%rax,4), %esi
leaq (%rsi,%rsi,2), %rsi
leaq (%rdx,%rsi,8), %rdx
movq (%rdx), %rsi
movq 0x20(%r15), %rdi
movq %rsi, %r8
shrq $0x21, %r8
cmpb $0x1, 0x4(%rdi,%r8,8)
jne 0xe5a33
movl 0x8(%rdx), %r8d
shrl %r8d
cmpb $0x1, 0x4(%rdi,%r8,8)
je 0xe5ad5
movq 0x28(%r15), %rdi
shrq $0x20, %rsi
movq (%rdi,%rsi,8), %r8
movq %r8, %rdi
andq %rcx, %rdi
je 0xe5a7f
movl 0x8(%rdx), %esi
movq 0x8(%r15), %r9
shrq $0x20, %r8
shlq $0x3, %rdi
leaq (%rdi,%rdi,2), %rdi
leaq (%r8,%r8,2), %r8
leaq (%r9,%r8,8), %r8
addq $0xc, %r8
xorl %r9d, %r9d
cmpl %esi, -0x4(%r8,%r9)
jne 0xe5a76
orb $-0x80, 0x3(%r8,%r9)
addq $0x18, %r9
cmpq %r9, %rdi
jne 0xe5a69
movl 0x8(%rdx), %esi
xorq $0x1, %rsi
movq 0x28(%r15), %rdi
movq (%rdi,%rsi,8), %rdi
movq %rdi, %rsi
andq %rcx, %rsi
je 0xe5ad5
movl 0x4(%rdx), %edx
movq 0x8(%r15), %r8
shrq $0x20, %rdi
shlq $0x3, %rsi
leaq (%rsi,%rsi,2), %rsi
leaq (%rdi,%rdi,2), %rdi
leaq (%r8,%rdi,8), %rdi
addq $0xc, %rdi
xorl %r8d, %r8d
movl -0x4(%rdi,%r8), %r9d
xorl %edx, %r9d
cmpl $0x1, %r9d
jne 0xe5acc
orb $-0x80, 0x3(%rdi,%r8)
addq $0x18, %r8
cmpq %r8, %rsi
jne 0xe5ab8
incl %eax
cmpq %rax, 0x50(%rbx)
ja 0xe59f3
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
movq 0x18(%rbx), %rax
movl (%rax), %eax
movl %r12d, 0x14(%rsp)
movq %r13, 0x28(%rsp)
movq %rbx, 0x20(%rsp)
movq (%rbx), %rcx
movl %eax, %edx
leaq (%rdx,%rdx,8), %rsi
leaq (%rsi,%rsi,2), %rsi
addq %rdx, %rsi
movl (%rcx,%rsi), %ebp
movq 0x20(%r15), %rdx
movl %eax, %ecx
shrl %ecx
andl $0x7fffffff, (%rdx,%rcx,8) # imm = 0x7FFFFFFF
movq 0x18(%r13), %rdx
movq 0x28(%r15), %rsi
movq (%rsi,%rbp,8), %rdi
testl %edi, %edi
je 0xe5b63
movq 0x8(%r15), %rsi
movq %rdi, %r8
shrq $0x20, %r8
movl %edi, %r9d
leaq (%r8,%r8,2), %rdi
leaq (%rsi,%rdi,8), %r8
addq $0xc, %r8
shlq $0x3, %r9
leaq (%r9,%r9,2), %r10
xorl %r9d, %r9d
cmpl %eax, -0x4(%r8,%r9)
je 0xe5b96
addq $0x18, %r9
cmpq %r9, %r10
jne 0xe5b53
movq 0x28(%rdx), %rsi
movq (%rsi,%rbp,8), %rdi
testl %edi, %edi
je 0xe5b92
movq %rdi, %rsi
shrq $0x20, %rsi
leaq (%rsi,%rsi,2), %rsi
shlq $0x3, %rsi
addq 0x8(%rdx), %rsi
movl %edi, %edi
cmpl %eax, 0x8(%rsi)
je 0xe5c00
addq $0x18, %rsi
decq %rdi
jne 0xe5b84
xorl %esi, %esi
jmp 0xe5c04
leaq (%rsi,%rdi,8), %rcx
andb $0x7f, 0xf(%r9,%rcx)
xorl $0x1, %eax
movq 0x28(%r15), %rcx
movq (%rcx,%rax,8), %rcx
testl %ecx, %ecx
je 0xe6004
movq 0x8(%r15), %rax
movq %rcx, %rdx
shrq $0x20, %rdx
movl %ecx, %esi
leaq (%rdx,%rdx,2), %rcx
leaq (%rax,%rcx,8), %rdx
addq $0xc, %rdx
shlq $0x3, %rsi
leaq (%rsi,%rsi,2), %rdi
xorl %esi, %esi
movl -0x4(%rdx,%rsi), %r8d
xorl %ebp, %r8d
cmpl $0x1, %r8d
je 0xe5bf2
addq $0x18, %rsi
cmpq %rsi, %rdi
jne 0xe5bd6
jmp 0xe6004
leaq (%rax,%rcx,8), %rax
andb $0x7f, 0xf(%rsi,%rax)
jmp 0xe5fa7
andb $0x7f, 0xf(%rsi)
testq %rsi, %rsi
je 0xe6023
movq 0x28(%r15), %rdi
movq (%rdi,%rbp,8), %rdi
movq %rdi, %r9
andq %r14, %r9
je 0xe6042
movq 0x8(%r15), %r10
movq %rdi, %r8
shrq $0x20, %r8
leaq (%r8,%r8,2), %r11
leaq (%r10,%r11,8), %r8
leaq (,%r9,8), %r12
leaq (%r12,%r12,2), %r12
xorl %r13d, %r13d
cmpl $0x0, 0xc(%r8,%r13)
jns 0xe5fc6
addq $0x18, %r13
cmpq %r13, %r12
jne 0xe5c43
movq (%rsi), %r12
cmpq %r12, (%r8)
jae 0xe5c8c
leaq (%r10,%r11,8), %r13
addq $0x18, %r13
movl $0x1, %r10d
movq %r10, %r11
cmpq %r10, %r9
je 0xe5c94
leaq 0x1(%r11), %r10
leaq 0x18(%r13), %rbx
cmpq %r12, (%r13)
movq %rbx, %r13
jb 0xe5c6e
decq %r10
jmp 0xe5c97
movb $0x1, %r9b
xorl %r10d, %r10d
jmp 0xe5c9e
movq %rdi, %r10
cmpq %r9, %r11
setb %r9b
addl %r14d, %edi
testb %r9b, %r9b
cmovneq %r10, %rdi
movl %edi, %edi
leaq (%rdi,%rdi,2), %rdi
movq 0x10(%rsi), %r9
movq %r9, 0x10(%r8,%rdi,8)
movups (%rsi), %xmm0
movups %xmm0, (%r8,%rdi,8)
movl %eax, %edi
xorl $0x1, %edi
movq 0x28(%rdx), %rsi
movq (%rsi,%rdi,8), %r8
testl %r8d, %r8d
je 0xe5cfd
movq %r8, %rsi
shrq $0x20, %rsi
leaq (%rsi,%rsi,2), %rsi
shlq $0x3, %rsi
addq 0x8(%rdx), %rsi
movl %r8d, %edx
movl 0x8(%rsi), %r8d
xorl %ebp, %r8d
cmpl $0x1, %r8d
je 0xe5d01
addq $0x18, %rsi
decq %rdx
jne 0xe5ce7
xorl %esi, %esi
jmp 0xe5d05
andb $0x7f, 0xf(%rsi)
testq %rsi, %rsi
je 0xe6061
movq 0x28(%r15), %rdx
movq (%rdx,%rdi,8), %rdx
movq %rdx, %r8
andq %r14, %r8
je 0xe6080
movq 0x8(%r15), %r9
movq %rdx, %rdi
shrq $0x20, %rdi
leaq (%rdi,%rdi,2), %r10
leaq (%r9,%r10,8), %rdi
leaq (,%r8,8), %r11
leaq (%r11,%r11,2), %r11
xorl %r12d, %r12d
cmpl $0x0, 0xc(%rdi,%r12)
jns 0xe5fe5
addq $0x18, %r12
cmpq %r12, %r11
jne 0xe5d44
movq (%rsi), %r11
cmpq %r11, (%rdi)
jae 0xe5d8e
leaq (%r9,%r10,8), %r12
addq $0x18, %r12
movl $0x1, %r9d
movq %r9, %r10
cmpq %r9, %r8
je 0xe5d96
leaq 0x1(%r10), %r9
leaq 0x18(%r12), %rbx
cmpq %r11, (%r12)
movq %rbx, %r12
jb 0xe5d6f
decq %r9
jmp 0xe5d99
movb $0x1, %r8b
xorl %r9d, %r9d
jmp 0xe5da0
movq %rdx, %r9
cmpq %r8, %r10
setb %r8b
addl %r14d, %edx
testb %r8b, %r8b
cmovneq %r9, %rdx
movl %edx, %edx
leaq (%rdx,%rdx,2), %rdx
movq 0x10(%rsi), %r8
movq %r8, 0x10(%rdi,%rdx,8)
movups (%rsi), %xmm0
movups %xmm0, (%rdi,%rdx,8)
movl %ebp, %edx
shrl %edx
testb $0x1, %bpl
jne 0xe5de9
movq 0x8(%rsp), %rsi
movq 0x10(%rsi), %rsi
leaq (%rdx,%rdx,4), %rdx
movq 0x18(%rsi,%rdx,8), %rdi
movl 0x10(%rsi,%rdx,8), %edx
decl %edx
movl 0x4(%rdi,%rdx,8), %r13d
jmp 0xe5e03
movq 0x8(%rsp), %rsi
movq 0x10(%rsi), %rsi
leaq (%rdx,%rdx,4), %rdx
movq 0x18(%rsi,%rdx,8), %rdx
movl 0x4(%rdx), %r13d
xorl $0x1, %r13d
testb $0x1, %al
jne 0xe5e1f
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rax
leaq (%rcx,%rcx,4), %rcx
movq 0x18(%rax,%rcx,8), %rax
movl 0x4(%rax), %r12d
jmp 0xe5e40
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rax
leaq (%rcx,%rcx,4), %rcx
movq 0x18(%rax,%rcx,8), %rdx
movl 0x10(%rax,%rcx,8), %eax
decl %eax
movl 0x4(%rdx,%rax,8), %r12d
xorl $0x1, %r12d
movq 0xb0(%rsp), %rdi
movq 0xb8(%rsp), %rsi
movl 0xc0(%rsp), %ecx
movl 0xc8(%rsp), %r8d
movl %r13d, %r9d
leaq 0x30(%rsp), %rax
pushq %rax
pushq %r12
callq 0xb2ced
addq $0x10, %rsp
testl %eax, %eax
je 0xe609f
movq 0xa8(%rsp), %rsi
movq 0x8(%rsi), %rax
cmpq %rax, (%rsi)
jne 0xe5ebd
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rcx
movq %rcx, 0x8(%rsi)
movq 0x10(%rsi), %rdi
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %rsi
callq 0x2370
movq 0xa8(%rsp), %rsi
movq %rax, 0x10(%rsi)
movq (%rsi), %rax
movq 0x10(%rsi), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%rsi)
leaq (%rax,%rax,2), %rax
movq 0x40(%rsp), %rdx
movq %rdx, 0x10(%rcx,%rax,8)
movups 0x30(%rsp), %xmm0
movups %xmm0, (%rcx,%rax,8)
xorl $0x1, %r12d
xorl $0x1, %r13d
movq 0xb0(%rsp), %rdi
movq %rsi, %r14
movq 0xb8(%rsp), %rsi
movl 0xc0(%rsp), %ecx
movl 0xc8(%rsp), %r8d
movl %r12d, %r9d
leaq 0x30(%rsp), %rax
pushq %rax
pushq %r13
callq 0xb2ced
addq $0x10, %rsp
testl %eax, %eax
je 0xe60be
movq 0x8(%r14), %rax
cmpq %rax, (%r14)
movq 0x20(%rsp), %rbx
movl 0x14(%rsp), %r12d
movq 0x28(%rsp), %r13
jne 0xe5f71
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rcx
movq %rcx, 0x8(%r14)
movq 0x10(%r14), %rdi
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %rsi
callq 0x2370
movq 0xa8(%rsp), %r14
movq %rax, 0x10(%r14)
movq (%r14), %rax
movq 0x10(%r14), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%r14)
leaq (%rax,%rax,2), %rax
movq 0x40(%rsp), %rdx
movq %rdx, 0x10(%rcx,%rax,8)
movups 0x30(%rsp), %xmm0
movups %xmm0, (%rcx,%rax,8)
movq 0xd8(%rsp), %rax
addl $0x2, (%rax)
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
movl %ebp, %eax
cmpl %r12d, %ebp
jne 0xe5afc
movq 0x18(%rsp), %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x147133(%rip), %rdi    # 0x22d100
leaq 0x143ccd(%rip), %rsi    # 0x229ca1
leaq 0x147086(%rip), %rcx    # 0x22d061
movl $0x67a3, %edx           # imm = 0x67A3
callq 0x2110
leaq 0x147114(%rip), %rdi    # 0x22d100
leaq 0x143cae(%rip), %rsi    # 0x229ca1
leaq 0x147067(%rip), %rcx    # 0x22d061
movl $0x67b1, %edx           # imm = 0x67B1
callq 0x2110
leaq 0x1440a3(%rip), %rdi    # 0x22a0ae
leaq 0x143c8f(%rip), %rsi    # 0x229ca1
leaq 0x147048(%rip), %rcx    # 0x22d061
movl $0x6793, %edx           # imm = 0x6793
callq 0x2110
leaq 0x154939(%rip), %rdi    # 0x23a963
leaq 0x143c70(%rip), %rsi    # 0x229ca1
leaq 0x147029(%rip), %rcx    # 0x22d061
movl $0x67a0, %edx           # imm = 0x67A0
callq 0x2110
leaq 0x144069(%rip), %rdi    # 0x22a0b2
leaq 0x143c51(%rip), %rsi    # 0x229ca1
leaq 0x14700a(%rip), %rcx    # 0x22d061
movl $0x67a2, %edx           # imm = 0x67A2
callq 0x2110
leaq 0x1548fb(%rip), %rdi    # 0x23a963
leaq 0x143c32(%rip), %rsi    # 0x229ca1
leaq 0x146feb(%rip), %rcx    # 0x22d061
movl $0x67ae, %edx           # imm = 0x67AE
callq 0x2110
leaq 0x14402b(%rip), %rdi    # 0x22a0b2
leaq 0x143c13(%rip), %rsi    # 0x229ca1
leaq 0x146fcc(%rip), %rcx    # 0x22d061
movl $0x67b0, %edx           # imm = 0x67B0
callq 0x2110
leaq 0x147064(%rip), %rdi    # 0x22d10a
leaq 0x143bf4(%rip), %rsi    # 0x229ca1
leaq 0x146fad(%rip), %rcx    # 0x22d061
movl $0x67b8, %edx           # imm = 0x67B8
callq 0x2110
leaq 0x14708c(%rip), %rdi    # 0x22d151
leaq 0x143bd5(%rip), %rsi    # 0x229ca1
leaq 0x146f8e(%rip), %rcx    # 0x22d061
movl $0x67bb, %edx           # imm = 0x67BB
callq 0x2110
leaq 0x145dc4(%rip), %rdi    # 0x22bea8
jmp 0xe60ed
leaq 0x145eac(%rip), %rdi    # 0x22bf99
leaq 0x143bad(%rip), %rsi    # 0x229ca1
leaq 0x145db4(%rip), %rcx    # 0x22beaf
movl $0x67c7, %edx           # imm = 0x67C7
callq 0x2110