// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/ecovlp.cpp
// Function: gen_ori_seq0(char*, unsigned long, UC_Read*, asg16_v*, unsigned long)
void gen_ori_seq0(char *tstr, uint64_t tl, UC_Read *qu, asg16_v *sc, uint64_t rid)
{
    uint64_t ck, qk, tk, k, wq[2], wt[2]; uint32_t len; uint16_t c, bq, bt; char *qstr = NULL;
    
    ck = qk = tk = 0;
    while (ck < sc->n) {
        wq[0] = qk; wt[0] = tk;
        ck = pop_trace_bp_f(sc, ck, &c, &bq, &bt, &len);
        if(c != 2) qk += len;
        if(c != 3) tk += len;
        wq[1] = qk; wt[1] = tk;
    }
    if(!(tk == tl)) {
        fprintf(stderr, "[M::%s] rid::%lu, tk::%lu, tl::%lu\n", __func__, rid, tk, tl);
    }
    assert(tk == tl);

    resize_UC_Read(qu, qk); qstr = qu->seq; qu->length = qk;
    ck = qk = tk = 0;
    while (ck < sc->n) {
        wq[0] = qk; wt[0] = tk;
        ck = pop_trace_bp_f(sc, ck, &c, &bq, &bt, &len);
        if(c != 2) qk += len;
        if(c != 3) tk += len;
        wq[1] = qk; wt[1] = tk;

        if(c == 0) {
            memcpy(qstr + wq[0], tstr + wt[0], (wq[1]-wq[0])*sizeof((*qstr)));
        } else if(c == 1 || c == 3) {
            for (k = wq[0]; k < wq[1]; k++) qstr[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
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r8, 0x18(%rsp)
movq %rdx, 0x20(%rsp)
movq %rsi, 0x28(%rsp)
movq %rdi, 0x30(%rsp)
xorl %ebx, %ebx
leaq 0x6(%rsp), %r15
leaq 0xe(%rsp), %r12
leaq 0x8(%rsp), %r14
xorl %esi, %esi
xorl %ebp, %ebp
xorl %r13d, %r13d
movq %rcx, 0x10(%rsp)
cmpq (%rcx), %rsi
jae 0x14a7a5
movq %rcx, %rdi
leaq 0x4(%rsp), %rdx
movq %r15, %rcx
movq %r12, %r8
movq %r14, %r9
callq 0xeeaa9
movl %eax, %esi
movzwl 0x4(%rsp), %eax
cmpw $0x2, %ax
movl 0x8(%rsp), %ecx
movq %rcx, %rdx
cmoveq %rbx, %rdx
addq %rdx, %rbp
cmpw $0x3, %ax
cmoveq %rbx, %rcx
addq %rcx, %r13
movq 0x10(%rsp), %rcx
jmp 0x14a75f
movq 0x28(%rsp), %r9
cmpq %r9, %r13
jne 0x14a899
movq 0x20(%rsp), %rbx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x562fa
movq (%rbx), %r13
movq %rbp, 0x8(%rbx)
leaq 0x108f5f(%rip), %rbp    # 0x253730
xorl %eax, %eax
xorl %ebx, %ebx
xorl %r14d, %r14d
movq 0x10(%rsp), %rdi
movl %eax, %ecx
cmpq %rcx, (%rdi)
jbe 0x14a88a
movq %rbx, %r15
movl %eax, %esi
leaq 0x4(%rsp), %rdx
leaq 0x6(%rsp), %rcx
leaq 0xe(%rsp), %r8
leaq 0x8(%rsp), %r9
callq 0xeeaa9
movzwl 0x4(%rsp), %ecx
cmpw $0x2, %cx
movl 0x8(%rsp), %edx
movq %rdx, %rbx
movl $0x0, %esi
cmoveq %rsi, %rbx
addq %r15, %rbx
cmpw $0x3, %cx
movq %rdx, %r12
cmoveq %rsi, %r12
addq %r14, %r12
testw %cx, %cx
je 0x14a869
andl $0xfffd, %ecx           # imm = 0xFFFD
movq %r12, %r14
cmpw $0x1, %cx
movq 0x10(%rsp), %rdi
jne 0x14a7dd
jmp 0x14a85c
movzwl 0x6(%rsp), %ecx
movb (%rbp,%rcx), %cl
movb %cl, (%r13,%r15)
incq %r15
cmpq %rbx, %r15
jb 0x14a84b
movq %r12, %r14
jmp 0x14a7dd
addq %r13, %r15
addq 0x30(%rsp), %r14
movq %r15, %rdi
movq %r14, %rsi
movl %eax, %r14d
callq 0x2160
movl %r14d, %eax
movq %r12, %r14
jmp 0x14a7d8
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x108740(%rip), %rax    # 0x252fe0
movq (%rax), %rdi
leaq 0xa693b(%rip), %rsi     # 0x1f11e5
leaq 0xa6958(%rip), %rdx     # 0x1f1209
movq 0x18(%rsp), %rcx
movq %r13, %r8
xorl %eax, %eax
callq 0x22b0
leaq 0xa694f(%rip), %rdi     # 0x1f1216
leaq 0xa562d(%rip), %rsi     # 0x1efefb
leaq 0xa694a(%rip), %rcx     # 0x1f121f
movl $0x14f8, %edx           # imm = 0x14F8
callq 0x2110