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

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

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

	i = 0; Peq[4] = 0; mm = ((Word)1 << (thre<<1));///for the incoming char/last char**
	while (i < tn0) {
		ed_core_64(Peq, VP, VN, X, D0, HN, HP, (uint8_t)tstr[i]);
		if (!(D0&(1ULL))) {
            ++err; if (err>cut) return;
        }

		Peq[0] >>= 1; Peq[1] >>= 1; Peq[2] >>= 1; Peq[3] >>= 1;
		++i; ++i_bd; c = 4; 
		if(i_bd < pn) c = seq_nt4_table[(uint8_t)pstr[i_bd]];
		if(c < 4) Peq[c] |= mm; 

		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;
	}
	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 - abs_diag;/**up bound**/
    /**in most cases, ai = (thre<<1)**/
    int32_t ai = pn - tn + abs_diag, uge = INT32_MAX; i = 0;
	if(ez->err > thre) {//diff
		for (i = 0; site < 0 && i < ai; i++, site++) {
			err += ((VP >> i)&(1ULL)); err -= ((VN >> i)&(1ULL));
		}
		if ((err <= thre) && (err <= ez->err)) {
			ez->err = err; ez->pe = site;
		}
		site -= i;
		while (i < ai) {
			err += ((VP >> i)&(1ULL)); err -= ((VN >> i)&(1ULL)); ++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;
	}
    ///should update ez->path.n for extension
    gen_trace(ez, abs_diag, 1);//diff
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %r9d, 0x4(%rsp)
movq %rdx, 0x38(%rsp)
movq 0xb0(%rsp), %rbx
andq $0x0, 0xa8(%rbx)
movq %rdi, %rbp
movl $0x1, 0x30(%rbx)
movl 0x2c(%rbx), %eax
cmpl %r8d, %eax
jle 0x592de
movl %r8d, 0x28(%rbx)
movl $0x7fffffff, 0x2c(%rbx) # imm = 0x7FFFFFFF
movl %esi, 0x18(%rbx)
movl %ecx, 0x24(%rbx)
pxor %xmm0, %xmm0
movdqu %xmm0, (%rbx)
orq $-0x1, 0x10(%rbx)
andl $0x0, 0x1c(%rbx)
leal -0x1(%rcx), %eax
movq %rax, 0x8(%rsp)
movl %eax, 0x20(%rbx)
jmp 0x592ee
testl %eax, %eax
je 0x596b1
leal -0x1(%rcx), %eax
movq %rax, 0x8(%rsp)
pxor %xmm0, %xmm0
movdqa %xmm0, 0x50(%rsp)
movdqa %xmm0, 0x40(%rsp)
andq $0x0, 0x60(%rsp)
movq %r8, 0x10(%rsp)
leal (%r8,%r8,2), %edx
leal (%rdx,%rcx), %eax
cmpl %esi, %eax
setl %al
movq %rsi, 0x18(%rsp)
movq %rdx, 0x30(%rsp)
addl %esi, %edx
movq %rcx, 0x20(%rsp)
cmpl %ecx, %edx
setl %cl
orb %al, %cl
jne 0x5974d
movq 0x10(%rsp), %rdx
leal (%rdx,%rdx), %r14d
movl %r14d, %eax
orl $0x1, %eax
movl 0x4(%rsp), %ecx
subl %ecx, %eax
movq 0x18(%rsp), %rsi
cmpl %esi, %eax
cmovgel %esi, %eax
pushq $0x1
popq %r15
movq %r15, 0x28(%rsp)
shlq %cl, %r15
movl %edx, %ecx
movq %rcx, 0x68(%rsp)
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
leaq 0x19278d(%rip), %r12    # 0x1ebb00
movq %r15, %rdx
cmpq %rcx, %rax
je 0x59392
movzbl (%rbp,%rcx), %esi
movzbl (%r12,%rsi), %esi
orq %rdx, 0x40(%rsp,%rsi,8)
addq %rdx, %rdx
incq %rcx
jmp 0x59376
movl %r14d, %r13d
subl 0x4(%rsp), %r13d
movq 0x20(%rsp), %rax
leal (%rax,%rax,4), %eax
cltq
movq %rax, 0xc0(%rbx)
cmpq %rax, 0xc8(%rbx)
jae 0x5940e
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 %rax, 0xd0(%rbx)
andq $0x0, 0xc0(%rbx)
andq $0x0, 0x60(%rsp)
movl %r14d, %ecx
shlq %cl, 0x28(%rsp)
decq %r15
movslq %r13d, %rdx
movslq 0x18(%rsp), %rsi
xorl %edi, %edi
movq 0x8(%rsp), %rax
testl %eax, %eax
movl $0x0, %r8d
cmovgl %eax, %r8d
leaq (%rdx,%rbp), %rax
incq %rax
movq %rax, 0x70(%rsp)
incq %rdx
movl 0x4(%rsp), %eax
xorl %ecx, %ecx
cmpq %rdi, %r8
je 0x5958b
movq 0x38(%rsp), %r9
movzbl (%r9,%rdi), %r10d
movzbl (%r12,%r10), %r10d
movq 0x40(%rsp,%r10,8), %r11
orq %r15, %r11
movq %r11, %r10
andq %rcx, %r10
addq %rcx, %r10
xorq %rcx, %r10
orq %r11, %r10
testb $0x1, %r10b
jne 0x59498
cmpl 0x30(%rsp), %eax
jge 0x5974d
incl %eax
movdqa 0x40(%rsp), %xmm0
movdqa 0x50(%rsp), %xmm1
psrlq $0x1, %xmm0
movdqa %xmm0, 0x40(%rsp)
psrlq $0x1, %xmm1
movdqa %xmm1, 0x50(%rsp)
leaq (%rdx,%rdi), %r11
cmpq %rsi, %r11
jge 0x594e2
movq 0x70(%rsp), %r9
movzbl (%r9,%rdi), %r11d
movzbl (%r12,%r11), %r11d
cmpq $0x3, %r11
ja 0x594e2
movq 0x28(%rsp), %r9
orq %r9, 0x40(%rsp,%r11,8)
movq %r10, %r11
andq %rcx, %r11
orq %r10, %rcx
notq %rcx
orq %rcx, %r15
movq %r10, %rcx
shrq %rcx
movq %r15, %rbp
andq %rcx, %rbp
orq %r15, %rcx
notq %rcx
orq %r11, %rcx
movq 0xc0(%rbx), %r14
movq 0xd0(%rbx), %r13
leaq 0x1(%r14), %r9
movq %r9, 0xc0(%rbx)
movq %r10, (%r13,%r14,8)
movq 0xc0(%rbx), %r9
leaq 0x1(%r9), %r10
movq %r10, 0xc0(%rbx)
movq %rcx, (%r13,%r9,8)
movq 0xc0(%rbx), %r9
leaq 0x1(%r9), %r10
movq %r10, 0xc0(%rbx)
movq %rbp, (%r13,%r9,8)
movq 0xc0(%rbx), %r9
leaq 0x1(%r9), %r10
movq %r10, 0xc0(%rbx)
movq %r15, (%r13,%r9,8)
movq 0xc0(%rbx), %r9
leaq 0x1(%r9), %r10
movq %r10, 0xc0(%rbx)
movq %r11, (%r13,%r9,8)
incq %rdi
movq %rbp, %r15
jmp 0x59457
movq 0x38(%rsp), %rdx
movzbl (%rdx,%r8), %edx
movzbl (%r12,%rdx), %edx
movq 0x40(%rsp,%rdx,8), %rdx
orq %r15, %rdx
movq %rdx, %rsi
andq %rcx, %rsi
addq %rcx, %rsi
xorq %rcx, %rsi
orq %rdx, %rsi
testb $0x1, %sil
jne 0x595c3
cmpl 0x30(%rsp), %eax
jge 0x5974d
incl %eax
movq 0x10(%rsp), %r14
movq %rsi, %rdi
andq %rcx, %rdi
orq %rsi, %rcx
notq %rcx
orq %rcx, %r15
movq %rsi, %rcx
shrq %rcx
movq %r15, %rdx
andq %rcx, %rdx
orq %r15, %rcx
notq %rcx
orq %rdi, %rcx
movq 0xc0(%rbx), %r8
movq 0xd0(%rbx), %r9
leaq 0x1(%r8), %r10
movq %r10, 0xc0(%rbx)
movq %rsi, (%r9,%r8,8)
movq 0xc0(%rbx), %rsi
leaq 0x1(%rsi), %r8
movq %r8, 0xc0(%rbx)
movq %rcx, (%r9,%rsi,8)
movq 0xc0(%rbx), %rsi
leaq 0x1(%rsi), %r8
movq %r8, 0xc0(%rbx)
movq %rdx, (%r9,%rsi,8)
movq 0xc0(%rbx), %rsi
leaq 0x1(%rsi), %r8
movq %r8, 0xc0(%rbx)
movq %r15, (%r9,%rsi,8)
movq 0xc0(%rbx), %rsi
leaq 0x1(%rsi), %r8
movq %r8, 0xc0(%rbx)
movq %rdi, (%r9,%rsi,8)
movl 0x2c(%rbx), %esi
cmpl %r14d, %esi
movq 0x68(%rsp), %r12
jle 0x5973e
movq 0x18(%rsp), %r8
subl 0x20(%rsp), %r8d
movl 0x4(%rsp), %edi
addl %edi, %r8d
movq 0x8(%rsp), %r15
subl %edi, %r15d
movslq %r8d, %rdi
xorl %r8d, %r8d
movl %r15d, %r9d
addl %r8d, %r9d
jns 0x596d5
cmpq %rdi, %r8
jge 0x596d5
btq %r8, %rcx
adcl $0x0, %eax
btq %r8, %rdx
sbbl $0x0, %eax
incq %r8
jmp 0x59691
leaq 0xa8(%rbx), %rdi
movl 0x20(%rbx), %edx
subl 0x1c(%rbx), %edx
incl %edx
xorl %esi, %esi
callq 0x62885
movl 0x14(%rbx), %eax
subl 0x20(%rbx), %eax
addl 0x1c(%rbx), %eax
movl %eax, 0x10(%rbx)
jmp 0x5974d
leaq (%r15,%r8), %r9
cmpl %r14d, %eax
jg 0x596e7
movl %eax, 0x2c(%rbx)
movl %r9d, 0x14(%rbx)
movl %eax, %esi
subl %r8d, %r9d
movq %r12, %r11
decq %r11
incl %r15d
movl $0x7fffffff, %r10d      # imm = 0x7FFFFFFF
cmpq %rdi, %r8
jge 0x5972d
btq %r8, %rcx
adcl $0x0, %eax
btq %r8, %rdx
sbbl $0x0, %eax
cmpl %r12d, %eax
jg 0x59721
cmpl %esi, %eax
jg 0x59721
movl %eax, 0x2c(%rbx)
leal (%r15,%r8), %esi
movl %esi, 0x14(%rbx)
movl %eax, %esi
cmpq %r8, %r11
cmovel %eax, %r10d
incq %r8
jmp 0x596f9
cmpl %r14d, %r10d
jg 0x5973e
cmpl %esi, %r10d
jne 0x5973e
addl %r14d, %r9d
movl %r9d, 0x14(%rbx)
pushq $0x1
popq %rdx
movq %rbx, %rdi
movl 0x4(%rsp), %esi
callq 0x65f7b
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq