// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/./Levenshtein_distance.h
// Function: cigar_check(char*, char*, bit_extz_t*)
inline uint32_t cigar_check(char *pstr, char *tstr, bit_extz_t *ez)
{
	int32_t pi = ez->ps, ti = ez->ts, err = 0; uint32_t ci = 0, cl, k; uint16_t c;
	while (ci < ez->cigar.n) {
		ci = pop_trace(&(ez->cigar), ci, &c, &cl);
		// fprintf(stderr, "# %u = %u\n", c, cl); 
		if(c == 0) {
			for (k=0;(k<cl)&&(pstr[pi]==tstr[ti]);k++,pi++,ti++);
			if(k!=cl) {
				fprintf(stderr, "ERROR-d-0, pi::%d, ti::%d\n", pi, ti); 
				return 0;
			}
		} else {
			err += cl;
			if(c == 1) {
				for (k=0;(k<cl)&&(pstr[pi]!=tstr[ti]);k++,pi++,ti++);
				if(k!=cl) {
					fprintf(stderr, "ERROR-d-1, pi::%d, ti::%d\n", pi, ti);  
					return 0;
				}
			} else if(c == 2) {///more p
				pi+=cl;
			} else if(c == 3) {
				ti+=cl;
			}
		}
	}
	if(err != ez->err) {
		fprintf(stderr, "ERROR-err\n"); 
		return 0;
	}
	return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq 0xa8(%rdx), %r8
testq %r8, %r8
movq %rdx, (%rsp)
je 0x98008
movl 0x10(%rdx), %eax
movl 0x1c(%rdx), %ecx
movq 0xb8(%rdx), %r10
xorl %ebx, %ebx
xorl %r11d, %r11d
xorl %edx, %edx
movzwl (%r10,%rbx,2), %r14d
movl %r14d, %ebp
shrl $0xe, %ebp
movl %r14d, %ebx
andl $0x3fff, %ebx           # imm = 0x3FFF
incl %r11d
cmpq %r11, %r8
jbe 0x97f3e
movzwl (%r10,%r11,2), %r15d
movl %r15d, %r12d
shrl $0xe, %r12d
cmpl %ebp, %r12d
jne 0x97f3e
andl $0x3fff, %r15d          # imm = 0x3FFF
addl %r15d, %ebx
jmp 0x97f19
movl %ebx, %ebx
movzwl %r14w, %r14d
cmpl $0x3fff, %r14d          # imm = 0x3FFF
ja 0x97f85
testq %rbx, %rbx
je 0x97f9b
movslq %ecx, %r15
movslq %eax, %r12
movl %ebx, %ebp
addl %eax, %ebp
leal (%rbx,%rcx), %r13d
addq %rdi, %r12
addq %rsi, %r15
xorl %r14d, %r14d
movb (%r12,%r14), %r9b
cmpb (%r15,%r14), %r9b
jne 0x97fdd
incq %r14
cmpl %r14d, %ebx
jne 0x97f69
movl %ebp, %eax
movl %r13d, %ecx
movl %ebx, %r14d
jmp 0x97fe3
addl %ebx, %edx
cmpw $0x3, %bp
je 0x97fa0
movzwl %bp, %r9d
cmpl $0x2, %r9d
jne 0x97fa6
addl %ebx, %eax
jmp 0x97ffa
xorl %r14d, %r14d
jmp 0x97fe3
addl %ecx, %ebx
movl %ebx, %ecx
jmp 0x97ffa
testq %rbx, %rbx
je 0x97fea
movslq %ecx, %r15
movslq %eax, %r12
leal (%rbx,%rax), %ebp
leal (%rbx,%rcx), %r13d
addq %rdi, %r12
addq %rsi, %r15
xorl %r14d, %r14d
movb (%r12,%r14), %r9b
cmpb (%r15,%r14), %r9b
je 0x97fef
incq %r14
cmpl %r14d, %ebx
jne 0x97fc1
movl %ebp, %eax
movl %r13d, %ecx
movl %ebx, %r14d
jmp 0x97ff5
addl %r14d, %ecx
addl %r14d, %eax
cmpl %ebx, %r14d
je 0x97ffa
jmp 0x98032
xorl %r14d, %r14d
jmp 0x97ff5
addl %r14d, %ecx
addl %r14d, %eax
cmpl %ebx, %r14d
jne 0x98045
movl %r11d, %ebx
cmpq %rbx, %r8
ja 0x97f05
jmp 0x9800a
xorl %edx, %edx
movl $0x1, %ebx
movq (%rsp), %rax
cmpl 0x2c(%rax), %edx
jne 0x98029
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x5ea5
xorl %ebx, %ebx
jmp 0x98018
movq 0x1f1fa7(%rip), %rdx    # 0x289fe0
movq (%rdx), %rdi
leaq 0x191a3a(%rip), %rsi    # 0x229a7d
jmp 0x98056
movq 0x1f1f94(%rip), %rdx    # 0x289fe0
movq (%rdx), %rdi
leaq 0x191a42(%rip), %rsi    # 0x229a98
xorl %ebx, %ebx
movl %eax, %edx
xorl %eax, %eax
callq 0x22b0
jmp 0x98018