// File: chhylp123[P]hifiasm/Correct.cpp
// Function: cigar_check_dbg(char*, char*, bit_extz_t*)
inline uint32_t cigar_check_dbg(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, cigar_n::%u\n", c, cl, (uint32_t)ez->cigar.n); 
		if(c == 0) {
			for (k=0;(k<cl)&&(pstr[pi]==tstr[ti]);k++,pi++,ti++);
			if(k!=cl) {
				fprintf(stderr, "ERROR-d-0\n"); 
				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\n"); 
					return 0;
				}
			} else if(c == 2) {///more p
				pi+=cl;
			} else if(c == 3) {
				ti+=cl;
			}
		}
	}
	if(err != ez->err) {
		fprintf(stderr, "ERROR-err, err::%d, ez->err::%d\n", err, ez->err); 
		return 0;
	}
	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x20(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x24(%rbp)
movq -0x20(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpq 0xa8(%rcx), %rax
jae 0xa9840
movq -0x20(%rbp), %rdi
addq $0xa8, %rdi
movl -0x30(%rbp), %esi
leaq -0x3a(%rbp), %rdx
leaq -0x34(%rbp), %rcx
callq 0xa1ee0
movl %eax, -0x30(%rbp)
movzwl -0x3a(%rbp), %eax
cmpl $0x0, %eax
jne 0xa9772
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %ecx
xorl %eax, %eax
cmpl -0x34(%rbp), %ecx
movb %al, -0x3b(%rbp)
jae 0xa9719
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movq -0x18(%rbp), %rcx
movslq -0x28(%rbp), %rdx
movsbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
sete %al
movb %al, -0x3b(%rbp)
movb -0x3b(%rbp), %al
testb $0x1, %al
jne 0xa9722
jmp 0xa9741
jmp 0xa9724
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0xa96ec
movl -0x38(%rbp), %eax
cmpl -0x34(%rbp), %eax
je 0xa976d
movq 0x31a890(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
leaq 0x2dcfc4(%rip), %rsi    # 0x38671e
movb $0x0, %al
callq 0x22a0
movl $0x0, -0x4(%rbp)
jmp 0xa987e
jmp 0xa983b
movl -0x34(%rbp), %eax
addl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movzwl -0x3a(%rbp), %eax
cmpl $0x1, %eax
jne 0xa980f
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %ecx
xorl %eax, %eax
cmpl -0x34(%rbp), %ecx
movb %al, -0x3c(%rbp)
jae 0xa97bc
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movq -0x18(%rbp), %rcx
movslq -0x28(%rbp), %rdx
movsbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
setne %al
movb %al, -0x3c(%rbp)
movb -0x3c(%rbp), %al
testb $0x1, %al
jne 0xa97c5
jmp 0xa97e4
jmp 0xa97c7
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0xa978f
movl -0x38(%rbp), %eax
cmpl -0x34(%rbp), %eax
je 0xa980d
movq 0x31a7ed(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
leaq 0x2dcf2c(%rip), %rsi    # 0x386729
movb $0x0, %al
callq 0x22a0
movl $0x0, -0x4(%rbp)
jmp 0xa987e
jmp 0xa9839
movzwl -0x3a(%rbp), %eax
cmpl $0x2, %eax
jne 0xa9823
movl -0x34(%rbp), %eax
addl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
jmp 0xa9837
movzwl -0x3a(%rbp), %eax
cmpl $0x3, %eax
jne 0xa9835
movl -0x34(%rbp), %eax
addl -0x28(%rbp), %eax
movl %eax, -0x28(%rbp)
jmp 0xa9837
jmp 0xa9839
jmp 0xa983b
jmp 0xa96a6
movl -0x2c(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x2c(%rcx), %eax
je 0xa9877
movq 0x31a78d(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movl -0x2c(%rbp), %edx
movq -0x20(%rbp), %rax
movl 0x2c(%rax), %ecx
leaq 0x2dcecd(%rip), %rsi    # 0x386734
movb $0x0, %al
callq 0x22a0
movl $0x0, -0x4(%rbp)
jmp 0xa987e
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)