// File: /workspace/github_cpp_makefile_star2_O2/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, 0x80(%rsp)
movq %rsi, %rbx
movq %rdi, %r15
movq %rsi, %rdi
callq 0x2090
leaq 0x19(%rax), %rdi
pushq $0x1
popq %r12
movq %r12, %rsi
callq 0x2120
movq %rax, %r14
leaq 0xee53d(%rip), %rsi     # 0x1ed731
movq %rax, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2050
leaq 0xf24af(%rip), %rsi     # 0x1f16b7
movq %r14, 0x50(%rsp)
movq %r14, %rdi
callq 0x2210
movq %rax, %r13
xorps %xmm0, %xmm0
leaq 0x90(%rsp), %rbx
movaps %xmm0, (%rbx)
andq $0x0, 0x10(%rbx)
pushq $0x8
popq %rsi
movq %rbx, %rdi
movq %r12, %rdx
movq %rax, %rcx
callq 0x22f0
movq (%rbx), %rbx
movq %rbx, %r14
shlq $0x5, %r14
movq %r14, %rdi
callq 0x2280
movq %rax, %r12
pushq $0x20
popq %rsi
movq %rax, %rdi
movq %rbx, %rdx
movq %r13, 0x48(%rsp)
movq %r13, %rcx
callq 0x22f0
addq %r12, %r14
movq %r12, %rdi
movq %r14, %rsi
callq 0xff195
movq (%r15), %rdi
imulq $0x18, 0x18(%r15), %rsi
addq %rdi, %rsi
callq 0xfef2c
movq 0x153d54(%rip), %rax    # 0x252fe0
movq (%rax), %rdi
movq 0x18(%r15), %rdx
leaq 0xee4c7(%rip), %rsi     # 0x1ed761
movq %rbx, %rcx
xorl %eax, %eax
callq 0x22b0
movq %r15, %r10
movq %r12, 0x40(%rsp)
movq %r12, %r11
addq $0x10, %r11
xorl %r13d, %r13d
xorl %eax, %eax
movq $0x0, 0x20(%rsp)
movq $0x0, (%rsp)
movq $0x0, 0x8(%rsp)
movq %r15, 0x18(%rsp)
movq %r11, 0x10(%rsp)
cmpq 0x18(%r10), %rax
jae 0xff54d
movq (%r10), %rdx
movq %rax, 0x88(%rsp)
imulq $0x18, %rax, %r8
movq (%rdx,%r8), %rdi
movq (%rdi), %rsi
movq %rsi, %r14
leaq (%rsi,%rsi), %r15
movq 0x80(%rsp), %r9
movq 0x18(%r9), %rcx
pushq $0x40
popq %rax
subq %rcx, %rax
negq %rcx
shrq %cl, %r15
movq %r15, 0x30(%rsp)
shrq $0x3f, %r14
movq %r14, 0x38(%rsp)
movq 0x30(%r9), %r12
movq %r12, %r14
andq %rsi, %r14
movzwl 0x10(%rdx,%r8), %r9d
movq (%rdi,%r9,8), %rdi
movq %rdi, %rbp
leaq (%rdi,%rdi), %r9
shrq %cl, %r9
movq %r9, 0x28(%rsp)
shrq $0x3f, %rbp
movq %rdi, %r15
andq %r12, %r15
cmpq %rbx, %r13
movq %rbx, %rcx
cmovaq %r13, %rcx
movq 0x8(%rdx,%r8), %rdx
movq %r13, %r8
shlq $0x5, %r8
addq %r11, %r8
cmpq %rbx, %r13
jae 0xff384
cmpq %rdx, (%r8)
ja 0xff3b8
je 0xff389
incq %r13
addq $0x20, %r8
jmp 0xff36f
movq %rcx, %r13
jmp 0xff3a8
movq -0x10(%r8), %r9
movq -0x8(%r8), %rcx
cmpq %r9, %rsi
jne 0xff426
cmpq %rcx, %rdi
jne 0xff426
incq 0x20(%rsp)
movq 0x88(%rsp), %rax
incq %rax
jmp 0xff2dc
incq 0x8(%rsp)
movq 0x153c1c(%rip), %r12    # 0x252fe0
movq (%r12), %rdi
leaq 0xee3b3(%rip), %rsi     # 0x1ed782
xorl %eax, %eax
callq 0x22b0
movq (%r12), %rcx
leaq 0xee3b1(%rip), %rdi     # 0x1ed792
pushq $0x16
popq %rsi
pushq $0x1
popq %rdx
callq 0x2410
movq (%r12), %rdi
leaq 0xee3b2(%rip), %rsi     # 0x1ed7a9
movq 0x38(%rsp), %rdx
movq 0x30(%rsp), %rcx
movq %r14, %r8
xorl %eax, %eax
callq 0x22b0
movq (%r12), %rdi
leaq 0xee3bd(%rip), %rsi     # 0x1ed7d3
movq %rbp, %rdx
movq 0x28(%rsp), %rcx
movq %r15, %r8
jmp 0xff537
leaq (%rcx,%rcx), %rsi
movq %rcx, %rdi
movl %eax, %ecx
shrq %cl, %rsi
movq %rsi, 0x78(%rsp)
movq %rdi, %rcx
andq %r12, %rcx
movq %rcx, 0x70(%rsp)
shrq $0x3f, %rdi
movq %rdi, 0x68(%rsp)
leaq (%r9,%r9), %rsi
movl %eax, %ecx
shrq %cl, %rsi
movq %rsi, 0x60(%rsp)
andq %r9, %r12
shrq $0x3f, %r9
movq %r9, 0x58(%rsp)
incq (%rsp)
movq 0x153b70(%rip), %rax    # 0x252fe0
movq (%rax), %rdi
leaq 0xee383(%rip), %rsi     # 0x1ed7fd
xorl %eax, %eax
callq 0x22b0
movq 0x153b58(%rip), %rax    # 0x252fe0
movq (%rax), %rcx
leaq 0xee300(%rip), %rdi     # 0x1ed792
pushq $0x16
popq %rsi
pushq $0x1
popq %rdx
callq 0x2410
movq 0x153b3c(%rip), %rax    # 0x252fe0
movq (%rax), %rdi
leaq 0xee2fb(%rip), %rsi     # 0x1ed7a9
movq 0x38(%rsp), %rdx
movq 0x30(%rsp), %rcx
movq %r14, %r8
xorl %eax, %eax
callq 0x22b0
movq 0x153b17(%rip), %rax    # 0x252fe0
movq (%rax), %rdi
leaq 0xee300(%rip), %r14     # 0x1ed7d3
movq %r14, %rsi
movq %rbp, %rdx
movq 0x28(%rsp), %rcx
movq %r15, %r8
xorl %eax, %eax
callq 0x22b0
movq 0x153af1(%rip), %r15    # 0x252fe0
movq (%r15), %rcx
leaq 0xee314(%rip), %rdi     # 0x1ed80d
pushq $0x16
popq %rsi
pushq $0x1
popq %rdx
callq 0x2410
movq (%r15), %rdi
leaq 0xee29b(%rip), %rsi     # 0x1ed7a9
movq 0x58(%rsp), %rdx
movq 0x60(%rsp), %rcx
movq %r12, %r8
xorl %eax, %eax
callq 0x22b0
movq (%r15), %rdi
movq %r14, %rsi
movq 0x68(%rsp), %rdx
movq 0x78(%rsp), %rcx
movq 0x70(%rsp), %r8
xorl %eax, %eax
callq 0x22b0
movq 0x10(%rsp), %r11
movq 0x18(%rsp), %r10
jmp 0xff3a8
movq 0x153a8c(%rip), %rax    # 0x252fe0
movq (%rax), %rdi
leaq 0xee2c6(%rip), %rsi     # 0x1ed824
movq 0x20(%rsp), %rdx
movq (%rsp), %rcx
movq 0x8(%rsp), %r8
xorl %eax, %eax
callq 0x22b0
movq 0x40(%rsp), %rdi
callq 0x2220
movq 0x48(%rsp), %rdi
callq 0x2190
movq 0x50(%rsp), %rdi
callq 0x2220
pushq $0x1
popq %rdi
callq 0x2250