// File: /workspace/github_cpp_makefile_star2_O1/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, %r13
movq %rsi, %rdi
callq 0x2090
leaq 0x19(%rax), %rdi
movl $0x1, %esi
callq 0x2120
movq %rax, %r15
leaq 0xee999(%rip), %rsi     # 0x22f5f1
xorl %r12d, %r12d
movq %rax, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2050
leaq 0x90(%rsp), %r14
movq %r12, 0x10(%r14)
xorl %ebx, %ebx
xorps %xmm0, %xmm0
movaps %xmm0, (%r14)
leaq 0xf2923(%rip), %rsi     # 0x2335a7
movq %r15, 0x68(%rsp)
movq %r15, %rdi
callq 0x2210
movq %rax, %rbp
xorps %xmm0, %xmm0
movaps %xmm0, (%r14)
movq %rbx, 0x10(%r14)
movl $0x8, %esi
movl $0x1, %edx
movq %r14, %rdi
movq %rax, %rcx
callq 0x22f0
movq (%r14), %r15
movq %r15, 0x8(%r14)
movq %r15, %rbx
shlq $0x5, %rbx
movq %rbx, %rdi
callq 0x2280
movq %rax, %r12
movq %rax, 0x10(%r14)
movl $0x20, %esi
movq %rax, %rdi
movq %r15, %rdx
movq %rbp, 0x60(%rsp)
movq %rbp, %rcx
callq 0x22f0
addq %r12, %rbx
movq %r12, 0x40(%rsp)
movq %r12, %rdi
movq %rbx, %rsi
callq 0x140bfa
movq (%r13), %rdi
movq 0x18(%r13), %rax
leaq (%rax,%rax,2), %rax
leaq (%rdi,%rax,8), %rsi
callq 0x140984
movq 0x1492c8(%rip), %rax    # 0x289fe0
movq (%rax), %rdi
movq 0x18(%r13), %rdx
leaq 0xee8fb(%rip), %rsi     # 0x22f621
movq %r15, %rcx
xorl %eax, %eax
callq 0x22b0
movq 0x10(%rsp), %r10
movl $0x0, %eax
movq %rax, (%rsp)
movl $0x0, %eax
movq %rax, 0x8(%rsp)
movq $0x0, 0x28(%rsp)
xorl %eax, %eax
cmpq %rax, 0x18(%r13)
jne 0x140da7
movq 0x149280(%rip), %rax    # 0x289fe0
movq (%rax), %rdi
leaq 0xee97a(%rip), %rsi     # 0x22f6e4
movq 0x28(%rsp), %rdx
movq (%rsp), %rcx
movq 0x8(%rsp), %r8
xorl %eax, %eax
callq 0x22b0
movq 0x40(%rsp), %rdi
callq 0x2220
movq 0x60(%rsp), %rdi
callq 0x2190
movq 0x68(%rsp), %rdi
callq 0x2220
movl $0x1, %edi
callq 0x2250
movq %r13, %r11
movq 0x40(%rsp), %rax
addq $0x10, %rax
movq %rax, 0x88(%rsp)
movq $0x0, 0x8(%rsp)
movq $0x0, (%rsp)
movq $0x0, 0x28(%rsp)
xorl %r14d, %r14d
xorl %ebx, %ebx
movq %r13, 0x48(%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 %r15, %rbx
jae 0x140ea0
movq 0x8(%rdx,%r8,8), %rdx
movq %rax, %rcx
shrq $0x3f, %rcx
movq %rcx, 0x58(%rsp)
movq 0x30(%r10), %r13
movl $0x40, %ecx
subq %rdi, %rcx
movq %r13, %rdi
andq %rax, %rdi
movq %rdi, 0x50(%rsp)
movq %rsi, %r9
shrq $0x3f, %r9
movq %rsi, %r8
movq %r13, 0x38(%rsp)
andq %r13, %r8
movq %rbx, %rdi
shlq $0x5, %rdi
addq 0x88(%rsp), %rdi
cmpq %rdx, (%rdi)
ja 0x140eb2
je 0x140e79
incq %rbx
addq $0x20, %rdi
cmpq %rbx, %r15
jne 0x140e61
movq %r15, %rbx
jmp 0x140ea0
movq -0x10(%rdi), %r13
movq -0x8(%rdi), %rdi
movq %r13, 0x30(%rsp)
cmpq %r13, %rax
movq %rdi, %r13
jne 0x140f30
cmpq %r13, %rsi
jne 0x140f30
incq 0x28(%rsp)
incq %r14
cmpq 0x18(%r11), %r14
jb 0x140ddf
jmp 0x140d59
incq 0x8(%rsp)
movq 0x149122(%rip), %r13    # 0x289fe0
movq (%r13), %rdi
leaq 0xee779(%rip), %rsi     # 0x22f642
xorl %eax, %eax
movq %r8, 0x20(%rsp)
movq %r9, 0x18(%rsp)
callq 0x22b0
movq (%r13), %rcx
movl $0x16, %esi
movl $0x1, %edx
leaq 0xee763(%rip), %rdi     # 0x22f652
callq 0x2410
movq (%r13), %rdi
leaq 0xee76a(%rip), %rsi     # 0x22f669
movq 0x58(%rsp), %rdx
movq %r12, %rcx
movq 0x50(%rsp), %r8
xorl %eax, %eax
callq 0x22b0
movq (%r13), %rdi
leaq 0xee775(%rip), %rsi     # 0x22f693
movq 0x18(%rsp), %rdx
movq %rbp, %rcx
movq 0x20(%rsp), %r8
jmp 0x141065
leaq (,%r13,2), %rax
shrq %cl, %rax
movq %rax, 0x80(%rsp)
movq %r13, %rax
movq 0x38(%rsp), %rsi
andq %rsi, %rax
movq %rax, 0x78(%rsp)
shrq $0x3f, %r13
movq 0x30(%rsp), %rdi
leaq (%rdi,%rdi), %rax
shrq %cl, %rax
movq %rax, 0x70(%rsp)
andq %rdi, %rsi
movq %rsi, 0x38(%rsp)
shrq $0x3f, %rdi
movq %rdi, 0x30(%rsp)
incq (%rsp)
movq 0x14905c(%rip), %rax    # 0x289fe0
movq (%rax), %rdi
leaq 0xee72f(%rip), %rsi     # 0x22f6bd
xorl %eax, %eax
movq %r8, 0x20(%rsp)
movq %r9, 0x18(%rsp)
callq 0x22b0
movq 0x14903a(%rip), %rax    # 0x289fe0
movq (%rax), %rcx
movl $0x16, %esi
movl $0x1, %edx
leaq 0xee698(%rip), %rdi     # 0x22f652
callq 0x2410
movq 0x14901a(%rip), %rax    # 0x289fe0
movq (%rax), %rdi
leaq 0xee699(%rip), %rsi     # 0x22f669
movq 0x58(%rsp), %rdx
movq %r12, %rcx
movq 0x50(%rsp), %r8
xorl %eax, %eax
callq 0x22b0
movq 0x148ff5(%rip), %rax    # 0x289fe0
movq (%rax), %rdi
leaq 0xee69e(%rip), %r12     # 0x22f693
movq %r12, %rsi
movq 0x18(%rsp), %rdx
movq %rbp, %rcx
movq 0x20(%rsp), %r8
xorl %eax, %eax
callq 0x22b0
movq 0x148fcd(%rip), %rbp    # 0x289fe0
movq (%rbp), %rcx
movl $0x16, %esi
movl $0x1, %edx
leaq 0xee6a5(%rip), %rdi     # 0x22f6cd
callq 0x2410
movq (%rbp), %rdi
leaq 0xee631(%rip), %rsi     # 0x22f669
movq 0x30(%rsp), %rdx
movq 0x70(%rsp), %rcx
movq 0x38(%rsp), %r8
xorl %eax, %eax
callq 0x22b0
movq (%rbp), %rdi
movq %r12, %rsi
movq %r13, %rdx
movq 0x80(%rsp), %rcx
movq 0x78(%rsp), %r8
xorl %eax, %eax
callq 0x22b0
movq 0x48(%rsp), %r11
movq 0x10(%rsp), %r10
jmp 0x140ea0