// File: /workspace/github_cpp_makefile_star2_O1/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 0x10b3a5(%rip), %rsi    # 0x28b230
movq %rdx, %rdi
movq %r15, %rdx
callq 0x33cf8
movq 0x10b6ab(%rip), %rcx    # 0x28b548
leaq (%r15,%r15,2), %r12
movq (%rcx,%r12,8), %rax
xorl %r15d, %r15d
testq %rax, %rax
movq %r12, (%rsp)
je 0x17ff6f
leaq (%rcx,%r12,8), %rcx
movq 0x10(%rcx), %rcx
movl $0xfff, %edx            # imm = 0xFFF
movl $0xffff, %esi           # imm = 0xFFFF
xorl %r9d, %r9d
xorl %r8d, %r8d
xorl %edi, %edi
movzwl (%rcx,%r9,2), %r11d
movl %r11d, %r9d
shrl $0xe, %r9d
leal -0x1(%r9), %ebp
cmpw $0x2, %bp
movl $0x3fff, %r10d          # imm = 0x3FFF
cmovbl %edx, %r10d
andl %r11d, %r10d
incl %r8d
cmpq %r8, %rax
jbe 0x17ff50
shrl $0xc, %r11d
andl $0x3, %r11d
cmpw $0x2, %bp
cmovael %esi, %r11d
movzwl (%rcx,%r8,2), %r13d
movl %r13d, %r12d
shrl $0xe, %r12d
cmpl %r9d, %r12d
jne 0x17ff50
cmpw $0x1, %bp
ja 0x17ff33
movl %r13d, %r12d
shrl $0xc, %r12d
andl $0x3, %r12d
andl $0xfff, %r13d           # imm = 0xFFF
jmp 0x17ff40
andl $0x3fff, %r13d          # imm = 0x3FFF
movl $0xffff, %r12d          # imm = 0xFFFF
cmpl %r11d, %r12d
jne 0x17ff50
addl %r13d, %r10d
incl %r8d
cmpq %r8, %rax
ja 0x17ff08
cmpw $0x3, %r9w
cmovel %r15d, %r10d
addl %r10d, %edi
movl %r8d, %r9d
cmpq %r9, %rax
ja 0x17fecf
movl %edi, %r15d
movq (%rsp), %r12
cmpq %r15, 0x10(%r14)
jge 0x17ff87
movq (%r14), %rdi
movq %r15, %rsi
callq 0x2370
movq %rax, (%r14)
movq %r15, 0x10(%r14)
movq 0x10b5ba(%rip), %rax    # 0x28b548
movq (%rax,%r12,8), %r10
testq %r10, %r10
je 0x1800d1
xorl %ecx, %ecx
xorl %edi, %edi
xorl %ebp, %ebp
xorl %r8d, %r8d
movq 0x10(%rax,%r12,8), %rdx
movzwl (%rdx,%rcx,2), %r13d
movl %r13d, %r15d
shrl $0xe, %r15d
leal -0x1(%r15), %eax
movl %r13d, %r11d
shrl $0xc, %r11d
andl $0x3, %r11d
cmpw $0x2, %ax
movl $0xffff, %ecx           # imm = 0xFFFF
cmovael %ecx, %r11d
movl %r8d, %r9d
movl $0x3fff, %r8d           # imm = 0x3FFF
movl $0xfff, %ecx            # imm = 0xFFF
cmovbl %ecx, %r8d
movl %ebp, %ecx
andl %r13d, %r8d
incl %edi
cmpq %rdi, %r10
jbe 0x180035
movzwl %r11w, %ebp
movzwl (%rdx,%rdi,2), %r12d
movl %r12d, %esi
shrl $0xe, %esi
cmpl %r15d, %esi
jne 0x180035
cmpw $0x1, %ax
ja 0x18001b
movl %r12d, %esi
shrl $0xc, %esi
andl $0x3, %esi
andl $0xfff, %r12d           # imm = 0xFFF
jmp 0x180027
andl $0x3fff, %r12d          # imm = 0x3FFF
movl $0xffff, %esi           # imm = 0xFFFF
cmpl %ebp, %esi
jne 0x180035
addl %r12d, %r8d
incl %edi
cmpq %rdi, %r10
ja 0x17fff3
cmpw $0x2, %r15w
movl %r8d, %ebp
movl $0x0, %eax
cmovel %eax, %ebp
addl %ecx, %ebp
cmpw $0x3, %r15w
cmovel %eax, %r8d
addl %r9d, %r8d
movzwl %r13w, %eax
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x180087
cmpl %ebp, %ecx
movq (%rsp), %r12
jae 0x1800bb
movl %ecx, %eax
movl %ebp, %ecx
movq (%rbx), %rdx
movb (%rdx,%rax), %dl
movq (%r14), %rsi
movl %r9d, %r10d
movb %dl, (%rsi,%r10)
incq %rax
incl %r9d
cmpq %rax, %rcx
jne 0x18006a
jmp 0x1800bb
cmpw $0x3, %r15w
movq (%rsp), %r12
leaq 0x10a699(%rip), %r10    # 0x28a730
je 0x1800bb
cmpl %r8d, %r9d
jae 0x1800bb
movzwl %r11w, %eax
movl %r9d, %ecx
movl %r8d, %edx
movb (%r10,%rax), %sil
movq (%r14), %r9
movb %sil, (%r9,%rcx)
incq %rcx
cmpq %rcx, %rdx
jne 0x1800a8
movl %edi, %ecx
movq 0x10b484(%rip), %rax    # 0x28b548
movq (%rax,%r12,8), %r10
cmpq %rcx, %r10
ja 0x17ffa4
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq