// File: /workspace/github_cpp_makefile_star2_O3/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, 0x38(%rsp)
movq %rdi, 0x30(%rsp)
movq 0xb0(%rsp), %r15
movl %r8d, 0x28(%r15)
movl $0x7fffffff, 0x2c(%r15) # imm = 0x7FFFFFFF
movl %esi, 0x18(%r15)
movl %ecx, 0x24(%r15)
xorl %eax, %eax
movl %eax, 0x1c(%r15)
leal (%r8,%r13), %ecx
cmpl %esi, %ecx
setl %cl
movq %rsi, 0x18(%rsp)
movq %r8, 0x8(%rsp)
leal (%r8,%rsi), %edx
subl %r13d, %edx
movq %rdx, 0x40(%rsp)
setl %dl
orb %cl, %dl
pxor %xmm0, %xmm0
movdqu %xmm0, (%r15)
movl %eax, 0x10(%r15)
jne 0x94a6f
movq 0x8(%rsp), %r10
leal (%r10,%r10), %ebp
testq %r9, %r9
je 0x94258
movl (%r9), %ecx
jmp 0x9425f
movl %ebp, %ecx
sarl $0x6, %ecx
incl %ecx
movq 0x18(%rsp), %r14
movl %ecx, 0x30(%r15)
cmpl %r10d, 0x3c(%r15)
jge 0x94371
movl %ebp, %eax
shrl $0x6, %eax
leal (%rax,%rax,2), %eax
leal 0xc(,%rax,4), %eax
movl %eax, 0x3c(%r15)
cmpl 0x38(%r15), %eax
jbe 0x9436d
movq 0x40(%r15), %rdi
movl %eax, %esi
shlq $0x3, %rsi
callq 0x2370
movq %rax, 0x40(%r15)
movl 0x30(%r15), %ecx
movl 0x3c(%r15), %esi
movl $0xaaaaaaab, %edx       # imm = 0xAAAAAAAB
imulq %rsi, %rdx
movq %rdx, %rsi
shrq $0x20, %rsi
shrq $0x23, %rdx
movl %edx, 0x3c(%r15)
movq %rax, 0x48(%r15)
andl $-0x8, %esi
leaq (%rax,%rsi), %rdi
movq %rdi, 0x50(%r15)
leal (%rdx,%rdx), %edi
leaq (%rax,%rdi,8), %r8
movq %r8, 0x58(%r15)
leal (%rdx,%rdx,2), %r8d
leaq (%rax,%r8,8), %r8
movq %r8, 0x60(%r15)
leal (,%rdx,4), %r8d
leaq (%rax,%r8,8), %r9
movq %r9, 0x68(%r15)
leal (%rdx,%rdx,4), %r9d
leaq (%rax,%r9,8), %r10
movq %r10, 0x70(%r15)
leal (%rdi,%rdi,2), %r10d
leaq (%rax,%r10,8), %r10
movq %r10, 0x78(%r15)
leal (,%rdx,8), %r10d
subl %edx, %r10d
leaq (%rax,%r10,8), %r10
movq %r10, 0x80(%r15)
movq 0x8(%rsp), %r10
leaq (%rax,%rsi,8), %rsi
movq %rsi, 0x88(%r15)
leal (%rdx,%rdx,8), %esi
leaq (%rax,%rsi,8), %rsi
movq %rsi, 0x90(%r15)
leal (%rdi,%rdi,4), %esi
leaq (%rax,%rsi,8), %rsi
movq %rsi, 0x98(%r15)
leal (%rdx,%r9,2), %esi
leaq (%rax,%rsi,8), %rax
movq %rax, 0xa0(%r15)
leal (%r8,%r8,2), %eax
movl %eax, 0x38(%r15)
movl %edx, 0x34(%r15)
movl %r10d, 0x3c(%r15)
movq %r10, %r12
shll $0x3, %ecx
movq 0x48(%r15), %rdi
movslq %ecx, %rbx
xorl %esi, %esi
movq %rbx, %rdx
callq 0x20e0
movq 0x50(%r15), %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x20e0
movq 0x58(%r15), %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x20e0
movq 0x60(%r15), %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x20e0
movq 0x68(%r15), %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x20e0
leal 0x1(%r12), %eax
cmpl %r14d, %eax
cmovgel %r14d, %eax
testl %eax, %eax
movq 0x30(%rsp), %r10
jle 0x94410
movl %eax, %eax
movl %r12d, %edx
xorl %esi, %esi
leaq 0x1a583d(%rip), %rdi    # 0x239c20
leal (%rdx,%rsi), %ecx
movl $0x1, %r8d
shlq %cl, %r8
movzbl (%r10,%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 0x943e3
movq 0x68(%r15), %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x20e0
movq 0x80(%r15), %rdi
movslq 0x30(%r15), %rdx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x20e0
movq 0x8(%rsp), %rcx
movl %ecx, %eax
sarl $0x6, %eax
movslq %eax, %rbx
cmpl $0x40, %ecx
jb 0x94464
movq 0x80(%r15), %rdi
leaq (,%rbx,8), %rdx
movl $0xff, %esi
callq 0x20e0
movq 0x8(%rsp), %rcx
andl $0x3f, %ecx
je 0x94481
movq $-0x1, %rax
shlq %cl, %rax
notq %rax
movq 0x80(%r15), %rcx
movq %rax, (%rcx,%rbx,8)
movq 0x78(%r15), %rdi
movslq 0x30(%r15), %rdx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x20e0
movl %ebp, %eax
sarl $0x6, %eax
cmpl $0x3f, %ebp
ja 0x944a3
movl %eax, %r9d
jmp 0x944bf
movq 0x78(%r15), %rdi
movslq %eax, %rbx
leaq (,%rbx,8), %rdx
movl $0xff, %esi
callq 0x20e0
movq %rbx, %r9
andl $0x3e, %ebp
leal 0x1(%rbp), %ecx
movq $-0x1, %rax
shlq %cl, %rax
notq %rax
movq 0x78(%r15), %rdx
movq %rax, (%rdx,%r9,8)
movl 0x30(%r15), %esi
testl %esi, %esi
movq 0x8(%rsp), %r8
jle 0x94500
movq 0x80(%r15), %rax
xorl %ecx, %ecx
movq (%rax,%rcx,8), %rdi
xorq %rdi, (%rdx,%rcx,8)
incq %rcx
cmpq %rcx, %rsi
jne 0x944f0
leal -0x1(%r13), %eax
leal (%r8,%r8,2), %ecx
movl %ecx, 0x24(%rsp)
movl $0x1, %edi
movl %ebp, %ecx
shlq %cl, %rdi
movq %rdi, 0x50(%rsp)
cmpl $0x2, %r13d
movl %eax, 0x14(%rsp)
jl 0x9477e
movq %r9, 0x48(%rsp)
movq 0x90(%r15), %r10
leal -0x1(%rsi), %r11d
movslq %r11d, %rcx
movq %rcx, 0x68(%rsp)
movslq %r8d, %r13
movslq %r14d, %rcx
movq %rcx, 0x60(%rsp)
movl %eax, %eax
movq %rax, 0x28(%rsp)
leaq 0x1(%rsi), %rax
movq %rax, 0x58(%rsp)
xorl %edi, %edi
movl %r8d, 0x4(%rsp)
testl %esi, %esi
jle 0x94692
movq %r13, 0x70(%rsp)
movq 0x38(%rsp), %rax
movzbl (%rax,%rdi), %eax
leaq 0x1a56a0(%rip), %rcx    # 0x239c20
movzbl (%rcx,%rax), %eax
movq 0x48(%r15,%rax,8), %rbx
movq 0x80(%r15), %r9
movq 0x88(%r15), %r14
movq 0x98(%r15), %r12
movq 0xa0(%r15), %rcx
xorl %eax, %eax
xorl %r8d, %r8d
movq (%r9,%rax,8), %r15
orq (%rbx,%rax,8), %r15
movq %r15, (%r14,%rax,8)
andq (%rdx,%rax,8), %r15
addq %r8, %r15
setb %r8b
movq %r15, (%r10,%rax,8)
addq (%rdx,%rax,8), %r15
movq %r15, (%r10,%rax,8)
movq (%rdx,%rax,8), %rbp
cmpq %rbp, %r15
setb %r13b
xorq %rbp, %r15
movq %r15, (%r10,%rax,8)
orq (%r14,%rax,8), %r15
orb %r8b, %r13b
movq %r15, (%r10,%rax,8)
andq (%rdx,%rax,8), %r15
movq %r15, (%r12,%rax,8)
movq (%r10,%rax,8), %r15
orq (%rdx,%rax,8), %r15
notq %r15
movq %r15, (%rcx,%rax,8)
orq (%r9,%rax,8), %r15
movzbl %r13b, %r8d
movq %r15, (%rcx,%rax,8)
incq %rax
cmpq %rax, %rsi
jne 0x945aa
testl %esi, %esi
movq 0xb0(%rsp), %r15
movq 0x70(%rsp), %r13
jle 0x94692
movq 0x80(%r15), %rax
movq 0x88(%r15), %rcx
movq 0xa0(%r15), %r9
movq 0x98(%r15), %rbx
movq 0x58(%rsp), %r14
xorl %r12d, %r12d
movq -0x10(%r10,%r14,8), %r8
shrq %r8
orq %r12, %r8
movq %r8, -0x10(%rcx,%r14,8)
movq -0x10(%r10,%r14,8), %r12
andq -0x10(%r9,%r14,8), %r8
movq %r8, -0x10(%rax,%r14,8)
movq -0x10(%r9,%r14,8), %r8
orq -0x10(%rcx,%r14,8), %r8
notq %r8
movq %r8, -0x10(%rdx,%r14,8)
orq -0x10(%rbx,%r14,8), %r8
shlq $0x3f, %r12
movq %r8, -0x10(%rdx,%r14,8)
decq %r14
cmpq $0x1, %r14
jg 0x9464a
testb $0x1, (%r10)
jne 0x946ac
movl 0x4(%rsp), %eax
cmpl 0x24(%rsp), %eax
jge 0x94a6f
incl %eax
movl %eax, 0x4(%rsp)
movq 0x48(%r15), %rax
movq 0x50(%r15), %rcx
movq 0x58(%r15), %r9
movq 0x60(%r15), %rbx
cmpl $0x2, %esi
jl 0x94714
xorl %r14d, %r14d
movq (%rax,%r14,8), %r8
movq 0x8(%rax,%r14,8), %r15
shldq $0x3f, %r8, %r15
movq %r15, (%rax,%r14,8)
movq (%rcx,%r14,8), %r8
movq 0x8(%rcx,%r14,8), %r15
shldq $0x3f, %r8, %r15
movq %r15, (%rcx,%r14,8)
movq (%r9,%r14,8), %r8
movq 0x8(%r9,%r14,8), %r15
shldq $0x3f, %r8, %r15
movq %r15, (%r9,%r14,8)
movq (%rbx,%r14,8), %r8
movq 0x8(%rbx,%r14,8), %r15
shldq $0x3f, %r8, %r15
movq %r15, (%rbx,%r14,8)
incq %r14
cmpq %r14, %r11
jne 0x946c4
movq 0x68(%rsp), %r8
shrq (%rax,%r8,8)
shrq (%rcx,%r8,8)
shrq (%r9,%r8,8)
shrq (%rbx,%r8,8)
incq %r13
cmpq 0x60(%rsp), %r13
movq 0xb0(%rsp), %r15
jge 0x94769
movq 0x30(%rsp), %rax
movzbl (%rax,%r13), %eax
leaq 0x1a54d4(%rip), %rcx    # 0x239c20
movzbl (%rcx,%rax), %eax
cmpq $0x3, %rax
ja 0x94769
movq 0x48(%r15,%rax,8), %rax
movq 0x48(%rsp), %rcx
movq 0x50(%rsp), %r8
orq %r8, (%rax,%rcx,8)
incq %rdi
cmpq 0x28(%rsp), %rdi
jne 0x94563
movq 0x18(%rsp), %r14
jmp 0x9478c
movq $0x0, 0x28(%rsp)
movl %r8d, 0x4(%rsp)
testl %esi, %esi
jle 0x948c7
movq 0x38(%rsp), %rax
movq 0x28(%rsp), %rcx
movzbl (%rax,%rcx), %eax
leaq 0x1a5477(%rip), %rcx    # 0x239c20
movzbl (%rcx,%rax), %eax
movq 0x48(%r15,%rax,8), %rax
movq 0x80(%r15), %rdi
movq 0x88(%r15), %r8
movq 0x90(%r15), %r9
movq 0x98(%r15), %r10
movq 0xa0(%r15), %r11
xorl %ecx, %ecx
xorl %ebx, %ebx
movq (%rdi,%rcx,8), %r14
orq (%rax,%rcx,8), %r14
movq %r14, (%r8,%rcx,8)
andq (%rdx,%rcx,8), %r14
addq %rbx, %r14
setb %bl
movq %r14, (%r9,%rcx,8)
addq (%rdx,%rcx,8), %r14
movq %r14, (%r9,%rcx,8)
movq (%rdx,%rcx,8), %r15
cmpq %r15, %r14
setb %bpl
xorq %r15, %r14
movq %r14, (%r9,%rcx,8)
orq (%r8,%rcx,8), %r14
orb %bl, %bpl
movq %r14, (%r9,%rcx,8)
andq (%rdx,%rcx,8), %r14
movq %r14, (%r10,%rcx,8)
movq (%r9,%rcx,8), %r14
orq (%rdx,%rcx,8), %r14
notq %r14
movq %r14, (%r11,%rcx,8)
orq (%rdi,%rcx,8), %r14
movzbl %bpl, %ebx
movq %r14, (%r11,%rcx,8)
incq %rcx
cmpq %rcx, %rsi
jne 0x947d9
testl %esi, %esi
movq 0x18(%rsp), %r14
movq 0xb0(%rsp), %r15
jle 0x948c7
movq 0x90(%r15), %rax
movq 0x80(%r15), %rcx
movq 0x88(%r15), %rdi
movq 0xa0(%r15), %r8
movq 0x98(%r15), %r9
incq %rsi
xorl %r10d, %r10d
movq -0x10(%rax,%rsi,8), %r11
shrq %r11
orq %r10, %r11
movq %r11, -0x10(%rdi,%rsi,8)
movq -0x10(%rax,%rsi,8), %r10
andq -0x10(%r8,%rsi,8), %r11
movq %r11, -0x10(%rcx,%rsi,8)
movq -0x10(%r8,%rsi,8), %r11
orq -0x10(%rdi,%rsi,8), %r11
notq %r11
movq %r11, -0x10(%rdx,%rsi,8)
orq -0x10(%r9,%rsi,8), %r11
shlq $0x3f, %r10
movq %r11, -0x10(%rdx,%rsi,8)
decq %rsi
cmpq $0x1, %rsi
ja 0x9487d
jmp 0x948ce
movq 0x90(%r15), %rax
testb $0x1, (%rax)
movl 0x4(%rsp), %edi
jne 0x948e8
cmpl 0x24(%rsp), %edi
jge 0x94a6f
incl %edi
movq 0x18(%rsp), %r14
movq 0x8(%rsp), %rcx
movl 0x14(%rsp), %eax
subl %ecx, %eax
decl %r14d
cmpl %r14d, %eax
jge 0x94a51
movq 0x80(%r15), %rax
movq 0x40(%rsp), %rcx
leal 0x1(%rcx), %esi
andl $-0x2, %esi
decl %ecx
movd %edi, %xmm10
movd %ecx, %xmm0
pshufd $0x50, %xmm0, %xmm0     # xmm0 = xmm0[0,0,1,1]
movq 0x19cbe7(%rip), %xmm1   # 0x231510
xorl %ecx, %ecx
movdqa 0x19c9ad(%rip), %xmm2   # 0x2312e0
pxor %xmm2, %xmm0
movdqa 0x19cc01(%rip), %xmm3   # 0x231540
pcmpeqd %xmm4, %xmm4
pxor %xmm5, %xmm5
movaps 0x19c281(%rip), %xmm8   # 0x230bd0
movdqa 0x19cbf8(%rip), %xmm9   # 0x231550
movdqa %xmm10, %xmm7
movdqa %xmm1, %xmm6
pxor %xmm2, %xmm6
pcmpgtd %xmm0, %xmm6
movl %ecx, %edi
shrl $0x6, %edi
movd %xmm6, %r8d
notl %r8d
testb $0x1, %r8b
je 0x94982
movq (%rdx,%rdi,8), %xmm10
movdqa %xmm6, %xmm11
pxor %xmm4, %xmm11
pextrw $0x2, %xmm11, %r9d
testb $0x1, %r9b
je 0x949a3
movq (%rdx,%rdi,8), %xmm11
punpcklqdq %xmm11, %xmm10  # xmm10 = xmm10[0],xmm11[0]
testb $0x1, %r8b
je 0x949af
movq (%rax,%rdi,8), %xmm11
testb $0x1, %r9b
je 0x949c0
movq (%rax,%rdi,8), %xmm12
punpcklqdq %xmm12, %xmm11  # xmm11 = xmm11[0],xmm12[0]
movdqa %xmm1, %xmm12
pand %xmm3, %xmm12
movdqa %xmm12, %xmm13
punpckldq %xmm5, %xmm13   # xmm13 = xmm13[0],xmm5[0],xmm13[1],xmm5[1]
movdqa %xmm10, %xmm14
psrlq %xmm13, %xmm14
psrlq $0x20, %xmm12
psrlq %xmm12, %xmm10
movsd %xmm14, %xmm10          # xmm10 = xmm14[0],xmm10[1]
shufps $0xe8, %xmm10, %xmm10   # xmm10 = xmm10[0,2,2,3]
movdqa %xmm11, %xmm12
psrlq %xmm13, %xmm12
andps %xmm8, %xmm10
pshufd $0xee, %xmm13, %xmm13   # xmm13 = xmm13[2,3,2,3]
psrlq %xmm13, %xmm11
paddd %xmm7, %xmm10
movsd %xmm12, %xmm11          # xmm11 = xmm12[0],xmm11[1]
shufps $0xe8, %xmm11, %xmm11   # xmm11 = xmm11[0,2,2,3]
andps %xmm8, %xmm11
psubd %xmm11, %xmm10
addl $0x2, %ecx
paddd %xmm9, %xmm1
cmpl %ecx, %esi
jne 0x94958
pand %xmm6, %xmm7
pandn %xmm10, %xmm6
por %xmm7, %xmm6
pshufd $0x55, %xmm6, %xmm0     # xmm0 = xmm6[1,1,1,1]
paddd %xmm6, %xmm0
movd %xmm0, %edi
movl %r14d, %eax
cmpl %r14d, %eax
jne 0x94a6f
cmpl 0x8(%rsp), %edi
jg 0x94a6f
movq %r14, %rcx
movl %edi, 0x2c(%r15)
movl %ecx, 0x14(%r15)
movl 0x14(%rsp), %eax
movl %eax, 0x20(%r15)
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq