// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/hic.cpp
// Function: print_bubble_chain(bubble_type*, char const*)
void print_bubble_chain(bubble_type* bub, const char* command)
{
    ma_ug_t *ug = NULL;
    ug = ma_ug_gen(bub->b_g);
    uint32_t i, k, j, rId, beg, sink, *a, n;
    ma_utg_t *u = NULL;
    asg_arc_t *t = NULL;
    for (i = 0; i < ug->u.n; i++)
    {
        u = &(ug->u.a[i]);
        if(u->n == 0) continue;
        fprintf(stderr,"\n%s: chain-%u\n", command, i);
        for (k = 0; k < u->n; k++)
        {
            rId = u->a[k]>>33;
            get_bubbles(bub, rId, &beg, &sink, &a, &n, NULL);
            t = NULL;
            if(k+1 < u->n) t = &(arc_first(bub->b_g, u->a[k]>>32));
            fprintf(stderr, "[utg%.6dl, utg%.6dl] el=%u no_long_indel=%u, rId=%u, nv: %u, nv^: %u\n", 
                (int)((beg>>1)+1), (int)((sink>>1)+1), t?t->el:16, t?t->no_l_indel:16, rId, arc_cnt(bub->b_g, u->a[k]>>32), arc_cnt(bub->b_g, (u->a[k]>>32)^1));
            // if((u->a[k]>>33) == 9658)
            // {
            //     asg_arc_t *av;
            //     uint32_t nv, nv_i;
            //     av = asg_arc_a(bub->b_g, u->a[k]>>32);
            //     nv = asg_arc_n(bub->b_g, u->a[k]>>32);
            //     for (nv_i = 0; nv_i < nv; nv_i++)
            //     {
            //         if(av[nv_i].del) continue;
            //         fprintf(stderr, "v--->%u\n", av[nv_i].v>>1);
            //     }
                


            //     av = asg_arc_a(bub->b_g, (u->a[k]>>32)^1);
            //     nv = asg_arc_n(bub->b_g, (u->a[k]>>32)^1);
            //     for (nv_i = 0; nv_i < nv; nv_i++)
            //     {
            //         if(av[nv_i].del) continue;
            //         fprintf(stderr, "v^1--->%u\n", av[nv_i].v>>1);
            //     }

            // }
            if(bub->b_g->seq[rId].c == HAP_LABLE)
            {
                for (j = 0; j < n; j++)
                {
                    fprintf(stderr, ">>>utg%.6dl\n", (int)((a[j]>>1)+1));
                }
            }
        }
    }

    ma_ug_destroy(ug);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, 0x20(%rsp)
movq %rdi, %r14
movq 0xb8(%rdi), %rdi
callq 0x76d91
movq %rax, %r15
xorl %r12d, %r12d
movq %r14, 0x18(%rsp)
movl %r12d, %r12d
cmpq %r12, (%r15)
jbe 0x103eec
movq 0x10(%r15), %rbx
imulq $0x28, %r12, %rax
cmpl $0x0, 0x10(%rbx,%rax)
jne 0x103d7c
incl %r12d
jmp 0x103d5c
addq %rax, %rbx
movq 0x14f25a(%rip), %rax    # 0x252fe0
movq (%rax), %rdi
leaq 0xe9eef(%rip), %rsi     # 0x1edc7f
movq 0x20(%rsp), %rdx
movl %r12d, %ecx
xorl %eax, %eax
callq 0x22b0
xorl %ebp, %ebp
movl 0x10(%rbx), %eax
cmpq %rax, %rbp
movq 0x18(%rsp), %r14
jae 0x103d77
movq 0x18(%rbx), %rax
movq (%rax,%rbp,8), %r13
shrq $0x21, %r13
subq $0x8, %rsp
movq %r14, %rdi
movq %r13, %rsi
leaq 0x1c(%rsp), %rdx
leaq 0x18(%rsp), %rcx
leaq 0x38(%rsp), %r8
leaq 0x14(%rsp), %r9
pushq $0x0
callq 0xf6ab5
addq $0x10, %rsp
leaq 0x1(%rbp), %rcx
movl 0x10(%rbx), %eax
movq %rcx, 0x28(%rsp)
cmpq %rax, %rcx
jae 0x103e15
movq 0xb8(%r14), %rcx
movq 0x28(%rcx), %rax
movq 0x18(%rbx), %rdx
movl 0x4(%rdx,%rbp,8), %edx
movl 0x4(%rax,%rdx,8), %eax
imulq $0x18, %rax, %rax
addq 0x8(%rcx), %rax
jmp 0x103e17
xorl %eax, %eax
movq 0x14f1c2(%rip), %rcx    # 0x252fe0
movq (%rcx), %rdi
movl 0x14(%rsp), %edx
movl 0x10(%rsp), %ecx
pushq $0x10
popq %r9
movl %r9d, %r8d
testq %rax, %rax
je 0x103e43
movzbl 0x12(%rax), %r8d
movzwl 0x10(%rax), %r9d
shrl $0xf, %r9d
shrl %edx
incl %edx
shrl %ecx
incl %ecx
movq 0x18(%rsp), %r14
movq 0xb8(%r14), %rax
movq 0x28(%rax), %rax
movq 0x18(%rbx), %rsi
movl 0x4(%rsi,%rbp,8), %esi
movl (%rax,%rsi,8), %r10d
shlq $0x3, %rsi
xorq $0x8, %rsi
movl (%rax,%rsi), %r11d
subq $0x8, %rsp
leaq 0xe9e10(%rip), %rsi     # 0x1edc8e
xorl %eax, %eax
pushq %r11
pushq %r10
pushq %r13
callq 0x22b0
addq $0x20, %rsp
movq 0xb8(%r14), %rax
movq 0x20(%rax), %rax
cmpb $0x2, 0x4(%rax,%r13,8)
movq 0x28(%rsp), %r14
movq %r14, %rbp
jne 0x103da1
xorl %r13d, %r13d
movl 0xc(%rsp), %eax
cmpq %rax, %r13
jae 0x103ee4
movq 0x14f11f(%rip), %rax    # 0x252fe0
movq (%rax), %rdi
movq 0x30(%rsp), %rax
movl (%rax,%r13,4), %edx
shrl %edx
incl %edx
leaq 0xe9dfc(%rip), %rsi     # 0x1edcd4
xorl %eax, %eax
callq 0x22b0
incq %r13
jmp 0x103eb1
movq %r14, %rbp
jmp 0x103da1
movq %r15, %rdi
callq 0x6921d
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq