// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movl %edi, %r15d
leaq 0x10eeab(%rip), %rsi    # 0x296230
movq %rdx, %rdi
movq %r15, %rdx
callq 0x333e0
movq 0x10f1b1(%rip), %rdi    # 0x296548
leaq (%r15,%r15,2), %rdx
movq (%rdi,%rdx,8), %rax
xorl %r15d, %r15d
testq %rax, %rax
movq %rdx, (%rsp)
je 0x18746d
leaq (%rdi,%rdx,8), %rcx
movq 0x10(%rcx), %rcx
xorl %r8d, %r8d
xorl %esi, %esi
xorl %edx, %edx
movzwl (%rcx,%r8,2), %r10d
movl %r10d, %r8d
shrl $0xe, %r8d
leal -0x1(%r8), %r9d
cmpw $0x1, %r9w
ja 0x1873e9
movl %r10d, %r11d
shrl $0xc, %r11d
andl $0x3, %r11d
andl $0xfff, %r10d           # imm = 0xFFF
jmp 0x1873f6
andl $0x3fff, %r10d          # imm = 0x3FFF
movl $0xffff, %r11d          # imm = 0xFFFF
movzwl %r10w, %r10d
incl %esi
movl %esi, %ebp
cmpq %rsi, %rax
jbe 0x18744c
movzwl (%rcx,%rsi,2), %ebp
movl %ebp, %r12d
shrl $0xe, %r12d
cmpl %r8d, %r12d
jne 0x187448
cmpw $0x1, %r9w
ja 0x18742d
movl %ebp, %r13d
shrl $0xc, %r13d
andl $0x3, %r13d
andl $0xfff, %ebp            # imm = 0xFFF
jmp 0x187439
andl $0x3fff, %ebp           # imm = 0x3FFF
movl $0xffff, %r13d          # imm = 0xFFFF
cmpl %r11d, %r13d
jne 0x187448
addl %ebp, %r10d
incl %esi
cmpq %rsi, %rax
ja 0x187403
movl %esi, %ebp
movl %esi, %esi
cmpw $0x3, %r8w
cmovel %r15d, %r10d
addl %r10d, %edx
movq %rsi, %r8
cmpq %rsi, %rax
movl %ebp, %esi
ja 0x1873be
movl %edx, %r15d
movq (%rsp), %rdx
cmpq %r15, 0x10(%r14)
jge 0x187494
movq (%r14), %rdi
movq %r15, %rsi
callq 0x2370
movq (%rsp), %rdx
movq %rax, (%r14)
movq %r15, 0x10(%r14)
movq 0x10f0b8(%rip), %rdi    # 0x296548
movq (%rdi,%rdx,8), %rax
testq %rax, %rax
je 0x1875d0
xorl %ecx, %ecx
xorl %esi, %esi
xorl %ebp, %ebp
xorl %r9d, %r9d
movl %r9d, %r8d
movl %ebp, %r10d
movq 0x10(%rdi,%rdx,8), %r13
movzwl (%r13,%rcx,2), %r11d
movl %r11d, %edi
shrl $0xe, %edi
leal -0x1(%rdi), %ebp
cmpw $0x1, %bp
ja 0x1874df
movl %r11d, %r15d
shrl $0xc, %r15d
andl $0x3, %r15d
movl %r11d, %ecx
andl $0xfff, %ecx            # imm = 0xFFF
movl %r15d, %edx
jmp 0x1874f3
movl %r11d, %ecx
andl $0x3fff, %ecx           # imm = 0x3FFF
movl $0xffff, %edx           # imm = 0xFFFF
movl $0xffff, %r15d          # imm = 0xFFFF
movzwl %cx, %r9d
incl %esi
cmpq %rsi, %rax
jbe 0x18753f
movzwl (%r13,%rsi,2), %ecx
movl %ecx, %r12d
shrl $0xe, %r12d
cmpl %edi, %r12d
jne 0x18753f
cmpw $0x1, %bp
ja 0x187529
movl %ecx, %r12d
shrl $0xc, %r12d
andl $0x3, %r12d
andl $0xfff, %ecx            # imm = 0xFFF
jmp 0x187535
andl $0x3fff, %ecx           # imm = 0x3FFF
movl $0xffff, %r12d          # imm = 0xFFFF
cmpl %edx, %r12d
jne 0x18753f
addl %ecx, %r9d
jmp 0x1874f7
cmpw $0x2, %di
movl %r9d, %ebp
movl $0x0, %eax
cmovel %eax, %ebp
addl %r10d, %ebp
cmpw $0x3, %di
cmovel %eax, %r9d
addl %r8d, %r9d
cmpl $0x3fff, %r11d          # imm = 0x3FFF
ja 0x18758c
cmpl %ebp, %r10d
jae 0x1875b6
movl %r10d, %eax
movl %ebp, %ecx
movq (%rbx), %rdx
movb (%rdx,%rax), %dl
movq (%r14), %rdi
movl %r8d, %r10d
movb %dl, (%rdi,%r10)
incq %rax
incl %r8d
cmpq %rax, %rcx
jne 0x18756f
jmp 0x1875b6
cmpw $0x3, %di
je 0x1875b6
cmpl %r9d, %r8d
jae 0x1875b6
movl %r8d, %eax
movl %r9d, %ecx
leaq 0x10e18c(%rip), %rdx    # 0x295730
movb (%rdx,%r15), %dl
movq (%r14), %rdi
movb %dl, (%rdi,%rax)
incq %rax
cmpq %rax, %rcx
jne 0x1875a8
movl %esi, %ecx
movq 0x10ef89(%rip), %rdi    # 0x296548
movq (%rsp), %rdx
movq (%rdi,%rdx,8), %rax
cmpq %rcx, %rax
ja 0x1874a6
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq