// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/ecovlp.cpp
// Function: dbg_rsc(char*, unsigned long, char*, unsigned long, asg16_v*, char*, unsigned int)
void dbg_rsc(char *str0, uint64_t l0, char *str1, uint64_t l1, asg16_v *sc, char *real, uint32_t id)
{
    uint64_t ck, xk, yk, k, wx[2], wy[2]; uint32_t len; uint16_t c, bq, bt; 
    
    ck = xk = yk = 0;
    while (ck < sc->n) {
        wx[0] = xk; wy[0] = yk;
        ck = pop_trace_bp_f(sc, ck, &c, &bq, &bt, &len);
        if(c != 2) xk += len;
        if(c != 3) yk += len;
        wx[1] = xk; wy[1] = yk;
    }
    assert(xk == l0);

    // char cm[4], cc[4]; 
    // cm[0] = 'M'; cm[1] = 'S'; cm[2] = 'I'; cm[3] = 'D';
    // cc[0] = 'A'; cc[1] = 'C'; cc[2] = 'G'; cc[3] = 'T';

    ck = xk = yk = 0;
    while (ck < sc->n) {
        wx[0] = xk; wy[0] = yk;
        ck = pop_trace_bp_f(sc, ck, &c, &bq, &bt, &len);
        if(c != 2) xk += len;
        if(c != 3) yk += len;
        wx[1] = xk; wy[1] = yk;

        if(c == 0) {
            memcpy(str0 + wx[0], str1 + wy[0], (wx[1]-wx[0])*sizeof((*str1)));
        } else if(c == 1 || c == 3) {
            for (k = wx[0]; k < wx[1]; k++) str0[k] = s_H[bq]; 
        }
        // fprintf(stderr, "%u%c(%c)(x::[%lu,%ld))(y::[%lu,%ld))\n", len, cm[c], ((c==1)||(c==2))?(cc[bt]):('*'), wx[0], wx[1], wy[0], wy[1]); // s_H
    }

    if(memcmp(str0, real, l0*sizeof((*str0)))) {
        fprintf(stderr, "-0-[M::%s]\tid::%u\n", __func__, id);
        // for (k = 0; k < l0 && str0[k] == real[k]; k++);
        
        // fprintf(stderr, "-0-[M::%s]\tid::%u\tk::%lu\tl0::%lu\tnc::%c\toc::%c\n", __func__, id, k, l0, str0[k], real[k]);
        // exit(1);
    } else {
        // fprintf(stderr, "-1-[M::%s]\tid::%u\n", __func__, id);
    }

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r9, 0x28(%rsp)
movq %rdx, 0x30(%rsp)
movq %rsi, 0x18(%rsp)
movq %rdi, %r13
xorl %esi, %esi
leaq 0x4(%rsp), %rbx
leaq 0x6(%rsp), %r14
leaq 0xe(%rsp), %r15
leaq 0x8(%rsp), %rbp
xorl %r12d, %r12d
movq %r8, 0x10(%rsp)
movq (%r8), %rax
cmpq %rax, %rsi
jae 0x14bb32
movq %r8, %rdi
movq %rbx, %rdx
movq %r14, %rcx
movq %r15, %r8
movq %rbp, %r9
callq 0xeeaa9
movq 0x10(%rsp), %r8
movl %eax, %esi
cmpw $0x2, 0x4(%rsp)
movl 0x8(%rsp), %eax
movl $0x0, %ecx
cmovneq %rax, %rcx
addq %rcx, %r12
jmp 0x14baf7
cmpq 0x18(%rsp), %r12
jne 0x14bc48
leaq 0x107bec(%rip), %rbp    # 0x253730
xorl %esi, %esi
xorl %ebx, %ebx
movq $0x0, 0x20(%rsp)
cmpq %rax, %rsi
jae 0x14bbfe
movq %r8, %rdi
leaq 0x4(%rsp), %rdx
leaq 0x6(%rsp), %rcx
leaq 0xe(%rsp), %r8
leaq 0x8(%rsp), %r9
callq 0xeeaa9
movl %eax, %r14d
movzwl 0x4(%rsp), %eax
cmpw $0x2, %ax
movl 0x8(%rsp), %edx
movq %rdx, %r15
movl $0x0, %ecx
cmoveq %rcx, %r15
addq %rbx, %r15
cmpw $0x3, %ax
movq %rdx, %r12
cmoveq %rcx, %r12
testw %ax, %ax
je 0x14bbcd
andl $0xfffd, %eax           # imm = 0xFFFD
cmpw $0x1, %ax
movq 0x10(%rsp), %r8
jne 0x14bbeb
movzwl 0x6(%rsp), %eax
cmpq %r15, %rbx
jae 0x14bbeb
movb (%rbp,%rax), %cl
movb %cl, (%r13,%rbx)
incq %rbx
jmp 0x14bbba
addq %r13, %rbx
movq 0x30(%rsp), %rax
movq 0x20(%rsp), %rcx
leaq (%rax,%rcx), %rsi
movq %rbx, %rdi
callq 0x2160
movq 0x10(%rsp), %r8
movl %r14d, %esi
addq %r12, 0x20(%rsp)
movq (%r8), %rax
movq %r15, %rbx
jmp 0x14bb51
movq %r13, %rdi
movq 0x28(%rsp), %rsi
movq 0x18(%rsp), %rdx
callq 0x21a0
testl %eax, %eax
jne 0x14bc23
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1073b6(%rip), %rax    # 0x252fe0
movq (%rax), %rdi
leaq 0xa57e9(%rip), %rsi     # 0x1f141d
leaq 0xa57f5(%rip), %rdx     # 0x1f1430
movl 0x70(%rsp), %ecx
xorl %eax, %eax
callq 0x22b0
jmp 0x14bc14
leaq 0xa5777(%rip), %rdi     # 0x1f13c6
leaq 0xa42a5(%rip), %rsi     # 0x1efefb
leaq 0xa5772(%rip), %rcx     # 0x1f13cf
movl $0x172b, %edx           # imm = 0x172B
callq 0x2110