// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/anchor.cpp
// Function: hpc_minimizer_test(long, All_reads*, UC_Read*, long, long, long, long, long, long)
int64_t hpc_minimizer_test(int64_t id, All_reads *rref, UC_Read *bu, int64_t str_s, int64_t str_e, int64_t z, int64_t len, int64_t rev, int64_t step)
{
	if(z < 0 || z >= len) return 0;
	if(z == 0 && rev == 1) return 0;
	if(z == len - 1 && rev == 0) return 0;

	int64_t an, sc, ec, k, tn = 0; char c = 0, *a = NULL;
	if(z >= str_s && z < str_e) c = bu->seq[z-str_s];

	if(rev) {
		if(c != 0) {
			if(z > str_s) {
				a = bu->seq; an = z - str_s;
				for (k = an - 1; k >= 0 && a[k] == c; k--);
				tn += an - k - 1;
				if((k >= 0) || (z - tn == 0)) return tn;
				ec = str_s; 
			} else {
				ec = z; 
			}
		} else {
			ec = z + 1; 
		}

		sc = ec - step; if(sc < 0) sc = 0;
		if(ec <= 0 || ec > len || ec <= sc) return tn;

		UC_Read_resize((*bu), (str_e - str_s) + (step)); 
		a = bu->seq + str_e - str_s;

		while (1) {
			recover_UC_Read_sub_region(a, sc, ec - sc, 0, rref, id); an = ec - sc; 
			if(c == 0) c = a[--an];
			for (k = an - 1; k >= 0 && a[k] == c; k--);
			tn += an - k - 1;
			if((k >= 0) || (z - tn == 0)) return tn;
			ec = sc;
			sc = ec - step; if(sc < 0) sc = 0;
			if(ec <= 0 || ec > len || ec <= sc) return tn;
		}
	} else {
		if(c != 0) {
			if(z + 1 < str_e) {
				a = bu->seq + z + 1 - str_s; an = str_e - z - 1;
				for (k = 0; k < an && a[k] == c; k++);
				tn += k;
				if((k < an) || (z + tn + 1 == len)) return tn;
				sc = str_e; 
			} else {
				sc = z + 1; 
			}
		} else {
			sc = z; 
		}

		ec = sc + step; if(ec > len) ec = len;
		if(sc < 0 || sc >= len || sc >= ec) return tn;

		UC_Read_resize((*bu), (str_e - str_s) + (step)); 
		a = bu->seq + str_e - str_s;

		while (1) {
			// if(bu->size < (a - bu->seq) + (ec - sc)) {
			// 	fprintf(stderr, "-1-[M::%s]\tid::%ld\n", __func__, id);
			// }
			recover_UC_Read_sub_region(a, sc, ec - sc, 0, rref, id); an = ec - sc; 
			a = bu->seq + str_e - str_s;
			if(c == 0) {
				c = a[0]; a = a + 1; an--; 
			} 
			for (k = 0; k < an && a[k] == c; k++);
			tn += k;
			if((k < an) || (z + tn + 1 == len)) return tn;
			sc = ec;
			ec = sc + step; if(ec > len) ec = len;
			if(sc < 0 || sc >= len || sc >= ec) return tn;
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rcx, %r14
movq 0x70(%rsp), %r11
testq %r9, %r9
sets %al
cmpq %r11, %r9
setge %cl
orb %al, %cl
jne 0xeb62b
movq 0x78(%rsp), %rbx
movq %rbx, %rax
xorq $0x1, %rax
orq %r9, %rax
je 0xeb62b
leaq -0x1(%r11), %rax
xorq %r9, %rax
orq %rbx, %rax
jne 0xeb646
movq $0x0, (%rsp)
movq (%rsp), %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x80(%rsp), %rbp
movq %r9, %rcx
subq %r14, %rcx
setl %al
cmpq %r8, %r9
setge %r10b
orb %al, %r10b
jne 0xeb6be
movq (%rdx), %rax
movb (%rax,%rcx), %r15b
testq %rbx, %rbx
je 0xeb82a
testb %r15b, %r15b
je 0xeb6c7
cmpq %r14, %r9
jle 0xeb9c9
movq %rdx, %r13
movq %rdi, %rbx
movq %rsi, %r10
movq %rcx, %rdx
sarq $0x3f, %rdx
andq %rcx, %rdx
pushq $-0x1
popq %rsi
movq %rsi, (%rsp)
movq %rcx, %rsi
testq %rsi, %rsi
jle 0xeb9e3
leaq -0x1(%rsi), %rdi
incq (%rsp)
cmpb %r15b, -0x1(%rax,%rsi)
movq %rdi, %rsi
je 0xeb69e
jmp 0xeb633
testq %rbx, %rbx
je 0xeb86f
leaq 0x1(%r9), %r12
xorl %r15d, %r15d
xorl %eax, %eax
movq %rax, (%rsp)
movq %r12, %rax
subq %rbp, %rax
xorl %ebx, %ebx
testq %rax, %rax
cmovgq %rax, %rbx
testq %rbp, %rbp
jle 0xeb633
testq %r12, %r12
jle 0xeb633
cmpq %r11, %r12
jg 0xeb633
movq %rdi, %r13
movq %rsi, %r10
movq (%rdx), %rax
movq %r8, 0x8(%rsp)
movq %rbp, %rcx
movq %r8, %rbp
subq %r14, %rbp
addq %rcx, %rbp
cmpq %rbp, 0x10(%rdx)
movq %r9, 0x10(%rsp)
jge 0xeb753
movq %rax, %rdi
movq %rbp, %rsi
movq %r10, 0x18(%rsp)
movq %r13, 0x20(%rsp)
movq %rdx, 0x28(%rsp)
callq 0x2370
movq 0x20(%rsp), %r13
movq 0x18(%rsp), %r10
movq 0x28(%rsp), %rcx
movq %rax, (%rcx)
movq %rbp, 0x10(%rcx)
movq 0x8(%rsp), %rcx
leaq (%rax,%rcx), %r8
subq %r14, %r8
notq %r14
addq %rcx, %r14
addq %rax, %r14
movq %r14, 0x8(%rsp)
movq %r12, %rbp
movq %rbx, %r12
subq %rbx, %rbp
movq %r8, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
xorl %ecx, %ecx
movq %r8, %r14
movq %r10, %rbx
movq %r10, %r8
movq %r13, %r9
callq 0x6c9e
testb %r15b, %r15b
jne 0xeb79f
movb -0x1(%r14,%rbp), %r15b
decq %rbp
movq %r14, %r8
movq %rbp, %rcx
sarq $0x3f, %rcx
andq %rbp, %rcx
movq %rbp, %rdx
movq 0x10(%rsp), %r9
movq %rbx, %r10
movq 0x70(%rsp), %rsi
movq 0x80(%rsp), %rdi
movq (%rsp), %r11
movq 0x8(%rsp), %r14
movq %rdx, %rax
testq %rdx, %rdx
jle 0xeb7e5
leaq -0x1(%rax), %rdx
cmpb %r15b, (%r14,%rax)
je 0xeb7cd
incq %rdx
movq %rdx, %rcx
subq %rcx, %rbp
addq %rbp, %r11
testq %rax, %rax
movq %r11, (%rsp)
jg 0xeb633
cmpq %r9, %r11
je 0xeb633
movq %r12, %rbx
subq %rdi, %rbx
testq %rbx, %rbx
movl $0x0, %eax
cmovleq %rax, %rbx
testq %r12, %r12
je 0xeb633
cmpq %rsi, %r12
jle 0xeb76d
jmp 0xeb633
testb %r15b, %r15b
je 0xeb86f
leaq 0x1(%r9), %r13
cmpq %r8, %r13
jae 0xeb9d3
addq %r9, %rax
subq %r14, %rax
incq %rax
movq %r9, %rbx
notq %rbx
addq %r8, %rbx
xorl %ecx, %ecx
testq %rbx, %rbx
cmovleq %rcx, %rbx
cmpq %rcx, %rbx
je 0xeba07
cmpb %r15b, (%rax,%rcx)
jne 0xeba2a
incq %rcx
jmp 0xeb857
movq %rdi, %r12
movq %rsi, %r10
movq %r8, 0x8(%rsp)
xorl %r15d, %r15d
movq %r9, %r13
movq $0x0, (%rsp)
movq %rbp, %rsi
addq %r13, %rbp
cmpq %r11, %rbp
cmovgeq %r11, %rbp
cmpq %r11, %r13
setl %al
cmpq %rbp, %r13
setl %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0xeb633
movq %r13, 0x30(%rsp)
movq (%rdx), %rdi
movq 0x8(%rsp), %rbx
subq %r14, %rbx
addq %rsi, %rbx
cmpq %rbx, 0x10(%rdx)
movq %rdx, 0x28(%rsp)
jge 0xeb8fe
movq %rdx, %r13
movq %rbx, %rsi
movq %r9, 0x10(%rsp)
movq %r10, 0x18(%rsp)
movq %r12, 0x20(%rsp)
callq 0x2370
movq 0x20(%rsp), %r12
movq 0x18(%rsp), %r10
movq 0x10(%rsp), %r9
movq %rax, %rdi
movq %rax, (%r13)
movq %rbx, 0x10(%r13)
addq 0x8(%rsp), %rdi
subq %r14, %rdi
negq %r14
incq %r9
movq 0x30(%rsp), %rsi
movq %r9, 0x10(%rsp)
movq %rbp, %rbx
subq %rsi, %rbx
movq %rbx, %rdx
xorl %ecx, %ecx
movq %r10, %r8
movq %r10, %r13
movq %r12, %r9
callq 0x6c9e
movq 0x28(%rsp), %rax
movq (%rax), %rdi
addq 0x8(%rsp), %rdi
addq %r14, %rdi
testb %r15b, %r15b
jne 0xeb94d
movb (%rdi), %r15b
incq %rdi
decq %rbx
testq %rbx, %rbx
movl $0x0, %eax
cmovleq %rax, %rbx
xorl %eax, %eax
movq 0x10(%rsp), %r9
movq %r13, %r10
movq 0x70(%rsp), %rcx
movq 0x80(%rsp), %rdx
cmpq %rax, %rbx
je 0xeb980
cmpb %r15b, (%rdi,%rax)
jne 0xeb9c0
incq %rax
jmp 0xeb970
movq (%rsp), %rsi
addq %rbx, %rsi
leaq (%r9,%rsi), %rax
cmpq %rcx, %rax
movq %rsi, (%rsp)
je 0xeb633
leaq (%rdx,%rbp), %rax
cmpq %rcx, %rax
cmovgeq %rcx, %rax
cmpq %rcx, %rbp
jge 0xeb633
movq %rbp, %rsi
cmpq %rax, %rbp
movq %rax, %rbp
jl 0xeb916
jmp 0xeb633
addq %rax, (%rsp)
jmp 0xeb633
xorl %eax, %eax
movq %r9, %r12
jmp 0xeb6d0
movq %rdi, %r12
movq %rsi, %r10
movq %r8, 0x8(%rsp)
jmp 0xeb880
subq %rdx, %rcx
movq %r14, %r12
movq %rcx, %rax
cmpq %r9, %rcx
movq %r10, %rsi
movq %rbx, %rdi
movq %r13, %rdx
jne 0xeb6d0
movq %r9, (%rsp)
jmp 0xeb633
movq %rdi, %r12
movq %rsi, %r10
movq %rbx, (%rsp)
addq %rbx, %r13
cmpq %r11, %r13
movq %r8, 0x8(%rsp)
movq %r8, %r13
je 0xeb633
jmp 0xeb888
movq %rcx, (%rsp)
jmp 0xeb633