// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/hic.cpp
// Function: update_bubble_graph(kvec_t_u32_warp*, unsigned int, unsigned int, unsigned int, unsigned int, bubble_type*, kvec_asg_arc_t_warp*, asg_t*, asg_arc_t*, unsigned char*, ma_ug_t*, unsigned long*, unsigned long)
void update_bubble_graph(kvec_t_u32_warp* broken, uint32_t beg, uint32_t beg_bub_id, 
uint32_t sink, uint32_t sink_bub_id, bubble_type* bub, kvec_asg_arc_t_warp* edges, asg_t *bsg, 
asg_arc_t *p_t, uint8_t *bsg_idx, ma_ug_t *unitig_ug, uint64_t* occ_thres, uint64_t is_b_bub)
{
    uint32_t i, pre, n, bub_id, v;
    uint64_t occ;
    asg_arc_t t_f, t_r;
    
    radix_sort_u32(broken->a.a, broken->a.a + broken->a.n);
    for (i = n = occ = 0, pre = (uint32_t)-1; i < broken->a.n; i++)
    {
        if((broken->a.a[i]>>1) == (pre>>1)) continue;
        if(IF_HOM((broken->a.a[i]>>1), *bub))
        {
            if(is_local_simple_circle(unitig_ug->g, broken->a.a[i]))
            {
                bub->index[broken->a.a[i]>>1] = bub->f_bub+1;
            }
            else
            {
                continue;
            }
        }
         
        pre = broken->a.a[i];
        broken->a.a[n] = pre;
        occ += unitig_ug->u.a[broken->a.a[n]>>1].n;
        n++;
    }
    broken->a.n = n;
    ///if(broken->a.n == 0) return;
    if(broken->a.n == 1)
    {
        ///fprintf(stderr, "+++++sb+++++utg%.6ul\n", (broken->a.a[0]>>1)+1);
        if(beg != (uint32_t)-1 && sink != (uint32_t)-1 && 
                            is_simple_broken_bubble(unitig_ug, broken->a.a[0], beg, sink, &v))
        {
            if((v>>1) != (broken->a.a[0]>>1))
            {
                ///fprintf(stderr, "-----sb-----utg%.6ul\n", (v>>1)+1);
                kv_push(uint32_t, broken->a, v);
                occ += unitig_ug->u.a[v>>1].n;
                if(occ_thres && occ > (*occ_thres)) return;
                bub->index[v>>1] = bub->f_bub+1; ///set to het
            }
        }
    } 
    
    
    if(occ_thres && occ > (*occ_thres)) return;
    /********************push graph node********************/
    bub_id = bub->b_g->n_seq;
    asg_seq_set(bub->b_g, bub_id, 0, 0);
    bub->b_g->seq[bub_id].c = HAP_LABLE;
    if(is_b_bub) bub->b_bub++;
    /********************push graph node********************/

    /********************push bubble********************/
    kv_push(uint32_t, bub->num, bub->list.n);
    kv_push(uint64_t, bub->pathLen, 0);
    kv_push(uint32_t, bub->list, beg);
    kv_push(uint32_t, bub->list, sink);

    for (i = 0; i < broken->a.n; i++)
    {
        kv_push(uint32_t, bub->list, broken->a.a[i]);
        if(bsg_idx) bsg_idx[broken->a.a[i]>>1] = 1;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %r9, %r13
movl %ecx, %r12d
movl %esi, %ebp
movq %rdi, %rbx
movq 0xe8(%rsp), %r14
movl %edx, 0x2c(%rsp)
movl %r8d, 0x28(%rsp)
movq (%rdi), %rax
movq 0x10(%rdi), %rdi
leaq (%rdi,%rax,4), %rsi
callq 0x137c5c
movq (%rbx), %r10
xorl %r9d, %r9d
testq %r10, %r10
movl %r12d, 0x10(%rsp)
movq %rbx, 0x18(%rsp)
je 0x14c4ee
movq %rbx, %rdx
movl %ebp, 0x24(%rsp)
movq 0xe0(%rsp), %rdi
movq 0x10(%rbx), %r12
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
xorl %r15d, %r15d
xorl %r8d, %r8d
movq %r13, 0x80(%rsp)
movq %r10, 0x68(%rsp)
movl (%r12,%r15,4), %esi
movl %esi, %r14d
shrl %r14d
movl %ebp, %eax
shrl %eax
cmpl %eax, %r14d
je 0x14c453
movq %r13, %rax
movq (%r13), %r13
movq 0x80(%rax), %rbx
movl (%r13,%r14,4), %eax
leaq 0x1(%rbx), %rcx
cmpq %rax, %rcx
jae 0x14c430
movq %r9, 0x70(%rsp)
movq %r8, 0x78(%rsp)
movq 0x18(%rdi), %rdi
callq 0x14c26d
testl %eax, %eax
je 0x14c464
incl %ebx
movl %ebx, (%r13,%r14,4)
movl (%r12,%r15,4), %esi
movl %esi, %r14d
shrl %r14d
movq 0x18(%rsp), %rdx
movq 0x78(%rsp), %r8
movq 0xe0(%rsp), %rdi
movq 0x70(%rsp), %r9
movq 0x68(%rsp), %r10
movl %r9d, %eax
movl %esi, (%r12,%rax,4)
movq 0x10(%rdi), %rax
leaq (%r14,%r14,4), %rcx
movl 0x10(%rax,%rcx,8), %eax
addq %rax, %r8
incl %r9d
movl %esi, %ebp
movq 0x80(%rsp), %r13
incq %r15
movl %r15d, %eax
cmpq %rax, %r10
ja 0x14c3b9
jmp 0x14c48a
movq 0x80(%rsp), %r13
movq 0x18(%rsp), %rdx
movq 0x78(%rsp), %r8
movq 0xe0(%rsp), %rdi
movq 0x70(%rsp), %r9
movq 0x68(%rsp), %r10
jmp 0x14c453
movl %r9d, %r14d
movq %r14, (%rdx)
cmpl $0x1, %r9d
jne 0x14c4f3
movl 0x24(%rsp), %ebp
cmpl $-0x1, %ebp
sete %al
movl 0x10(%rsp), %r12d
cmpl $-0x1, %r12d
sete %cl
orb %al, %cl
jne 0x14c4fc
movq %r8, %r15
movl %r12d, %ecx
movq %r13, %r12
movq 0x10(%rdx), %r13
movl (%r13), %ebx
leaq 0x64(%rsp), %r8
movl %ebx, %esi
movl %ebp, %edx
callq 0x14bdbb
testl %eax, %eax
je 0x14ca01
movl 0x64(%rsp), %edi
xorl %edi, %ebx
cmpl $0x2, %ebx
movq %r15, %r8
jae 0x14ca19
movq %r12, %r13
jmp 0x14c4f7
xorl %r8d, %r8d
jmp 0x14c504
movl 0x24(%rsp), %ebp
movl 0x10(%rsp), %r12d
movq 0xe8(%rsp), %r14
testq %r14, %r14
je 0x14c512
cmpq (%r14), %r8
ja 0x14c9ef
movq 0xf0(%rsp), %r14
movq 0xb8(%r13), %rdi
movl 0x14(%rdi), %ebx
andl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
movl %ebx, 0x14(%rsp)
movl %ebx, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xa0887
movq 0xb8(%r13), %rax
movq 0x20(%rax), %rax
movb $0x2, 0x4(%rax,%rbx,8)
testq %r14, %r14
je 0x14c555
incq 0x88(%r13)
movq 0x30(%r13), %rcx
cmpq 0x38(%r13), %rcx
jne 0x14c58a
leaq (%rcx,%rcx), %rax
testq %rcx, %rcx
movl $0x2, %esi
cmovneq %rax, %rsi
movq %rsi, 0x38(%r13)
movq 0x40(%r13), %rdi
shlq $0x2, %rsi
callq 0x2370
movq %rax, 0x40(%r13)
movq 0x30(%r13), %rcx
jmp 0x14c58e
movq 0x40(%r13), %rax
movl 0x18(%r13), %edx
leaq 0x1(%rcx), %rsi
movq %rsi, 0x30(%r13)
movl %edx, (%rax,%rcx,4)
movq 0x48(%r13), %rcx
cmpq 0x50(%r13), %rcx
jne 0x14c5d2
leaq (%rcx,%rcx), %rax
testq %rcx, %rcx
movl $0x2, %esi
cmovneq %rax, %rsi
movq %rsi, 0x50(%r13)
movq 0x58(%r13), %rdi
shlq $0x3, %rsi
callq 0x2370
movq %rax, 0x58(%r13)
movq 0x48(%r13), %rcx
jmp 0x14c5d6
movq 0x58(%r13), %rax
leaq 0x1(%rcx), %rdx
movq %rdx, 0x48(%r13)
movq $0x0, (%rax,%rcx,8)
movq 0x18(%r13), %rdx
movq 0x20(%r13), %rcx
cmpq %rcx, %rdx
jne 0x14c622
leaq (%rdx,%rdx), %rax
testq %rdx, %rdx
movl $0x2, %esi
cmovneq %rax, %rsi
movq %rsi, 0x20(%r13)
movq 0x28(%r13), %rdi
shlq $0x2, %rsi
callq 0x2370
movq %rax, 0x28(%r13)
movq 0x18(%r13), %rdx
movq 0x20(%r13), %rcx
jmp 0x14c626
movq 0x28(%r13), %rax
leaq 0x1(%rdx), %rsi
movq %rsi, 0x18(%r13)
movl %ebp, (%rax,%rdx,4)
movl %ebp, %r14d
cmpq %rcx, %rsi
jne 0x14c661
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
movl $0x2, %esi
cmovneq %rdx, %rsi
movq %rsi, 0x20(%r13)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x28(%r13)
movq 0x18(%r13), %rsi
movq 0x18(%rsp), %rdi
leaq 0x1(%rsi), %rcx
movq %rcx, 0x18(%r13)
movl %r12d, (%rax,%rsi,4)
cmpq $0x0, (%rdi)
je 0x14c6ec
movq 0xd8(%rsp), %rbx
movl $0x1, %ebp
xorl %r12d, %r12d
movl $0x2, %r15d
movq 0x18(%r13), %rcx
movq 0x28(%r13), %rax
cmpq 0x20(%r13), %rcx
jne 0x14c6c4
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
cmoveq %r15, %rsi
movq %rsi, 0x20(%r13)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq 0x18(%rsp), %rdi
movq %rax, 0x28(%r13)
movq 0x18(%r13), %rcx
leaq 0x1(%rcx), %rsi
movq 0x10(%rdi), %rdx
movl (%rdx,%r12,4), %edx
movq %rsi, 0x18(%r13)
movl %edx, (%rax,%rcx,4)
testq %rbx, %rbx
je 0x14c6e2
shrl %edx
movb $0x1, (%rbx,%rdx)
movl %ebp, %r12d
incl %ebp
cmpq %r12, (%rdi)
ja 0x14c68e
movq 0xc0(%rsp), %rbx
movl %r14d, %ebp
cmpl $-0x1, %r14d
movl 0x10(%rsp), %r14d
je 0x14c836
movl %ebp, %r15d
xorl $0x1, %r15d
movl 0xb0(%r13), %eax
movl %eax, (%rsp)
leaq 0x2c(%rsp), %rdx
leaq 0x14(%rsp), %r8
leaq 0x48(%rsp), %r9
movq %r13, %rdi
movl %ebp, %esi
movl %r15d, %ecx
callq 0x14adb4
testl %eax, %eax
je 0x14c836
movl 0xb0(%r13), %eax
movl %eax, (%rsp)
leaq 0x14(%rsp), %rdx
leaq 0x2c(%rsp), %r8
leaq 0x30(%rsp), %r9
movq %r13, %rdi
movl %r15d, %esi
movl %ebp, %ecx
callq 0x14adb4
testl %eax, %eax
je 0x14c836
movb $0x0, 0x5a(%rsp)
andb $0x7f, 0x59(%rsp)
andb $0x7f, 0x57(%rsp)
movq (%rbx), %rcx
cmpq 0x8(%rbx), %rcx
jne 0x14c7af
leaq (%rcx,%rcx), %rax
testq %rcx, %rcx
movl $0x2, %ecx
cmovneq %rax, %rcx
movq %rcx, 0x8(%rbx)
movq 0x10(%rbx), %rdi
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %rsi
callq 0x2370
movq %rax, 0x10(%rbx)
movq (%rbx), %rcx
jmp 0x14c7b3
movq 0x10(%rbx), %rax
leaq 0x1(%rcx), %rdx
movq %rdx, (%rbx)
leaq (%rcx,%rcx,2), %rcx
movq 0x58(%rsp), %rdx
movq %rdx, 0x10(%rax,%rcx,8)
movups 0x48(%rsp), %xmm0
movups %xmm0, (%rax,%rcx,8)
movb $0x0, 0x42(%rsp)
andb $0x7f, 0x41(%rsp)
andb $0x7f, 0x3f(%rsp)
movq (%rbx), %rcx
movq 0x10(%rbx), %rax
cmpq 0x8(%rbx), %rcx
jne 0x14c818
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
movl $0x2, %ecx
cmovneq %rdx, %rcx
movq %rcx, 0x8(%rbx)
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x10(%rbx)
movq (%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%rbx)
leaq (%rcx,%rcx,2), %rcx
movq 0x40(%rsp), %rdx
movq %rdx, 0x10(%rax,%rcx,8)
movups 0x30(%rsp), %xmm0
movups %xmm0, (%rax,%rcx,8)
cmpl $-0x1, %r14d
je 0x14c9ef
movq 0xd0(%rsp), %r12
movl %r14d, %r15d
xorl $0x1, %r15d
movl 0xb0(%r13), %eax
movl %eax, (%rsp)
leaq 0x14(%rsp), %rdx
leaq 0x28(%rsp), %r8
leaq 0x48(%rsp), %r9
movq %r13, %rdi
movl %r15d, %esi
movl %r14d, %ecx
callq 0x14adb4
testl %eax, %eax
je 0x14c97a
movl 0xb0(%r13), %eax
movl %eax, (%rsp)
leaq 0x28(%rsp), %rdx
leaq 0x14(%rsp), %r8
leaq 0x30(%rsp), %r9
movq %r13, %rdi
movl %r14d, %esi
movl %r15d, %ecx
callq 0x14adb4
testl %eax, %eax
je 0x14c97a
movb $0x0, 0x5a(%rsp)
andb $0x7f, 0x59(%rsp)
andb $0x7f, 0x57(%rsp)
movq (%rbx), %rcx
cmpq 0x8(%rbx), %rcx
jne 0x14c8f3
leaq (%rcx,%rcx), %rax
testq %rcx, %rcx
movl $0x2, %ecx
cmovneq %rax, %rcx
movq %rcx, 0x8(%rbx)
movq 0x10(%rbx), %rdi
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %rsi
callq 0x2370
movq %rax, 0x10(%rbx)
movq (%rbx), %rcx
jmp 0x14c8f7
movq 0x10(%rbx), %rax
leaq 0x1(%rcx), %rdx
movq %rdx, (%rbx)
leaq (%rcx,%rcx,2), %rcx
movq 0x58(%rsp), %rdx
movq %rdx, 0x10(%rax,%rcx,8)
movups 0x48(%rsp), %xmm0
movups %xmm0, (%rax,%rcx,8)
movb $0x0, 0x42(%rsp)
andb $0x7f, 0x41(%rsp)
andb $0x7f, 0x3f(%rsp)
movq (%rbx), %rcx
movq 0x10(%rbx), %rax
cmpq 0x8(%rbx), %rcx
jne 0x14c95c
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
movl $0x2, %ecx
cmovneq %rdx, %rcx
movq %rcx, 0x8(%rbx)
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x10(%rbx)
movq (%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%rbx)
leaq (%rcx,%rcx,2), %rcx
movq 0x40(%rsp), %rdx
movq %rdx, 0x10(%rax,%rcx,8)
movups 0x30(%rsp), %xmm0
movups %xmm0, (%rax,%rcx,8)
cmpl $-0x1, %ebp
sete %al
testq %r12, %r12
sete %cl
orb %al, %cl
jne 0x14c9ef
orb $-0x80, 0xf(%r12)
movq 0xc8(%rsp), %rcx
movl 0x8(%r12), %eax
xorq $0x1, %rax
movq 0x28(%rcx), %rdx
movq (%rdx,%rax,8), %rdx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
andq %rdx, %rsi
je 0x14c9ef
movl 0x4(%r12), %eax
movq 0x8(%rcx), %rdi
shrq $0x20, %rdx
shlq $0x3, %rsi
leaq (%rsi,%rsi,2), %rcx
leaq (%rdx,%rdx,2), %rdx
leaq (%rdi,%rdx,8), %rdx
addq $0xc, %rdx
xorl %esi, %esi
movl -0x4(%rdx,%rsi), %edi
xorl %eax, %edi
cmpl $0x1, %edi
jne 0x14c9e6
orb $-0x80, 0x3(%rdx,%rsi)
addq $0x18, %rsi
cmpq %rsi, %rcx
jne 0x14c9d6
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r12, %r13
movl 0x10(%rsp), %r12d
movq 0xe8(%rsp), %r14
movq %r15, %r8
jmp 0x14c504
movl $0x1, %eax
movq 0x18(%rsp), %rdx
cmpq %r14, 0x8(%rdx)
jne 0x14ca56
movq $0x2, 0x8(%rdx)
movl $0x8, %esi
movq %rdi, %rbx
movq %r13, %rdi
callq 0x2370
movq %rbx, %rdi
movq %r15, %r8
movq 0x18(%rsp), %rdx
movq %rax, %r13
movq %rax, 0x10(%rdx)
movq (%rdx), %rax
movq 0xe8(%rsp), %r14
movq 0xe0(%rsp), %rsi
leaq 0x1(%rax), %rcx
movq %rcx, (%rdx)
movl %edi, (%r13,%rax,4)
movq 0x10(%rsi), %rax
shrl %edi
leaq (%rdi,%rdi,4), %rcx
movl 0x10(%rax,%rcx,8), %eax
addq %rax, %r8
testq %r14, %r14
movq %r12, %r13
movl 0x10(%rsp), %r12d
je 0x14ca99
cmpq (%r14), %r8
ja 0x14c9ef
movl 0x80(%r13), %eax
incl %eax
movq (%r13), %rcx
movl %eax, (%rcx,%rdi,4)
jmp 0x14c504