// File: /workspace/github_cpp_makefile_star2_O1/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 $0x88, %rsp
movl %r9d, 0x4(%rsp)
movq %rdx, 0x30(%rsp)
movl %esi, %r13d
movq 0xc8(%rsp), %r15
movl %r8d, 0x28(%r15)
movl $0x7fffffff, 0x2c(%r15) # imm = 0x7FFFFFFF
movl %esi, 0x18(%r15)
movl %ecx, 0x24(%r15)
xorps %xmm0, %xmm0
movups %xmm0, (%r15)
movq $-0x1, 0x10(%r15)
movl $0x0, 0x1c(%r15)
leal -0x1(%rcx), %eax
movq %rax, 0x18(%rsp)
movl %eax, 0x20(%r15)
movq %r8, 0x8(%rsp)
leal (%r8,%r8,2), %edx
leal (%rdx,%rcx), %eax
cmpl %esi, %eax
setl %al
movq %rdx, 0x28(%rsp)
addl %r13d, %edx
movq %rcx, 0x20(%rsp)
cmpl %ecx, %edx
setl %cl
orb %al, %cl
jne 0x97ec0
movq %rdi, %r14
movq 0xc0(%rsp), %rax
movq 0x8(%rsp), %rcx
leal (%rcx,%rcx), %r12d
testq %rax, %rax
je 0x97745
movl (%rax), %eax
jmp 0x9774d
movl %r12d, %eax
sarl $0x6, %eax
incl %eax
movl %eax, 0x30(%r15)
movq 0x8(%rsp), %rax
cmpl %eax, 0x3c(%r15)
jge 0x97859
movl %r12d, %eax
shrl $0x6, %eax
leal (%rax,%rax,2), %eax
leal 0xc(,%rax,4), %eax
movl %eax, 0x3c(%r15)
cmpl 0x38(%r15), %eax
jbe 0x97850
movq 0x40(%r15), %rdi
movl %eax, %esi
shlq $0x3, %rsi
callq 0x2370
movq %rax, 0x40(%r15)
movl 0x3c(%r15), %edx
movl $0xaaaaaaab, %ecx       # imm = 0xAAAAAAAB
imulq %rdx, %rcx
movq %rcx, %rdx
shrq $0x20, %rdx
shrq $0x23, %rcx
movl %ecx, 0x3c(%r15)
movq %rax, 0x48(%r15)
andl $-0x8, %edx
leaq (%rax,%rdx), %rsi
movq %rsi, 0x50(%r15)
leal (%rcx,%rcx), %esi
leaq (%rax,%rsi,8), %rdi
movq %rdi, 0x58(%r15)
leal (%rcx,%rcx,2), %edi
leaq (%rax,%rdi,8), %rdi
movq %rdi, 0x60(%r15)
leal (,%rcx,4), %edi
leaq (%rax,%rdi,8), %r8
movq %r8, 0x68(%r15)
leal (%rcx,%rcx,4), %r8d
leaq (%rax,%r8,8), %r9
movq %r9, 0x70(%r15)
leal (%rsi,%rsi,2), %r9d
leaq (%rax,%r9,8), %r9
movq %r9, 0x78(%r15)
leal (,%rcx,8), %r9d
subl %ecx, %r9d
leaq (%rax,%r9,8), %r9
movq %r9, 0x80(%r15)
leaq (%rax,%rdx,8), %rdx
movq %rdx, 0x88(%r15)
leal (%rcx,%rcx,8), %edx
leaq (%rax,%rdx,8), %rdx
movq %rdx, 0x90(%r15)
leal (%rsi,%rsi,4), %edx
leaq (%rax,%rdx,8), %rdx
movq %rdx, 0x98(%r15)
leal (%rcx,%r8,2), %edx
leaq (%rax,%rdx,8), %rax
movq %rax, 0xa0(%r15)
leal (%rdi,%rdi,2), %eax
movl %eax, 0x38(%r15)
movl %ecx, 0x34(%r15)
movq 0x8(%rsp), %rax
movl %eax, 0x3c(%r15)
movl 0x30(%r15), %eax
shll $0x3, %eax
movq 0x48(%r15), %rdi
movslq %eax, %rbp
xorl %esi, %esi
movq %rbp, %rdx
callq 0x20e0
movq 0x50(%r15), %rdi
xorl %esi, %esi
movq %rbp, %rdx
callq 0x20e0
movq 0x58(%r15), %rdi
xorl %esi, %esi
movq %rbp, %rdx
callq 0x20e0
movq 0x60(%r15), %rdi
xorl %esi, %esi
movq %rbp, %rdx
callq 0x20e0
movq 0x68(%r15), %rdi
xorl %esi, %esi
movq %rbp, %rdx
callq 0x20e0
movq 0x78(%r15), %rdi
xorl %esi, %esi
movq %rbp, %rdx
callq 0x20e0
movq 0x80(%r15), %rdi
movslq 0x30(%r15), %rdx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x20e0
movl 0x4(%rsp), %ecx
movl %ecx, %eax
sarl $0x6, %eax
movslq %eax, %rbx
cmpl $0x40, %ecx
jb 0x978f7
movq 0x80(%r15), %rdi
leaq (,%rbx,8), %rdx
movl $0xff, %esi
callq 0x20e0
movl 0x4(%rsp), %ecx
andl $0x3f, %ecx
je 0x97918
movq $-0x1, %rax
shlq %cl, %rax
notq %rax
movq 0x80(%r15), %rcx
movq %rax, (%rcx,%rbx,8)
movl %r12d, %eax
orl $0x1, %eax
subl 0x4(%rsp), %eax
cmpl %r13d, %eax
cmovgel %r13d, %eax
testl %eax, %eax
jle 0x97969
movl %eax, %eax
movl 0x4(%rsp), %edx
xorl %esi, %esi
leaq 0x1960d4(%rip), %rdi    # 0x22da10
leal (%rdx,%rsi), %ecx
movl $0x1, %r8d
shlq %cl, %r8
movzbl (%r14,%rsi), %r9d
movzbl (%rdi,%r9), %r9d
movq 0x48(%r15,%r9,8), %r9
sarl $0x6, %ecx
movslq %ecx, %rcx
orq %r8, (%r9,%rcx,8)
incq %rsi
cmpq %rsi, %rax
jne 0x9793c
movq 0x68(%r15), %rdi
xorl %ebx, %ebx
xorl %esi, %esi
movq %rbp, %rdx
callq 0x20e0
movl %r12d, %ecx
andb $0x3e, %cl
movl $0x1, %eax
shlq %cl, %rax
movq %rax, 0x48(%rsp)
cmpl $0x2, 0x20(%rsp)
jl 0x97c5f
movl %r12d, %eax
sarl $0x6, %eax
movl 0x4(%rsp), %edx
subl %edx, %r12d
movl 0x30(%r15), %ecx
movslq %ecx, %rsi
movq 0x90(%r15), %rdi
movq %rdi, 0x70(%rsp)
cltq
movq %rax, 0x40(%rsp)
movq %rsi, 0x68(%rsp)
leal -0x1(%rsi), %r9d
movslq %r12d, %r8
movslq %r13d, %rax
movq %rax, 0x60(%rsp)
movl 0x18(%rsp), %eax
movq %rax, 0x58(%rsp)
leaq 0x1(%rcx), %rax
movq %rax, 0x50(%rsp)
movq $0x0, 0x10(%rsp)
movl %edx, %eax
movq %r13, 0x78(%rsp)
movq %r14, 0x38(%rsp)
movq %r8, 0x80(%rsp)
testl %ecx, %ecx
jle 0x97ac9
movq 0x30(%rsp), %rdx
movq 0x10(%rsp), %rsi
movzbl (%rdx,%rsi), %edx
leaq 0x195ff2(%rip), %rsi    # 0x22da10
movzbl (%rsi,%rdx), %edx
movq 0xc8(%rsp), %rsi
movq 0x48(%rsi,%rdx,8), %rbx
movq 0x78(%rsi), %r8
movq 0x80(%rsi), %rdx
movq 0x88(%rsi), %r14
movq 0x90(%rsi), %rdi
movq 0x98(%rsi), %r11
movq 0xa0(%rsi), %rbp
xorl %r13d, %r13d
xorl %r12d, %r12d
movq (%rdx,%r13,8), %r10
orq (%rbx,%r13,8), %r10
movq %r10, (%r14,%r13,8)
andq (%r8,%r13,8), %r10
addq %r12, %r10
setb %r12b
movq %r10, (%rdi,%r13,8)
addq (%r8,%r13,8), %r10
movq %r10, (%rdi,%r13,8)
movq (%r8,%r13,8), %rsi
cmpq %rsi, %r10
setb %r15b
xorq %rsi, %r10
movq %r10, (%rdi,%r13,8)
orq (%r14,%r13,8), %r10
orb %r12b, %r15b
movq %r10, (%rdi,%r13,8)
andq (%r8,%r13,8), %r10
movq %r10, (%r11,%r13,8)
movq (%rdi,%r13,8), %rsi
orq (%r8,%r13,8), %rsi
notq %rsi
movq %rsi, (%rbp,%r13,8)
orq (%rdx,%r13,8), %rsi
movzbl %r15b, %r12d
movq %rsi, (%rbp,%r13,8)
incq %r13
cmpq %r13, %rcx
jne 0x97a5c
testl %ecx, %ecx
movq 0xc8(%rsp), %r15
jle 0x97b4b
movq 0x90(%r15), %rdx
movq 0x88(%r15), %rdi
movq 0xa0(%r15), %r8
movq 0x78(%r15), %r11
movq 0x80(%r15), %rbx
movq 0x98(%r15), %r14
movq 0x50(%rsp), %r13
xorl %ebp, %ebp
movq -0x10(%rdx,%r13,8), %rsi
shrq %rsi
orq %rbp, %rsi
movq %rsi, -0x10(%rdi,%r13,8)
movq -0x10(%rdx,%r13,8), %rbp
andq -0x10(%r8,%r13,8), %rsi
movq %rsi, -0x10(%rbx,%r13,8)
movq -0x10(%r8,%r13,8), %rsi
orq -0x10(%rdi,%r13,8), %rsi
notq %rsi
movq %rsi, -0x10(%r11,%r13,8)
orq -0x10(%r14,%r13,8), %rsi
shlq $0x3f, %rbp
movq %rsi, -0x10(%r11,%r13,8)
decq %r13
cmpq $0x1, %r13
jg 0x97b03
movq 0x70(%rsp), %rdx
testb $0x1, (%rdx)
movq 0x78(%rsp), %r13
jne 0x97b6d
cmpl 0x28(%rsp), %eax
movq 0x38(%rsp), %r14
jge 0x97ec0
incl %eax
jmp 0x97b72
movq 0x38(%rsp), %r14
cmpl $0x2, %ecx
jl 0x97bd9
movq 0x48(%r15), %rdx
movq 0x50(%r15), %rdi
movq 0x58(%r15), %r8
movq 0x60(%r15), %r11
xorl %ebx, %ebx
movq (%rdx,%rbx,8), %rsi
movq 0x8(%rdx,%rbx,8), %r10
shldq $0x3f, %rsi, %r10
movq %r10, (%rdx,%rbx,8)
movq (%rdi,%rbx,8), %rsi
movq 0x8(%rdi,%rbx,8), %r10
shldq $0x3f, %rsi, %r10
movq %r10, (%rdi,%rbx,8)
movq (%r8,%rbx,8), %rsi
movq 0x8(%r8,%rbx,8), %r10
shldq $0x3f, %rsi, %r10
movq %r10, (%r8,%rbx,8)
movq (%r11,%rbx,8), %rsi
movq 0x8(%r11,%rbx,8), %r10
shldq $0x3f, %rsi, %r10
movq %r10, (%r11,%rbx,8)
incq %rbx
cmpq %rbx, %r9
jne 0x97b89
movq 0x48(%r15), %rdx
movq 0x68(%rsp), %rsi
shrq -0x8(%rdx,%rsi,8)
movq 0x50(%r15), %rdx
shrq -0x8(%rdx,%rsi,8)
movq 0x58(%r15), %rdx
shrq -0x8(%rdx,%rsi,8)
movq 0x60(%r15), %rdx
shrq -0x8(%rdx,%rsi,8)
movq 0x80(%rsp), %r8
incq %r8
movl $0x4, %edx
cmpq 0x60(%rsp), %r8
jge 0x97c29
movzbl (%r14,%r8), %edx
leaq 0x195deb(%rip), %rsi    # 0x22da10
movzbl (%rsi,%rdx), %edx
cmpl $0x3, %edx
ja 0x97c41
movq 0x48(%r15,%rdx,8), %rdx
movq 0x48(%rsp), %rsi
movq 0x40(%rsp), %rdi
orq %rsi, (%rdx,%rdi,8)
movq 0x10(%rsp), %rsi
incq %rsi
movq %rsi, 0x10(%rsp)
cmpq 0x58(%rsp), %rsi
jne 0x979f9
movl 0x10(%rsp), %ebx
jmp 0x97c63
movl 0x4(%rsp), %eax
movslq 0x30(%r15), %rcx
testq %rcx, %rcx
jle 0x97d28
movq 0x30(%rsp), %rdx
movzbl (%rdx,%rbx), %edx
leaq 0x195d90(%rip), %rsi    # 0x22da10
movzbl (%rsi,%rdx), %edx
movq 0xc8(%rsp), %r11
movq 0x48(%r11,%rdx,8), %rdx
movq 0x78(%r11), %rsi
movq 0x80(%r11), %rdi
movq 0x88(%r11), %r8
movq 0x90(%r11), %r9
movq 0x98(%r11), %r10
movq 0xa0(%r11), %r11
xorl %ebx, %ebx
xorl %r14d, %r14d
movq (%rdi,%rbx,8), %r15
orq (%rdx,%rbx,8), %r15
movq %r15, (%r8,%rbx,8)
andq (%rsi,%rbx,8), %r15
addq %r14, %r15
setb %bpl
movq %r15, (%r9,%rbx,8)
addq (%rsi,%rbx,8), %r15
movq %r15, (%r9,%rbx,8)
movq (%rsi,%rbx,8), %r14
cmpq %r14, %r15
setb %r12b
xorq %r14, %r15
movq %r15, (%r9,%rbx,8)
orq (%r8,%rbx,8), %r15
orb %bpl, %r12b
movq %r15, (%r9,%rbx,8)
andq (%rsi,%rbx,8), %r15
movq %r15, (%r10,%rbx,8)
movq (%r9,%rbx,8), %r15
orq (%rsi,%rbx,8), %r15
notq %r15
movq %r15, (%r11,%rbx,8)
orq (%rdi,%rbx,8), %r15
movzbl %r12b, %r14d
movq %r15, (%r11,%rbx,8)
incq %rbx
cmpq %rbx, %rcx
jne 0x97cbd
testl %ecx, %ecx
movq 0xc8(%rsp), %r14
jle 0x97da9
movq 0x90(%r14), %rdx
movq 0x88(%r14), %rsi
movq 0xa0(%r14), %rdi
movq 0x78(%r14), %r8
movq 0x80(%r14), %r9
movq 0x98(%r14), %r10
incq %rcx
xorl %r11d, %r11d
movq -0x10(%rdx,%rcx,8), %rbx
shrq %rbx
orq %r11, %rbx
movq %rbx, -0x10(%rsi,%rcx,8)
movq -0x10(%rdx,%rcx,8), %r11
andq -0x10(%rdi,%rcx,8), %rbx
movq %rbx, -0x10(%r9,%rcx,8)
movq -0x10(%rdi,%rcx,8), %rbx
orq -0x10(%rsi,%rcx,8), %rbx
notq %rbx
movq %rbx, -0x10(%r8,%rcx,8)
orq -0x10(%r10,%rcx,8), %rbx
shlq $0x3f, %r11
movq %rbx, -0x10(%r8,%rcx,8)
decq %rcx
cmpq $0x1, %rcx
jg 0x97d61
movq 0x90(%r14), %rcx
testb $0x1, (%rcx)
jne 0x97dc1
cmpl 0x28(%rsp), %eax
jge 0x97ec0
incl %eax
movq 0x18(%rsp), %r15
subl 0x20(%rsp), %r13d
movl 0x4(%rsp), %ecx
addl %ecx, %r13d
subl %ecx, %r15d
sets %cl
testl %r13d, %r13d
setg %dl
andb %cl, %dl
xorl %ecx, %ecx
cmpb $0x1, %dl
jne 0x97e24
movq 0x78(%r14), %rdx
movq 0x80(%r14), %rsi
xorl %ecx, %ecx
leal (%r15,%rcx), %edi
movl %ecx, %r8d
shrl $0x6, %r8d
movq (%rdx,%r8,8), %r9
btq %rcx, %r9
adcl $0x0, %eax
movq (%rsi,%r8,8), %r8
btq %rcx, %r8
sbbl $0x0, %eax
incl %ecx
cmpl $-0x2, %edi
jg 0x97e21
cmpl %r13d, %ecx
jl 0x97df4
addl %ecx, %r15d
cmpl 0x8(%rsp), %eax
jg 0x97e38
cmpl 0x2c(%r14), %eax
jg 0x97e38
movl %eax, 0x2c(%r14)
movl %r15d, 0x14(%r14)
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
cmpl %r13d, %ecx
jge 0x97ea8
movq 0x78(%r14), %rsi
movq 0x80(%r14), %rdi
movq 0x8(%rsp), %rdx
leal -0x1(%rdx), %r8d
leal 0x1(%r15), %r9d
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movl %ecx, %r10d
movl %r10d, %r11d
shrl $0x6, %r11d
movq (%rsi,%r11,8), %rbx
btq %r10, %rbx
adcl $0x0, %eax
movq (%rdi,%r11,8), %r11
btq %r10, %r11
sbbl $0x0, %eax
cmpl 0x8(%rsp), %eax
jg 0x97e93
cmpl 0x2c(%r14), %eax
jg 0x97e93
movl %eax, 0x2c(%r14)
movl %r9d, 0x14(%r14)
cmpl %r10d, %r8d
cmovel %eax, %edx
leal 0x1(%r10), %r11d
incl %r9d
movl %r11d, %r10d
cmpl %r13d, %r11d
jl 0x97e62
cmpl 0x8(%rsp), %edx
jg 0x97ec0
cmpl 0x2c(%r14), %edx
jne 0x97ec0
subl %ecx, %r15d
addl 0x8(%rsp), %r15d
movl %r15d, 0x14(%r14)
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq