// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/sketch.cpp
// Function: debug_pl(char const*, int, int, int, int, ha_mz1_v*, void const*, st_mt_t*)
void debug_pl(const char *str, int len, int w, int k, int is_hpc, ha_mz1_v *p, const void *hf, st_mt_t *mt)
{
	int i, l, dbi, dbcnt = 0, kmer_span = 0;
	tiny_queue_t tq;
	memset(&tq, 0, sizeof(tiny_queue_t));
	uint64_t shift1 = k - 1, mask = (1ULL<<k) - 1, kmer[4] = {0,0,0,0};
	
    for (i = l = dbi = 0; i < len; ++i) {
        int c = seq_nt4_table[(uint8_t)str[i]];
        if (c < 4) { // not an ambiguous base
            int z;
            if (is_hpc) {
                int skip_len = 1;
                if (i + 1 < len && seq_nt4_table[(uint8_t)str[i + 1]] == c) {
                    for (skip_len = 2; i + skip_len < len; ++skip_len)
                        if (seq_nt4_table[(uint8_t)str[i + skip_len]] != c)
                            break;
                    i += skip_len - 1; // put $i at the end of the current homopolymer run
                }
                tq_push(&tq, skip_len);
                kmer_span += skip_len;
                ///how many bases that are covered by this HPC k-mer
                ///kmer_span includes at most k HPC elements
                if (tq.count > k) kmer_span -= tq_shift(&tq);
            } else kmer_span = l + 1 < k? l + 1 : k; 
            ///kmer_span should be used for HPC k-mer
            ///non-HPC k-mer, kmer_span should be k
            ///kmer_span is used to calculate anchor pos on reverse complementary strand

            kmer[0] = (kmer[0] << 1 | (c&1))  & mask;                  // forward k-mer
            kmer[1] = (kmer[1] << 1 | (c>>1)) & mask;
            kmer[2] = kmer[2] >> 1 | (uint64_t)(1 - (c&1))  << shift1; // reverse k-mer
            kmer[3] = kmer[3] >> 1 | (uint64_t)(1 - (c>>1)) << shift1;
            if (kmer[1] == kmer[3]) continue; // skip "symmetric k-mers" as we don't know it strand
            z = kmer[1] < kmer[3]? 0 : 1; // strand
            ++l;

            if (l >= k && kmer_span < 256) {
                uint64_t y;
                int32_t cnt;
                y = yak_hash64_64(kmer[z<<1|0]) + yak_hash64_64(kmer[z<<1|1]);
                cnt = hf? ha_ft_cnt(hf, y) : 0;

				for (dbi = 0; dbi < (int32_t)mt->n; dbi++)
				{
					if(p->a[dbi].x == y && p->a[dbi].rid == cnt && p->a[dbi].pos == i && p->a[dbi].rev == z && p->a[dbi].span == kmer_span)
					{
						if(l != (int)mt->a[dbi]) fprintf(stderr, "ERROR\n");
						dbcnt++;
					}
				}
            }
        } else l = 0, tq.count = tq.front = 0, kmer_span = 0;
	}

	if(dbcnt != (int32_t)mt->n) fprintf(stderr, "ERROR\n");
	if(mt->n != p->n) fprintf(stderr, "ERROR\n");
	for (dbi = 1; dbi < (int32_t)mt->n; dbi++)
	{
		if(p->a[dbi].pos <= p->a[dbi-1].pos || (int)mt->a[dbi] <= (int)mt->a[dbi-1])
		{
			fprintf(stderr, "ERROR\n");
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movq %r9, %rbx
movl %r8d, 0x44(%rsp)
movl %ecx, %r15d
movl %esi, %r12d
movq %rdi, %r13
leaq 0xa8(%rsp), %rdi
movl $0x100, %edx            # imm = 0x100
xorl %esi, %esi
callq 0x20e0
xorl %r8d, %r8d
movq %rbx, %r9
movq $-0x1, %r14
movq %r15, 0x28(%rsp)
movl %r15d, %ecx
shlq %cl, %r14
movl %r12d, 0xc(%rsp)
testl %r12d, %r12d
movq %rbx, 0x18(%rsp)
jle 0x11f9c6
movq %r13, %rbx
movq 0x28(%rsp), %rax
decl %eax
cltq
movq %rax, 0x70(%rsp)
notq %r14
movl 0xc(%rsp), %eax
movq %rax, 0x78(%rsp)
xorl %r13d, %r13d
movq $0x0, 0x60(%rsp)
xorl %edi, %edi
xorl %r15d, %r15d
xorl %r12d, %r12d
xorl %r10d, %r10d
xorl %r8d, %r8d
xorl %r11d, %r11d
movq $0x0, 0x30(%rsp)
xorl %ebp, %ebp
movq %rbx, 0x50(%rsp)
movq %r14, 0x48(%rsp)
movslq %r12d, %rdx
movzbl (%rbx,%rdx), %eax
leaq 0x11a640(%rip), %rcx    # 0x239c20
movzbl (%rcx,%rax), %eax
cmpl $0x3, %eax
ja 0x11f684
cmpl $0x0, 0x44(%rsp)
je 0x11f6a7
leaq 0x1(%rdx), %rsi
movl $0x1, %ecx
cmpl 0xc(%rsp), %esi
jge 0x11f6d9
movl %r11d, 0x14(%rsp)
movq %r10, %r11
movq %rdi, %r10
movzbl (%rbx,%rsi), %esi
leaq 0x11a5ff(%rip), %rdi    # 0x239c20
cmpb %al, (%rdi,%rsi)
jne 0x11f6ce
leal 0x2(%r12), %esi
movl $0x2, %ecx
cmpl 0xc(%rsp), %esi
jge 0x11f6c8
movq %rbp, 0x20(%rsp)
movl %r8d, 0x10(%rsp)
movl 0xc(%rsp), %ecx
subl %r12d, %ecx
movl %r12d, %edi
movl $0x2, %esi
leal (%rdi,%rsi), %r8d
movslq %r8d, %r8
movzbl (%rbx,%r8), %r8d
leaq 0x11a5b6(%rip), %rbp    # 0x239c20
cmpb %al, (%rbp,%r8)
jne 0x11f6bc
leaq (%rdx,%rsi), %r8
incq %r8
incq %rsi
cmpq 0x78(%rsp), %r8
jl 0x11f657
jmp 0x11f6be
movq $0x0, 0xa0(%rsp)
xorl %r15d, %r15d
movq $0x0, 0x30(%rsp)
xorl %r11d, %r11d
xorl %r10d, %r10d
jmp 0x11f9b8
leal 0x1(%r10), %r11d
movq 0x28(%rsp), %rcx
cmpl %ecx, %r11d
cmovgel %ecx, %r11d
jmp 0x11f745
movl %esi, %ecx
movl 0x10(%rsp), %r8d
movq 0x20(%rsp), %rbp
addl %ecx, %r12d
decl %r12d
movq %r10, %rdi
movq %r11, %r10
movl 0x14(%rsp), %r11d
leal 0x1(%r15), %edx
movl %edx, 0xa4(%rsp)
movq 0x30(%rsp), %rsi
addl %r15d, %esi
andl $0x3f, %esi
movl %ecx, 0xa8(%rsp,%rsi,4)
addl %ecx, %r11d
cmpl 0x28(%rsp), %r15d
jge 0x11f705
movl %edx, %r15d
jmp 0x11f745
testl %edx, %edx
je 0x11f73a
movq 0x30(%rsp), %rdx
movslq %edx, %rcx
incl %edx
movl %edx, 0xa0(%rsp)
movl 0xa8(%rsp,%rcx,4), %ecx
andl $0x3f, %edx
movl %edx, 0xa0(%rsp)
movl %r15d, 0xa4(%rsp)
movq %rdx, 0x30(%rsp)
jmp 0x11f742
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
xorl %r15d, %r15d
subl %ecx, %r11d
movq 0x60(%rsp), %rdx
movl %eax, %esi
andl $0x1, %esi
leaq (%rsi,%rbp,2), %rbp
andq %r14, %rbp
movq %rbp, 0x80(%rsp)
addq %rdi, %rdi
shrl %eax
orq %rax, %rdi
andq %r14, %rdi
xorl $0x1, %esi
movq 0x70(%rsp), %rcx
shlq %cl, %rsi
movq %rdi, 0x88(%rsp)
shrq %rdx
orq %rdx, %rsi
movq %rsi, 0x60(%rsp)
movq %rsi, 0x90(%rsp)
movq %r13, %rdx
movl $0x1, %r13d
subl %eax, %r13d
shlq %cl, %r13
shrq %rdx
orq %rdx, %r13
movq %r13, 0x98(%rsp)
cmpq %r13, %rdi
jne 0x11f7b9
movq %rdi, %r13
jmp 0x11f9b8
incl %r10d
cmpl 0x28(%rsp), %r10d
jl 0x11f9b8
cmpl $0xff, %r11d
jg 0x11f9b8
movq %rbp, 0x20(%rsp)
movq %r15, 0x58(%rsp)
xorl %eax, %eax
cmpq %r13, %rdi
setae %al
shll $0x4, %eax
movq 0x80(%rsp,%rax), %rcx
movq 0x88(%rsp,%rax), %rax
movq %rcx, %rdx
notq %rdx
shlq $0x15, %rcx
addq %rdx, %rcx
movq %rcx, %rdx
shrq $0x18, %rdx
xorq %rcx, %rdx
imulq $0x109, %rdx, %rcx      # imm = 0x109
movq %rcx, %rdx
shrq $0xe, %rdx
xorq %rcx, %rdx
leaq (%rdx,%rdx,4), %rcx
leaq (%rdx,%rcx,4), %rcx
movq %rcx, %rdx
shrq $0x1c, %rdx
xorq %rcx, %rdx
movq %rax, %rcx
notq %rcx
shlq $0x15, %rax
addq %rcx, %rax
movq %rax, %rcx
shrq $0x18, %rcx
xorq %rax, %rcx
imulq $0x109, %rcx, %rax      # imm = 0x109
movq %rax, %rcx
shrq $0xe, %rcx
xorq %rax, %rcx
leaq (%rcx,%rcx,4), %rax
leaq (%rcx,%rax,4), %rax
movq %rax, %rcx
shrq $0x1c, %rcx
xorq %rax, %rcx
addq %rdx, %rcx
movq %rcx, %rbp
shlq $0x1f, %rbp
addq %rcx, %rbp
cmpq $0x0, 0x1e0(%rsp)
je 0x11f8bb
movq %rdi, 0x38(%rsp)
movq 0x1e0(%rsp), %rdi
movq %rbp, %rsi
movl %r8d, %r14d
movq %r10, %rbx
movl %r11d, %r15d
callq 0x11a473
movl %r15d, %r11d
movq %rbx, %r10
movl %r14d, %r8d
movq 0x38(%rsp), %rdi
movq 0x18(%rsp), %r9
movl %eax, %r14d
jmp 0x11f8be
xorl %r14d, %r14d
movq 0x1e8(%rsp), %rax
movq (%rax), %rax
testl %eax, %eax
jle 0x11f9a4
movl $0x8, %ebx
xorl %r15d, %r15d
movq 0x8(%r9), %rcx
cmpq %rbp, -0x8(%rcx,%rbx)
jne 0x11f939
movq (%rcx,%rbx), %rcx
movl %ecx, %edx
andl $0xfffffff, %edx        # imm = 0xFFFFFFF
cmpl %r14d, %edx
jne 0x11f939
movq %rcx, %rdx
shrq $0x1c, %rdx
andl $0x7ffffff, %edx        # imm = 0x7FFFFFF
cmpl %r12d, %edx
jne 0x11f939
cmpq %r13, %rdi
setae %dl
btq $0x37, %rcx
setae %sil
cmpb %sil, %dl
je 0x11f939
shrq $0x38, %rcx
cmpl %ecx, %r11d
jne 0x11f939
movq 0x1e8(%rsp), %rcx
movq 0x10(%rcx), %rcx
cmpl (%rcx,%r15,8), %r10d
jne 0x11f94a
incl %r8d
incq %r15
movslq %eax, %rcx
addq $0x10, %rbx
cmpq %rcx, %r15
jl 0x11f8d9
jmp 0x11f9a4
movq 0x17568f(%rip), %rax    # 0x294fe0
movq (%rax), %rcx
movl $0x6, %esi
movl $0x1, %edx
movq %rdi, 0x38(%rsp)
leaq 0x11951a(%rip), %rdi    # 0x238e84
movl %r8d, 0x10(%rsp)
movq %r10, 0x68(%rsp)
movl %r11d, 0x14(%rsp)
callq 0x2410
movl 0x14(%rsp), %r11d
movl 0x10(%rsp), %r8d
movq 0x38(%rsp), %rdi
movq 0x1e8(%rsp), %r10
movq 0x18(%rsp), %r9
movq (%r10), %rax
movq 0x68(%rsp), %r10
jmp 0x11f936
movq 0x50(%rsp), %rbx
movq 0x48(%rsp), %r14
movq 0x58(%rsp), %r15
movq 0x20(%rsp), %rbp
incl %r12d
cmpl 0xc(%rsp), %r12d
jl 0x11f5d2
movq 0x1e8(%rsp), %rax
movq (%rax), %rax
cmpl %eax, %r8d
jne 0x11fa8a
movl (%r9), %ecx
cmpq %rcx, %rax
jne 0x11fabf
cmpl $0x2, %eax
jl 0x11fa78
movl $0x1, %ebx
movl $0x3, %r15d
movl $0x7ffffff, %ebp        # imm = 0x7FFFFFF
movq 0x1755da(%rip), %r12    # 0x294fe0
leaq 0x119477(%rip), %r14    # 0x238e84
movq 0x8(%r9), %rcx
movq -0x10(%rcx,%r15,8), %rdx
movq (%rcx,%r15,8), %rcx
shrq $0x1c, %rcx
andl %ebp, %ecx
shrq $0x1c, %rdx
andl %ebp, %edx
cmpl %edx, %ecx
jbe 0x11fa50
movq 0x1e8(%rsp), %rcx
movq 0x10(%rcx), %rcx
movl (%rcx,%rbx,8), %edx
cmpl -0x8(%rcx,%rbx,8), %edx
jle 0x11fa50
incq %rbx
movslq %eax, %rcx
addq $0x2, %r15
cmpq %rcx, %rbx
jl 0x11fa0d
jmp 0x11fa78
movq (%r12), %rcx
movl $0x6, %esi
movl $0x1, %edx
movq %r14, %rdi
callq 0x2410
movq 0x1e8(%rsp), %r10
movq 0x18(%rsp), %r9
movq (%r10), %rax
jmp 0x11fa3f
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x17554f(%rip), %rax    # 0x294fe0
movq (%rax), %rcx
leaq 0x1193e9(%rip), %rdi    # 0x238e84
movl $0x6, %esi
movl $0x1, %edx
callq 0x2410
movq 0x1e8(%rsp), %r10
movq 0x18(%rsp), %r9
movq (%r10), %rax
jmp 0x11f9da
movq 0x17551a(%rip), %rax    # 0x294fe0
movq (%rax), %rcx
leaq 0x1193b4(%rip), %rdi    # 0x238e84
movl $0x6, %esi
movl $0x1, %edx
callq 0x2410
movq 0x1e8(%rsp), %r10
movq 0x18(%rsp), %r9
movq (%r10), %rax
jmp 0x11f9e6