// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: push_integer_seq_exact(ul_vec_t*, ma_ug_t*, unsigned long*, unsigned long, unsigned long*, unsigned int)
void push_integer_seq_exact(ul_vec_t *res, ma_ug_t *ug, uint64_t *seq, uint64_t seq_n, uint64_t *off, uint32_t tid)
{
    if(seq_n <= 0) return;
    uint64_t k, v, ql, ul; uc_block_t *x;
    // fprintf(stderr, "[M::%s::] old_len::%u, new_len::%u\n", __func__, res->rlen, (uint32_t)off[seq_n-1]);
    res->rlen = (uint32_t)off[seq_n-1]; res->bb.n = 0; kv_resize(uc_block_t, res->bb, seq_n);
    for (k = 0; k < seq_n; k++) {
        v = (uint32_t)seq[k];
        kv_pushp(uc_block_t, res->bb, &x);
        x->hid = v>>1; x->rev = !!(v&1); x->pchain = 1; x->el = 1; x->base = 0;
        x->qs = off[k]>>32; x->qe = (uint32_t)off[k]; 
        ql = x->qe - x->qs; ul = ug->g->seq[x->hid].len;
        if((ul == ql) || (k > 0 && k + 1 < seq_n)) {
            x->ts = 0; x->te = ul;
        } else {
            // if(!(k == 0 || k + 1 == seq_n)){
            //     fprintf(stderr, "[M::%s::] k::%lu, ql::%lu, ul::%lu\n", __func__, k, ql, ul);
            // }
            // assert(k == 0 || k + 1 == seq_n);
            if(k == 0) {
                if(x->rev) {
                    x->ts = 0; x->te = MIN(ql, ul);                 
                } else {
                    x->ts = ul - MIN(ql, ul); x->te = ul;
                }
            }

            if(k + 1 == seq_n) {
                if(!x->rev) {
                    x->ts = 0; x->te = MIN(ql, ul);
                } else {
                    x->ts = ul - MIN(ql, ul); x->te = ul;
                }
            }
        }
        x->pidx = x->aidx = x->pdis = (uint32_t)-1;
        if(k > 0 && (seq[k]&((uint64_t)(0x8000000000000000)))) {
            x->pidx = k - 1; x->pdis = (seq[k]<<1)>>33;
            res->bb.a[x->pidx].aidx = k;
        }
    }
    assert(res->rlen == x->qe);
    // res->rlen = ((uint32_t)-1) - tid;
    // print_primary_ul_chain(NULL, res, ug);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
testq %rcx, %rcx
je 0x2086ee
movq %r8, %rbx
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r9
movq %rdi, %r12
movl -0x8(%r8,%rcx,8), %eax
movl %eax, 0x18(%rdi)
movq $0x0, 0x20(%rdi)
cmpq %rcx, 0x28(%rdi)
jae 0x208525
leaq -0x1(%r14), %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x10, %rcx
orq %rax, %rcx
leaq 0x1(%rcx), %rax
movq %rax, 0x28(%r12)
movq 0x30(%r12), %rdi
leaq 0x4(,%rcx,4), %rax
leaq (%rax,%rax,8), %rsi
movq %r9, %r13
callq 0x2370
movq %r13, %r9
movq %rax, 0x30(%r12)
leaq -0x1(%r14), %rax
movq %rax, 0x8(%rsp)
xorl %ebp, %ebp
movq %r12, 0x10(%rsp)
movq (%r15,%rbp,8), %r13
movq 0x20(%r12), %rcx
movq 0x30(%r12), %rax
cmpq 0x28(%r12), %rcx
jne 0x208596
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rdx
movq %rdx, 0x28(%r12)
shlq $0x2, %rdx
leaq (%rdx,%rdx,8), %rsi
movq %rax, %rdi
movq %r14, %r12
movq %r15, %r14
movq %rbx, %r15
movq %r9, %rbx
callq 0x2370
movq %rbx, %r9
movq %r15, %rbx
movq %r14, %r15
movq %r12, %r14
movq 0x10(%rsp), %r12
movq %rax, 0x30(%r12)
movq 0x20(%r12), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x20(%r12)
leaq (%rcx,%rcx,8), %rcx
leaq (%rax,%rcx,4), %rax
movl %r13d, %edx
shrl %edx
movl %edx, (%rax)
shlb $0x5, %r13b
andb $0x20, %r13b
leal -0x7f(%r13), %ecx
movb %cl, 0x20(%rax)
movq (%rbx,%rbp,8), %rcx
movq %rcx, %rdi
shrq $0x20, %rdi
movq %rcx, %rsi
rorq $0x20, %rsi
movq %rsi, 0x4(%rax)
movl %ecx, %esi
subl %edi, %esi
movq 0x18(%r9), %rdi
movq 0x20(%rdi), %rdi
movl (%rdi,%rdx,8), %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
cmpq %rdx, %rsi
je 0x208608
testq %rbp, %rbp
setne %dil
leaq 0x1(%rbp), %r8
cmpq %r14, %r8
setb %r8b
andb %dil, %r8b
cmpb $0x1, %r8b
jne 0x208660
movl $0x0, 0xc(%rax)
movl %edx, 0x10(%rax)
movl $0xffffffff, 0x1c(%rax) # imm = 0xFFFFFFFF
movq $-0x1, 0x14(%rax)
testq %rbp, %rbp
je 0x20864f
movq (%r15,%rbp,8), %rdx
testq %rdx, %rdx
jns 0x20864f
leal -0x1(%rbp), %esi
movl %esi, 0x14(%rax)
shrq $0x20, %rdx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movl %edx, 0x18(%rax)
movq 0x30(%r12), %rax
leaq (%rsi,%rsi,8), %rdx
movl %ebp, 0x1c(%rax,%rdx,4)
incq %rbp
cmpq %rbp, %r14
jne 0x208535
jmp 0x2086e7
testq %rbp, %rbp
jne 0x2086ad
testb %r13b, %r13b
jne 0x208699
movq %rdx, %rdi
subq %rsi, %rdi
movl $0x0, %r8d
cmovaeq %rdi, %r8
movl %r8d, 0xc(%rax)
movl %edx, 0x10(%rax)
cmpq %rbp, 0x8(%rsp)
je 0x2086bd
movl $0xffffffff, 0x1c(%rax) # imm = 0xFFFFFFFF
movq $-0x1, 0x14(%rax)
jmp 0x20864f
movl $0x0, 0xc(%rax)
cmpq %rdx, %rsi
movq %rdx, %rdi
cmovbq %rsi, %rdi
movl %edi, 0x10(%rax)
cmpq %rbp, 0x8(%rsp)
jne 0x208612
testb %r13b, %r13b
jne 0x2086d0
movl $0x0, 0xc(%rax)
cmpq %rdx, %rsi
cmovbq %rsi, %rdx
jmp 0x20860f
movq %rdx, %rdi
subq %rsi, %rdi
movl $0x0, %esi
cmovaeq %rdi, %rsi
movl %esi, 0xc(%rax)
jmp 0x20860f
cmpl %ecx, 0x18(%r12)
jne 0x2086fd
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3f211(%rip), %rdi     # 0x247915
leaq 0x3cefe(%rip), %rsi     # 0x245609
leaq 0x3f216(%rip), %rcx     # 0x247928
movl $0x1cb5, %edx           # imm = 0x1CB5
callq 0x2110