// File: /workspace/github_cpp_makefile_star2_O2/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 $0x78, %rsp
movq %r9, 0x20(%rsp)
movl %ecx, 0xc(%rsp)
movl %esi, 0x10(%rsp)
movq %rdi, %r12
movl %edx, 0x1c(%rsp)
movl %r8d, 0x18(%rsp)
movq (%rdi), %rax
movq 0x10(%rdi), %rdi
leaq (%rdi,%rax,4), %rsi
callq 0xf1352
movq (%r12), %rdx
pushq $-0x1
popq %r9
xorl %r15d, %r15d
xorl %r8d, %r8d
xorl %edi, %edi
movq %r12, 0x70(%rsp)
movq %rdx, 0x60(%rsp)
movl %r15d, %r15d
movl %r8d, %ebx
cmpq %r15, %rdx
jbe 0x10453f
movq 0x10(%r12), %r14
movl (%r14,%r15,4), %esi
movl %esi, %ebp
shrl %ebp
movl %r9d, %eax
shrl %eax
cmpl %eax, %ebp
je 0x10451c
movq 0x20(%rsp), %rax
movq (%rax), %r12
movq 0x80(%rax), %r13
movl (%r12,%rbp,4), %eax
leaq 0x1(%r13), %rcx
cmpq %rax, %rcx
jae 0x1044f6
movl %r9d, 0x58(%rsp)
movl %r8d, 0x14(%rsp)
movq %rdi, 0x68(%rsp)
movq 0xd0(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x10437b
testl %eax, %eax
je 0x104524
incl %r13d
movl %r13d, (%r12,%rbp,4)
movl (%r14,%r15,4), %esi
movl %esi, %ebp
shrl %ebp
movq 0x68(%rsp), %rdi
movq 0x60(%rsp), %rdx
movl 0x14(%rsp), %r8d
movl %esi, (%r14,%rbx,4)
movq 0xd0(%rsp), %rax
movq 0x10(%rax), %rax
imulq $0x28, %rbp, %rcx
movl 0x10(%rax,%rcx), %eax
addq %rax, %rdi
incl %r8d
movl %esi, %r9d
movq 0x70(%rsp), %r12
incl %r15d
jmp 0x10446f
movq 0x70(%rsp), %r12
movq 0x68(%rsp), %rdi
movq 0x60(%rsp), %rdx
movl 0x14(%rsp), %r8d
movl 0x58(%rsp), %r9d
jmp 0x10451c
movq %rbx, (%r12)
cmpl $0x1, %r8d
jne 0x10459f
movl 0x10(%rsp), %edx
cmpl $-0x1, %edx
sete %al
movl 0xc(%rsp), %ecx
cmpl $-0x1, %ecx
sete %sil
orb %al, %sil
jne 0x10459f
movq %rdi, %r14
movq 0x10(%r12), %r13
movl (%r13), %ebp
leaq 0x5c(%rsp), %r8
movq 0xd0(%rsp), %rdi
movl %ebp, %esi
callq 0x103f03
testl %eax, %eax
je 0x104820
movl 0x5c(%rsp), %r15d
xorl %r15d, %ebp
cmpl $0x2, %ebp
movq %r14, %rdi
jae 0x104a35
movq 0xd8(%rsp), %rdx
testq %rdx, %rdx
je 0x1045b5
cmpq (%rdx), %rdi
ja 0x104a26
movq 0x20(%rsp), %r14
movq 0xb8(%r14), %rdi
movl 0x14(%rdi), %ebx
andl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
movl %ebx, 0x8(%rsp)
movl %ebx, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x69316
movq 0xb8(%r14), %rax
movq 0x20(%rax), %rax
movb $0x2, 0x4(%rax,%rbx,8)
cmpq $0x0, 0xe0(%rsp)
je 0x1045fb
incq 0x88(%r14)
movq 0x30(%r14), %rcx
pushq $0x2
popq %r13
cmpq 0x38(%r14), %rcx
jne 0x10462f
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
cmoveq %r13, %rsi
movq %rsi, 0x38(%r14)
movq 0x40(%r14), %rdi
shlq $0x2, %rsi
callq 0x2370
movq %rax, 0x40(%r14)
movq 0x30(%r14), %rcx
jmp 0x104633
movq 0x40(%r14), %rax
movl 0x18(%r14), %edx
leaq 0x1(%rcx), %rsi
movq %rsi, 0x30(%r14)
movl %edx, (%rax,%rcx,4)
movq 0x48(%r14), %rcx
cmpq 0x50(%r14), %rcx
movl 0x10(%rsp), %ebp
movl 0xc(%rsp), %r15d
jne 0x10467b
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
cmoveq %r13, %rsi
movq %rsi, 0x50(%r14)
movq 0x58(%r14), %rdi
shlq $0x3, %rsi
callq 0x2370
movq %rax, 0x58(%r14)
movq 0x48(%r14), %rcx
jmp 0x10467f
movq 0x58(%r14), %rax
leaq 0x1(%rcx), %rdx
movq %rdx, 0x48(%r14)
andq $0x0, (%rax,%rcx,8)
movq 0x18(%r14), %rdx
movq 0x20(%r14), %rcx
cmpq %rcx, %rdx
jne 0x1046c3
leaq (%rdx,%rdx), %rsi
testq %rdx, %rdx
cmoveq %r13, %rsi
movq %rsi, 0x20(%r14)
movq 0x28(%r14), %rdi
shlq $0x2, %rsi
callq 0x2370
movq %rax, 0x28(%r14)
movq 0x18(%r14), %rdx
movq 0x20(%r14), %rcx
jmp 0x1046c7
movq 0x28(%r14), %rax
leaq 0x1(%rdx), %rsi
movq %rsi, 0x18(%r14)
movl %ebp, (%rax,%rdx,4)
cmpq %rcx, %rsi
jne 0x1046fa
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
cmoveq %r13, %rsi
movq %rsi, 0x20(%r14)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x28(%r14)
movq 0x18(%r14), %rsi
movq 0xc8(%rsp), %rdi
leaq 0x1(%rsi), %rcx
movq %rcx, 0x18(%r14)
movl %r15d, (%rax,%rsi,4)
xorl %ebx, %ebx
movl %ebx, %ebx
cmpq %rbx, (%r12)
jbe 0x104773
movq 0x18(%r14), %rcx
movq 0x28(%r14), %rax
cmpq 0x20(%r14), %rcx
jne 0x104751
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
cmoveq %r13, %rsi
movq %rsi, 0x20(%r14)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq 0xc8(%rsp), %rdi
movq %rax, 0x28(%r14)
movq 0x18(%r14), %rcx
leaq 0x1(%rcx), %rsi
movq 0x10(%r12), %rdx
movl (%rdx,%rbx,4), %edx
movq %rsi, 0x18(%r14)
movl %edx, (%rax,%rcx,4)
testq %rdi, %rdi
je 0x10476f
shrl %edx
movb $0x1, (%rdi,%rdx)
incl %ebx
jmp 0x104710
cmpl $-0x1, %ebp
je 0x1048ae
movl %ebp, %ebx
xorl $0x1, %ebx
movl 0xb0(%r14), %eax
movl %eax, (%rsp)
leaq 0x1c(%rsp), %rdx
leaq 0x8(%rsp), %r8
leaq 0x40(%rsp), %r9
movq %r14, %rdi
movl %ebp, %esi
movl %ebx, %ecx
callq 0x102f0f
testl %eax, %eax
je 0x1048ae
movl 0xb0(%r14), %eax
movl %eax, (%rsp)
leaq 0x8(%rsp), %rdx
leaq 0x1c(%rsp), %r8
leaq 0x28(%rsp), %r9
movq %r14, %rdi
movl %ebx, %esi
movl %ebp, %ecx
callq 0x102f0f
testl %eax, %eax
je 0x1048ae
movb $0x0, 0x52(%rsp)
andb $0x7f, 0x51(%rsp)
andb $0x7f, 0x4f(%rsp)
movq 0xb0(%rsp), %rbx
movq (%rbx), %rcx
cmpq 0x8(%rbx), %rcx
jne 0x104830
leaq (%rcx,%rcx), %rax
testq %rcx, %rcx
cmoveq %r13, %rax
movq %rax, 0x8(%rbx)
movq 0x10(%rbx), %rdi
imulq $0x18, %rax, %rsi
callq 0x2370
movq %rax, 0x10(%rbx)
movq (%rbx), %rcx
jmp 0x104834
movq 0xd8(%rsp), %rdx
movq %r14, %rdi
jmp 0x1045a7
movq 0x10(%rbx), %rax
leaq 0x1(%rcx), %rdx
movq %rdx, (%rbx)
imulq $0x18, %rcx, %rcx
movq 0x50(%rsp), %rdx
movq %rdx, 0x10(%rax,%rcx)
movups 0x40(%rsp), %xmm0
movups %xmm0, (%rax,%rcx)
movb $0x0, 0x3a(%rsp)
andb $0x7f, 0x39(%rsp)
andb $0x7f, 0x37(%rsp)
movq (%rbx), %rcx
movq 0x10(%rbx), %rax
cmpq 0x8(%rbx), %rcx
jne 0x104890
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
cmoveq %r13, %rdx
movq %rdx, 0x8(%rbx)
imulq $0x18, %rdx, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x10(%rbx)
movq (%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%rbx)
imulq $0x18, %rcx, %rcx
movq 0x38(%rsp), %rdx
movq %rdx, 0x10(%rax,%rcx)
movups 0x28(%rsp), %xmm0
movups %xmm0, (%rax,%rcx)
cmpl $-0x1, %r15d
je 0x104a26
movl 0xc(%rsp), %r15d
movl %r15d, %ebx
xorl $0x1, %ebx
movq 0x20(%rsp), %r14
movl 0xb0(%r14), %eax
movl %eax, (%rsp)
leaq 0x8(%rsp), %rdx
leaq 0x18(%rsp), %r8
leaq 0x40(%rsp), %r9
movq %r14, %rdi
movl %ebx, %esi
movl %r15d, %ecx
callq 0x102f0f
testl %eax, %eax
movl 0x10(%rsp), %ebp
je 0x1049eb
movl 0xb0(%r14), %eax
movl %eax, (%rsp)
leaq 0x18(%rsp), %rdx
leaq 0x8(%rsp), %r8
leaq 0x28(%rsp), %r9
movq %r14, %rdi
movl %r15d, %esi
movl %ebx, %ecx
callq 0x102f0f
testl %eax, %eax
je 0x1049eb
movb $0x0, 0x52(%rsp)
andb $0x7f, 0x51(%rsp)
andb $0x7f, 0x4f(%rsp)
movq 0xb0(%rsp), %rbx
movq (%rbx), %rcx
cmpq 0x8(%rbx), %rcx
jne 0x10496d
leaq (%rcx,%rcx), %rax
testq %rcx, %rcx
cmoveq %r13, %rax
movq %rax, 0x8(%rbx)
movq 0x10(%rbx), %rdi
imulq $0x18, %rax, %rsi
callq 0x2370
movq %rax, 0x10(%rbx)
movq (%rbx), %rcx
jmp 0x104971
movq 0x10(%rbx), %rax
leaq 0x1(%rcx), %rdx
movq %rdx, (%rbx)
imulq $0x18, %rcx, %rcx
movq 0x50(%rsp), %rdx
movq %rdx, 0x10(%rax,%rcx)
movups 0x40(%rsp), %xmm0
movups %xmm0, (%rax,%rcx)
movb $0x0, 0x3a(%rsp)
andb $0x7f, 0x39(%rsp)
andb $0x7f, 0x37(%rsp)
movq (%rbx), %rcx
movq 0x10(%rbx), %rax
cmpq 0x8(%rbx), %rcx
jne 0x1049cd
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
cmoveq %r13, %rdx
movq %rdx, 0x8(%rbx)
imulq $0x18, %rdx, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x10(%rbx)
movq (%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%rbx)
imulq $0x18, %rcx, %rcx
movq 0x38(%rsp), %rdx
movq %rdx, 0x10(%rax,%rcx)
movups 0x28(%rsp), %xmm0
movups %xmm0, (%rax,%rcx)
cmpl $-0x1, %ebp
sete %al
cmpq $0x0, 0xc0(%rsp)
sete %cl
orb %al, %cl
jne 0x104a26
movq 0xc0(%rsp), %rax
orb $-0x80, 0xf(%rax)
movl 0x4(%rax), %edx
movl 0x8(%rax), %esi
xorl $0x1, %esi
xorl $0x1, %edx
movq 0xb8(%rsp), %rdi
callq 0x10433c
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpq %rbx, 0x8(%r12)
jne 0x104a61
movq $0x2, 0x8(%r12)
pushq $0x8
popq %rsi
movq %r13, %rdi
callq 0x2370
movq %r14, %rdi
movq %rax, %r13
movq %rax, 0x10(%r12)
movq (%r12), %rax
jmp 0x104a64
pushq $0x1
popq %rax
movq 0xd8(%rsp), %rdx
leaq 0x1(%rax), %rcx
movq %rcx, (%r12)
movl %r15d, (%r13,%rax,4)
movq 0xd0(%rsp), %rax
movq 0x10(%rax), %rax
shrl %r15d
imulq $0x28, %r15, %rcx
movl 0x10(%rax,%rcx), %eax
addq %rax, %rdi
testq %rdx, %rdx
je 0x104a9d
cmpq (%rdx), %rdi
ja 0x104a26
movq 0x20(%rsp), %rcx
movl 0x80(%rcx), %eax
incl %eax
movq (%rcx), %rcx
movl %eax, (%rcx,%r15,4)
jmp 0x1045a7