// File: 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
movq %rsp, %rbp
subq $0x80, %rsp
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq -0x28(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x2669da
movq -0x40(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x28(%rbp), %rdi
movq -0x38(%rbp), %rax
movl %eax, %esi
leaq -0x76(%rbp), %rdx
leaq -0x78(%rbp), %rcx
leaq -0x7a(%rbp), %r8
leaq -0x74(%rbp), %r9
callq 0x1b53f0
movl %eax, %eax
movq %rax, -0x38(%rbp)
movzwl -0x76(%rbp), %eax
cmpl $0x2, %eax
je 0x2669b4
movl -0x74(%rbp), %eax
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
movzwl -0x76(%rbp), %eax
cmpl $0x3, %eax
je 0x2669c8
movl -0x74(%rbp), %eax
addq -0x48(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x68(%rbp)
jmp 0x26695e
movq -0x40(%rbp), %rax
cmpq -0x10(%rbp), %rax
jne 0x2669e6
jmp 0x266a05
leaq 0x1296f8(%rip), %rdi    # 0x3900e5
leaq 0x128217(%rip), %rsi    # 0x38ec0b
movl $0x172b, %edx           # imm = 0x172B
leaq 0x1296ee(%rip), %rcx    # 0x3900ee
callq 0x2130
movq $0x0, -0x48(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq -0x28(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x266b1d
movq -0x40(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x28(%rbp), %rdi
movq -0x38(%rbp), %rax
movl %eax, %esi
leaq -0x76(%rbp), %rdx
leaq -0x78(%rbp), %rcx
leaq -0x7a(%rbp), %r8
leaq -0x74(%rbp), %r9
callq 0x1b53f0
movl %eax, %eax
movq %rax, -0x38(%rbp)
movzwl -0x76(%rbp), %eax
cmpl $0x2, %eax
je 0x266a77
movl -0x74(%rbp), %eax
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
movzwl -0x76(%rbp), %eax
cmpl $0x3, %eax
je 0x266a8b
movl -0x74(%rbp), %eax
addq -0x48(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x68(%rbp)
movzwl -0x76(%rbp), %eax
cmpl $0x0, %eax
jne 0x266ac7
movq -0x8(%rbp), %rdi
addq -0x60(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq -0x70(%rbp), %rsi
movq -0x58(%rbp), %rdx
subq -0x60(%rbp), %rdx
shlq $0x0, %rdx
callq 0x2180
jmp 0x266b18
movzwl -0x76(%rbp), %eax
cmpl $0x1, %eax
je 0x266ad9
movzwl -0x76(%rbp), %eax
cmpl $0x3, %eax
jne 0x266b16
movq -0x60(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x58(%rbp), %rax
jae 0x266b14
movzwl -0x78(%rbp), %eax
movl %eax, %ecx
leaq 0x15dc58(%rip), %rax    # 0x3c4750
movb (%rax,%rcx), %dl
movq -0x8(%rbp), %rax
movq -0x50(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x266ae1
jmp 0x266b16
jmp 0x266b18
jmp 0x266a1d
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x10(%rbp), %rdx
shlq $0x0, %rdx
callq 0x20b0
cmpl $0x0, %eax
je 0x266b5b
movq 0x15d4a2(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movl 0x10(%rbp), %ecx
leaq 0x1295f1(%rip), %rsi    # 0x39013c
leaq 0x1295fd(%rip), %rdx    # 0x39014f
movb $0x0, %al
callq 0x22a0
jmp 0x266b5d
jmp 0x266b5d
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)