// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/./Levenshtein_distance.h
// Function: ed_band_cal_semi_infi_w_absent_diag(char*, int, char*, int, int, int, int*, bit_extz_t*)
inline void ed_band_cal_semi_infi_w_absent_diag(char *pstr, int32_t pn, char *tstr, int32_t tn, int32_t thre, int32_t abs_diag, int32_t *nword, bit_extz_t *ez)
{
	init_base_ed(*ez, thre, pn, tn); ez->ps = ez->pe = -1; ez->ts = 0; ez->te = tn-1;
	int32_t bd, i, err = abs_diag, i_bd, cut = thre+(thre<<1), tn0 = tn - 1, wz, wz1, Peq_i; w_sig c, ad, Peq_m;
	if((pn > tn + cut) || (tn > pn + cut)) return;

	if(nword) {
        ez->nword = (*nword);
    } else {
        bd = (((thre)<<1)+1); ez->nword = ((bd>>bitw)+(!!(bd&bitz)));
    }
    resize_bit_extz_t((*ez), (thre)); 
	wz = sizeof(*(ez->a))*(ez->nword);
	memset((ez->Peq[0]).a, 0, wz);
	memset((ez->Peq[1]).a, 0, wz);
	memset((ez->Peq[2]).a, 0, wz);
	memset((ez->Peq[3]).a, 0, wz);
	memset((ez->Peq[4]).a, 0, wz);
	memset((ez->VP).a, 0, wz);
	w_infi_set_bit_lsub(ez->VN, abs_diag, ez->nword); /**VN = (((Word)1)<<(abs_diag))-1; ;**/ 

	bd = ((thre<<1)+1)-abs_diag; bd = ((bd<=pn)?bd:pn); i_bd = abs_diag; 
    ed_init_core(i, bd, i_bd, pstr, ez->Peq);
    i_bd = (thre<<1)-abs_diag;

	memset((ez->Peq[4]).a, 0, wz);
	i = 0; 
    /**for the incoming char/last char; mm = ((Word)1 << (thre<<1))**/
    Peq_i = (((thre<<1))>>bitw); Peq_m = (((w_sig)1)<<(((thre<<1))&bitz));
	while (i < tn0) {
        ed_infi_core(ez->Peq, ez->VP, ez->VN, ez->X, ez->D0, ez->HN, ez->HP, (uint8_t)tstr[i], c, ad, wz, ez->nword);
        if (!(ez->D0.a[0]&(1ULL))) {
            ++err; if (err>cut) return;
        }
        
        ed_infi_post_Peq(ez->Peq, wz, wz1, ez->nword);
        ++i; ++i_bd; c = 4;
        if(i_bd < pn) c = seq_nt4_table[(uint8_t)pstr[i_bd]];
        if(c < 4) ez->Peq[c].a[Peq_i]|=Peq_m;
    }
	ed_infi_core(ez->Peq, ez->VP, ez->VN, ez->X, ez->D0, ez->HN, ez->HP, (uint8_t)tstr[i], c, ad, wz, ez->nword);
    if (!(ez->D0.a[0]&(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++) {
		bd = (i>>bitw); i_bd = (i&bitz);
		err += (((*ez).VP.a[bd]>>i_bd)&((w_sig)1));
		err -= (((*ez).VN.a[bd]>>i_bd)&((w_sig)1));
	}
    if ((err <= thre) && (err <= ez->err)) {
        ez->err = err; ez->pe = site;
    }
	site -= i;
	while (i < ai) {
		bd = (i>>bitw); i_bd = (i&bitz);
		err += (((*ez).VP.a[bd]>>i_bd)&((w_sig)1));
		err -= (((*ez).VN.a[bd]>>i_bd)&((w_sig)1));
        ++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
subq $0x78, %rsp
movq 0xb8(%rsp), %rbp
movl %r8d, 0x28(%rbp)
movl $0x7fffffff, 0x2c(%rbp) # imm = 0x7FFFFFFF
movl %esi, 0x18(%rbp)
movl %ecx, 0x24(%rbp)
xorps %xmm0, %xmm0
movups %xmm0, (%rbp)
orq $-0x1, 0x10(%rbp)
movl %r9d, 0x8(%rsp)
andl $0x0, 0x1c(%rbp)
movq %rdx, 0x40(%rsp)
movq %rdi, 0x30(%rsp)
leal -0x1(%rcx), %eax
movl %eax, 0xc(%rsp)
movl %eax, 0x20(%rbp)
movq %r8, 0x10(%rsp)
leal (%r8,%r8,2), %edx
leal (%rdx,%rcx), %eax
cmpl %esi, %eax
setl %al
movq %rsi, 0x20(%rsp)
movq %rdx, 0x28(%rsp)
addl %esi, %edx
movq %rcx, 0x18(%rsp)
cmpl %ecx, %edx
setl %cl
orb %al, %cl
jne 0x625ed
movq 0xb0(%rsp), %rax
movq 0x10(%rsp), %r8
leal (%r8,%r8), %r15d
testq %rax, %rax
je 0x61f06
movl (%rax), %esi
jmp 0x61f0e
movl %r15d, %esi
sarl $0x6, %esi
incl %esi
movl %esi, 0x30(%rbp)
cmpl %r8d, 0x3c(%rbp)
jge 0x61ffc
movl %r15d, %eax
shrl $0x6, %eax
imull $0xc, %eax, %eax
addl $0xc, %eax
movl %eax, 0x3c(%rbp)
cmpl 0x38(%rbp), %eax
jbe 0x61ff8
movq 0x40(%rbp), %rdi
movl %eax, %esi
shlq $0x3, %rsi
callq 0x2370
movq 0x10(%rsp), %r8
movq %rax, %rcx
movq %rax, 0x40(%rbp)
movl 0x30(%rbp), %esi
movl 0x3c(%rbp), %eax
pushq $0xc
popq %rdi
xorl %edx, %edx
divl %edi
movl %eax, 0x3c(%rbp)
movq %rcx, 0x48(%rbp)
leal (,%rax,8), %edx
leaq (%rcx,%rdx), %rdi
movq %rdi, 0x50(%rbp)
leal (%rax,%rax), %edi
leaq (%rcx,%rdi,8), %rdi
movq %rdi, 0x58(%rbp)
leal (%rax,%rax,2), %edi
leaq (%rcx,%rdi,8), %rdi
movq %rdi, 0x60(%rbp)
leal (,%rax,4), %edi
leaq (%rcx,%rdi,8), %rdi
movq %rdi, 0x68(%rbp)
leal (%rax,%rax,4), %edi
leaq (%rcx,%rdi,8), %rdi
movq %rdi, 0x70(%rbp)
imull $0x6, %eax, %edi
leaq (%rcx,%rdi,8), %rdi
movq %rdi, 0x78(%rbp)
imull $0x7, %eax, %edi
leaq (%rcx,%rdi,8), %rdi
movq %rdi, 0x80(%rbp)
leaq (%rcx,%rdx,8), %rdx
movq %rdx, 0x88(%rbp)
leal (%rax,%rax,8), %edx
leaq (%rcx,%rdx,8), %rdx
movq %rdx, 0x90(%rbp)
imull $0xa, %eax, %edx
leaq (%rcx,%rdx,8), %rdx
movq %rdx, 0x98(%rbp)
imull $0xb, %eax, %edx
leaq (%rcx,%rdx,8), %rcx
movq %rcx, 0xa0(%rbp)
imull $0xc, %eax, %ecx
movl %ecx, 0x38(%rbp)
movl %eax, 0x34(%rbp)
movl %r8d, 0x3c(%rbp)
shll $0x3, %esi
movq 0x48(%rbp), %rdi
movslq %esi, %r12
xorl %esi, %esi
movq %r12, %rdx
callq 0x20e0
movq 0x50(%rbp), %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x20e0
movq 0x58(%rbp), %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x20e0
movq 0x60(%rbp), %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x20e0
movq 0x68(%rbp), %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x20e0
movq 0x78(%rbp), %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x20e0
movq 0x80(%rbp), %rdi
movslq 0x30(%rbp), %rdx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x20e0
movl 0x8(%rsp), %r8d
movl %r8d, %eax
sarl $0x6, %eax
movslq %eax, %r14
cmpl $0x40, %r8d
jb 0x6209e
movq 0x80(%rbp), %rdi
leaq (,%r14,8), %rdx
movl $0xff, %esi
callq 0x20e0
movl 0x8(%rsp), %r8d
movl %r8d, %ebx
movl %r8d, %ecx
andl $0x3f, %ecx
je 0x620bd
pushq $-0x1
popq %rax
shlq %cl, %rax
notq %rax
movq 0x80(%rbp), %rcx
movq %rax, (%rcx,%r14,8)
movl %r15d, %eax
orl $0x1, %eax
subl %r8d, %eax
movq 0x20(%rsp), %rcx
cmpl %ecx, %eax
cmovgel %ecx, %eax
xorl %edx, %edx
testl %eax, %eax
cmovlel %edx, %eax
pushq $0x1
popq %r14
leaq 0x189a1e(%rip), %r10    # 0x1ebb00
movq 0x30(%rsp), %r9
cmpq %rdx, %rax
je 0x62114
leaq (%rbx,%rdx), %rcx
movq %r14, %rsi
shlq %cl, %rsi
movzbl (%r9,%rdx), %edi
movzbl (%r10,%rdi), %edi
movq 0x48(%rbp,%rdi,8), %rdi
sarl $0x6, %ecx
movslq %ecx, %rcx
orq %rsi, (%rdi,%rcx,8)
incq %rdx
jmp 0x620e7
movl %r15d, %r13d
subl %r8d, %r13d
movq 0x68(%rbp), %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x20e0
xorl %r11d, %r11d
leaq 0x1899ce(%rip), %r9     # 0x1ebb00
movl %r15d, %eax
sarl $0x6, %eax
andb $0x3e, %r15b
movq %r14, %rdx
movl %r15d, %ecx
shlq %cl, %rdx
movq %rdx, 0x58(%rsp)
cltq
movq %rax, 0x50(%rsp)
movslq %r13d, %r15
movslq 0x20(%rsp), %rax
movq %rax, 0x60(%rsp)
movl 0xc(%rsp), %eax
testl %eax, %eax
movl $0x0, %ecx
cmovgl %eax, %ecx
movq %rcx, 0x38(%rsp)
movl 0x30(%rbp), %eax
movslq %eax, %r10
testl %r10d, %r10d
movl $0x0, %ecx
cmovgl %r10d, %ecx
cmpq 0x38(%rsp), %r11
je 0x623d6
movq %r15, 0x68(%rsp)
movq %rbx, 0x70(%rsp)
movq %r14, %rbx
movq 0x40(%rsp), %rdx
movq %r11, 0x48(%rsp)
movzbl (%rdx,%r11), %edx
movzbl (%r9,%rdx), %r11d
xorl %esi, %esi
xorl %r13d, %r13d
cmpq %rsi, %rcx
je 0x62254
movq 0x48(%rbp,%r11,8), %r14
movq 0x80(%rbp), %rdx
movq (%rdx,%rsi,8), %r8
orq (%r14,%rsi,8), %r8
movq 0x88(%rbp), %r14
movq %r8, (%r14,%rsi,8)
movq 0x78(%rbp), %r9
movq 0x90(%rbp), %r12
andq (%r9,%rsi,8), %r8
addq %r13, %r8
setb %r13b
movq %r8, (%r12,%rsi,8)
addq (%r9,%rsi,8), %r8
movq %r8, (%r12,%rsi,8)
movq (%r9,%rsi,8), %rdi
cmpq %rdi, %r8
setb %r15b
orb %r13b, %r15b
xorq %rdi, %r8
movq %r8, (%r12,%rsi,8)
orq (%r14,%rsi,8), %r8
movq %r8, (%r12,%rsi,8)
andq (%r9,%rsi,8), %r8
movq 0x98(%rbp), %rdi
movq %r8, (%rdi,%rsi,8)
movq (%r12,%rsi,8), %rdi
orq (%r9,%rsi,8), %rdi
movzbl %r15b, %r13d
notq %rdi
movq 0xa0(%rbp), %r8
movq %rdi, (%r8,%rsi,8)
orq (%rdx,%rsi,8), %rdi
movq %rdi, (%r8,%rsi,8)
incq %rsi
jmp 0x621b4
movq %rax, %rdx
xorl %esi, %esi
movq %rbx, %r14
movq 0x70(%rsp), %rbx
movq 0x68(%rsp), %r15
testl %edx, %edx
jle 0x622d5
movq 0x88(%rbp), %rdi
movq 0x90(%rbp), %r8
movq -0x8(%r8,%rdx,8), %r9
shrq %r9
orq %rsi, %r9
movq %r9, -0x8(%rdi,%rdx,8)
movq -0x8(%r8,%rdx,8), %rsi
movq 0x80(%rbp), %r8
movq 0xa0(%rbp), %r11
andq -0x8(%r11,%rdx,8), %r9
movq %r9, -0x8(%r8,%rdx,8)
movq -0x8(%r11,%rdx,8), %r8
orq -0x8(%rdi,%rdx,8), %r8
notq %r8
movq 0x78(%rbp), %rdi
movq %r8, -0x8(%rdi,%rdx,8)
movq 0x98(%rbp), %r9
orq -0x8(%r9,%rdx,8), %r8
movq %r8, -0x8(%rdi,%rdx,8)
decq %rdx
shlq $0x3f, %rsi
jmp 0x62266
movq 0x90(%rbp), %rdx
testb $0x1, (%rdx)
jne 0x622fb
cmpl 0x28(%rsp), %ebx
leaq 0x189814(%rip), %r9     # 0x1ebb00
movq 0x48(%rsp), %r11
jge 0x625ed
incl %ebx
jmp 0x62307
leaq 0x1897fe(%rip), %r9     # 0x1ebb00
movq 0x48(%rsp), %r11
movq %r14, %rdx
cmpq %r10, %rdx
jge 0x62370
movq 0x48(%rbp), %rsi
movq -0x8(%rsi,%rdx,8), %rdi
movq (%rsi,%rdx,8), %r8
shldq $0x3f, %rdi, %r8
movq %r8, -0x8(%rsi,%rdx,8)
movq 0x50(%rbp), %rsi
movq -0x8(%rsi,%rdx,8), %rdi
movq (%rsi,%rdx,8), %r8
shldq $0x3f, %rdi, %r8
movq %r8, -0x8(%rsi,%rdx,8)
movq 0x58(%rbp), %rsi
movq -0x8(%rsi,%rdx,8), %rdi
movq (%rsi,%rdx,8), %r8
shldq $0x3f, %rdi, %r8
movq %r8, -0x8(%rsi,%rdx,8)
movq 0x60(%rbp), %rsi
movq -0x8(%rsi,%rdx,8), %rdi
movq (%rsi,%rdx,8), %r8
shldq $0x3f, %rdi, %r8
movq %r8, -0x8(%rsi,%rdx,8)
incq %rdx
jmp 0x6230a
movq 0x48(%rbp), %rdx
shrq -0x8(%rdx,%r10,8)
movq 0x50(%rbp), %rdx
shrq -0x8(%rdx,%r10,8)
movq 0x58(%rbp), %rdx
shrq -0x8(%rdx,%r10,8)
movq 0x60(%rbp), %rdx
shrq -0x8(%rdx,%r10,8)
incq %r11
incq %r15
cmpq 0x60(%rsp), %r15
jge 0x62183
movq 0x30(%rsp), %rdx
movzbl (%rdx,%r15), %edx
movzbl (%r9,%rdx), %edx
cmpq $0x3, %rdx
ja 0x62183
movq 0x48(%rbp,%rdx,8), %rdx
movq 0x58(%rsp), %rsi
movq 0x50(%rsp), %rdi
orq %rsi, (%rdx,%rdi,8)
jmp 0x62183
movq 0x40(%rsp), %rdx
movq 0x38(%rsp), %rsi
movzbl (%rdx,%rsi), %edx
movzbl (%r9,%rdx), %edx
xorl %esi, %esi
xorl %r8d, %r8d
cmpq %rsi, %rcx
je 0x6248e
movq 0x48(%rbp,%rdx,8), %r10
movq 0x80(%rbp), %rdi
movq (%rdi,%rsi,8), %r9
orq (%r10,%rsi,8), %r9
movq 0x88(%rbp), %r10
movq %r9, (%r10,%rsi,8)
movq 0x78(%rbp), %r11
movq 0x90(%rbp), %r14
andq (%r11,%rsi,8), %r9
addq %r8, %r9
setb %r8b
movq %r9, (%r14,%rsi,8)
addq (%r11,%rsi,8), %r9
movq %r9, (%r14,%rsi,8)
movq (%r11,%rsi,8), %r15
cmpq %r15, %r9
setb %r12b
orb %r8b, %r12b
xorq %r15, %r9
movq %r9, (%r14,%rsi,8)
orq (%r10,%rsi,8), %r9
movq %r9, (%r14,%rsi,8)
andq (%r11,%rsi,8), %r9
movq 0x98(%rbp), %r8
movq %r9, (%r8,%rsi,8)
movq (%r14,%rsi,8), %r9
orq (%r11,%rsi,8), %r9
movzbl %r12b, %r8d
notq %r9
movq 0xa0(%rbp), %r10
movq %r9, (%r10,%rsi,8)
orq (%rdi,%rsi,8), %r9
movq %r9, (%r10,%rsi,8)
incq %rsi
jmp 0x623ee
xorl %ecx, %ecx
testl %eax, %eax
jle 0x624ff
movq 0x88(%rbp), %rdx
movq 0x90(%rbp), %rsi
movq -0x8(%rsi,%rax,8), %rdi
shrq %rdi
orq %rcx, %rdi
movq %rdi, -0x8(%rdx,%rax,8)
movq -0x8(%rsi,%rax,8), %rcx
movq 0x80(%rbp), %rsi
movq 0xa0(%rbp), %r8
andq -0x8(%r8,%rax,8), %rdi
movq %rdi, -0x8(%rsi,%rax,8)
movq -0x8(%r8,%rax,8), %rsi
orq -0x8(%rdx,%rax,8), %rsi
notq %rsi
movq 0x78(%rbp), %rdx
movq %rsi, -0x8(%rdx,%rax,8)
movq 0x98(%rbp), %rdi
orq -0x8(%rdi,%rax,8), %rsi
movq %rsi, -0x8(%rdx,%rax,8)
decq %rax
shlq $0x3f, %rcx
jmp 0x62490
movq 0x90(%rbp), %rax
testb $0x1, (%rax)
jne 0x62517
cmpl 0x28(%rsp), %ebx
jge 0x625ed
incl %ebx
movl 0x8(%rsp), %edi
subl %edi, 0xc(%rsp)
movq 0x20(%rsp), %r11
subl 0x18(%rsp), %r11d
addl %edi, %r11d
xorl %eax, %eax
movq 0x10(%rsp), %r10
movl 0xc(%rsp), %ecx
addl %eax, %ecx
jns 0x6256a
cmpl %r11d, %eax
jge 0x6256a
movl %eax, %ecx
shrl $0x6, %ecx
movq 0x78(%rbp), %rdx
movq 0x80(%rbp), %rsi
movq (%rdx,%rcx,8), %rdx
btq %rax, %rdx
adcl $0x0, %ebx
movq (%rsi,%rcx,8), %rcx
btq %rax, %rcx
sbbl $0x0, %ebx
incl %eax
jmp 0x62533
cmpl %r10d, %ebx
jg 0x6257a
cmpl 0x2c(%rbp), %ebx
jg 0x6257a
movl %ebx, 0x2c(%rbp)
movl %ecx, 0x14(%rbp)
subl %eax, %ecx
leal -0x1(%r10), %esi
movq 0x18(%rsp), %rdx
subl %edi, %edx
movq %rdx, 0x18(%rsp)
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
cmpl %r11d, %eax
jge 0x625dc
movl %eax, %edi
shrl $0x6, %edi
movq 0x78(%rbp), %r8
movq 0x80(%rbp), %r9
movq (%r8,%rdi,8), %r8
btq %rax, %r8
adcl $0x0, %ebx
movq (%r9,%rdi,8), %rdi
btq %rax, %rdi
sbbl $0x0, %ebx
cmpl %r10d, %ebx
jg 0x625d3
cmpl 0x2c(%rbp), %ebx
jg 0x625d3
movl %ebx, 0x2c(%rbp)
movq 0x18(%rsp), %rdi
addl %eax, %edi
movl %edi, 0x14(%rbp)
cmpl %eax, %esi
cmovel %ebx, %edx
incl %eax
jmp 0x62591
cmpl %r10d, %edx
jg 0x625ed
cmpl 0x2c(%rbp), %edx
jne 0x625ed
addl 0x10(%rsp), %ecx
movl %ecx, 0x14(%rbp)
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq