// File: chhylp123[P]hifiasm/hic.cpp
// Function: debug_output_disconnected_hits(ha_ug_index*, kv_u_trans_t*, kvec_pe_hit*, hc_links*, bubble_type*, signed char*)
void debug_output_disconnected_hits(ha_ug_index* idx, kv_u_trans_t *ta, kvec_pe_hit *hits, hc_links *link, bubble_type *bub, int8_t *s)
{
    uint32_t k, l, i, m, h_occ;
    uint64_t shif = 64 - idx->uID_bits, qn, tn, u_dis;
    pe_hit *h_a = NULL;
    hc_linkeage *t = NULL;
    u_trans_t *p = NULL;
    kv_u_trans_t k_trans; 
    kv_init(k_trans);


    for (qn = 0; qn < hits->idx.n; qn++)
    {
        if(IF_HOM(qn, *bub)) continue;
        h_a = hits->a.a + (hits->idx.a[qn]>>32);
        h_occ = (uint32_t)(hits->idx.a[qn]);

        for (k = 1, l = 0; k <= h_occ; ++k) ///same qn
        {
            if (k == h_occ || ((h_a[k].e<<1)>>shif) != ((h_a[l].e<<1)>>shif)) //same qn and tn
            {
                tn = ((h_a[l].e<<1)>>shif);
                if(!IF_HOM(tn, *bub) && tn != qn)
                {
                    // t = &(link->a.a[qn]);
                    // for (i = 0, u_dis = (uint64_t)-1; i < t->e.n; i++)
                    // {
                    //     if(t->e.a[i].del || t->e.a[i].uID != tn) continue;
                    //     u_dis = (t->e.a[i].dis ==(uint64_t)-1? (uint64_t)-1 : t->e.a[i].dis>>3);
                    //     break;
                    // }
                    
                    // if(u_dis == (uint64_t)-1)
                    {
                        kv_pushp(u_trans_t, k_trans, &p);
                        p->qn = qn; p->tn = tn; p->occ = (k-l);
                        kv_pushp(u_trans_t, k_trans, &p);
                        p->qn = tn; p->tn = qn; p->occ = (k-l);
                    }
                }
                l = k;
            }
        }
    }


    radix_sort_u_trans_m(k_trans.a, k_trans.a + k_trans.n);

    for (k = 1, l = 0, m = 0; k <= k_trans.n; ++k)
    {
        if (k == k_trans.n || k_trans.a[l].qn != k_trans.a[k].qn || k_trans.a[l].tn != k_trans.a[k].tn) //same qn and tn
        {
            for (i = l, h_occ = 0; i < k; i++)
            {
                h_occ += k_trans.a[i].occ;
            }

            k_trans.a[m] = k_trans.a[l];
            k_trans.a[m].occ = ((uint32_t)-1) - h_occ;
            m++;
            l = k;
        }
    }
    k_trans.n = m;

    radix_sort_u_trans_occ(k_trans.a, k_trans.a + k_trans.n);
    for (i = 0; i < k_trans.n; i++)
    {
        qn = k_trans.a[i].qn;
        tn = k_trans.a[i].tn;

        t = &(link->a.a[qn]);
        for (k = 0, u_dis = (uint64_t)-1; k < t->e.n; k++)
        {
            if(t->e.a[k].del || t->e.a[k].uID != tn) continue;
            u_dis = (t->e.a[k].dis ==(uint64_t)-1? (uint64_t)-1 : t->e.a[k].dis>>3);
            break;
        }
        get_u_trans_spec(ta, qn, tn, &p, NULL);

        fprintf(stderr, "s-utg%.6lul[hap-%d]<--->d-utg%.6lul[hap-%d](occ: %u, ",
        qn + 1, s[qn], tn + 1, s[tn], ((uint32_t)-1) - k_trans.a[i].occ);
        if(p) fprintf(stderr, "weight: %f", p->nw);
        else fprintf(stderr, "weight: NA");
        fprintf(stderr, "):(dis-%lu)\n", u_dis);
    }

    // fprintf(stderr, "########hits########\n");
    // char dir[2] = {'+', '-'};
    // for (k = 0; k < hits->a.n; ++k) 
    // { 
    //     fprintf(stderr, "%c\tutg%.6dl(len-%u)\t%lu\t%c\tutg%.6dl(len-%u)\t%lu\ti:%lu\n", 
    //     dir[hits->a.a[k].s>>63], (int)((hits->a.a[k].s<<1)>>shif)+1, 
    //     idx->ug->g->seq[((hits->a.a[k].s<<1)>>shif)].len, hits->a.a[k].s&idx->pos_mode,
    //     dir[hits->a.a[k].e>>63], (int)((hits->a.a[k].e<<1)>>shif)+1, 
    //     idx->ug->g->seq[((hits->a.a[k].e<<1)>>shif)].len, hits->a.a[k].e&idx->pos_mode,
    //     hits->a.a[k].id);        
    // }
    kv_destroy(k_trans);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x8(%rbp), %rcx
movl $0x40, %eax
subq 0x18(%rcx), %rax
movq %rax, -0x50(%rbp)
movq $0x0, -0x70(%rbp)
movq $0x0, -0x78(%rbp)
movq $0x0, -0x80(%rbp)
movq $0x0, -0xa8(%rbp)
movq $0x0, -0xb0(%rbp)
movq $0x0, -0xa0(%rbp)
movq $0x0, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jae 0x205391
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq -0x58(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq -0x28(%rbp), %rcx
movq 0x80(%rcx), %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
jbe 0x20510e
jmp 0x205380
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rcx
movq 0x28(%rcx), %rcx
movq -0x58(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x70(%rbp)
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x58(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, -0x44(%rbp)
movl $0x1, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x44(%rbp), %eax
ja 0x20537e
movl -0x34(%rbp), %eax
cmpl -0x44(%rbp), %eax
je 0x2051ae
movq -0x70(%rbp), %rax
movl -0x34(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
shlq %rax
movq -0x50(%rbp), %rcx
shrq %cl, %rax
movq -0x70(%rbp), %rcx
movl -0x38(%rbp), %edx
shlq $0x5, %rdx
addq %rdx, %rcx
movq 0x8(%rcx), %rdx
shlq %rdx
movq -0x50(%rbp), %rcx
shrq %cl, %rdx
movq %rdx, %rcx
cmpq %rcx, %rax
je 0x20536e
movq -0x70(%rbp), %rax
movl -0x38(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
shlq %rax
movq -0x50(%rbp), %rcx
shrq %cl, %rax
movq %rax, -0x60(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq -0x60(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq -0x28(%rbp), %rcx
movq 0x80(%rcx), %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
ja 0x205368
movq -0x60(%rbp), %rax
cmpq -0x58(%rbp), %rax
je 0x205368
jmp 0x205204
movq -0xb0(%rbp), %rax
cmpq -0xa8(%rbp), %rax
jne 0x205268
cmpq $0x0, -0xa8(%rbp)
je 0x205231
movq -0xa8(%rbp), %rax
shlq %rax
movq %rax, -0xb8(%rbp)
jmp 0x20523f
movl $0x2, %eax
movq %rax, -0xb8(%rbp)
jmp 0x20523f
movq -0xb8(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0xa0(%rbp), %rdi
imulq $0x30, -0xa8(%rbp), %rsi
callq 0x2360
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movq -0xb0(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0xb0(%rbp)
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movq -0x58(%rbp), %rax
movl %eax, %ecx
movq -0x80(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x60(%rbp), %rax
movl %eax, %ecx
movq -0x80(%rbp), %rax
movl %ecx, 0x14(%rax)
movl -0x34(%rbp), %ecx
subl -0x38(%rbp), %ecx
movq -0x80(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0xb0(%rbp), %rax
cmpq -0xa8(%rbp), %rax
jne 0x20531a
cmpq $0x0, -0xa8(%rbp)
je 0x2052e3
movq -0xa8(%rbp), %rax
shlq %rax
movq %rax, -0xc0(%rbp)
jmp 0x2052f1
movl $0x2, %eax
movq %rax, -0xc0(%rbp)
jmp 0x2052f1
movq -0xc0(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0xa0(%rbp), %rdi
imulq $0x30, -0xa8(%rbp), %rsi
callq 0x2360
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movq -0xb0(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0xb0(%rbp)
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movq -0x60(%rbp), %rax
movl %eax, %ecx
movq -0x80(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x58(%rbp), %rax
movl %eax, %ecx
movq -0x80(%rbp), %rax
movl %ecx, 0x14(%rax)
movl -0x34(%rbp), %ecx
subl -0x38(%rbp), %ecx
movq -0x80(%rbp), %rax
movl %ecx, 0x18(%rax)
movl -0x34(%rbp), %eax
movl %eax, -0x38(%rbp)
jmp 0x205370
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x205156
jmp 0x205380
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x2050d5
movq -0xa0(%rbp), %rdi
movq -0xa0(%rbp), %rsi
imulq $0x30, -0xb0(%rbp), %rax
addq %rax, %rsi
callq 0x1b8260
movl $0x1, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
movl $0x0, -0x40(%rbp)
movl -0x34(%rbp), %eax
cmpq -0xb0(%rbp), %rax
ja 0x2054d9
movl -0x34(%rbp), %eax
cmpq -0xb0(%rbp), %rax
je 0x205438
movq -0xa0(%rbp), %rax
movl -0x38(%rbp), %ecx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movq -0xa0(%rbp), %rcx
movl -0x34(%rbp), %edx
imulq $0x30, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x8(%rcx), %eax
jne 0x205438
movq -0xa0(%rbp), %rax
movl -0x38(%rbp), %ecx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movl 0x14(%rax), %eax
movq -0xa0(%rbp), %rcx
movl -0x34(%rbp), %edx
imulq $0x30, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x14(%rcx), %eax
je 0x2054c9
movl -0x38(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x34(%rbp), %eax
jae 0x205472
movq -0xa0(%rbp), %rax
movl -0x3c(%rbp), %ecx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
addl -0x44(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x205445
movq -0xa0(%rbp), %rsi
movl -0x38(%rbp), %eax
imulq $0x30, %rax, %rax
addq %rax, %rsi
movq -0xa0(%rbp), %rdi
movl -0x40(%rbp), %eax
imulq $0x30, %rax, %rax
addq %rax, %rdi
movl $0x30, %edx
callq 0x2180
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
subl -0x44(%rbp), %ecx
movq -0xa0(%rbp), %rax
movl -0x40(%rbp), %edx
imulq $0x30, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x18(%rax)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x38(%rbp)
jmp 0x2054cb
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x2053c4
movl -0x40(%rbp), %eax
movq %rax, -0xb0(%rbp)
movq -0xa0(%rbp), %rdi
movq -0xa0(%rbp), %rsi
imulq $0x30, -0xb0(%rbp), %rax
addq %rax, %rsi
callq 0x1b8730
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpq -0xb0(%rbp), %rax
jae 0x205700
movq -0xa0(%rbp), %rax
movl -0x3c(%rbp), %ecx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movq %rax, -0x58(%rbp)
movq -0xa0(%rbp), %rax
movl -0x3c(%rbp), %ecx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movl 0x14(%rax), %eax
movq %rax, -0x60(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
imulq $0x30, -0x58(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movl $0x0, -0x34(%rbp)
movq $-0x1, -0x68(%rbp)
movl -0x34(%rbp), %eax
movq -0x78(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x205619
movq -0x78(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x34(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movb 0x18(%rax), %al
shrb $0x7, %al
cmpb $0x0, %al
jne 0x2055b2
movq -0x78(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x34(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
cmpq -0x60(%rbp), %rax
je 0x2055b4
jmp 0x20560b
movq -0x78(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x34(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
cmpq $-0x1, 0x10(%rax)
jne 0x2055dd
movq $-0x1, %rax
movq %rax, -0xc8(%rbp)
jmp 0x2055fe
movq -0x78(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x34(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
shrq $0x3, %rax
movq %rax, -0xc8(%rbp)
movq -0xc8(%rbp), %rax
movq %rax, -0x68(%rbp)
jmp 0x205619
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x20556b
movq -0x10(%rbp), %rdi
movq -0x58(%rbp), %rax
movl %eax, %esi
movq -0x60(%rbp), %rax
movl %eax, %edx
leaq -0x80(%rbp), %rcx
xorl %eax, %eax
movl %eax, %r8d
callq 0x110ee0
movq 0x1be9a2(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movq -0x58(%rbp), %rdx
addq $0x1, %rdx
movq -0x30(%rbp), %rax
movq -0x58(%rbp), %rcx
movsbl (%rax,%rcx), %ecx
movq -0x60(%rbp), %r8
addq $0x1, %r8
movq -0x30(%rbp), %rax
movq -0x60(%rbp), %rsi
movsbl (%rax,%rsi), %r9d
movq -0xa0(%rbp), %rsi
movl -0x3c(%rbp), %eax
imulq $0x30, %rax, %rax
addq %rax, %rsi
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
subl 0x18(%rsi), %eax
leaq 0x187bd5(%rip), %rsi    # 0x38d25f
movl %eax, (%rsp)
movb $0x0, %al
callq 0x22a0
cmpq $0x0, -0x80(%rbp)
je 0x2056be
movq 0x1be93e(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movq -0x80(%rbp), %rax
movsd 0x20(%rax), %xmm0
leaq 0x187be0(%rip), %rsi    # 0x38d295
movb $0x1, %al
callq 0x22a0
jmp 0x2056d6
movq 0x1be91b(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
leaq 0x187bd1(%rip), %rsi    # 0x38d2a0
movb $0x0, %al
callq 0x22a0
movq 0x1be903(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movq -0x68(%rbp), %rdx
leaq 0x187bc0(%rip), %rsi    # 0x38d2ab
movb $0x0, %al
callq 0x22a0
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x205508
movq -0xa0(%rbp), %rdi
callq 0x2210
addq $0xd0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)