// File: /workspace/github_cpp_makefile_star2_O1/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 $0x28, %rsp
movq %r8, 0x10(%rsp)
movq %rdx, (%rsp)
movq %rsi, 0x18(%rsp)
movq %rdi, 0x20(%rsp)
movq (%rcx), %rax
testq %rax, %rax
movq %rcx, 0x8(%rsp)
je 0x188257
movq 0x10(%rcx), %rcx
xorl %esi, %esi
xorl %edi, %edi
xorl %r12d, %r12d
xorl %r9d, %r9d
movzwl (%rcx,%r9,2), %edx
movl %edx, %r10d
shrl $0xe, %r10d
leal -0x2(%r10), %r8d
cmpl $0x2, %r8d
jae 0x188176
movl %edx, %r11d
shrl $0xc, %r11d
andl $0x3, %r11d
andl $0xfff, %edx            # imm = 0xFFF
jmp 0x188186
testl %r10d, %r10d
jne 0x18818d
andl $0x3fff, %edx           # imm = 0x3FFF
movw $0xffff, %r11w          # imm = 0xFFFF
movl $0xffff, %ebp           # imm = 0xFFFF
jmp 0x1881a6
movl %edx, %r11d
shrl $0xc, %r11d
andl $0x3, %r11d
movl %edx, %ebp
shrl $0xa, %ebp
andl $0x3, %ebp
andl $0x3ff, %edx            # imm = 0x3FF
movzwl %dx, %r14d
incl %r9d
cmpq %r9, %rax
jbe 0x18822b
movzwl %r10w, %r13d
leal -0x2(%r13), %edx
movzwl (%rcx,%r9,2), %r8d
movl %r8d, %ebx
shrl $0xe, %ebx
cmpl %r10d, %ebx
jne 0x18822b
cmpl $0x2, %edx
jae 0x1881e3
movl %r8d, %r15d
shrl $0xc, %r15d
andl $0x3, %r15d
andl $0xfff, %r8d            # imm = 0xFFF
jmp 0x1881f4
testl %r13d, %r13d
jne 0x1881fb
andl $0x3fff, %r8d           # imm = 0x3FFF
movw $0xffff, %r15w          # imm = 0xFFFF
movl $0xffff, %ebx           # imm = 0xFFFF
jmp 0x188216
movl %r8d, %r15d
shrl $0xc, %r15d
andl $0x3, %r15d
movl %r8d, %ebx
shrl $0xa, %ebx
andl $0x3, %ebx
andl $0x3ff, %r8d            # imm = 0x3FF
cmpl %ebp, %ebx
jne 0x18822b
cmpw %r15w, %r11w
jne 0x18822b
addl %r8d, %r14d
incl %r9d
cmpq %r9, %rax
ja 0x1881ba
cmpw $0x2, %r10w
movl %r14d, %edx
movq %rdx, %r8
cmoveq %rdi, %r8
addq %r8, %r12
cmpw $0x3, %r10w
movl %r9d, %r9d
cmoveq %rdi, %rdx
addq %rdx, %rsi
cmpq %r9, %rax
ja 0x18814d
jmp 0x18825c
xorl %r12d, %r12d
xorl %esi, %esi
movq 0x18(%rsp), %rdx
cmpq %rdx, %rsi
jne 0x188424
movq (%rsp), %rcx
cmpq %r12, 0x10(%rcx)
jge 0x18828a
movq (%rcx), %rdi
movq %r12, %rsi
callq 0x2370
movq (%rsp), %rcx
movq %rax, (%rcx)
movq %r12, 0x10(%rcx)
movq (%rcx), %rax
movq %rax, (%rsp)
movq %r12, 0x8(%rcx)
movq 0x8(%rsp), %rax
movq (%rax), %rdx
testq %rdx, %rdx
je 0x188415
leaq 0x102483(%rip), %r12    # 0x28a730
xorl %ebp, %ebp
xorl %r13d, %r13d
xorl %r14d, %r14d
movq %r13, %rdi
movq 0x10(%rax), %r9
movzwl (%r9,%r14,2), %eax
movl %eax, %esi
shrl $0xe, %esi
movw $0xffff, %cx            # imm = 0xFFFF
leal -0x2(%rsi), %r8d
cmpl $0x2, %r8d
jae 0x1882e6
movl %eax, %r8d
shrl $0xc, %r8d
andl $0x3, %r8d
movw $0xfff, %r10w           # imm = 0xFFF
jmp 0x18830c
movw $0x3fff, %r10w          # imm = 0x3FFF
movw $0xffff, %r8w           # imm = 0xFFFF
testl %esi, %esi
je 0x18830c
movl %eax, %r8d
shrl $0xc, %r8d
andl $0x3, %r8d
movl %eax, %ecx
shrl $0xa, %ecx
andl $0x3, %ecx
movw $0x3ff, %r10w           # imm = 0x3FF
movzwl %r10w, %r10d
andl %eax, %r10d
incl %r14d
cmpq %r14, %rdx
jbe 0x188397
movzwl %cx, %r11d
movzwl (%r9,%r14,2), %r13d
movl %r13d, %ebx
shrl $0xe, %ebx
cmpl %esi, %ebx
jne 0x188397
movzwl %si, %ebx
leal -0x2(%rbx), %r15d
cmpl $0x2, %r15d
jae 0x18834f
movl %r13d, %r15d
shrl $0xc, %r15d
andl $0x3, %r15d
andl $0xfff, %r13d           # imm = 0xFFF
jmp 0x18835f
testl %ebx, %ebx
jne 0x188366
andl $0x3fff, %r13d          # imm = 0x3FFF
movw $0xffff, %r15w          # imm = 0xFFFF
movl $0xffff, %ebx           # imm = 0xFFFF
jmp 0x188381
movl %r13d, %r15d
shrl $0xc, %r15d
andl $0x3, %r15d
movl %r13d, %ebx
shrl $0xa, %ebx
andl $0x3, %ebx
andl $0x3ff, %r13d           # imm = 0x3FF
cmpl %r11d, %ebx
jne 0x188397
cmpw %r15w, %r8w
jne 0x188397
addl %r13d, %r10d
incl %r14d
cmpq %r14, %rdx
ja 0x18831f
cmpw $0x2, %si
movl %r10d, %r15d
movq %r15, %rdx
movl $0x0, %r9d
cmoveq %r9, %rdx
leaq (%rdx,%rdi), %r13
cmpw $0x3, %si
cmovel %r8d, %ecx
cmoveq %r9, %r15
movzwl %ax, %esi
cmpl $0x3fff, %esi           # imm = 0x3FFF
ja 0x1883da
addq (%rsp), %rdi
movq 0x20(%rsp), %rax
leaq (%rax,%rbp), %rsi
callq 0x2160
jmp 0x1883fe
btl $0xe, %eax
jae 0x1883fe
cmpq %r13, %rdi
jae 0x1883fe
movzwl %cx, %eax
addq (%rsp), %rdi
xorl %ecx, %ecx
movb (%r12,%rax), %sil
movb %sil, (%rdi,%rcx)
incq %rcx
cmpq %rcx, %rdx
jne 0x1883ee
movl %r14d, %r14d
addq %r15, %rbp
movq 0x8(%rsp), %rax
movq (%rax), %rdx
cmpq %r14, %rdx
ja 0x1882b5
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%rsp), %rdi
callq 0x23872