// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/hic.cpp
// Function: debug_hc_hits_v14(kvec_pe_hit_hap*, char const*, ha_ug_index const*)
void debug_hc_hits_v14(kvec_pe_hit_hap* i_hits, const char *fn, const ha_ug_index* idx)
{
    uint64_t flag = 0;
    char *buf = (char*)calloc(strlen(fn) + 25, 1);
	sprintf(buf, "%s.v14.hic.lk.bin", fn);
    kvec_pe_hit hits; 
    kv_init(hits.a);
    FILE* fp = NULL; 
    fp = fopen(buf, "r"); 

    kv_init(hits.a);
    flag += fread(&hits.a.n, sizeof(hits.a.n), 1, fp);
    hits.a.m = hits.a.n; MALLOC(hits.a.a, hits.a.n);
    flag += fread(hits.a.a, sizeof(pe_hit), hits.a.n, fp);

    radix_sort_pe_hit_id(hits.a.a, hits.a.a + hits.a.n);
    radix_sort_pe_hit_hap_id(i_hits->a, i_hits->a + i_hits->n_u);

    fprintf(stderr, "i_hits->n_u: %lu, hits.a.n: %lu\n", (uint64_t)i_hits->n_u, (uint64_t)hits.a.n);

    uint64_t i, k;
    uint64_t i_beg_utg, i_beg_pos, i_beg_rev;
    uint64_t i_end_utg, i_end_pos, i_end_rev;
    uint64_t k_beg_utg, k_beg_pos, k_beg_rev;
    uint64_t k_end_utg, k_end_pos, k_end_rev;
    uint64_t i_id, k_id;
    uint64_t same_occ = 0, diff_occ = 0, miss_occ = 0;
    for (i = 0, k = 0; i < i_hits->n_u; i++)
    {
        i_beg_rev = get_pe_s(i_hits->a[i])>>63;
        i_beg_utg = ((get_pe_s(i_hits->a[i])<<1)>>(64 - idx->uID_bits));
        i_beg_pos = get_pe_s(i_hits->a[i]) & idx->pos_mode;

        i_end_rev = get_pe_e(i_hits->a[i])>>63;
        i_end_utg = ((get_pe_e(i_hits->a[i])<<1)>>(64 - idx->uID_bits));
        i_end_pos = get_pe_e(i_hits->a[i]) & idx->pos_mode;

        i_id = i_hits->a[i].id;
        for (; k < hits.a.n; k++)
        {
            k_beg_rev = hits.a.a[k].s>>63;
            k_beg_utg = ((hits.a.a[k].s<<1)>>(64 - idx->uID_bits));
            k_beg_pos = hits.a.a[k].s & idx->pos_mode;

            k_end_rev = hits.a.a[k].e>>63;
            k_end_utg = ((hits.a.a[k].e<<1)>>(64 - idx->uID_bits));
            k_end_pos = hits.a.a[k].e & idx->pos_mode;

            k_id = hits.a.a[k].id;

            if(k_id > i_id)
            {
                miss_occ++;
                fprintf(stderr, "\n[MISS]rid=%lu\n", i_id);
                fprintf(stderr, "********v0.15********\n");
                fprintf(stderr, "beg_rev: %lu, beg_utg: %lu, beg_pos: %lu\n", 
                i_beg_rev, i_beg_utg, i_beg_pos);
                fprintf(stderr, "end_rev: %lu, end_utg: %lu, end_pos: %lu\n", 
                i_end_rev, i_end_utg, i_end_pos);
                break;
            } 
            
            if(k_id == i_id)
            {
                if(get_pe_s(i_hits->a[i]) == hits.a.a[k].s && get_pe_e(i_hits->a[i]) == hits.a.a[k].e)
                {
                    same_occ++;
                    // fprintf(stderr, "\n[SAME]rid=%lu\n", i_id);
                    // fprintf(stderr, "********v0.15********\n");
                    // fprintf(stderr, "beg_rev: %lu, beg_utg: %lu, beg_pos: %lu\n", 
                    // i_beg_rev, i_beg_utg, i_beg_pos);
                    // fprintf(stderr, "end_rev: %lu, end_utg: %lu, end_pos: %lu\n", 
                    // i_end_rev, i_end_utg, i_end_pos);
                    // fprintf(stderr, "********v0.14********\n");
                    // fprintf(stderr, "beg_rev: %lu, beg_utg: %lu, beg_pos: %lu\n", 
                    // k_beg_rev, k_beg_utg, k_beg_pos);
                    // fprintf(stderr, "end_rev: %lu, end_utg: %lu, end_pos: %lu\n", 
                    // k_end_rev, k_end_utg, k_end_pos);
                }
                else
                {
                    diff_occ++;
                    fprintf(stderr, "\n[DIFF]rid=%lu\n", i_id);
                    fprintf(stderr, "********v0.15********\n");
                    fprintf(stderr, "beg_rev: %lu, beg_utg: %lu, beg_pos: %lu\n", 
                    i_beg_rev, i_beg_utg, i_beg_pos);
                    fprintf(stderr, "end_rev: %lu, end_utg: %lu, end_pos: %lu\n", 
                    i_end_rev, i_end_utg, i_end_pos);
                    fprintf(stderr, "********v0.14********\n");
                    fprintf(stderr, "beg_rev: %lu, beg_utg: %lu, beg_pos: %lu\n", 
                    k_beg_rev, k_beg_utg, k_beg_pos);
                    fprintf(stderr, "end_rev: %lu, end_utg: %lu, end_pos: %lu\n", 
                    k_end_rev, k_end_utg, k_end_pos);
                }
                break;
            }
        }
    }
    
    fprintf(stderr, "same_occ: %lu, diff_occ: %lu, miss_occ: %lu", same_occ, diff_occ, miss_occ);


    kv_destroy(hits.a);
    fclose(fp);
    free(buf);
    exit(1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rdx, 0x10(%rsp)
movq %rsi, %rbx
movq %rdi, %r15
movq %rsi, %rdi
callq 0x2090
leaq 0x19(%rax), %rdi
movl $0x1, %esi
callq 0x2120
movq %rax, %r14
leaq 0xf4f2c(%rip), %rsi     # 0x23b841
movq $0x0, 0x28(%rsp)
movq %rax, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2050
leaq 0xf8ec5(%rip), %rsi     # 0x23f7f7
movq %r14, 0x60(%rsp)
movq %r14, %rdi
callq 0x2210
movq %rax, %r12
xorps %xmm0, %xmm0
leaq 0x90(%rsp), %rbx
movaps %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
movl $0x8, %esi
movl $0x1, %edx
movq %rbx, %rdi
movq %rax, %rcx
callq 0x22f0
movq (%rbx), %r13
movq %r13, %r14
shlq $0x5, %r14
movq %r14, %rdi
callq 0x2280
movq %rax, %rbx
movl $0x20, %esi
movq %rax, %rdi
movq %r13, %rdx
movq %r12, 0x58(%rsp)
movq %r12, %rcx
callq 0x22f0
addq %rbx, %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1468b7
movq (%r15), %rdi
movq 0x18(%r15), %rax
leaq (%rax,%rax,2), %rax
leaq (%rdi,%rax,8), %rsi
callq 0x146649
movq 0x14e61d(%rip), %rax    # 0x294fe0
movq (%rax), %rdi
movq 0x18(%r15), %rdx
leaq 0xf4ea0(%rip), %rsi     # 0x23b871
movq %r13, %rcx
xorl %eax, %eax
callq 0x22b0
cmpq $0x0, 0x18(%r15)
movq %rbx, 0x50(%rsp)
jne 0x146a46
movq $0x0, (%rsp)
movq $0x0, 0x8(%rsp)
movq 0x14e5e1(%rip), %rax    # 0x294fe0
movq (%rax), %rdi
leaq 0xf4f2b(%rip), %rsi     # 0x23b934
movq 0x28(%rsp), %rdx
movq (%rsp), %rcx
movq 0x8(%rsp), %r8
xorl %eax, %eax
callq 0x22b0
movq 0x50(%rsp), %rdi
callq 0x2220
movq 0x58(%rsp), %rdi
callq 0x2190
movq 0x60(%rsp), %rdi
callq 0x2220
movl $0x1, %edi
callq 0x2250
movq %r15, %r11
addq $0x10, %rbx
movq %rbx, 0x88(%rsp)
movq $0x0, 0x8(%rsp)
movq $0x0, (%rsp)
movq $0x0, 0x28(%rsp)
xorl %r14d, %r14d
xorl %ebx, %ebx
movq 0x10(%rsp), %r10
movq %r15, 0x38(%rsp)
movq (%r11), %rdx
leaq (%r14,%r14,2), %r8
movq (%rdx,%r8,8), %rsi
movq (%rsi), %rax
leaq (%rax,%rax), %r12
movq 0x18(%r10), %rdi
movq %rdi, %rcx
negq %rcx
shrq %cl, %r12
movzwl 0x10(%rdx,%r8,8), %r9d
movq (%rsi,%r9,8), %rsi
leaq (%rsi,%rsi), %rbp
shrq %cl, %rbp
cmpq %r13, %rbx
jae 0x146b37
movq 0x8(%rdx,%r8,8), %rdx
movq %rax, %rcx
shrq $0x3f, %rcx
movq %rcx, 0x48(%rsp)
movq 0x30(%r10), %r15
movl $0x40, %ecx
subq %rdi, %rcx
movq %r15, %rdi
andq %rax, %rdi
movq %rdi, 0x40(%rsp)
movq %rsi, %r9
shrq $0x3f, %r9
movq %rsi, %r8
movq %r15, 0x30(%rsp)
andq %r15, %r8
movq %rbx, %rdi
shlq $0x5, %rdi
addq 0x88(%rsp), %rdi
cmpq %rdx, (%rdi)
ja 0x146b49
je 0x146b18
incq %rbx
addq $0x20, %rdi
cmpq %rbx, %r13
jne 0x146b00
movq %r13, %rbx
jmp 0x146b37
movq -0x10(%rdi), %r15
movq -0x8(%rdi), %rdi
cmpq %r15, %rax
jne 0x146bc3
cmpq %rdi, %rsi
jne 0x146bc3
incq 0x28(%rsp)
incq %r14
cmpq 0x18(%r11), %r14
jb 0x146a7e
jmp 0x1469f8
incq 0x8(%rsp)
movq 0x14e48b(%rip), %r15    # 0x294fe0
movq (%r15), %rdi
leaq 0xf4d33(%rip), %rsi     # 0x23b892
xorl %eax, %eax
movq %r8, 0x20(%rsp)
movq %r9, 0x18(%rsp)
callq 0x22b0
movq (%r15), %rcx
movl $0x16, %esi
movl $0x1, %edx
leaq 0xf4d1e(%rip), %rdi     # 0x23b8a2
callq 0x2410
movq (%r15), %rdi
leaq 0xf4d26(%rip), %rsi     # 0x23b8b9
movq 0x48(%rsp), %rdx
movq %r12, %rcx
movq 0x40(%rsp), %r8
xorl %eax, %eax
callq 0x22b0
movq (%r15), %rdi
leaq 0xf4d32(%rip), %rsi     # 0x23b8e3
movq 0x18(%rsp), %rdx
movq %rbp, %rcx
movq 0x20(%rsp), %r8
jmp 0x146cf2
leaq (%rdi,%rdi), %rax
shrq %cl, %rax
movq %rax, 0x80(%rsp)
movq %rdi, %rax
movq 0x30(%rsp), %rsi
andq %rsi, %rax
movq %rax, 0x78(%rsp)
shrq $0x3f, %rdi
movq %rdi, 0x70(%rsp)
leaq (%r15,%r15), %rax
shrq %cl, %rax
movq %rax, 0x68(%rsp)
andq %r15, %rsi
movq %rsi, 0x30(%rsp)
shrq $0x3f, %r15
incq (%rsp)
movq 0x14e3d2(%rip), %rax    # 0x294fe0
movq (%rax), %rdi
leaq 0xf4cf5(%rip), %rsi     # 0x23b90d
xorl %eax, %eax
movq %r8, 0x20(%rsp)
movq %r9, 0x18(%rsp)
callq 0x22b0
movq 0x14e3b0(%rip), %rax    # 0x294fe0
movq (%rax), %rcx
movl $0x16, %esi
movl $0x1, %edx
leaq 0xf4c5e(%rip), %rdi     # 0x23b8a2
callq 0x2410
movq 0x14e390(%rip), %rax    # 0x294fe0
movq (%rax), %rdi
leaq 0xf4c5f(%rip), %rsi     # 0x23b8b9
movq 0x48(%rsp), %rdx
movq %r12, %rcx
movq 0x40(%rsp), %r8
xorl %eax, %eax
callq 0x22b0
movq 0x14e36b(%rip), %rax    # 0x294fe0
movq (%rax), %rdi
movq %r15, %r12
leaq 0xf4c61(%rip), %r15     # 0x23b8e3
movq %r15, %rsi
movq 0x18(%rsp), %rdx
movq %rbp, %rcx
movq 0x20(%rsp), %r8
xorl %eax, %eax
callq 0x22b0
movq 0x14e340(%rip), %rbp    # 0x294fe0
movq (%rbp), %rcx
movl $0x16, %esi
movl $0x1, %edx
leaq 0xf4c68(%rip), %rdi     # 0x23b91d
callq 0x2410
movq (%rbp), %rdi
leaq 0xf4bf4(%rip), %rsi     # 0x23b8b9
movq %r12, %rdx
movq 0x68(%rsp), %rcx
movq 0x30(%rsp), %r8
xorl %eax, %eax
callq 0x22b0
movq (%rbp), %rdi
movq %r15, %rsi
movq 0x70(%rsp), %rdx
movq 0x80(%rsp), %rcx
movq 0x78(%rsp), %r8
xorl %eax, %eax
callq 0x22b0
movq 0x38(%rsp), %r11
movq 0x10(%rsp), %r10
jmp 0x146b37