// File: 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
movq %rsp, %rbp
pushq %rbx
subq $0x88, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0xb8(%rax), %rdi
callq 0xe5910
movq %rax, -0x20(%rbp)
movq $0x0, -0x50(%rbp)
movq $0x0, -0x58(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x1de05c
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x24(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jne 0x1dde1c
jmp 0x1de04e
movq 0x1e61bd(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movq -0x18(%rbp), %rdx
movl -0x24(%rbp), %ecx
leaq 0x1aeb78(%rip), %rsi    # 0x38c9ac
movb $0x0, %al
callq 0x22a0
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
movq -0x50(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jae 0x1de04c
movq -0x50(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x28(%rbp), %ecx
movq (%rax,%rcx,8), %rax
shrq $0x21, %rax
movl %eax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
movl -0x30(%rbp), %eax
movl %eax, %esi
leaq -0x34(%rbp), %rdx
leaq -0x38(%rbp), %rcx
leaq -0x40(%rbp), %r8
leaq -0x44(%rbp), %r9
xorl %eax, %eax
movq $0x0, (%rsp)
callq 0x1c4b20
movq $0x0, -0x58(%rbp)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movq -0x50(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jae 0x1ddeeb
movq -0x10(%rbp), %rax
movq 0xb8(%rax), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0xb8(%rcx), %rcx
movq 0x28(%rcx), %rcx
movq -0x50(%rbp), %rdx
movq 0x18(%rdx), %rdx
movl -0x28(%rbp), %esi
movq (%rdx,%rsi,8), %rdx
shrq $0x20, %rdx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movq 0x1e60ee(%rip), %rax    # 0x3c3fe0
movq (%rax), %rax
movq %rax, -0x68(%rbp)
movl -0x34(%rbp), %eax
shrl %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
movl -0x38(%rbp), %eax
shrl %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
cmpq $0x0, -0x58(%rbp)
je 0x1ddf23
movq -0x58(%rbp), %rax
movzbl 0x12(%rax), %eax
movl %eax, -0x6c(%rbp)
jmp 0x1ddf2d
movl $0x10, %eax
movl %eax, -0x6c(%rbp)
jmp 0x1ddf2d
movl -0x6c(%rbp), %eax
movl %eax, -0x70(%rbp)
cmpq $0x0, -0x58(%rbp)
je 0x1ddf4e
movq -0x58(%rbp), %rax
movw 0x10(%rax), %ax
shrw $0xf, %ax
movzwl %ax, %eax
movl %eax, -0x74(%rbp)
jmp 0x1ddf58
movl $0x10, %eax
movl %eax, -0x74(%rbp)
jmp 0x1ddf58
movl -0x70(%rbp), %r8d
movl -0x5c(%rbp), %ecx
movl -0x60(%rbp), %edx
movq -0x68(%rbp), %rdi
movl -0x74(%rbp), %r9d
movl -0x30(%rbp), %r11d
movq -0x10(%rbp), %rax
movq 0xb8(%rax), %rax
movq 0x28(%rax), %rax
movq -0x50(%rbp), %rsi
movq 0x18(%rsi), %rsi
movl -0x28(%rbp), %r10d
movq (%rsi,%r10,8), %rsi
shrq $0x20, %rsi
movq (%rax,%rsi,8), %rax
movl %eax, %r10d
movq -0x10(%rbp), %rax
movq 0xb8(%rax), %rax
movq 0x28(%rax), %rax
movq -0x50(%rbp), %rsi
movq 0x18(%rsi), %rsi
movl -0x28(%rbp), %ebx
movq (%rsi,%rbx,8), %rsi
shrq $0x20, %rsi
xorq $0x1, %rsi
movq (%rax,%rsi,8), %rax
leaq 0x1ae9f2(%rip), %rsi    # 0x38c9bb
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movb $0x0, %al
callq 0x22a0
movq -0x10(%rbp), %rax
movq 0xb8(%rax), %rax
movq 0x20(%rax), %rax
movl -0x30(%rbp), %ecx
movzbl 0x4(%rax,%rcx,8), %eax
cmpl $0x2, %eax
jne 0x1de03c
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x44(%rbp), %eax
jae 0x1de03a
movq 0x1e5fd1(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movq -0x40(%rbp), %rax
movl -0x2c(%rbp), %ecx
movl (%rax,%rcx,4), %edx
shrl %edx
addl $0x1, %edx
leaq 0x1ae9d9(%rip), %rsi    # 0x38ca01
movb $0x0, %al
callq 0x22a0
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x1de000
jmp 0x1de03c
jmp 0x1de03e
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x1dde42
jmp 0x1de04e
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x1ddde7
movq -0x20(%rbp), %rdi
callq 0xcd6f0
addq $0x88, %rsp
popq %rbx
popq %rbp
retq
nop