// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/anchor.cpp
// Function: recalu_minimizer0_adv(char*, unsigned long, unsigned long, long, unsigned long, unsigned long, tiny_queue_t*, unsigned long*, unsigned long*)
uint64_t recalu_minimizer0_adv(char *s, uint64_t len, uint64_t is_hpc, int64_t mz_k, uint64_t mz_h, uint64_t rev, tiny_queue_t *tq, uint64_t *rpos, uint64_t *rspan)
{
	uint64_t k, l, shift1 = mz_k - 1, mask = (1ULL<<mz_k) - 1, kmer[4] = {0,0,0,0}, c, z, hs; int64_t mz_l, mz_span;
	(*rpos) = (*rspan) = (uint64_t)-1;
	if(!rev) {
		if(is_hpc) {
			tq->front = tq->count = 0;
			for (k = 1, l = 0, mz_l = mz_span = 0; k <= len; ++k) {
				if (k == len || seq_nt4_table[(uint8_t)s[k]] != seq_nt4_table[(uint8_t)s[l]]) {
					c = seq_nt4_table[(uint8_t)s[l]];
					if(c < 4) {
						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**/
						mz_l++; mz_span += (k - l);
						tq_push(tq, k - l); if (tq->count > mz_k) mz_span -= tq_shift(tq);
						if(mz_l >= mz_k && mz_span < 256) {
							hs = yak_hash64_64(kmer[z<<1|0]) + yak_hash64_64(kmer[z<<1|1]);
							if(mz_h == hs) {
								(*rpos) = k - 1; (*rspan) = mz_span;
								return 1;
							}
						}
					} else {
						mz_l = mz_span = 0;
					}

					l = k;
				}
			}
		} else {
			for (k = 0, mz_l = mz_span = 0; k < len; ++k) {
				c = seq_nt4_table[(uint8_t)s[k]];
				if(c < 4) {
					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**/
					mz_l++; mz_span++; if(mz_span > mz_k) mz_span = mz_k;
					if(mz_l >= mz_k) {
						hs = yak_hash64_64(kmer[z<<1|0]) + yak_hash64_64(kmer[z<<1|1]);
						if(mz_h == hs) {
							(*rpos) = k; (*rspan) = mz_span;
							return 1;
						}
					}
				} else {
					mz_l = mz_span = 0;
				}
			}
		}
	} else {
		uint8_t ch[5] = {3, 2, 1, 0, 5};
		if(is_hpc) {
			tq->front = tq->count = 0;
			for (k = 1, l = 0, mz_l = mz_span = 0; k <= len; ++k) {
				if (k == len || seq_nt4_table[(uint8_t)s[len-k-1]] != seq_nt4_table[(uint8_t)s[len-l-1]]) {
					c = ch[seq_nt4_table[(uint8_t)s[len-l-1]]];
					if(c < 4) {
						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**/
						mz_l++; mz_span += (k - l);
						tq_push(tq, k - l); if (tq->count > mz_k) mz_span -= tq_shift(tq);
						if(mz_l >= mz_k && mz_span < 256) {
							hs = yak_hash64_64(kmer[z<<1|0]) + yak_hash64_64(kmer[z<<1|1]);
							if(mz_h == hs) {
								(*rpos) = k - 1; (*rspan) = mz_span;
								return 1;
							}
						}
					} else {
						mz_l = mz_span = 0;
					}

					l = k;
				}
			}
		} else {
			for (k = 0, mz_l = mz_span = 0; k < len; ++k) {
				c = ch[seq_nt4_table[(uint8_t)s[len-k-1]]];
				if(c < 4) {
					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**/
					mz_l++; mz_span++; if(mz_span > mz_k) mz_span = mz_k;
					if(mz_l >= mz_k) {
						hs = yak_hash64_64(kmer[z<<1|0]) + yak_hash64_64(kmer[z<<1|1]);
						if(mz_h == hs) {
							(*rpos) = k; (*rspan) = mz_span;
							return 1;
						}
					}
				} else {
					mz_l = mz_span = 0;
				}
			}
		}
	}
	
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r8, 0x48(%rsp)
movq %rdi, 0x10(%rsp)
movq 0xa0(%rsp), %r8
movq 0x98(%rsp), %rbx
movq 0x90(%rsp), %rdi
leaq -0x1(%rcx), %r10
pushq $-0x1
popq %rax
movq %rax, %r11
shlq %cl, %r11
xorq %rax, %r11
orq $-0x1, (%r8)
orq $-0x1, (%rbx)
testq %r9, %r9
movq %rcx, 0x40(%rsp)
movq %rsi, 0x28(%rsp)
movq %r10, 0x38(%rsp)
movq %r11, 0x30(%rsp)
je 0xeac64
testq %rdx, %rdx
je 0xeae42
pushq $0x1
popq %r12
andq $0x0, (%rdi)
movq 0x10(%rsp), %r8
leaq (%r8,%rsi), %r15
addq $-0x2, %r15
addq %rsi, %r8
leaq 0x10105f(%rip), %rbx    # 0x1ebb00
xorl %ebp, %ebp
xorl %r14d, %r14d
xorl %r13d, %r13d
movq $0x0, 0x8(%rsp)
xorl %eax, %eax
movq $0x0, 0x18(%rsp)
xorl %r9d, %r9d
movq %r8, 0x10(%rsp)
cmpq %rsi, %r12
ja 0xeb099
movq %rax, %rcx
notq %rcx
je 0xeaaeb
movzbl (%r15), %edx
movb (%rbx,%rdx), %dl
movzbl (%r8,%rcx), %edi
cmpb (%rbx,%rdi), %dl
je 0xeac59
movzbl (%r8,%rcx), %ecx
movzbl (%rbx,%rcx), %ecx
cmpq $0x4, %rcx
jne 0xeab0e
movq %r12, %rax
movq $0x0, 0x18(%rsp)
xorl %r9d, %r9d
jmp 0xeac59
leaq 0x102587(%rip), %rdx    # 0x1ed09c
movzbl (%rcx,%rdx), %ecx
movq %r14, %rdx
movl %ecx, %r14d
addq %r13, %r13
shrl %ecx
orq %rcx, %r13
movq %rbp, %rdi
pushq $0x1
popq %rbp
subq %rcx, %rbp
andl $0x1, %r14d
movq 0x8(%rsp), %rcx
leaq (%r14,%rcx,2), %rcx
andq %r11, %rcx
movq %rcx, 0x8(%rsp)
andq %r11, %r13
shrq %rdx
xorq $0x1, %r14
movl %r10d, %ecx
shlq %cl, %r14
shlq %cl, %rbp
orq %rdx, %r14
shrq %rdi
orq %rdi, %rbp
cmpq %rbp, %r13
jne 0xeab6e
movq %r13, %rbp
jmp 0xeac59
movl %r12d, %ecx
subl %eax, %ecx
movq 0x90(%rsp), %rbx
movslq 0x4(%rbx), %rdx
movq %rdx, %r8
incq %r8
movl %r8d, 0x4(%rbx)
movl (%rbx), %edi
addl %edx, %edi
andl $0x3f, %edi
movl %ecx, 0x8(%rbx,%rdi,4)
cmpq 0x40(%rsp), %r8
jle 0xeabc8
movq %r12, %rcx
subq %rax, %rcx
addq %rcx, %r9
movq %rbx, %rdi
movq %r9, %rbx
callq 0xea9b2
movq %rbx, %r9
movq 0x30(%rsp), %r11
movq 0x38(%rsp), %r10
movq 0x28(%rsp), %rsi
cltq
subq %rax, %r9
jmp 0xeabce
subq %rax, %r9
addq %r12, %r9
movq 0x18(%rsp), %rcx
incq %rcx
movq %rcx, 0x18(%rsp)
cmpq 0x40(%rsp), %rcx
movq 0x10(%rsp), %r8
leaq 0x100f14(%rip), %rbx    # 0x1ebb00
jl 0xeac56
cmpq $0xff, %r9
jg 0xeac56
movq %r9, 0x20(%rsp)
cmpq %rbp, %r13
movq %r14, %rdi
cmovbq 0x8(%rsp), %rdi
movq %rbp, %rbx
cmovbq %r13, %rbx
callq 0xea9d4
movq %rax, 0x50(%rsp)
movq %rbx, %rdi
callq 0xea9d4
addq 0x50(%rsp), %rax
cmpq 0x48(%rsp), %rax
je 0xeb0aa
movq %r12, %rax
movq 0x28(%rsp), %rsi
movq 0x38(%rsp), %r10
movq 0x30(%rsp), %r11
movq 0x20(%rsp), %r9
movq 0x10(%rsp), %r8
leaq 0x100eac(%rip), %rbx    # 0x1ebb00
jmp 0xeac59
movq %r12, %rax
incq %r12
decq %r15
jmp 0xeaac5
testq %rdx, %rdx
je 0xeaf81
andq $0x0, (%rdi)
pushq $0x1
popq %r15
leaq 0x100e84(%rip), %rbx    # 0x1ebb00
xorl %ebp, %ebp
xorl %r13d, %r13d
xorl %r14d, %r14d
movq $0x0, 0x8(%rsp)
xorl %eax, %eax
movq %r15, %r12
movq $0x0, 0x18(%rsp)
xorl %r9d, %r9d
movq 0x10(%rsp), %r8
cmpq %rsi, %r12
ja 0xeb099
jne 0xeacb8
movzbl (%r8,%rax), %ecx
movb (%rbx,%rcx), %cl
jmp 0xeacce
movzbl (%r8,%r12), %edx
movzbl (%r8,%rax), %ecx
movb (%rbx,%rcx), %cl
cmpb %cl, (%rbx,%rdx)
je 0xeae3a
cmpb $0x3, %cl
ja 0xead32
movzbl %cl, %ecx
movq %r13, %rdx
movl %ecx, %r13d
addq %r14, %r14
shrl %ecx
orq %rcx, %r14
movq %rbp, %rbx
movq %r15, %rbp
subq %rcx, %rbp
andl $0x1, %r13d
movq 0x8(%rsp), %rcx
leaq (,%rcx,2), %rcx
addq %r13, %rcx
andq %r11, %rcx
movq %rcx, 0x8(%rsp)
andq %r11, %r14
shrq %rdx
xorq $0x1, %r13
movl %r10d, %ecx
shlq %cl, %r13
shlq %cl, %rbp
orq %rdx, %r13
shrq %rbx
orq %rbx, %rbp
cmpq %rbp, %r14
jne 0xead46
movq %r14, %rbp
jmp 0xeae2e
movq %r12, %rax
movq $0x0, 0x18(%rsp)
xorl %r9d, %r9d
jmp 0xeae3a
movl %r12d, %ecx
subl %eax, %ecx
movslq 0x4(%rdi), %rdx
movq %rdx, %r8
incq %r8
movl %r8d, 0x4(%rdi)
movl (%rdi), %ebx
addl %edx, %ebx
andl $0x3f, %ebx
movl %ecx, 0x8(%rdi,%rbx,4)
cmpq 0x40(%rsp), %r8
jle 0xeada1
movq %r12, %rcx
subq %rax, %rcx
addq %rcx, %r9
movq %r9, %r15
callq 0xea9b2
movq %r15, %r9
pushq $0x1
popq %r15
movq 0x90(%rsp), %rdi
movq 0x30(%rsp), %r11
movq 0x38(%rsp), %r10
movq 0x28(%rsp), %rsi
cltq
subq %rax, %r9
jmp 0xeada7
subq %rax, %r9
addq %r12, %r9
leaq 0x100d52(%rip), %rbx    # 0x1ebb00
movq 0x18(%rsp), %rax
incq %rax
movq %rax, 0x18(%rsp)
cmpq 0x40(%rsp), %rax
movq 0x10(%rsp), %r8
jl 0xeae37
cmpq $0xff, %r9
jg 0xeae37
movq %r9, %r15
cmpq %rbp, %r14
movq %r13, %rdi
cmovbq 0x8(%rsp), %rdi
movq %rbp, %rbx
cmovbq %r14, %rbx
callq 0xea9d4
movq %rax, 0x20(%rsp)
movq %rbx, %rdi
callq 0xea9d4
addq 0x20(%rsp), %rax
cmpq 0x48(%rsp), %rax
je 0xeb0b9
movq %r12, %rax
movq 0x28(%rsp), %rsi
movq 0x38(%rsp), %r10
movq 0x30(%rsp), %r11
movq %r15, %r9
movq 0x10(%rsp), %r8
movq 0x90(%rsp), %rdi
pushq $0x1
popq %r15
leaq 0x100ccb(%rip), %rbx    # 0x1ebb00
jmp 0xeae3a
movq %r12, %rax
incq %r12
jmp 0xeaca3
movq 0x10(%rsp), %rax
leaq (%rsi,%rax), %r9
decq %r9
negq %rsi
leaq 0x100ca8(%rip), %rbx    # 0x1ebb00
xorl %r12d, %r12d
xorl %ebp, %ebp
xorl %r13d, %r13d
xorl %r14d, %r14d
xorl %r15d, %r15d
movq $0x0, 0x10(%rsp)
xorl %r8d, %r8d
movq %rsi, 0x28(%rsp)
movq %r9, 0x18(%rsp)
cmpq %r12, %rsi
je 0xeb099
movzbl (%r9,%r12), %eax
movzbl (%rbx,%rax), %eax
cmpq $0x4, %rax
jne 0xeaea5
movq $0x0, 0x10(%rsp)
xorl %r8d, %r8d
jmp 0xeaf79
leaq 0x1021f0(%rip), %rcx    # 0x1ed09c
movzbl (%rax,%rcx), %eax
movq %r13, %rdx
movl %eax, %r13d
addq %r14, %r14
shrl %eax
orq %rax, %r14
movq %rbp, %rdi
pushq $0x1
popq %rbp
subq %rax, %rbp
andl $0x1, %r13d
leaq (,%r15,2), %r15
addq %r13, %r15
andq %r11, %r15
andq %r11, %r14
shrq %rdx
xorq $0x1, %r13
movl %r10d, %ecx
shlq %cl, %r13
shlq %cl, %rbp
orq %rdx, %r13
shrq %rdi
orq %rdi, %rbp
cmpq %rbp, %r14
jne 0xeaeff
movq %r14, %rbp
jmp 0xeaf79
movq 0x10(%rsp), %rdx
incq %rdx
movq 0x40(%rsp), %rcx
cmpq %rcx, %r8
leaq 0x1(%r8), %r8
cmovgeq %rcx, %r8
movq %rdx, 0x10(%rsp)
cmpq %rcx, %rdx
jl 0xeaf79
movq %r8, 0x20(%rsp)
cmpq %rbp, %r14
movq %r13, %rdi
cmovbq %r15, %rdi
movq %rbp, %rbx
cmovbq %r14, %rbx
callq 0xea9d4
movq %rax, 0x8(%rsp)
movq %rbx, %rdi
callq 0xea9d4
addq 0x8(%rsp), %rax
cmpq 0x48(%rsp), %rax
je 0xeb0af
movq 0x28(%rsp), %rsi
movq 0x38(%rsp), %r10
movq 0x30(%rsp), %r11
movq 0x20(%rsp), %r8
movq 0x18(%rsp), %r9
leaq 0x100b87(%rip), %rbx    # 0x1ebb00
decq %r12
jmp 0xeae7c
leaq 0x100b78(%rip), %r9     # 0x1ebb00
pushq $0x1
popq %rbx
xorl %ebp, %ebp
xorl %r13d, %r13d
xorl %r14d, %r14d
xorl %r15d, %r15d
xorl %r12d, %r12d
movq $0x0, 0x8(%rsp)
xorl %r8d, %r8d
cmpq %r12, %rsi
je 0xeb099
movq 0x10(%rsp), %rax
movzbl (%rax,%r12), %eax
movzbl (%r9,%rax), %eax
cmpq $0x3, %rax
ja 0xeb012
movq %r13, %rdx
movl %eax, %r13d
addq %r14, %r14
shrl %eax
orq %rax, %r14
movq %rbp, %rdi
movq %rbx, %rbp
subq %rax, %rbp
andl $0x1, %r13d
leaq (,%r15,2), %r15
addq %r13, %r15
andq %r11, %r15
andq %r11, %r14
shrq %rdx
xorq $0x1, %r13
movl %r10d, %ecx
shlq %cl, %r13
shlq %cl, %rbp
orq %rdx, %r13
shrq %rdi
orq %rdi, %rbp
cmpq %rbp, %r14
jne 0xeb023
movq %r14, %rbp
jmp 0xeb01e
movq $0x0, 0x8(%rsp)
xorl %r8d, %r8d
incq %r12
jmp 0xeafa5
movq 0x8(%rsp), %rdx
incq %rdx
movq 0x40(%rsp), %rcx
cmpq %rcx, %r8
leaq 0x1(%r8), %r8
cmovgeq %rcx, %r8
movq %rdx, 0x8(%rsp)
cmpq %rcx, %rdx
jl 0xeb01e
cmpq %rbp, %r14
movq %r13, %rdi
cmovbq %r15, %rdi
movq %rbp, %rbx
cmovbq %r14, %rbx
movq %r8, 0x20(%rsp)
callq 0xea9d4
movq %rax, 0x18(%rsp)
movq %rbx, %rdi
pushq $0x1
popq %rbx
callq 0xea9d4
leaq 0x100a89(%rip), %r9     # 0x1ebb00
movq 0x20(%rsp), %r8
movq 0x30(%rsp), %r11
movq 0x38(%rsp), %r10
movq 0x28(%rsp), %rsi
addq 0x18(%rsp), %rax
cmpq 0x48(%rsp), %rax
jne 0xeb01e
jmp 0xeb0bf
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
decq %r12
jmp 0xeb0b2
negq %r12
movq 0x20(%rsp), %r8
jmp 0xeb0bf
decq %r12
movq %r15, %r8
movq 0x98(%rsp), %rax
movq %r12, (%rax)
movq 0xa0(%rsp), %rax
movq %r8, (%rax)
pushq $0x1
popq %rax
jmp 0xeb09b