// File: 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
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq $0x0, -0x88(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq -0x20(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x26465e
movq -0x38(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rax
movl %eax, %esi
leaq -0x76(%rbp), %rdx
leaq -0x78(%rbp), %rcx
leaq -0x7a(%rbp), %r8
leaq -0x74(%rbp), %r9
callq 0x1b53f0
movl %eax, %eax
movq %rax, -0x30(%rbp)
movzwl -0x76(%rbp), %eax
cmpl $0x2, %eax
je 0x264638
movl -0x74(%rbp), %eax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movzwl -0x76(%rbp), %eax
cmpl $0x3, %eax
je 0x26464c
movl -0x74(%rbp), %eax
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x68(%rbp)
jmp 0x2645e2
movq -0x40(%rbp), %rax
cmpq -0x10(%rbp), %rax
je 0x264693
movq 0x15f971(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movq -0x28(%rbp), %rcx
movq -0x40(%rbp), %r8
movq -0x10(%rbp), %r9
leaq 0x12b87f(%rip), %rsi    # 0x38ff04
leaq 0x12b89c(%rip), %rdx    # 0x38ff28
movb $0x0, %al
callq 0x22a0
movq -0x40(%rbp), %rax
cmpq -0x10(%rbp), %rax
jne 0x26469f
jmp 0x2646be
leaq 0x12b88f(%rip), %rdi    # 0x38ff35
leaq 0x12a55e(%rip), %rsi    # 0x38ec0b
movl $0x14f8, %edx           # imm = 0x14F8
leaq 0x12b885(%rip), %rcx    # 0x38ff3e
callq 0x2130
movq -0x18(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0xa62c0
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x88(%rbp)
movq -0x38(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq -0x20(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x264803
movq -0x38(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rax
movl %eax, %esi
leaq -0x76(%rbp), %rdx
leaq -0x78(%rbp), %rcx
leaq -0x7a(%rbp), %r8
leaq -0x74(%rbp), %r9
callq 0x1b53f0
movl %eax, %eax
movq %rax, -0x30(%rbp)
movzwl -0x76(%rbp), %eax
cmpl $0x2, %eax
je 0x264757
movl -0x74(%rbp), %eax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movzwl -0x76(%rbp), %eax
cmpl $0x3, %eax
je 0x26476b
movl -0x74(%rbp), %eax
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x68(%rbp)
movzwl -0x76(%rbp), %eax
cmpl $0x0, %eax
jne 0x2647aa
movq -0x88(%rbp), %rdi
addq -0x60(%rbp), %rdi
movq -0x8(%rbp), %rsi
addq -0x70(%rbp), %rsi
movq -0x58(%rbp), %rdx
subq -0x60(%rbp), %rdx
shlq $0x0, %rdx
callq 0x2180
jmp 0x2647fe
movzwl -0x76(%rbp), %eax
cmpl $0x1, %eax
je 0x2647bc
movzwl -0x76(%rbp), %eax
cmpl $0x3, %eax
jne 0x2647fc
movq -0x60(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x58(%rbp), %rax
jae 0x2647fa
movzwl -0x78(%rbp), %eax
movl %eax, %ecx
leaq 0x15ff75(%rip), %rax    # 0x3c4750
movb (%rax,%rcx), %dl
movq -0x88(%rbp), %rax
movq -0x48(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x2647c4
jmp 0x2647fc
jmp 0x2647fe
jmp 0x2646fd
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax)