// File: /workspace/github_cpp_makefile_star2_O2/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 $0x38, %rsp
movq %r9, %rbx
movl %ecx, %r12d
movl %edx, %r14d
movq %rdi, 0x8(%rsp)
movl 0x70(%rsp), %r9d
movl 0x78(%rsp), %eax
movq 0x80(%rsp), %rcx
movl 0x88(%rsp), %edx
movq 0x90(%rsp), %r10
movq 0x18(%rsi), %rdi
subq $0x40, %rsp
movq %r10, 0x38(%rsp)
movl %edx, 0x28(%rsp)
movq %rcx, 0x20(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rsp)
andl $0x0, 0x8(%rsp)
movl %eax, (%rsp)
movl $0x1, 0x30(%rsp)
movq %rsi, 0x50(%rsp)
movl %r14d, %edx
movq %r8, %rcx
movq %rbx, %r8
callq 0x84a86
addq $0x40, %rsp
movq %rax, %r9
testl %r9d, %r9d
je 0xa9a48
movq 0x18(%rbx), %rax
cmpl %r12d, (%rax)
jne 0xa9a51
movq 0x98(%rsp), %rbp
movq 0x8(%rsp), %rax
movq 0x18(%rax), %r13
movq 0x20(%r13), %rax
movl %r12d, %ecx
shrl %ecx
movb 0x4(%rax,%rcx,8), %dl
movq 0x38(%rbx), %rsi
xorl %edi, %edi
movl %edi, %edi
cmpq %rdi, %rsi
jbe 0xa9434
movq 0x48(%rbx), %r8
movl (%r8,%rdi,4), %r8d
shrl %r8d
movb $0x1, 0x4(%rax,%r8,8)
incl %edi
jmp 0xa9418
movq %r9, 0x18(%rsp)
movq (%rbx), %rsi
movl %r12d, %edi
imulq $0x1c, %rdi, %rdi
movl (%rsi,%rdi), %edi
shrl %r12d
movb $0x2, 0x4(%rax,%r12,8)
movl %edi, %r12d
cmpl %r14d, %edi
jne 0xa943c
movl %r14d, 0x4(%rsp)
movb %dl, 0x4(%rax,%rcx,8)
xorl %r14d, %r14d
pushq $0x1
popq %r15
movl %r14d, %r14d
cmpq %r14, 0x50(%rbx)
jbe 0xa94e1
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x8(%rax), %r12
movq 0x60(%rbx), %rax
movl (%rax,%r14,4), %eax
imulq $0x18, %rax, %rax
movq (%r12,%rax), %rsi
movq 0x20(%r13), %rcx
movq %rsi, %rdx
shrq $0x21, %rdx
cmpb $0x1, 0x4(%rcx,%rdx,8)
movl 0x8(%r12,%rax), %edx
jne 0xa94af
movl %edx, %edi
shrl %edi
cmpb $0x1, 0x4(%rcx,%rdi,8)
je 0xa94dc
addq %rax, %r12
shrq $0x20, %rsi
movq %r13, %rdi
movl %r15d, %ecx
callq 0x6db50
movl 0x4(%r12), %edx
movl 0x8(%r12), %esi
xorl $0x1, %esi
xorl $0x1, %edx
movq %r13, %rdi
movl %r15d, %ecx
callq 0x6db50
incl %r14d
jmp 0xa9467
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movq 0x18(%rbx), %rax
movl (%rax), %r14d
movl 0x4(%rsp), %r15d
movl %r14d, %eax
movq (%rbx), %rcx
movl %r14d, %edx
imulq $0x1c, %rdx, %rdx
movl (%rcx,%rdx), %r14d
movq 0x20(%r13), %rdx
movl %eax, %ecx
shrl %ecx
andl $0x7fffffff, (%rdx,%rcx,8) # imm = 0x7FFFFFFF
movq 0x10(%rsp), %rdx
movq 0x18(%rdx), %rdx
movq 0x8(%r13), %rsi
movq 0x28(%r13), %rdi
movq (%rdi,%r14,8), %rdi
movl %edi, %r9d
shrq $0x20, %rdi
imulq $0x18, %rdi, %rdi
leaq (%rsi,%rdi), %r8
addq $-0xc, %r8
imulq $0x18, %r9, %r9
addq $0x18, %r9
xorl %r11d, %r11d
leaq 0x18(%r11), %r10
cmpq %r10, %r9
je 0xa95b9
cmpl %eax, 0x14(%r8,%r11)
movq %r10, %r11
jne 0xa9546
addq %rdi, %rsi
andb $0x7f, -0x9(%r10,%rsi)
xorl $0x1, %eax
movq 0x8(%r13), %rcx
movq 0x28(%r13), %rdx
movq (%rdx,%rax,8), %rax
movl %eax, %esi
shrq $0x20, %rax
imulq $0x18, %rax, %rax
leaq (%rcx,%rax), %rdx
addq $-0xc, %rdx
imulq $0x18, %rsi, %rsi
addq $0x18, %rsi
xorl %r8d, %r8d
leaq 0x18(%r8), %rdi
cmpq %rdi, %rsi
je 0xa996f
movl 0x14(%rdx,%r8), %r9d
xorl %r14d, %r9d
movq %rdi, %r8
cmpl $0x1, %r9d
jne 0xa958e
addq %rax, %rcx
andb $0x7f, -0x9(%rdi,%rcx)
jmp 0xa9914
movq 0x28(%rdx), %rsi
movq (%rsi,%r14,8), %rsi
movl %esi, %edi
shrq $0x20, %rsi
imulq $0x18, %rsi, %rsi
addq 0x8(%rdx), %rsi
imulq $0x18, %rdi, %rdi
pushq $-0x18
popq %r9
leaq 0x18(%r9), %r8
cmpq %r8, %rdi
je 0xa9931
cmpl %eax, 0x20(%rsi,%r9)
movq %r8, %r9
jne 0xa95d7
andb $0x7f, 0xf(%rsi,%r8)
movq 0x28(%r13), %rdi
movq (%rdi,%r14,8), %rdi
movq %rdi, %r9
andq %r12, %r9
je 0xa99cc
addq %r8, %rsi
movq 0x8(%r13), %r10
movq %rdi, %r8
shrq $0x20, %r8
imulq $0x18, %r8, %r11
leaq (%r10,%r11), %r8
addq %r11, %r10
addq $0xc, %r10
imulq $0x18, %r9, %r11
addq $0x18, %r11
xorl %r15d, %r15d
leaq 0x18(%r15), %r12
cmpq %r12, %r11
je 0xa9648
cmpl $0x0, (%r10,%r15)
movq %r12, %r15
js 0xa9630
jmp 0xa998e
movq %r8, %r11
xorl %r10d, %r10d
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
cmpq %r10, %r9
je 0xa966a
movq (%r11), %r15
cmpq (%rsi), %r15
jae 0xa9672
incq %r10
addq $0x18, %r11
jmp 0xa9654
movq %r9, %r10
movq %rdi, %r11
jmp 0xa9675
movq %r10, %r11
addl %r12d, %edi
cmpq %r9, %r10
cmovbq %r11, %rdi
movl %edi, %edi
imulq $0x18, %rdi, %rdi
movq 0x10(%rsi), %r9
movq %r9, 0x10(%r8,%rdi)
movups (%rsi), %xmm0
movups %xmm0, (%r8,%rdi)
movl %eax, %edi
xorl $0x1, %edi
movq 0x28(%rdx), %rsi
movq (%rsi,%rdi,8), %rsi
movl %esi, %r8d
shrq $0x20, %rsi
imulq $0x18, %rsi, %rsi
addq 0x8(%rdx), %rsi
imulq $0x18, %r8, %rdx
pushq $-0x18
popq %r8
leaq 0x18(%r8), %r9
cmpq %r9, %rdx
je 0xa9950
movl 0x20(%rsi,%r8), %r10d
xorl %r14d, %r10d
movq %r9, %r8
cmpl $0x1, %r10d
jne 0xa96ba
andb $0x7f, 0xf(%rsi,%r9)
movq 0x28(%r13), %rdx
movq (%rdx,%rdi,8), %rdx
movq %rdx, %r8
andq %r12, %r8
je 0xa99eb
addq %r9, %rsi
movq 0x8(%r13), %r9
movq %rdx, %rdi
shrq $0x20, %rdi
imulq $0x18, %rdi, %r10
leaq (%r9,%r10), %rdi
addq %r10, %r9
addq $0xc, %r9
imulq $0x18, %r8, %r10
addq $0x18, %r10
xorl %r11d, %r11d
leaq 0x18(%r11), %r15
cmpq %r15, %r10
je 0xa9732
cmpl $0x0, (%r9,%r11)
movq %r15, %r11
js 0xa971a
jmp 0xa99ad
movq %rdi, %r10
xorl %r9d, %r9d
cmpq %r9, %r8
je 0xa974e
movq (%r10), %r11
cmpq (%rsi), %r11
jae 0xa9756
incq %r9
addq $0x18, %r10
jmp 0xa9738
movq %r8, %r9
movq %rdx, %r10
jmp 0xa9759
movq %r9, %r10
addl %r12d, %edx
cmpq %r8, %r9
cmovbq %r10, %rdx
movl %edx, %edx
imulq $0x18, %rdx, %rdx
movq 0x10(%rsi), %r8
movq %r8, 0x10(%rdi,%rdx)
movups (%rsi), %xmm0
movups %xmm0, (%rdi,%rdx)
movl %r14d, %esi
shrl %esi
movq 0x8(%rsp), %rdx
movq 0x10(%rdx), %rdx
imulq $0x28, %rsi, %rsi
testb $0x1, %r14b
jne 0xa97a3
movq 0x18(%rdx,%rsi), %rdi
movl 0x10(%rdx,%rsi), %esi
decl %esi
movl 0x4(%rdi,%rsi,8), %r12d
jmp 0xa97b0
movq 0x18(%rdx,%rsi), %rsi
movl 0x4(%rsi), %r12d
xorl $0x1, %r12d
testb $0x1, %al
jne 0xa97c3
imulq $0x28, %rcx, %rax
movq 0x18(%rdx,%rax), %rax
movl 0x4(%rax), %r15d
jmp 0xa97db
imulq $0x28, %rcx, %rax
movq 0x18(%rdx,%rax), %rcx
movl 0x10(%rdx,%rax), %eax
decl %eax
movl 0x4(%rcx,%rax,8), %r15d
xorl $0x1, %r15d
movq 0xa0(%rsp), %rdi
movq 0xa8(%rsp), %rsi
movl 0xb0(%rsp), %ecx
movl 0xb8(%rsp), %r8d
movl %r12d, %r9d
leaq 0x20(%rsp), %rax
pushq %rax
pushq %r15
callq 0x79204
popq %rcx
popq %rdx
testl %eax, %eax
je 0xa9a29
movq (%rbp), %rcx
cmpq 0x8(%rbp), %rcx
jne 0xa9847
leaq (%rcx,%rcx), %rax
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rax
movq %rax, 0x8(%rbp)
movq 0x10(%rbp), %rdi
imulq $0x18, %rax, %rsi
callq 0x2370
movq %rax, 0x10(%rbp)
movq (%rbp), %rcx
jmp 0xa984b
movq 0x10(%rbp), %rax
leaq 0x1(%rcx), %rdx
movq %rdx, (%rbp)
imulq $0x18, %rcx, %rcx
movq 0x30(%rsp), %rdx
movq %rdx, 0x10(%rax,%rcx)
movups 0x20(%rsp), %xmm0
movups %xmm0, (%rax,%rcx)
xorl $0x1, %r15d
xorl $0x1, %r12d
movq 0xa0(%rsp), %rdi
movq 0xa8(%rsp), %rsi
movl 0xb0(%rsp), %ecx
movl 0xb8(%rsp), %r8d
movl %r15d, %r9d
leaq 0x20(%rsp), %rax
pushq %rax
pushq %r12
callq 0x79204
popq %rcx
popq %rdx
testl %eax, %eax
je 0xa9a0a
movq (%rbp), %rcx
movq 0x10(%rbp), %rax
cmpq 0x8(%rbp), %rcx
movl 0x4(%rsp), %r15d
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
jne 0xa98ea
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rdx
movq %rdx, 0x8(%rbp)
imulq $0x18, %rdx, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x10(%rbp)
movq (%rbp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%rbp)
imulq $0x18, %rcx, %rcx
movq 0x30(%rsp), %rdx
movq %rdx, 0x10(%rax,%rcx)
movups 0x20(%rsp), %xmm0
movups %xmm0, (%rax,%rcx)
movq 0xc8(%rsp), %rax
addl $0x2, (%rax)
cmpl %r15d, %r14d
jne 0xa94f3
movq 0x18(%rsp), %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x14f26b(%rip), %rdi    # 0x1f8ba3
leaq 0x13e452(%rip), %rsi    # 0x1e7d91
leaq 0x14180b(%rip), %rcx    # 0x1eb151
movl $0x67a0, %edx           # imm = 0x67A0
callq 0x2110
leaq 0x14f24c(%rip), %rdi    # 0x1f8ba3
leaq 0x13e433(%rip), %rsi    # 0x1e7d91
leaq 0x1417ec(%rip), %rcx    # 0x1eb151
movl $0x67ae, %edx           # imm = 0x67AE
callq 0x2110
leaq 0x13e828(%rip), %rdi    # 0x1e819e
leaq 0x13e414(%rip), %rsi    # 0x1e7d91
leaq 0x1417cd(%rip), %rcx    # 0x1eb151
movl $0x6793, %edx           # imm = 0x6793
callq 0x2110
leaq 0x14185b(%rip), %rdi    # 0x1eb1f0
leaq 0x13e3f5(%rip), %rsi    # 0x1e7d91
leaq 0x1417ae(%rip), %rcx    # 0x1eb151
movl $0x67a3, %edx           # imm = 0x67A3
callq 0x2110
leaq 0x14183c(%rip), %rdi    # 0x1eb1f0
leaq 0x13e3d6(%rip), %rsi    # 0x1e7d91
leaq 0x14178f(%rip), %rcx    # 0x1eb151
movl $0x67b1, %edx           # imm = 0x67B1
callq 0x2110
leaq 0x13e7cf(%rip), %rdi    # 0x1e81a2
leaq 0x13e3b7(%rip), %rsi    # 0x1e7d91
leaq 0x141770(%rip), %rcx    # 0x1eb151
movl $0x67a2, %edx           # imm = 0x67A2
callq 0x2110
leaq 0x13e7b0(%rip), %rdi    # 0x1e81a2
leaq 0x13e398(%rip), %rsi    # 0x1e7d91
leaq 0x141751(%rip), %rcx    # 0x1eb151
movl $0x67b0, %edx           # imm = 0x67B0
callq 0x2110
leaq 0x141830(%rip), %rdi    # 0x1eb241
leaq 0x13e379(%rip), %rsi    # 0x1e7d91
leaq 0x141732(%rip), %rcx    # 0x1eb151
movl $0x67bb, %edx           # imm = 0x67BB
callq 0x2110
leaq 0x1417ca(%rip), %rdi    # 0x1eb1fa
leaq 0x13e35a(%rip), %rsi    # 0x1e7d91
leaq 0x141713(%rip), %rcx    # 0x1eb151
movl $0x67b8, %edx           # imm = 0x67B8
callq 0x2110
leaq 0x140549(%rip), %rdi    # 0x1e9f98
jmp 0xa9a58
leaq 0x140631(%rip), %rdi    # 0x1ea089
leaq 0x13e332(%rip), %rsi    # 0x1e7d91
leaq 0x140539(%rip), %rcx    # 0x1e9f9f
movl $0x67c7, %edx           # imm = 0x67C7
callq 0x2110