// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/./Levenshtein_distance.h
// Function: ed_band_cal_extension_64_0_w_trace(char*, int, char*, int, int, bit_extz_t*)
inline void ed_band_cal_extension_64_0_w_trace(char *pstr, int32_t pn, char *tstr, int32_t tn, int32_t thre, bit_extz_t *ez)
{
	int32_t done = 1;//diff
	ez->cigar.n = 0; ez->nword = 1;//diff
    if(ez->err > thre) {//diff
		init_base_ed(*ez, thre, pn, tn); ez->ps = ez->ts = 0; ez->pe = ez->te = -1;
		if(pn > tn + thre) pn = tn + thre;
    	else if(tn > pn + thre) tn = pn + thre;
		done = 0;//diff
	} else if(ez->err == 0) {//diff
        push_trace(&(ez->cigar), 0, ez->te+1-ez->ts); return;//diff
    } else {
		pn = ez->pe + 1 - ez->ps; tn = ez->te + 1 - ez->ts; //diff
	}
	int32_t i, err, tn0 = tn - 1, cut = thre+(thre<<1), bd, i_bd, poff, pe = pn-1, tmp_e = INT32_MAX, k;
	Word c, Peq[5] = {0}, VP, VN, X, D0, HN, HP, mm;

	bd = thre+1; bd = ((bd<=pn)?bd:pn); i_bd = thre;
	for (i = 0, mm = (((Word)1)<<i_bd); i < bd; i++) {
        Peq[seq_nt4_table[(uint8_t)pstr[i]]] |= mm; mm <<= 1;
    }	
	bd = thre+1, i_bd = thre; Peq[4] = 0; err = thre;
	VN = (((Word)1)<<(thre))-1; VP = (((Word)1)<<((thre<<1)+1))-1; VP ^= VN;

	ez->path.n=(ez->nword*tn*5);//diff
    kv_resize(w_sig, ez->path, ez->path.n); ez->path.n=0;//diff

	i = 0; mm = ((Word)1 << (thre<<1));
	// X = D0 = HN = HP = mm = 0;//for debug
	while (i < tn0) {
		// fprintf(stderr, "i::%d\n", i);
		// prt_vector(Peq, VP, VN, X, D0, HN, HP, ((thre<<1)+1));
		ed_core_64(Peq, VP, VN, X, D0, HN, HP, (uint8_t)tstr[i]);
		if (!(D0&(1ULL))) {
			++err; if (err>cut) return;
		}

		if(!done) {//diff
			poff = i-thre; k = i+thre-pe;/**poff:[i-thre, i+thre]**/
            if(k >= 0) {
                if(tmp_e == INT32_MAX) {
                    tmp_e = err;
                    for (k = 0; poff < pe; poff++, (k)++) {
                        tmp_e += ((VP>>k)&(1ULL)); tmp_e -= ((VN>>k)&(1ULL));
                    } 
                } else {
                    k = (thre<<1) - k; 
                    if(k >= 0) {
                        tmp_e += ((HP>>k)&(1ULL)); tmp_e -= ((HN>>k)&(1ULL)); 
                    }
                }
                if(tmp_e <= (*ez).thre && tmp_e < (*ez).err) {
					(*ez).err = tmp_e; (*ez).pe = pe; (*ez).te = i;
                }
				// fprintf(stderr, "i::%d, (*ez).err::%d, (*ez).pe::%d, (*ez).te::%d, thre::%d, err::%d, tmp_e::%d, poff::%d, k::%d, pe::%d\n", 
				// i, (*ez).err, (*ez).pe, (*ez).te, thre, err, tmp_e, i-thre, i+thre-pe, pe);
            }
        }

		Peq[0] >>= 1; Peq[1] >>= 1; Peq[2] >>= 1; Peq[3] >>= 1;
		++i; ++i_bd;
        if(i_bd < pn) {
            c = seq_nt4_table[(uint8_t)pstr[i_bd]]; 
            if(c < 4) Peq[c] |= mm;
        }
		// if(((ez->path.n+5)>(ez->nword*tn*5))||((ez->path.n+5)>(ez->path.m))) {
		// 	fprintf(stderr, "[M::%s::] pn::%d, tn::%d\n", __func__, pn, tn);
		// }
		ez->path.a[ez->path.n++] = D0;//diff
        ez->path.a[ez->path.n++] = VP;//diff
        ez->path.a[ez->path.n++] = VN;//diff
        ez->path.a[ez->path.n++] = HP;//diff
        ez->path.a[ez->path.n++] = HN;//diff
	}
	ed_core_64(Peq, VP, VN, X, D0, HN, HP, (uint8_t)tstr[i]);
	if (!(D0&(1ULL))) {
		++err; if (err>cut) return;
	}
	// if(((ez->path.n+5)>(ez->nword*tn*5))||((ez->path.n+5)>(ez->path.m))) {
	// 	fprintf(stderr, "[M::%s::] pn::%d, tn::%d\n", __func__, pn, tn);
	// }
	ez->path.a[ez->path.n++] = D0;//diff
	ez->path.a[ez->path.n++] = VP;//diff
	ez->path.a[ez->path.n++] = VN;//diff
	ez->path.a[ez->path.n++] = HP;//diff
	ez->path.a[ez->path.n++] = HN;//diff

	int32_t site = tn - 1 - thre;/**up bound; site:[tn - 1 - thre, tn - 1 + thre]**/
	if(!done) {//diff
		for (cut = pn - 1; site < cut; ) {
			err += VP&(1ULL); VP >>= 1; err -= VN&(1ULL); VN >>= 1; 
			site++;
			if(err <= thre && err < ez->err) {
				ez->err = err; ez->pe = site; ez->te = tn-1;
			}
		}
		if(err <= thre && err < ez->err) {
			ez->err = err; ez->pe = site; ez->te = tn-1;
		}
	}

	if((ez->te-ez->ts+1) != tn) {//diff
		ez->path.n /= tn; ez->path.n *= (ez->te+1-ez->ts);//diff
	}//diff
	gen_trace(ez, thre, 1);//diff
    return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %r9, %rbx
movl %ecx, %r15d
movq %rdx, 0x38(%rsp)
movq $0x0, 0xa8(%r9)
movl $0x1, 0x30(%r9)
movl 0x2c(%r9), %ecx
cmpl %r8d, %ecx
jle 0x8c2ce
movl %r8d, 0x28(%rbx)
movl $0x7fffffff, 0x2c(%rbx) # imm = 0x7FFFFFFF
movl %esi, 0x18(%rbx)
movl %r15d, 0x24(%rbx)
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
movq %rax, 0x1c(%rbx)
pxor %xmm0, %xmm0
movdqu %xmm0, (%rbx)
movq %rax, 0x10(%rbx)
leal (%r8,%r15), %eax
cmpl %esi, %eax
movl %ecx, 0x14(%rsp)
jge 0x8c2ef
movl %eax, %esi
jmp 0x8c2fa
testl %ecx, %ecx
je 0x8c992
movl %ecx, 0x14(%rsp)
movl 0x14(%rbx), %esi
movl 0x20(%rbx), %r15d
subl 0x10(%rbx), %esi
incl %esi
subl 0x1c(%rbx), %r15d
incl %r15d
jmp 0x8c2fa
leal (%r8,%rsi), %eax
cmpl %r15d, %eax
cmovll %eax, %r15d
leal (%r8,%r8), %eax
movl %eax, 0x10(%rsp)
pxor %xmm0, %xmm0
movdqa %xmm0, 0x50(%rsp)
movdqa %xmm0, 0x40(%rsp)
movq $0x0, 0x60(%rsp)
leal 0x1(%r8), %eax
cmpl %esi, %eax
cmovgel %esi, %eax
movl $0x1, %ebp
movl %r8d, %ecx
shlq %cl, %rbp
testl %eax, %eax
jle 0x8c35b
movl %eax, %eax
xorl %ecx, %ecx
leaq 0x1ad8e2(%rip), %rdx    # 0x239c20
movq %rbp, %r9
movzbl (%rdi,%rcx), %r10d
movzbl (%rdx,%r10), %r10d
orq %r9, 0x40(%rsp,%r10,8)
addq %r9, %r9
incq %rcx
cmpq %rcx, %rax
jne 0x8c341
movq %rdi, 0x80(%rsp)
movl 0x10(%rsp), %eax
movl %eax, %ecx
orb $0x1, %cl
movq $-0x1, %r13
shlq %cl, %r13
movq $0x0, 0x60(%rsp)
movq %rbp, %r14
negq %r14
leal (%r15,%r15,4), %eax
cltq
movq %rax, 0xc0(%rbx)
cmpq %rax, 0xc8(%rbx)
movq %r8, 0x20(%rsp)
movq %rsi, 0x30(%rsp)
jae 0x8c409
decq %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x10, %rcx
orq %rax, %rcx
leaq 0x1(%rcx), %rax
movq %rax, 0xc8(%rbx)
movq 0xd0(%rbx), %rdi
leaq 0x8(,%rcx,8), %rsi
callq 0x2370
movq 0x30(%rsp), %rsi
movq 0x20(%rsp), %r8
movq %rax, 0xd0(%rbx)
leal -0x1(%r15), %edx
leal (%r8,%r8,2), %eax
movl %eax, 0x18(%rsp)
leal -0x1(%rsi), %r12d
decq %rbp
xorq %r14, %r13
movq $0x0, 0xc0(%rbx)
movl $0x1, %eax
movl 0x10(%rsp), %ecx
shlq %cl, %rax
movq %rax, 0x78(%rsp)
cmpl $0x2, %r15d
jl 0x8c804
movq %r15, 0x68(%rsp)
movl %r8d, %eax
subl %esi, %eax
incl %eax
movl %eax, 0x2c(%rsp)
movslq %r8d, %r10
movslq %esi, %rax
movq %rax, 0x88(%rsp)
movslq %r12d, %rax
movl %edx, 0x28(%rsp)
movl %edx, %esi
addq %r10, %rax
movq %rax, 0x70(%rsp)
movl $0x1, %eax
subl %r8d, %eax
leal -0x1(%r8), %edx
movl $0x7fffffff, 0xc(%rsp)  # imm = 0x7FFFFFFF
xorl %r14d, %r14d
movaps 0x1a505e(%rip), %xmm2   # 0x2314f0
movdqa 0x1a5096(%rip), %xmm3   # 0x231530
movdqa 0x1a4e3e(%rip), %xmm4   # 0x2312e0
movl %r8d, %ecx
movl %r12d, 0x1c(%rsp)
movq %rsi, 0x90(%rsp)
cmpl %r12d, %eax
movl %r12d, %edi
cmovgl %eax, %edi
movl %r14d, %esi
subl %r8d, %esi
incl %esi
cmpl %r12d, %esi
cmovlel %r12d, %esi
movq 0x38(%rsp), %r9
movzbl (%r9,%r14), %r9d
leaq 0x1ad745(%rip), %r11    # 0x239c20
movzbl (%r11,%r9), %r9d
movq 0x40(%rsp,%r9,8), %r9
orq %rbp, %r9
movq %r9, %r15
andq %r13, %r15
addq %r13, %r15
xorq %r13, %r15
orq %r9, %r15
testb $0x1, %r15b
jne 0x8c509
cmpl 0x18(%rsp), %ecx
jge 0x8c980
incl %ecx
movq %r15, %r9
andq %r13, %r9
orq %r15, %r13
notq %r13
movq %rbp, %r12
orq %r13, %r12
movq %r15, %r13
shrq %r13
movq %r12, %rbp
andq %r13, %rbp
orq %r12, %r13
notq %r13
orq %r9, %r13
cmpl %r8d, 0x14(%rsp)
jle 0x8c70b
movl 0x2c(%rsp), %r11d
addl %r14d, %r11d
js 0x8c70b
cmpl $0x7fffffff, 0xc(%rsp)  # imm = 0x7FFFFFFF
jne 0x8c6c6
movl %ecx, %r8d
cmpq 0x70(%rsp), %r14
jge 0x8c6eb
addl %edx, %edi
addq $0x4, %rdi
andq $-0x4, %rdi
movl %r14d, %r11d
notl %r11d
addl 0x20(%rsp), %r11d
addl %r11d, %esi
movd %ecx, %xmm5
movd %esi, %xmm6
pshufd $0x44, %xmm6, %xmm7     # xmm7 = xmm6[0,1,0,1]
movq %r13, %xmm6
pshufd $0x44, %xmm6, %xmm1     # xmm1 = xmm6[0,1,0,1]
movq %rbp, %xmm6
pshufd $0x44, %xmm6, %xmm11    # xmm11 = xmm6[0,1,0,1]
movdqa 0x1a4d28(%rip), %xmm12  # 0x2312d0
movdqa 0x1a4d0f(%rip), %xmm13  # 0x2312c0
movdqa %xmm5, %xmm6
movdqa %xmm13, %xmm9
movdqa %xmm12, %xmm8
movdqa %xmm1, %xmm14
psrlq %xmm12, %xmm14
pshufd $0xee, %xmm12, %xmm15   # xmm15 = xmm12[2,3,2,3]
movdqa %xmm1, %xmm5
psrlq %xmm15, %xmm5
movsd %xmm14, %xmm5           # xmm5 = xmm14[0],xmm5[1]
movdqa %xmm1, %xmm14
psrlq %xmm13, %xmm14
pshufd $0xee, %xmm13, %xmm0    # xmm0 = xmm13[2,3,2,3]
movdqa %xmm1, %xmm10
psrlq %xmm0, %xmm10
movsd %xmm14, %xmm10          # xmm10 = xmm14[0],xmm10[1]
movdqa %xmm11, %xmm14
psrlq %xmm12, %xmm14
shufps $0x88, %xmm10, %xmm5    # xmm5 = xmm5[0,2],xmm10[0,2]
movdqa %xmm11, %xmm10
psrlq %xmm15, %xmm10
andps %xmm2, %xmm5
movdqa %xmm11, %xmm15
psrlq %xmm0, %xmm15
paddd %xmm6, %xmm5
movdqa %xmm11, %xmm0
psrlq %xmm13, %xmm0
movsd %xmm14, %xmm10          # xmm10 = xmm14[0],xmm10[1]
movsd %xmm0, %xmm15           # xmm15 = xmm0[0],xmm15[1]
shufps $0x88, %xmm15, %xmm10   # xmm10 = xmm10[0,2],xmm15[0,2]
andps %xmm2, %xmm10
psubd %xmm10, %xmm5
paddq %xmm3, %xmm12
paddq %xmm3, %xmm13
addq $-0x4, %rdi
jne 0x8c5b1
pxor %xmm4, %xmm7
pxor %xmm4, %xmm8
movdqa %xmm8, %xmm0
pcmpgtd %xmm7, %xmm0
pxor %xmm4, %xmm9
movdqa %xmm9, %xmm1
pcmpgtd %xmm7, %xmm1
movdqa %xmm0, %xmm10
shufps $0x88, %xmm1, %xmm10    # xmm10 = xmm10[0,2],xmm1[0,2]
pcmpeqd %xmm7, %xmm8
pcmpeqd %xmm7, %xmm9
shufps $0xdd, %xmm9, %xmm8     # xmm8 = xmm8[1,3],xmm9[1,3]
andps %xmm10, %xmm8
shufps $0xdd, %xmm1, %xmm0     # xmm0 = xmm0[1,3],xmm1[1,3]
orps %xmm8, %xmm0
pand %xmm0, %xmm6
pandn %xmm5, %xmm0
por %xmm6, %xmm0
pshufd $0xee, %xmm0, %xmm1     # xmm1 = xmm0[2,3,2,3]
paddd %xmm0, %xmm1
pshufd $0x55, %xmm1, %xmm0     # xmm0 = xmm1[1,1,1,1]
paddd %xmm1, %xmm0
movd %xmm0, %r8d
jmp 0x8c6eb
movl 0x10(%rsp), %esi
subl %r11d, %esi
js 0x8c6e6
btq %rsi, %r9
movl 0xc(%rsp), %r8d
sbbl $0x0, %r8d
btq %rsi, %r12
adcl $0x0, %r8d
jmp 0x8c6eb
movl 0xc(%rsp), %r8d
cmpl 0x28(%rbx), %r8d
movl %r8d, 0xc(%rsp)
jg 0x8c70b
cmpl 0x2c(%rbx), %r8d
jge 0x8c70b
movl %r8d, 0x2c(%rbx)
movl 0x1c(%rsp), %esi
movl %esi, 0x14(%rbx)
movl %r14d, 0x20(%rbx)
movdqa 0x40(%rsp), %xmm0
movdqa 0x50(%rsp), %xmm1
psrlq $0x1, %xmm0
movdqa %xmm0, 0x40(%rsp)
psrlq $0x1, %xmm1
movdqa %xmm1, 0x50(%rsp)
incq %r10
cmpq 0x88(%rsp), %r10
jge 0x8c762
movq 0x80(%rsp), %rsi
movzbl (%rsi,%r10), %esi
leaq 0x1ad4d2(%rip), %rdi    # 0x239c20
movzbl (%rdi,%rsi), %esi
cmpq $0x3, %rsi
ja 0x8c762
movq 0x78(%rsp), %rdi
orq %rdi, 0x40(%rsp,%rsi,8)
incq %r14
movq 0xc0(%rbx), %rsi
movq 0xd0(%rbx), %rdi
leaq 0x1(%rsi), %r11
movq %r11, 0xc0(%rbx)
movq %r15, (%rdi,%rsi,8)
movq 0xc0(%rbx), %rsi
leaq 0x1(%rsi), %r11
movq %r11, 0xc0(%rbx)
movq %r13, (%rdi,%rsi,8)
movq 0xc0(%rbx), %rsi
leaq 0x1(%rsi), %r11
movq %r11, 0xc0(%rbx)
movq %rbp, (%rdi,%rsi,8)
movq 0xc0(%rbx), %rsi
leaq 0x1(%rsi), %r11
movq %r11, 0xc0(%rbx)
movq %r12, (%rdi,%rsi,8)
movq 0xc0(%rbx), %rsi
leaq 0x1(%rsi), %r11
movq %r11, 0xc0(%rbx)
movq %r9, (%rdi,%rsi,8)
incl %eax
decl %edx
movq 0x90(%rsp), %rsi
cmpq %rsi, %r14
movq 0x20(%rsp), %r8
movl 0x1c(%rsp), %r12d
jne 0x8c4b2
movq 0x68(%rsp), %r15
movl 0x28(%rsp), %edx
jmp 0x8c809
xorl %esi, %esi
movl %r8d, %ecx
movq 0x38(%rsp), %rax
movzbl (%rax,%rsi), %eax
leaq 0x1ad407(%rip), %rsi    # 0x239c20
movzbl (%rsi,%rax), %eax
movq 0x40(%rsp,%rax,8), %rax
orq %rbp, %rax
movq %rax, %rdi
andq %r13, %rdi
addq %r13, %rdi
xorq %r13, %rdi
orq %rax, %rdi
testb $0x1, %dil
jne 0x8c846
cmpl 0x18(%rsp), %ecx
jge 0x8c980
incl %ecx
movq %rdi, %r8
andq %r13, %r8
orq %rdi, %r13
notq %r13
orq %r13, %rbp
movq %rdi, %rax
shrq %rax
movq %rbp, %r14
andq %rax, %r14
orq %rbp, %rax
notq %rax
orq %r8, %rax
movq 0xc0(%rbx), %r9
movq 0xd0(%rbx), %r10
leaq 0x1(%r9), %r11
movq %r11, 0xc0(%rbx)
movq %rdi, (%r10,%r9,8)
movq 0xc0(%rbx), %rdi
leaq 0x1(%rdi), %r9
movq %r9, 0xc0(%rbx)
movq %rax, (%r10,%rdi,8)
movq 0xc0(%rbx), %rdi
leaq 0x1(%rdi), %r9
movq %r9, 0xc0(%rbx)
movq %r14, (%r10,%rdi,8)
movq 0xc0(%rbx), %rdi
leaq 0x1(%rdi), %r9
movq %r9, 0xc0(%rbx)
movq %rbp, (%r10,%rdi,8)
movq 0xc0(%rbx), %rdi
leaq 0x1(%rdi), %r9
movq %r9, 0xc0(%rbx)
movq %r8, (%r10,%rdi,8)
movq 0x20(%rsp), %rsi
cmpl %esi, 0x14(%rsp)
jle 0x8c949
movl %edx, %r9d
movl %edx, %edi
subl %esi, %edi
cmpl %r12d, %edi
jge 0x8c936
movl %r15d, %edi
subl %esi, %edi
movq 0x30(%rsp), %rdx
movl %eax, %r8d
andl $0x1, %r8d
addl %r8d, %ecx
movl %r14d, %r8d
andl $0x1, %r8d
subl %r8d, %ecx
cmpl %esi, %ecx
jg 0x8c927
cmpl 0x2c(%rbx), %ecx
jge 0x8c927
movl %ecx, 0x2c(%rbx)
movl %edi, 0x14(%rbx)
movl %r9d, 0x20(%rbx)
shrq %rax
shrq %r14
incl %edi
cmpl %edi, %edx
jne 0x8c900
movl %r12d, %edi
cmpl %esi, %ecx
jg 0x8c949
cmpl 0x2c(%rbx), %ecx
jge 0x8c949
movl %ecx, 0x2c(%rbx)
movl %edi, 0x14(%rbx)
movl %r9d, 0x20(%rbx)
movl 0x20(%rbx), %ecx
subl 0x1c(%rbx), %ecx
incl %ecx
cmpl %r15d, %ecx
je 0x8c973
movslq %r15d, %rdi
movq 0xc0(%rbx), %rax
xorl %edx, %edx
divq %rdi
movslq %ecx, %rcx
imulq %rax, %rcx
movq %rcx, 0xc0(%rbx)
movq %rbx, %rdi
movl $0x1, %edx
callq 0x9cb86
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x20(%rbx), %ebp
subl 0x1c(%rbx), %ebp
incl %ebp
cmpl $0x3fff, %ebp           # imm = 0x3FFF
jb 0x8ca09
movq 0xb8(%rbx), %rax
xorl %edx, %edx
movl $0x2, %r14d
cmpq 0xb0(%rbx), %rdx
jne 0x8c9e5
leaq (%rdx,%rdx), %rsi
testq %rdx, %rdx
cmoveq %r14, %rsi
movq %rsi, 0xb0(%rbx)
addq %rsi, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0xb8(%rbx)
movq 0xa8(%rbx), %rdx
leaq 0x1(%rdx), %rcx
movq %rcx, 0xa8(%rbx)
movw $0x3fff, (%rax,%rdx,2)  # imm = 0x3FFF
addl $0xffffc001, %ebp       # imm = 0xFFFFC001
movq %rcx, %rdx
cmpl $0x3ffe, %ebp           # imm = 0x3FFE
ja 0x8c9b1
jmp 0x8ca0b
xorl %ecx, %ecx
testl %ebp, %ebp
je 0x8c980
cmpq 0xb0(%rbx), %rcx
jne 0x8ca52
leaq (%rcx,%rcx), %rax
testq %rcx, %rcx
movl $0x2, %esi
cmovneq %rax, %rsi
movq %rsi, 0xb0(%rbx)
movq 0xb8(%rbx), %rdi
addq %rsi, %rsi
callq 0x2370
movq %rax, 0xb8(%rbx)
movq 0xa8(%rbx), %rcx
jmp 0x8ca59
movq 0xb8(%rbx), %rax
leaq 0x1(%rcx), %rdx
movq %rdx, 0xa8(%rbx)
movw %bp, (%rax,%rcx,2)
jmp 0x8c980