// File: chhylp123[P]hifiasm/ecovlp.cpp
// Function: debug_extract_max_exact_sub(unsigned int, UC_Read*, UC_Read*)
void debug_extract_max_exact_sub(uint32_t qid, UC_Read* qu, UC_Read* tu)
{
    uint32_t ci = 0, len, xk, yk, wx[2], wy[2], k; uint16_t c, b; 

    recover_UC_Read(tu, &R_INF, qid);

    ci = 0; yk = 0;
    while (ci < scc.a[qid].n) {
        ci = pop_trace_bp(&scc.a[qid], ci, &c, &b, &len);
        if(c != 3) yk += len;
    }
    resize_UC_Read(qu, yk);

    ci = 0; xk = yk = 0; 
    while (ci < scc.a[qid].n) {
        wx[0] = xk; wy[0] = yk;
        ci = pop_trace_bp(&scc.a[qid], ci, &c, &b, &len);
        if(c != 2) xk += len;
        if(c != 3) yk += len;
        wx[1] = xk; wy[1] = yk;
        if(c == 0) {
            // memcpy(p->a + wy[0], p->z.seq + wx[0], (wx[1]-wx[0])*sizeof((*(p->a))));
            for (; wx[0] < wx[1]; wx[0]++, wy[0]++) {
                qu->seq[wy[0]] = tu->seq[wx[0]];
            }
        } else if(c == 1 || c == 2) {
            for (k = wy[0]; k < wy[1]; k++) {
                qu->seq[k] = s_H[b]; 
            }
        }
        // if(i == 700) fprintf(stderr, "|%u%c(%c)(x::%u)(y::%u)", len, cm[c], ((c==1)||(c==2))?(cc[b]):('*'), wx[1], wy[1]); // s_H
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movq -0x18(%rbp), %rdi
movl -0x4(%rbp), %eax
movl %eax, %edx
leaq 0x16f346(%rip), %rsi    # 0x3c52d0
callq 0xa380
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x28(%rbp)
movl -0x1c(%rbp), %eax
movq 0x16f641(%rip), %rcx    # 0x3c55e8
movl -0x4(%rbp), %edx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpq (%rcx), %rax
jae 0x255ff2
movq 0x16f62b(%rip), %rdi    # 0x3c55e8
movl -0x4(%rbp), %eax
imulq $0x18, %rax, %rax
addq %rax, %rdi
movl -0x1c(%rbp), %esi
leaq -0x3e(%rbp), %rdx
leaq -0x40(%rbp), %rcx
leaq -0x20(%rbp), %r8
callq 0x26db30
movl %eax, -0x1c(%rbp)
movzwl -0x3e(%rbp), %eax
cmpl $0x3, %eax
je 0x255ff0
movl -0x20(%rbp), %eax
addl -0x28(%rbp), %eax
movl %eax, -0x28(%rbp)
jmp 0x255f9d
movq -0x10(%rbp), %rdi
movl -0x28(%rbp), %eax
movl %eax, %esi
callq 0xa62c0
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x28(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x1c(%rbp), %eax
movq 0x16f5c9(%rip), %rcx    # 0x3c55e8
movl -0x4(%rbp), %edx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpq (%rcx), %rax
jae 0x25612a
movl -0x24(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x28(%rbp), %eax
movl %eax, -0x38(%rbp)
movq 0x16f5a3(%rip), %rdi    # 0x3c55e8
movl -0x4(%rbp), %eax
imulq $0x18, %rax, %rax
addq %rax, %rdi
movl -0x1c(%rbp), %esi
leaq -0x3e(%rbp), %rdx
leaq -0x40(%rbp), %rcx
leaq -0x20(%rbp), %r8
callq 0x26db30
movl %eax, -0x1c(%rbp)
movzwl -0x3e(%rbp), %eax
cmpl $0x2, %eax
je 0x256078
movl -0x20(%rbp), %eax
addl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
movzwl -0x3e(%rbp), %eax
cmpl $0x3, %eax
je 0x25608a
movl -0x20(%rbp), %eax
addl -0x28(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x28(%rbp), %eax
movl %eax, -0x34(%rbp)
movzwl -0x3e(%rbp), %eax
cmpl $0x0, %eax
jne 0x2560d9
jmp 0x2560a1
movl -0x30(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jae 0x2560d7
movq -0x18(%rbp), %rax
movq (%rax), %rax
movl -0x30(%rbp), %ecx
movb (%rax,%rcx), %dl
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl -0x38(%rbp), %ecx
movb %dl, (%rax,%rcx)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x2560a1
jmp 0x256125
movzwl -0x3e(%rbp), %eax
cmpl $0x1, %eax
je 0x2560eb
movzwl -0x3e(%rbp), %eax
cmpl $0x2, %eax
jne 0x256123
movl -0x38(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x34(%rbp), %eax
jae 0x256121
movzwl -0x40(%rbp), %eax
movl %eax, %ecx
leaq 0x16e64a(%rip), %rax    # 0x3c4750
movb (%rax,%rcx), %dl
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl -0x3c(%rbp), %ecx
movb %dl, (%rax,%rcx)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x2560f1
jmp 0x256123
jmp 0x256125
jmp 0x256015
addq $0x40, %rsp
popq %rbp
retq