// File: 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
movq %rsp, %rbp
subq $0xd0, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movl %r9d, -0x24(%rbp)
movl -0x20(%rbp), %ecx
movq 0x10(%rbp), %rax
movl %ecx, 0x28(%rax)
movq 0x10(%rbp), %rax
movl $0x7fffffff, 0x2c(%rax) # imm = 0x7FFFFFFF
movl -0xc(%rbp), %ecx
movq 0x10(%rbp), %rax
movl %ecx, 0x18(%rax)
movl -0x1c(%rbp), %ecx
movq 0x10(%rbp), %rax
movl %ecx, 0x24(%rax)
movq 0x10(%rbp), %rax
movl $0x0, 0xc(%rax)
movq 0x10(%rbp), %rax
movl $0x0, 0x4(%rax)
movq 0x10(%rbp), %rax
movl $0x0, 0x8(%rax)
movq 0x10(%rbp), %rax
movl $0x0, (%rax)
movq 0x10(%rbp), %rax
movl $0xffffffff, 0x14(%rax) # imm = 0xFFFFFFFF
movq 0x10(%rbp), %rax
movl $0xffffffff, 0x10(%rax) # imm = 0xFFFFFFFF
movq 0x10(%rbp), %rax
movl $0x0, 0x1c(%rax)
movl -0x1c(%rbp), %ecx
subl $0x1, %ecx
movq 0x10(%rbp), %rax
movl %ecx, 0x20(%rax)
leaq -0x60(%rbp), %rdi
xorl %esi, %esi
movl $0x28, %edx
callq 0x2100
movq $0x0, -0x68(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0xa4(%rbp)
movl -0x20(%rbp), %eax
shll %eax
movl %eax, -0xac(%rbp)
movl -0x1c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0xb0(%rbp)
movl -0x20(%rbp), %eax
addl -0xac(%rbp), %eax
movl %eax, -0xb4(%rbp)
movl -0xc(%rbp), %eax
movl -0x1c(%rbp), %ecx
addl -0xb4(%rbp), %ecx
cmpl %ecx, %eax
jg 0xa8a6e
movl -0x1c(%rbp), %eax
movl -0xc(%rbp), %ecx
addl -0xb4(%rbp), %ecx
cmpl %ecx, %eax
jle 0xa8a73
jmp 0xa8fec
movl -0x20(%rbp), %eax
shll %eax
addl $0x1, %eax
subl -0x24(%rbp), %eax
movl %eax, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
cmpl -0xc(%rbp), %eax
jg 0xa8a9d
movl -0x9c(%rbp), %eax
movl %eax, -0xc4(%rbp)
jmp 0xa8aa6
movl -0xc(%rbp), %eax
movl %eax, -0xc4(%rbp)
movl -0xc4(%rbp), %eax
movl %eax, -0x9c(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0xa8(%rbp)
movl $0x0, -0xa0(%rbp)
movl -0xa8(%rbp), %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, -0x98(%rbp)
movl -0xa0(%rbp), %eax
cmpl -0x9c(%rbp), %eax
jge 0xa8b39
movq -0x98(%rbp), %rcx
movq -0x8(%rbp), %rax
movslq -0xa0(%rbp), %rdx
movzbl (%rax,%rdx), %eax
movl %eax, %edx
leaq 0x2e1cd7(%rip), %rax    # 0x38a7e0
movzbl (%rax,%rdx), %eax
orq -0x60(%rbp,%rax,8), %rcx
movq %rcx, -0x60(%rbp,%rax,8)
movq -0x98(%rbp), %rax
shlq %rax
movq %rax, -0x98(%rbp)
movl -0xa0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa0(%rbp)
jmp 0xa8adc
movl -0x20(%rbp), %eax
shll %eax
subl -0x24(%rbp), %eax
movl %eax, -0xa8(%rbp)
movl -0x24(%rbp), %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
subq $0x1, %rax
movq %rax, -0x70(%rbp)
movl $0x0, -0xa0(%rbp)
movq $0x0, -0x40(%rbp)
movl -0x20(%rbp), %eax
shll %eax
movl %eax, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, -0x98(%rbp)
movl -0xa0(%rbp), %eax
cmpl -0xb0(%rbp), %eax
jge 0xa8d0c
movq -0x18(%rbp), %rax
movslq -0xa0(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl %eax, %ecx
leaq 0x2e1c30(%rip), %rax    # 0x38a7e0
movzbl (%rax,%rcx), %eax
movq -0x60(%rbp,%rax,8), %rax
orq -0x70(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x68(%rbp), %rax
movq -0x78(%rbp), %rcx
andq -0x68(%rbp), %rcx
addq %rcx, %rax
xorq -0x68(%rbp), %rax
orq -0x78(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x68(%rbp), %rax
andq -0x80(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x70(%rbp), %rax
movq -0x68(%rbp), %rcx
orq -0x80(%rbp), %rcx
xorq $-0x1, %rcx
orq %rcx, %rax
movq %rax, -0x90(%rbp)
movq -0x80(%rbp), %rax
shrq %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
andq -0x90(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x88(%rbp), %rax
movq -0x78(%rbp), %rcx
orq -0x90(%rbp), %rcx
xorq $-0x1, %rcx
orq %rcx, %rax
movq %rax, -0x68(%rbp)
movq -0x80(%rbp), %rax
andq $0x1, %rax
cmpq $0x0, %rax
jne 0xa8c6e
movl -0xa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa4(%rbp)
movl -0xa4(%rbp), %eax
cmpl -0xb4(%rbp), %eax
jle 0xa8c6c
jmp 0xa8fec
jmp 0xa8c6e
movq -0x60(%rbp), %rax
shrq %rax
movq %rax, -0x60(%rbp)
movq -0x58(%rbp), %rax
shrq %rax
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rax
shrq %rax
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rax
shrq %rax
movq %rax, -0x48(%rbp)
movl -0xa0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa0(%rbp)
movl -0xa8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa8(%rbp)
movq $0x4, -0x30(%rbp)
movl -0xa8(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0xa8ceb
movq -0x8(%rbp), %rax
movslq -0xa8(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl %eax, %ecx
leaq 0x2e1afd(%rip), %rax    # 0x38a7e0
movzbl (%rax,%rcx), %eax
movq %rax, -0x30(%rbp)
cmpq $0x4, -0x30(%rbp)
jae 0xa8d07
movq -0x98(%rbp), %rcx
movq -0x30(%rbp), %rax
orq -0x60(%rbp,%rax,8), %rcx
movq %rcx, -0x60(%rbp,%rax,8)
jmp 0xa8b86
movq -0x18(%rbp), %rax
movslq -0xa0(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl %eax, %ecx
leaq 0x2e1abc(%rip), %rax    # 0x38a7e0
movzbl (%rax,%rcx), %eax
movq -0x60(%rbp,%rax,8), %rax
orq -0x70(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x68(%rbp), %rax
movq -0x78(%rbp), %rcx
andq -0x68(%rbp), %rcx
addq %rcx, %rax
xorq -0x68(%rbp), %rax
orq -0x78(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x68(%rbp), %rax
andq -0x80(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x70(%rbp), %rax
movq -0x68(%rbp), %rcx
orq -0x80(%rbp), %rcx
xorq $-0x1, %rcx
orq %rcx, %rax
movq %rax, -0x90(%rbp)
movq -0x80(%rbp), %rax
shrq %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
andq -0x90(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x88(%rbp), %rax
movq -0x78(%rbp), %rcx
orq -0x90(%rbp), %rcx
xorq $-0x1, %rcx
orq %rcx, %rax
movq %rax, -0x68(%rbp)
movq -0x80(%rbp), %rax
andq $0x1, %rax
cmpq $0x0, %rax
jne 0xa8de2
movl -0xa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa4(%rbp)
movl -0xa4(%rbp), %eax
cmpl -0xb4(%rbp), %eax
jle 0xa8de0
jmp 0xa8fec
jmp 0xa8de2
movl -0x1c(%rbp), %eax
subl $0x1, %eax
subl -0x24(%rbp), %eax
movl %eax, -0xb8(%rbp)
movl -0xc(%rbp), %eax
subl -0x1c(%rbp), %eax
addl -0x24(%rbp), %eax
movl %eax, -0xbc(%rbp)
movl $0x7fffffff, -0xc0(%rbp) # imm = 0x7FFFFFFF
movl $0x0, -0xa0(%rbp)
movl $0x0, -0xa0(%rbp)
xorl %eax, %eax
cmpl $0x0, -0xb8(%rbp)
movb %al, -0xc5(%rbp)
jge 0xa8e44
movl -0xa0(%rbp), %eax
cmpl -0xbc(%rbp), %eax
setl %al
movb %al, -0xc5(%rbp)
movb -0xc5(%rbp), %al
testb $0x1, %al
jne 0xa8e50
jmp 0xa8ebb
movq -0x68(%rbp), %rax
movl -0xa0(%rbp), %ecx
shrq %cl, %rax
movq %rax, %rcx
andq $0x1, %rcx
movslq -0xa4(%rbp), %rax
addq %rcx, %rax
movl %eax, -0xa4(%rbp)
movq -0x70(%rbp), %rax
movl -0xa0(%rbp), %ecx
shrq %cl, %rax
movq %rax, %rcx
andq $0x1, %rcx
movslq -0xa4(%rbp), %rax
subq %rcx, %rax
movl %eax, -0xa4(%rbp)
movl -0xa0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa0(%rbp)
movl -0xb8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb8(%rbp)
jmp 0xa8e1e
movl -0xa4(%rbp), %eax
cmpl -0x20(%rbp), %eax
jg 0xa8eef
movl -0xa4(%rbp), %eax
movq 0x10(%rbp), %rcx
cmpl 0x2c(%rcx), %eax
jg 0xa8eef
movl -0xa4(%rbp), %ecx
movq 0x10(%rbp), %rax
movl %ecx, 0x2c(%rax)
movl -0xb8(%rbp), %ecx
movq 0x10(%rbp), %rax
movl %ecx, 0x14(%rax)
movl -0xa0(%rbp), %ecx
movl -0xb8(%rbp), %eax
subl %ecx, %eax
movl %eax, -0xb8(%rbp)
movl -0xa0(%rbp), %eax
cmpl -0xbc(%rbp), %eax
jge 0xa8fc2
movq -0x68(%rbp), %rax
movl -0xa0(%rbp), %ecx
shrq %cl, %rax
movq %rax, %rcx
andq $0x1, %rcx
movslq -0xa4(%rbp), %rax
addq %rcx, %rax
movl %eax, -0xa4(%rbp)
movq -0x70(%rbp), %rax
movl -0xa0(%rbp), %ecx
shrq %cl, %rax
movq %rax, %rcx
andq $0x1, %rcx
movslq -0xa4(%rbp), %rax
subq %rcx, %rax
movl %eax, -0xa4(%rbp)
movl -0xa0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa0(%rbp)
movl -0xa4(%rbp), %eax
cmpl -0x20(%rbp), %eax
jg 0xa8fa6
movl -0xa4(%rbp), %eax
movq 0x10(%rbp), %rcx
cmpl 0x2c(%rcx), %eax
jg 0xa8fa6
movl -0xa4(%rbp), %ecx
movq 0x10(%rbp), %rax
movl %ecx, 0x2c(%rax)
movl -0xb8(%rbp), %ecx
addl -0xa0(%rbp), %ecx
movq 0x10(%rbp), %rax
movl %ecx, 0x14(%rax)
movl -0xa0(%rbp), %eax
cmpl -0x20(%rbp), %eax
jne 0xa8fbd
movl -0xa4(%rbp), %eax
movl %eax, -0xc0(%rbp)
jmp 0xa8f03
movl -0xc0(%rbp), %eax
cmpl -0x20(%rbp), %eax
jg 0xa8fec
movl -0xc0(%rbp), %eax
movq 0x10(%rbp), %rcx
cmpl 0x2c(%rcx), %eax
jne 0xa8fec
movl -0xb8(%rbp), %ecx
addl -0x20(%rbp), %ecx
movq 0x10(%rbp), %rax
movl %ecx, 0x14(%rax)
addq $0xd0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop