// File: /workspace/github_cpp_makefile_star2_O2/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 0x1bc320
movq %rcx, %rbx
movq %rdx, %r15
movq %rsi, %r11
movq %rdi, %r12
movl -0x8(%r8,%rcx,8), %eax
movl %eax, 0x18(%rdi)
andq $0x0, 0x20(%rdi)
cmpq %rcx, 0x28(%rdi)
movq %r8, (%rsp)
jae 0x1bc16e
leaq -0x1(%rbx), %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
incq %rcx
movq %rcx, 0x28(%r12)
movq 0x30(%r12), %rdi
imulq $0x24, %rcx, %rsi
movq %r11, %r14
callq 0x2370
movq %r14, %r11
movq (%rsp), %r8
movq %rax, 0x30(%r12)
movq %rbx, 0x8(%rsp)
movq %rbx, %rbp
negq %rbp
pushq $0x1
popq %r14
leaq (%r14,%rbp), %r13
cmpq $0x1, %r13
je 0x1bc316
movq -0x8(%r15,%r14,8), %rbx
movq 0x20(%r12), %rcx
movq 0x30(%r12), %rax
cmpq 0x28(%r12), %rcx
jne 0x1bc1f0
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rdx
movq %rdx, 0x28(%r12)
imulq $0x24, %rdx, %rsi
movq %rax, %rdi
movq %r13, 0x10(%rsp)
movq %r12, %r13
movq %r15, %r12
movq %rbp, %r15
movq %r11, %rbp
callq 0x2370
movq %rbp, %r11
movq %r15, %rbp
movq %r12, %r15
movq %r13, %r12
movq 0x10(%rsp), %r13
movq (%rsp), %r8
movq %rax, 0x30(%r12)
movq 0x20(%r12), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x20(%r12)
imulq $0x24, %rcx, %rsi
leaq (%rax,%rsi), %rcx
movl %ebx, %edi
shrl %edi
movl %edi, (%rax,%rsi)
shlb $0x5, %bl
andb $0x20, %bl
leal -0x7f(%rbx), %edx
movb %dl, 0x20(%rax,%rsi)
movq -0x8(%r8,%r14,8), %rdx
movq %rdx, %r10
movq %rdx, %r9
rorq $0x20, %r9
shrq $0x20, %r10
movq %r9, 0x4(%rax,%rsi)
subl %r10d, %edx
movq 0x18(%r11), %rax
movq 0x20(%rax), %rax
movl (%rax,%rdi,8), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmpq %rax, %rdx
je 0x1bc25f
cmpq $0x1, %r14
setne %sil
cmpq 0x8(%rsp), %r14
setb %dil
andb %sil, %dil
cmpb $0x1, %dil
jne 0x1bc2ab
andl $0x0, 0xc(%rcx)
movl %eax, 0x10(%rcx)
orl $-0x1, 0x1c(%rcx)
orq $-0x1, 0x14(%rcx)
cmpq $0x1, %r14
je 0x1bc2a3
movq -0x8(%r15,%r14,8), %rax
testq %rax, %rax
jns 0x1bc2a3
leal -0x1(%r14), %edx
leal -0x2(%r14), %esi
movl %esi, 0x14(%rcx)
shrq $0x20, %rax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, 0x18(%rcx)
movq 0x30(%r12), %rax
imulq $0x24, %rsi, %rsi
movl %edx, 0x1c(%rax,%rsi)
incq %r14
jmp 0x1bc17d
cmpq $0x1, %r14
jne 0x1bc2e2
testb %bl, %bl
jne 0x1bc2d1
movq %rax, %rsi
subq %rdx, %rsi
movl $0x0, %edi
cmovbq %rdi, %rsi
movl %esi, 0xc(%rcx)
movl %eax, 0x10(%rcx)
testq %r13, %r13
jne 0x1bc266
jmp 0x1bc2ef
andl $0x0, 0xc(%rcx)
cmpq %rax, %rdx
movq %rax, %rsi
cmovbq %rdx, %rsi
movl %esi, 0x10(%rcx)
testq %r13, %r13
jne 0x1bc266
testb %bl, %bl
jne 0x1bc2ff
andl $0x0, 0xc(%rcx)
cmpq %rax, %rdx
cmovbq %rdx, %rax
jmp 0x1bc263
movq %rax, %rsi
subq %rdx, %rsi
movl $0x0, %edx
cmovaeq %rsi, %rdx
movl %edx, 0xc(%rcx)
jmp 0x1bc263
movl 0x18(%r12), %eax
cmpl 0x8(%rcx), %eax
jne 0x1bc32f
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3d59e(%rip), %rdi     # 0x1f98d4
leaq 0x3b19c(%rip), %rsi     # 0x1f74d9
leaq 0x3d5a3(%rip), %rcx     # 0x1f98e7
movl $0x1cb5, %edx           # imm = 0x1CB5
callq 0x2110