// File: /workspace/github_cpp_makefile_star2_O3/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, 0xc(%rsp)
movq %rdx, 0x38(%rsp)
movq %rdi, %rbp
movq 0xb0(%rsp), %rbx
movq $0x0, 0xa8(%rbx)
movl $0x1, 0x30(%rbx)
movl 0x2c(%rbx), %eax
cmpl %r8d, %eax
jle 0x8d39e
movl %r8d, 0x28(%rbx)
movl $0x7fffffff, 0x2c(%rbx) # imm = 0x7FFFFFFF
movl %esi, 0x18(%rbx)
movl %ecx, 0x24(%rbx)
pxor %xmm0, %xmm0
movdqu %xmm0, (%rbx)
movq $-0x1, 0x10(%rbx)
movl $0x0, 0x1c(%rbx)
leal -0x1(%rcx), %eax
movq %rax, 0x10(%rsp)
movl %eax, 0x20(%rbx)
jmp 0x8d3ae
testl %eax, %eax
je 0x8d6a6
leal -0x1(%rcx), %eax
movq %rax, 0x10(%rsp)
pxor %xmm0, %xmm0
movdqa %xmm0, 0x50(%rsp)
movdqa %xmm0, 0x40(%rsp)
movq $0x0, 0x60(%rsp)
movq %r8, 0x28(%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 0x8d91d
movq 0x28(%rsp), %rax
leal (%rax,%rax), %r14d
movl %r14d, %eax
orl $0x1, %eax
movl 0xc(%rsp), %ecx
subl %ecx, %eax
movq 0x18(%rsp), %r11
cmpl %r11d, %eax
cmovgel %r11d, %eax
movl $0x1, %r12d
shlq %cl, %r12
testl %eax, %eax
jle 0x8d44b
movl %eax, %eax
xorl %ecx, %ecx
leaq 0x1ac7f1(%rip), %rdx    # 0x239c20
movq %r12, %rsi
movzbl (%rbp,%rcx), %edi
movzbl (%rdx,%rdi), %edi
orq %rsi, 0x40(%rsp,%rdi,8)
addq %rsi, %rsi
incq %rcx
cmpq %rcx, %rax
jne 0x8d432
movq 0x20(%rsp), %rsi
leal (%rsi,%rsi,4), %eax
cltq
movq %rax, 0xc0(%rbx)
cmpq %rax, 0xc8(%rbx)
jae 0x8d4c9
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 0x20(%rsp), %rsi
movq 0x18(%rsp), %r11
movq %rax, 0xd0(%rbx)
decq %r12
xorl %edx, %edx
movq %rdx, 0xc0(%rbx)
movq %rdx, 0x60(%rsp)
movl $0x1, %eax
movl %r14d, %ecx
shlq %cl, %rax
movq %rax, 0x68(%rsp)
cmpl $0x2, %esi
jl 0x8d650
movl 0xc(%rsp), %eax
subl %eax, %r14d
movslq %r14d, %rdi
movslq %r11d, %r8
movl 0x10(%rsp), %edx
leaq (%rdi,%rbp), %rcx
incq %rcx
movq %rcx, 0x70(%rsp)
incq %rdi
xorl %r10d, %r10d
leaq 0x1ac703(%rip), %r11    # 0x239c20
xorl %ecx, %ecx
movq 0x38(%rsp), %rsi
movzbl (%rsi,%r10), %r14d
movzbl (%r11,%r14), %r14d
movq 0x40(%rsp,%r14,8), %rbp
orq %r12, %rbp
movq %rbp, %r14
andq %rcx, %r14
addq %rcx, %r14
xorq %rcx, %r14
orq %rbp, %r14
testb $0x1, %r14b
jne 0x8d557
cmpl 0x30(%rsp), %eax
jge 0x8d91d
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 (%rdi,%r10), %rbp
cmpq %r8, %rbp
jge 0x8d5a1
movq 0x70(%rsp), %rsi
movzbl (%rsi,%r10), %ebp
movzbl (%r11,%rbp), %ebp
cmpq $0x3, %rbp
ja 0x8d5a1
movq 0x68(%rsp), %rsi
orq %rsi, 0x40(%rsp,%rbp,8)
movq %r14, %rbp
andq %rcx, %rbp
orq %r14, %rcx
notq %rcx
movq %r12, %r15
orq %rcx, %r15
movq %r14, %rcx
shrq %rcx
movq %r15, %r12
andq %rcx, %r12
orq %r15, %rcx
notq %rcx
orq %rbp, %rcx
incq %r10
movq 0xc0(%rbx), %rsi
movq 0xd0(%rbx), %r9
leaq 0x1(%rsi), %r13
movq %r13, 0xc0(%rbx)
movq %r14, (%r9,%rsi,8)
movq 0xc0(%rbx), %rsi
leaq 0x1(%rsi), %r14
movq %r14, 0xc0(%rbx)
movq %rcx, (%r9,%rsi,8)
movq 0xc0(%rbx), %rsi
leaq 0x1(%rsi), %r14
movq %r14, 0xc0(%rbx)
movq %r12, (%r9,%rsi,8)
movq 0xc0(%rbx), %rsi
leaq 0x1(%rsi), %r14
movq %r14, 0xc0(%rbx)
movq %r15, (%r9,%rsi,8)
movq 0xc0(%rbx), %rsi
leaq 0x1(%rsi), %r14
movq %r14, 0xc0(%rbx)
movq %rbp, (%r9,%rsi,8)
cmpq %r10, %rdx
jne 0x8d51f
movq 0x18(%rsp), %r11
jmp 0x8d656
movl 0xc(%rsp), %eax
xorl %ecx, %ecx
movq 0x38(%rsp), %rsi
movzbl (%rsi,%rdx), %edx
leaq 0x1ac5ba(%rip), %rsi    # 0x239c20
movzbl (%rsi,%rdx), %edx
movq 0x40(%rsp,%rdx,8), %rdx
orq %r12, %rdx
movq %rdx, %rsi
andq %rcx, %rsi
addq %rcx, %rsi
xorq %rcx, %rsi
orq %rdx, %rsi
testb $0x1, %sil
jne 0x8d724
cmpl 0x30(%rsp), %eax
jge 0x8d91d
incl %eax
movq 0x10(%rsp), %r15
movq 0x18(%rsp), %r11
jmp 0x8d729
movl 0x20(%rbx), %ebp
subl 0x1c(%rbx), %ebp
incl %ebp
cmpl $0x3fff, %ebp           # imm = 0x3FFF
jb 0x8d88c
movq 0xb8(%rbx), %rax
xorl %edx, %edx
movl $0x2, %r14d
cmpq 0xb0(%rbx), %rdx
jne 0x8d6fd
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 0x8d6c9
jmp 0x8d88e
movq 0x10(%rsp), %r15
movq %rsi, %rdi
andq %rcx, %rdi
orq %rsi, %rcx
notq %rcx
orq %rcx, %r12
movq %rsi, %rcx
shrq %rcx
movq %r12, %rdx
andq %rcx, %rdx
orq %r12, %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 %r12, (%r9,%rsi,8)
movq 0xc0(%rbx), %rsi
leaq 0x1(%rsi), %r8
movq %r8, 0xc0(%rbx)
movq %rdi, (%r9,%rsi,8)
movl 0x2c(%rbx), %esi
movq 0x28(%rsp), %r12
cmpl %r12d, %esi
jle 0x8d8e8
subl 0x20(%rsp), %r11d
movl 0xc(%rsp), %edi
addl %edi, %r11d
subl %edi, %r15d
sets %dil
testl %r11d, %r11d
setg %r8b
andb %dil, %r8b
xorl %edi, %edi
cmpb $0x1, %r8b
jne 0x8d823
movl %r11d, %r8d
movl %r15d, %r9d
xorl %edi, %edi
leal (%r9,%rdi), %r10d
btq %rdi, %rcx
adcl $0x0, %eax
btq %rdi, %rdx
sbbl $0x0, %eax
incq %rdi
cmpl $-0x1, %r10d
je 0x8d820
cmpq %r8, %rdi
jb 0x8d800
addl %edi, %r15d
cmpl %r12d, %eax
jg 0x8d831
movl %eax, 0x2c(%rbx)
movl %r15d, 0x14(%rbx)
movl %eax, %esi
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
cmpl %r11d, %edi
jge 0x8d8d1
movl %r12d, %r9d
movl %edi, %r14d
movslq %r11d, %r10
movq %r9, %r11
decq %r11
movq %r15, %r13
leal 0x1(%r15), %ebp
btq %r14, %rcx
adcl $0x0, %eax
btq %r14, %rdx
sbbl $0x0, %eax
cmpl %r9d, %eax
jg 0x8d875
cmpl %esi, %eax
jg 0x8d875
movl %eax, 0x2c(%rbx)
movl %ebp, 0x14(%rbx)
movl %eax, %esi
cmpq %r14, %r11
cmovel %eax, %r8d
leaq 0x1(%r14), %r15
incl %ebp
movq %r15, %r14
cmpq %r10, %r15
jl 0x8d856
jmp 0x8d8d4
xorl %ecx, %ecx
testl %ebp, %ebp
je 0x8d911
cmpq 0xb0(%rbx), %rcx
jne 0x8d8fb
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 0x8d902
movq %r15, %r13
cmpl %r12d, %r8d
jg 0x8d8e8
cmpl %esi, %r8d
jne 0x8d8e8
subl %edi, %r13d
addl %r12d, %r13d
movl %r13d, 0x14(%rbx)
movq %rbx, %rdi
movl 0xc(%rsp), %esi
movl $0x1, %edx
callq 0x9cb86
jmp 0x8d91d
movq 0xb8(%rbx), %rax
leaq 0x1(%rcx), %rdx
movq %rdx, 0xa8(%rbx)
movw %bp, (%rax,%rcx,2)
movl 0x14(%rbx), %eax
subl 0x20(%rbx), %eax
addl 0x1c(%rbx), %eax
movl %eax, 0x10(%rbx)
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq