// File: /workspace/github_cpp_makefile_star2_O1/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 0x1fcf4b
movq %r8, %rbp
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)
movq %rcx, (%rsp)
jae 0x1fcd8b
leaq -0x1(%rcx), %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, %r14
callq 0x2370
movq %r14, %r9
movq (%rsp), %rcx
movq %rax, 0x30(%r12)
cmpq $0x1, %rcx
movq %rcx, %r10
adcq $0x0, %r10
leaq -0x1(%rcx), %rax
movq %rax, 0x8(%rsp)
xorl %r14d, %r14d
movq %r12, 0x10(%rsp)
movq (%r15,%r14,8), %r13
movq 0x28(%r12), %rax
cmpq %rax, 0x20(%r12)
jne 0x1fcdfe
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rcx
movq %rcx, 0x28(%r12)
movq 0x30(%r12), %rdi
shlq $0x2, %rcx
leaq (%rcx,%rcx,8), %rsi
movq %r9, %rbx
movq %r15, %r12
movq %r10, %r15
callq 0x2370
movq %r15, %r10
movq %r12, %r15
movq 0x10(%rsp), %r12
movq %rbx, %r9
movq (%rsp), %rcx
movq %rax, 0x30(%r12)
movq 0x20(%r12), %rax
movq 0x30(%r12), %rsi
leaq 0x1(%rax), %rdx
movq %rdx, 0x20(%r12)
leaq (%rax,%rax,8), %rax
leaq (%rsi,%rax,4), %rax
movl %r13d, %edx
shrl %edx
movl %edx, (%rax)
shlb $0x5, %r13b
andb $0x20, %r13b
leal -0x7f(%r13), %esi
movb %sil, 0x20(%rax)
movq (%rbp,%r14,8), %r8
movq %r8, %rsi
movq %r8, %rdi
rorq $0x20, %rdi
shrq $0x20, %rsi
movq %rdi, 0x4(%rax)
subl %esi, %r8d
movq 0x18(%r9), %rsi
movq 0x20(%rsi), %rsi
movl (%rsi,%rdx,8), %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
cmpq %rdx, %r8
je 0x1fce7b
testq %r14, %r14
setne %sil
leaq 0x1(%r14), %rdi
cmpq %rcx, %rdi
setb %dil
andb %sil, %dil
cmpb $0x1, %dil
jne 0x1fced2
movl $0x0, 0xc(%rax)
movl %edx, 0x10(%rax)
movl $0xffffffff, 0x1c(%rax) # imm = 0xFFFFFFFF
movq $-0x1, 0x14(%rax)
testq %r14, %r14
je 0x1fcec4
movq (%r15,%r14,8), %rsi
testq %rsi, %rsi
jns 0x1fcec4
leal -0x1(%r14), %edx
movl %edx, 0x14(%rax)
shrq $0x20, %rsi
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
movl %esi, 0x18(%rax)
movq 0x30(%r12), %rsi
leaq (%rdx,%rdx,8), %rdx
movl %r14d, 0x1c(%rsi,%rdx,4)
incq %r14
cmpq %r14, %r10
jne 0x1fcda7
jmp 0x1fcf41
testq %r14, %r14
jne 0x1fcf06
testb %r13b, %r13b
jne 0x1fcef2
movq %rdx, %rsi
subq %r8, %rsi
movl $0x0, %edi
cmovaeq %rsi, %rdi
movl %edi, 0xc(%rax)
movl %edx, %esi
jmp 0x1fcf03
movl $0x0, 0xc(%rax)
cmpq %rdx, %r8
movq %rdx, %rsi
cmovbq %r8, %rsi
movl %esi, 0x10(%rax)
cmpq %r14, 0x8(%rsp)
jne 0x1fce85
testb $0x20, 0x20(%rax)
jne 0x1fcf2a
movl $0x0, 0xc(%rax)
cmpq %rdx, %r8
cmovbq %r8, %rdx
jmp 0x1fce82
movq %rdx, %rsi
subq %r8, %rsi
movl $0x0, %edi
cmovaeq %rsi, %rdi
movl %edi, 0xc(%rax)
jmp 0x1fce82
movl 0x18(%r12), %ecx
cmpl 0x8(%rax), %ecx
jne 0x1fcf5a
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3e6d0(%rip), %rdi     # 0x23b631
leaq 0x3c3bd(%rip), %rsi     # 0x239325
leaq 0x3e6d5(%rip), %rcx     # 0x23b644
movl $0x1cb5, %edx           # imm = 0x1CB5
callq 0x2110