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

	bd = thre+1; bd = ((bd<=pn)?bd:pn); i_bd = thre;
	ed_init_core(i, bd, i_bd, pstr, ez->Peq);
	bd = thre+1, i_bd = thre;
	
	memset((ez->Peq[4]).a, 0, wz);
	err = thre;
	w_infi_set_bit_lsub(ez->VN, thre, ez->nword); /**VN = (((Word)1)<<(thre))-1;**/ 
	w_infi_set_bit_lsub(ez->VP, (thre<<1)+1, ez->nword); /**VP = (((Word)1)<<((thre<<1)+1))-1;**/
	w_infi_self_xor(ez->VP, ez->VN, ez->nword, wz) /**VP ^= VN;**/
	
	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) {
		// fprintf(stderr, "\ni::%d\n", i);
		// prt_bit_extz_t((*ez), (((thre<<1))+1));
		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;
		// fprintf(stderr, "c::%u\n", c);
		// print_bits(ez->Peq[c].a, (((thre<<1))+1), "Peq[c]");
    }
	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 - thre;/**up bound**/
	for (cut = pn - 1, i = 0; site < cut; site++, i++) {
		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 (site == cut && err <= thre) {
		ez->err = err; 
		ez->pe = pn-1; ez->te = tn-1;
	}
    return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %ecx, %r13d
movq %rdx, 0x30(%rsp)
movq %rdi, 0x28(%rsp)
movq 0xb0(%rsp), %rbx
movl %r8d, 0x28(%rbx)
movl $0x7fffffff, 0x2c(%rbx) # imm = 0x7FFFFFFF
movl %esi, 0x18(%rbx)
movl %ecx, 0x24(%rbx)
xorl %eax, %eax
movl %eax, 0x1c(%rbx)
leal (%r8,%r13), %ecx
cmpl %esi, %ecx
setl %cl
movq %rsi, 0x18(%rsp)
movq %r8, (%rsp)
leal (%r8,%rsi), %edx
subl %r13d, %edx
movl %edx, 0x24(%rsp)
setl %dl
orb %cl, %dl
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movl %eax, 0x10(%rbx)
jne 0x948b4
movq (%rsp), %r10
leal (%r10,%r10), %ebp
testq %r9, %r9
je 0x941b3
movl (%r9), %eax
jmp 0x941ba
movl %ebp, %eax
sarl $0x6, %eax
incl %eax
movl %eax, 0x30(%rbx)
cmpl %r10d, 0x3c(%rbx)
jge 0x942b8
movl %ebp, %eax
shrl $0x6, %eax
leal (%rax,%rax,2), %eax
leal 0xc(,%rax,4), %eax
movl %eax, 0x3c(%rbx)
cmpl 0x38(%rbx), %eax
jbe 0x942b4
movq 0x40(%rbx), %rdi
movl %eax, %esi
shlq $0x3, %rsi
callq 0x2370
movq (%rsp), %r10
movq %rax, 0x40(%rbx)
movl 0x3c(%rbx), %edx
movl $0xaaaaaaab, %ecx       # imm = 0xAAAAAAAB
imulq %rdx, %rcx
movq %rcx, %rdx
shrq $0x20, %rdx
shrq $0x23, %rcx
movl %ecx, 0x3c(%rbx)
movq %rax, 0x48(%rbx)
andl $-0x8, %edx
leaq (%rax,%rdx), %rsi
movq %rsi, 0x50(%rbx)
leal (%rcx,%rcx), %esi
leaq (%rax,%rsi,8), %rdi
movq %rdi, 0x58(%rbx)
leal (%rcx,%rcx,2), %edi
leaq (%rax,%rdi,8), %rdi
movq %rdi, 0x60(%rbx)
leal (,%rcx,4), %edi
leaq (%rax,%rdi,8), %r8
movq %r8, 0x68(%rbx)
leal (%rcx,%rcx,4), %r8d
leaq (%rax,%r8,8), %r9
movq %r9, 0x70(%rbx)
leal (%rsi,%rsi,2), %r9d
leaq (%rax,%r9,8), %r9
movq %r9, 0x78(%rbx)
leal (,%rcx,8), %r9d
subl %ecx, %r9d
leaq (%rax,%r9,8), %r9
movq %r9, 0x80(%rbx)
leaq (%rax,%rdx,8), %rdx
movq %rdx, 0x88(%rbx)
leal (%rcx,%rcx,8), %edx
leaq (%rax,%rdx,8), %rdx
movq %rdx, 0x90(%rbx)
leal (%rsi,%rsi,4), %edx
leaq (%rax,%rdx,8), %rdx
movq %rdx, 0x98(%rbx)
leal (%rcx,%r8,2), %edx
leaq (%rax,%rdx,8), %rax
movq %rax, 0xa0(%rbx)
leal (%rdi,%rdi,2), %eax
movl %eax, 0x38(%rbx)
movl %ecx, 0x34(%rbx)
movl %r10d, 0x3c(%rbx)
movl 0x30(%rbx), %eax
shll $0x3, %eax
movq 0x48(%rbx), %rdi
movslq %eax, %r15
xorl %esi, %esi
movq %r15, %rdx
callq 0x20e0
movq 0x50(%rbx), %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x20e0
movq 0x58(%rbx), %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x20e0
movq 0x60(%rbx), %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x20e0
movq 0x68(%rbx), %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x20e0
movq (%rsp), %rdx
leal 0x1(%rdx), %eax
movq 0x18(%rsp), %rcx
cmpl %ecx, %eax
cmovgel %ecx, %eax
testl %eax, %eax
movq 0x28(%rsp), %r10
jle 0x9435b
movl %eax, %eax
movl %edx, %edx
xorl %esi, %esi
leaq 0x1996e2(%rip), %rdi    # 0x22da10
leal (%rdx,%rsi), %ecx
movl $0x1, %r8d
shlq %cl, %r8
movzbl (%r10,%rsi), %r9d
movzbl (%rdi,%r9), %r9d
movq 0x48(%rbx,%r9,8), %r9
sarl $0x6, %ecx
movslq %ecx, %rcx
orq %r8, (%r9,%rcx,8)
incq %rsi
cmpq %rsi, %rax
jne 0x9432e
movq 0x68(%rbx), %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x20e0
movq 0x80(%rbx), %rdi
movslq 0x30(%rbx), %rdx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x20e0
movq (%rsp), %rcx
movl %ecx, %eax
sarl $0x6, %eax
movslq %eax, %r14
cmpl $0x40, %ecx
jb 0x943ad
movq 0x80(%rbx), %rdi
leaq (,%r14,8), %rdx
movl $0xff, %esi
callq 0x20e0
movq (%rsp), %rcx
andl $0x3f, %ecx
je 0x943ca
movq $-0x1, %rax
shlq %cl, %rax
notq %rax
movq 0x80(%rbx), %rcx
movq %rax, (%rcx,%r14,8)
movq 0x78(%rbx), %rdi
movslq 0x30(%rbx), %rdx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x20e0
movl %ebp, %eax
sarl $0x6, %eax
movslq %eax, %r14
cmpl $0x40, %ebp
jb 0x94400
movq 0x78(%rbx), %rdi
leaq (,%r14,8), %rdx
movl $0xff, %esi
callq 0x20e0
andl $0x3e, %ebp
leal 0x1(%rbp), %ecx
movq $-0x1, %rdx
shlq %cl, %rdx
notq %rdx
movq 0x78(%rbx), %rax
movq %rdx, (%rax,%r14,8)
movslq 0x30(%rbx), %rcx
movl %ecx, %esi
movq %rcx, 0x38(%rsp)
testq %rcx, %rcx
movq (%rsp), %r8
jle 0x94448
movq 0x80(%rbx), %rcx
xorl %edx, %edx
movq (%rcx,%rdx,8), %rdi
xorq %rdi, (%rax,%rdx,8)
incq %rdx
cmpq %rdx, %rsi
jne 0x94438
leal -0x1(%r13), %edx
leal (%r8,%r8,2), %ecx
movl %ecx, 0x10(%rsp)
movl $0x1, %edi
movl %ebp, %ecx
shlq %cl, %rdi
movq %rdi, 0x48(%rsp)
cmpl $0x2, %r13d
movl %edx, 0xc(%rsp)
jl 0x946f2
movq %r14, 0x40(%rsp)
movq 0x90(%rbx), %rcx
movq %rcx, 0x68(%rsp)
leal -0x1(%rsi), %r11d
movslq %r8d, %r9
movslq 0x18(%rsp), %rcx
movq %rcx, 0x60(%rsp)
movl %edx, %ecx
movq %rcx, 0x58(%rsp)
leaq 0x1(%rsi), %rcx
movq %rcx, 0x50(%rsp)
xorl %edi, %edi
movl %r8d, %r12d
movq %r9, 0x70(%rsp)
movl %r12d, 0x14(%rsp)
testl %esi, %esi
jle 0x9456b
movq 0x30(%rsp), %rcx
movzbl (%rcx,%rdi), %edx
leaq 0x199546(%rip), %rcx    # 0x22da10
movzbl (%rcx,%rdx), %edx
movq 0xb0(%rsp), %rcx
movq 0x48(%rcx,%rdx,8), %r15
movq 0x80(%rcx), %r14
movq 0x88(%rcx), %r9
movq 0x90(%rcx), %r10
movq 0x98(%rcx), %rbp
movq 0xa0(%rcx), %rdx
xorl %r12d, %r12d
xorl %ebx, %ebx
movq (%r14,%r12,8), %r13
orq (%r15,%r12,8), %r13
movq %r13, (%r9,%r12,8)
andq (%rax,%r12,8), %r13
addq %rbx, %r13
setb %bl
movq %r13, (%r10,%r12,8)
addq (%rax,%r12,8), %r13
movq %r13, (%r10,%r12,8)
movq (%rax,%r12,8), %r8
cmpq %r8, %r13
setb %cl
xorq %r8, %r13
movq %r13, (%r10,%r12,8)
orq (%r9,%r12,8), %r13
orb %bl, %cl
movq %r13, (%r10,%r12,8)
andq (%rax,%r12,8), %r13
movq %r13, (%rbp,%r12,8)
movq (%r10,%r12,8), %r8
orq (%rax,%r12,8), %r8
notq %r8
movq %r8, (%rdx,%r12,8)
orq (%r14,%r12,8), %r8
movzbl %cl, %ebx
movq %r8, (%rdx,%r12,8)
incq %r12
cmpq %r12, %rsi
jne 0x94503
testl %esi, %esi
movq 0xb0(%rsp), %rbx
jle 0x945e9
movq 0x90(%rbx), %rdx
movq 0x80(%rbx), %r9
movq 0x88(%rbx), %r10
movq 0xa0(%rbx), %r14
movq 0x98(%rbx), %r15
movq 0x50(%rsp), %r12
xorl %ebp, %ebp
movq -0x10(%rdx,%r12,8), %rcx
shrq %rcx
orq %rbp, %rcx
movq %rcx, -0x10(%r10,%r12,8)
movq -0x10(%rdx,%r12,8), %rbp
andq -0x10(%r14,%r12,8), %rcx
movq %rcx, -0x10(%r9,%r12,8)
movq -0x10(%r14,%r12,8), %rcx
orq -0x10(%r10,%r12,8), %rcx
notq %rcx
movq %rcx, -0x10(%rax,%r12,8)
orq -0x10(%r15,%r12,8), %rcx
shlq $0x3f, %rbp
movq %rcx, -0x10(%rax,%r12,8)
decq %r12
cmpq $0x1, %r12
jg 0x945a1
movq 0x68(%rsp), %rcx
testb $0x1, (%rcx)
movq 0x38(%rsp), %r13
jne 0x9460d
movl 0x14(%rsp), %r12d
cmpl 0x10(%rsp), %r12d
jge 0x948b4
incl %r12d
jmp 0x94612
movl 0x14(%rsp), %r12d
cmpl $0x2, %r13d
jl 0x9467b
movq 0x48(%rbx), %rdx
movq 0x50(%rbx), %r9
movq 0x58(%rbx), %r10
movq 0x60(%rbx), %r14
xorl %r15d, %r15d
movq (%rdx,%r15,8), %rcx
movq 0x8(%rdx,%r15,8), %r8
shldq $0x3f, %rcx, %r8
movq %r8, (%rdx,%r15,8)
movq (%r9,%r15,8), %rcx
movq 0x8(%r9,%r15,8), %r8
shldq $0x3f, %rcx, %r8
movq %r8, (%r9,%r15,8)
movq (%r10,%r15,8), %rcx
movq 0x8(%r10,%r15,8), %r8
shldq $0x3f, %rcx, %r8
movq %r8, (%r10,%r15,8)
movq (%r14,%r15,8), %rcx
movq 0x8(%r14,%r15,8), %r8
shldq $0x3f, %rcx, %r8
movq %r8, (%r14,%r15,8)
incq %r15
cmpq %r15, %r11
jne 0x9462b
movq 0x48(%rbx), %rcx
shrq -0x8(%rcx,%r13,8)
movq 0x50(%rbx), %rcx
shrq -0x8(%rcx,%r13,8)
movq 0x58(%rbx), %rcx
shrq -0x8(%rcx,%r13,8)
movq 0x60(%rbx), %rcx
shrq -0x8(%rcx,%r13,8)
movq 0x70(%rsp), %r9
incq %r9
movl $0x4, %edx
cmpq 0x60(%rsp), %r9
jge 0x946c8
movq 0x28(%rsp), %rcx
movzbl (%rcx,%r9), %ecx
leaq 0x19934c(%rip), %rdx    # 0x22da10
movzbl (%rdx,%rcx), %edx
cmpl $0x3, %edx
ja 0x946e0
movq 0x48(%rbx,%rdx,8), %rcx
movq 0x40(%rsp), %rdx
movq 0x48(%rsp), %r8
orq %r8, (%rcx,%rdx,8)
incq %rdi
cmpq 0x58(%rsp), %rdi
jne 0x944a8
movl %edi, %edx
jmp 0x946fc
xorl %edx, %edx
movl %r8d, %r12d
movq 0x38(%rsp), %r13
testl %esi, %esi
jle 0x947b8
movq 0x30(%rsp), %rcx
movzbl (%rcx,%rdx), %ecx
leaq 0x1992fc(%rip), %rdx    # 0x22da10
movzbl (%rdx,%rcx), %ecx
movq 0xb0(%rsp), %r8
movq 0x48(%r8,%rcx,8), %rdx
movq 0x80(%r8), %rdi
movq 0x88(%r8), %r9
movq 0x90(%r8), %r10
movq 0x98(%r8), %r11
movq 0xa0(%r8), %r14
xorl %r15d, %r15d
xorl %ebx, %ebx
movq (%rdi,%r15,8), %rcx
orq (%rdx,%r15,8), %rcx
movq %rcx, (%r9,%r15,8)
andq (%rax,%r15,8), %rcx
addq %rbx, %rcx
setb %r8b
movq %rcx, (%r10,%r15,8)
addq (%rax,%r15,8), %rcx
movq %rcx, (%r10,%r15,8)
movq (%rax,%r15,8), %rbx
cmpq %rbx, %rcx
setb %bpl
xorq %rbx, %rcx
movq %rcx, (%r10,%r15,8)
orq (%r9,%r15,8), %rcx
orb %r8b, %bpl
movq %rcx, (%r10,%r15,8)
andq (%rax,%r15,8), %rcx
movq %rcx, (%r11,%r15,8)
movq (%r10,%r15,8), %rcx
orq (%rax,%r15,8), %rcx
notq %rcx
movq %rcx, (%r14,%r15,8)
orq (%rdi,%r15,8), %rcx
movzbl %bpl, %ebx
movq %rcx, (%r14,%r15,8)
incq %r15
cmpq %r15, %r13
jne 0x9474d
testl %r13d, %r13d
movq 0xb0(%rsp), %rbx
jle 0x94836
movq 0x90(%rbx), %rdx
movq 0x80(%rbx), %rdi
movq 0x88(%rbx), %r8
movq 0xa0(%rbx), %r9
movq 0x98(%rbx), %r10
incq %rsi
xorl %r11d, %r11d
movq -0x10(%rdx,%rsi,8), %rcx
shrq %rcx
orq %r11, %rcx
movq %rcx, -0x10(%r8,%rsi,8)
movq -0x10(%rdx,%rsi,8), %r11
andq -0x10(%r9,%rsi,8), %rcx
movq %rcx, -0x10(%rdi,%rsi,8)
movq -0x10(%r9,%rsi,8), %rcx
orq -0x10(%r8,%rsi,8), %rcx
notq %rcx
movq %rcx, -0x10(%rax,%rsi,8)
orq -0x10(%r10,%rsi,8), %rcx
shlq $0x3f, %r11
movq %rcx, -0x10(%rax,%rsi,8)
decq %rsi
cmpq $0x1, %rsi
jg 0x947ee
movq 0x90(%rbx), %rcx
testb $0x1, (%rcx)
jne 0x9484c
cmpl 0x10(%rsp), %r12d
jge 0x948b4
incl %r12d
movq 0x18(%rsp), %r8
movq (%rsp), %rcx
movl 0xc(%rsp), %edx
subl %ecx, %edx
decl %r8d
cmpl %r8d, %edx
jge 0x94898
movq 0x80(%rbx), %rdx
xorl %esi, %esi
movl 0x24(%rsp), %r9d
movl %esi, %ecx
shrl $0x6, %ecx
movq (%rax,%rcx,8), %rdi
btq %rsi, %rdi
adcl $0x0, %r12d
movq (%rdx,%rcx,8), %rcx
btq %rsi, %rcx
sbbl $0x0, %r12d
incl %esi
cmpl %esi, %r9d
jne 0x94871
movl %r8d, %edx
cmpl %r8d, %edx
jne 0x948b4
cmpl (%rsp), %r12d
jg 0x948b4
movq %r8, %rax
movl %r12d, 0x2c(%rbx)
movl %eax, 0x14(%rbx)
movl 0xc(%rsp), %eax
movl %eax, 0x20(%rbx)
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq