// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/./Levenshtein_distance.h
// Function: ed_band_cal_semi_64_w_absent_diag(char*, int, char*, int, int, int, bit_extz_t*)
inline void ed_band_cal_semi_64_w_absent_diag(char *pstr, int32_t pn, char *tstr, int32_t tn, int32_t thre, int32_t abs_diag, bit_extz_t *ez)
{
	init_base_ed(*ez, thre, pn, tn); ez->ps = ez->pe = -1; ez->ts = 0; ez->te = tn-1;
	Word c, Peq[5] = {0}, VP = 0, VN, X, D0, HN, HP, mm;
	int32_t bd, i, err = abs_diag, i_bd, last_high = (thre<<1), tn0 = tn - 1, cut = thre+last_high;
	if((pn > tn + cut) || (tn > pn + cut)) return;

	bd = ((thre<<1)+1)-abs_diag; bd = ((bd<=pn)?bd:pn); i_bd = abs_diag; 
	for (i = 0, mm = (((Word)1)<<i_bd); i < bd; i++) {
        Peq[seq_nt4_table[(uint8_t)pstr[i]]] |= mm; mm <<= 1;
    }
	i_bd = (thre<<1)-abs_diag; VN = (((Word)1)<<(abs_diag))-1; 

	i = 0; Peq[4] = 0; mm = ((Word)1 << (thre<<1));///for the incoming char/last char**
	while (i < tn0) {
		ed_core_64(Peq, VP, VN, X, D0, HN, HP, (uint8_t)tstr[i]);
		if (!(D0&(1ULL))) {
            ++err; if (err>cut) return;
        }

		Peq[0] >>= 1; Peq[1] >>= 1; Peq[2] >>= 1; Peq[3] >>= 1;
		++i; ++i_bd; c = 4;
		if(i_bd < pn) c = seq_nt4_table[(uint8_t)pstr[i_bd]];
		if(c < 4) Peq[c] |= mm; 
	}
	ed_core_64(Peq, VP, VN, X, D0, HN, HP, (uint8_t)tstr[i]);
	if (!(D0&(1ULL))) {
		++err; if (err>cut) return;
	}

	int32_t site = tn - 1 - abs_diag;/**up bound**/
    /**in most cases, ai = (thre<<1)**/
    int32_t ai = pn - tn + abs_diag, uge = INT32_MAX; i = 0;
	for (i = 0; site < 0 && i < ai; i++, site++) {
		err += ((VP >> i)&(1ULL)); err -= ((VN >> i)&(1ULL));
	}
    if ((err <= thre) && (err <= ez->err)) {
        ez->err = err; ez->pe = site;
    }
    site -= i;
    while (i < ai) {
        err += ((VP >> i)&(1ULL)); err -= ((VN >> i)&(1ULL)); ++i;
        if ((err <= thre) && (err <= ez->err)) {
            ez->err = err; ez->pe = site + i;
        }
        if(i == thre) uge = err;
    }
    
    if((uge <= thre) && (uge == ez->err)) ez->pe = site + thre;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl %r9d, -0x4c(%rsp)
movq 0x38(%rsp), %rax
movl %r8d, 0x28(%rax)
movl $0x7fffffff, 0x2c(%rax) # imm = 0x7FFFFFFF
movl %esi, 0x18(%rax)
movl %ecx, 0x24(%rax)
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq $-0x1, 0x10(%rax)
movl $0x0, 0x1c(%rax)
leal -0x1(%rcx), %r9d
movq %r9, -0x40(%rsp)
movl %r9d, 0x20(%rax)
movaps %xmm0, -0x18(%rsp)
movaps %xmm0, -0x28(%rsp)
movq $0x0, -0x8(%rsp)
movq %r8, -0x48(%rsp)
leal (%r8,%r8,2), %r14d
leal (%r14,%rcx), %eax
cmpl %esi, %eax
setl %al
movq %rsi, -0x38(%rsp)
addl %r14d, %esi
movq %rcx, -0x30(%rsp)
cmpl %ecx, %esi
setl %cl
orb %al, %cl
jne 0x8c499
movq -0x48(%rsp), %rax
leal (%rax,%rax), %r10d
movl %r10d, %r8d
orl $0x1, %r8d
movl -0x4c(%rsp), %ecx
subl %ecx, %r8d
movq -0x38(%rsp), %rbx
cmpl %ebx, %r8d
cmovgel %ebx, %r8d
movl $0x1, %r12d
movl $0x1, %r15d
shlq %cl, %r15
testl %r8d, %r8d
jle 0x8c260
movl %r8d, %ecx
xorl %r8d, %r8d
leaq 0x1a17cd(%rip), %r9     # 0x22da10
movq %r15, %r11
movzbl (%rdi,%r8), %eax
movzbl (%r9,%rax), %eax
orq %r11, -0x28(%rsp,%rax,8)
addq %r11, %r11
incq %r8
cmpq %r8, %rcx
jne 0x8c246
decq %r15
movq $0x0, -0x8(%rsp)
movl %r10d, %ecx
shlq %cl, %r12
cmpl $0x2, -0x30(%rsp)
jl 0x8c348
movl -0x4c(%rsp), %ecx
subl %ecx, %r10d
movslq %r10d, %r13
movslq %ebx, %rbp
movl -0x40(%rsp), %r10d
leaq (%rdi,%r13), %rsi
incq %rsi
incq %r13
xorl %r11d, %r11d
leaq 0x1a176d(%rip), %r8     # 0x22da10
xorl %r9d, %r9d
movzbl (%rdx,%r11), %eax
movzbl (%r8,%rax), %eax
movq -0x28(%rsp,%rax,8), %rax
orq %r15, %rax
movq %rax, %rdi
andq %r9, %rdi
addq %r9, %rdi
xorq %r9, %rdi
orq %rax, %rdi
testb $0x1, %dil
jne 0x8c2d8
cmpl %r14d, %ecx
jge 0x8c499
incl %ecx
shrq -0x28(%rsp)
shrq -0x20(%rsp)
shrq -0x18(%rsp)
shrq -0x10(%rsp)
leaq (%r11,%r13), %rbx
movl $0x4, %eax
cmpq %rbp, %rbx
jge 0x8c304
movzbl (%rsi,%r11), %eax
movzbl (%r8,%rax), %eax
cmpl $0x3, %eax
ja 0x8c30e
orq %r12, -0x28(%rsp,%rax,8)
movq %rdi, %rax
andq %r9, %rax
orq %rdi, %r9
notq %r9
movq %r15, %rbx
orq %r9, %rbx
shrq %rdi
movq %rbx, %r15
andq %rdi, %r15
orq %rbx, %rdi
notq %rdi
movq %rdi, %r9
orq %rax, %r9
incq %r11
cmpq %r11, %r10
jne 0x8c2a6
movq -0x38(%rsp), %rbx
jmp 0x8c352
xorl %r10d, %r10d
movl -0x4c(%rsp), %ecx
xorl %r9d, %r9d
movzbl (%rdx,%r10), %eax
leaq 0x1a16b2(%rip), %rdx    # 0x22da10
movzbl (%rdx,%rax), %eax
movq -0x28(%rsp,%rax,8), %rax
orq %r15, %rax
movq %rax, %rdx
andq %r9, %rdx
addq %r9, %rdx
xorq %r9, %rdx
orq %rax, %rdx
testb $0x1, %dl
jne 0x8c395
cmpl %r14d, %ecx
jge 0x8c499
incl %ecx
movq -0x40(%rsp), %r12
movq -0x38(%rsp), %rbx
jmp 0x8c39a
movq -0x40(%rsp), %r12
movq %rdx, %rax
andq %r9, %rax
orq %rdx, %r9
notq %r9
orq %r9, %r15
shrq %rdx
movq %r15, %rdi
andq %rdx, %rdi
orq %r15, %rdx
notq %rdx
orq %rax, %rdx
subl -0x30(%rsp), %ebx
movl -0x4c(%rsp), %eax
addl %eax, %ebx
subl %eax, %r12d
sets %al
testl %ebx, %ebx
setg %sil
andb %al, %sil
xorl %eax, %eax
cmpb $0x1, %sil
jne 0x8c40d
movl %ebx, %r8d
movl %r12d, %r9d
xorl %eax, %eax
movq 0x38(%rsp), %r15
leal (%r9,%rax), %esi
btq %rax, %rdx
adcl $0x0, %ecx
btq %rax, %rdi
sbbl $0x0, %ecx
incq %rax
cmpl $-0x2, %esi
jg 0x8c408
cmpq %r8, %rax
jb 0x8c3e9
addl %eax, %r12d
jmp 0x8c412
movq 0x38(%rsp), %r15
cmpl -0x48(%rsp), %ecx
jg 0x8c420
movl %ecx, 0x2c(%r15)
movl %r12d, 0x14(%r15)
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
cmpl %ebx, %eax
jge 0x8c476
movl -0x48(%rsp), %r9d
movl %eax, %r11d
movslq %ebx, %rsi
movq %r9, %r10
decq %r10
leal 0x1(%r12), %ebx
btq %r11, %rdx
adcl $0x0, %ecx
btq %r11, %rdi
sbbl $0x0, %ecx
cmpl %r9d, %ecx
jg 0x8c461
cmpl 0x2c(%r15), %ecx
jg 0x8c461
movl %ecx, 0x2c(%r15)
movl %ebx, 0x14(%r15)
cmpq %r11, %r10
cmovel %ecx, %r8d
leaq 0x1(%r11), %r14
incl %ebx
movq %r14, %r11
cmpq %rsi, %r14
jl 0x8c440
cmpl -0x48(%rsp), %r8d
jg 0x8c499
movq 0x38(%rsp), %rcx
cmpl 0x2c(%rcx), %r8d
jne 0x8c499
subl %eax, %r12d
addl -0x48(%rsp), %r12d
movq 0x38(%rsp), %rax
movl %r12d, 0x14(%rax)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq