// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: update_raw_integer_seq(poa_g_t*, ma_ug_t*, unsigned int*, unsigned int, all_ul_t*, ul_str_t*, unsigned int, integer_t*, ul_chain_t*, unsigned long)
void update_raw_integer_seq(poa_g_t *pg, ma_ug_t *ug, uint32_t *cns_seq, uint32_t cns_occ, all_ul_t *ul_idx, ul_str_t *str, uint32_t qid, integer_t *buf, ul_chain_t *idx_a, uint64_t idx_n)
{
    if(cns_occ <= 0) return;
    ///no need to check edges if there is just one node -> no dege
    if(cns_occ > 1) radix_sort_emap_t_srt(pg->e_idx.a, pg->e_idx.a + pg->e_idx.n); 
    kv_resize(uint64_t, buf->u, cns_occ); buf->u.n = cns_occ - 1; memset(buf->u.a, 0, sizeof(*(buf->u.a)*buf->u.n));
    uint64_t *arc_idx = buf->u.a, arc_idx_n = buf->u.n, x; uint64_t k, l, i, n = pg->e_idx.n, fe = cns_occ - 1;
    for (k = 1, l = 0; k <= n && fe > 0; k++) {
        if(k == n || pg->e_idx.a[k].pge != pg->e_idx.a[l].pge) {
            if(k > l) {
                for (i = 0; i < arc_idx_n; i++) {
                    x = (cns_seq[i]>>1); x <<= 32; x += (cns_seq[i+1]>>1);
                    if(x == pg->e_idx.a[l].pge) {
                        arc_idx[i] = l; arc_idx[i] <<= 32; arc_idx[i] += k; fe--;
                        break;
                    }
                }
            }
            l = k;
        }
    }
    assert(fe == 0);
    // for (k = 0; k < pg->e_idx.n; k++) {
    //     assert((pg->seq.a[pg->e_idx.a[k].pge>>32].nid>>1) == 
    //                             (((uint32_t)str[pg->e_idx.a[k].ulid].a[pg->e_idx.a[k].ule>>32])>>1));
    //     assert((pg->seq.a[(uint32_t)pg->e_idx.a[k].pge].nid>>1) == 
    //                             (((uint32_t)str[pg->e_idx.a[k].ulid].a[(uint32_t)pg->e_idx.a[k].ule])>>1));
    //     assert(((pg->seq.a[pg->e_idx.a[k].pge>>32].nid&1)^(((uint32_t)str[pg->e_idx.a[k].ulid].a[pg->e_idx.a[k].ule>>32])&1)) ==
    //         ((pg->seq.a[(uint32_t)pg->e_idx.a[k].pge].nid&1)^(((uint32_t)str[pg->e_idx.a[k].ulid].a[(uint32_t)pg->e_idx.a[k].ule])&1)));
    // }

    uint32_t e_s, e_e; emap_t *g_arc; uint64_t l_clip = 0, r_clip = 0; int64_t e_occ;
    if(arc_idx_n > 0) {
        ///clip unreliable left/right end
        for (l_clip = 0; l_clip < arc_idx_n; l_clip++) {
            k = l_clip;
            e_s = arc_idx[k]>>32; e_e = (uint32_t)arc_idx[k]; 
            assert(poa_g_arc_w(pg, cns_seq[k], cns_seq[k+1]) == (e_e - e_s)); 
            e_occ = ((int64_t)e_e) - ((int64_t)e_s);
            if(e_occ > 1) break;///more than one read supporting this edge
            for (i = e_s; i < e_e; i++) {
                g_arc = &(pg->e_idx.a[i]);
                if(g_arc->ulid == qid) break;
            }
            if(i < e_e) break;///the query read itself supports this edge
        }
        
        for (r_clip = 0; r_clip < arc_idx_n; r_clip++) {
            k = arc_idx_n - r_clip - 1;
            e_s = arc_idx[k]>>32; e_e = (uint32_t)arc_idx[k]; 
            assert(poa_g_arc_w(pg, cns_seq[k], cns_seq[k+1]) == (e_e - e_s)); 
            e_occ = ((int64_t)e_e) - ((int64_t)e_s);
            if(e_occ > 1) break;///more than one read supporting this edge
            for (i = e_s; i < e_e; i++) {
                g_arc = &(pg->e_idx.a[i]);
                if(g_arc->ulid == qid) break;
            }
            if(i < e_e) break;///the query read itself supports this edge
        }
    }
    if(l_clip+r_clip >= cns_occ) return;
    dump_cns_res(pg, ug, cns_seq+l_clip, cns_occ-l_clip-r_clip, ul_idx, str, qid, buf, arc_idx+l_clip, arc_idx_n-l_clip-r_clip);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r9, 0x30(%rsp)
movq %r8, 0x28(%rsp)
movq %rsi, 0x20(%rsp)
testl %ecx, %ecx
je 0x1b9b2e
movl %ecx, %r12d
movq %rdx, %rbp
movq %rdi, %r13
movq 0x78(%rsp), %rbx
cmpl $0x1, %ecx
je 0x1b986f
movq 0xd8(%r13), %rdi
imulq $0x18, 0xc8(%r13), %rsi
addq %rdi, %rsi
callq 0x1a4e10
movl %r12d, %r14d
cmpq %r14, 0x98(%rbx)
jae 0x1b98d8
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, 0x98(%rbx)
movq 0xa0(%rbx), %rdi
leaq 0x8(,%rcx,8), %rsi
callq 0x2370
movq %rax, 0xa0(%rbx)
jmp 0x1b98df
movq 0xa0(%rbx), %rax
movl 0x70(%rsp), %r11d
leal -0x1(%r12), %ecx
movq %rcx, 0x90(%rbx)
andq $0x0, (%rax)
movq %rbx, %rax
movq 0x90(%rbx), %rbx
movq 0xa0(%rax), %r15
movq 0xc8(%r13), %rax
pushq $0x1
popq %rdx
xorl %esi, %esi
cmpq %rax, %rdx
ja 0x1b9987
testq %rcx, %rcx
je 0x1b9987
cmpq %rax, %rdx
je 0x1b9939
movq 0xd8(%r13), %rdi
imulq $0x18, %rdx, %r8
movq (%rdi,%r8), %r8
imulq $0x18, %rsi, %r9
cmpq (%rdi,%r9), %r8
je 0x1b9982
cmpq %rsi, %rdx
jbe 0x1b997f
imulq $0x18, %rsi, %r8
xorl %edi, %edi
cmpq %rdi, %rbx
je 0x1b997f
movl (%rbp,%rdi,4), %r9d
movl 0x4(%rbp,%rdi,4), %r10d
shrl %r9d
shlq $0x20, %r9
incq %rdi
shrl %r10d
orq %r9, %r10
movq 0xd8(%r13), %r9
cmpq (%r9,%r8), %r10
jne 0x1b9944
shlq $0x20, %rsi
addq %rdx, %rsi
movq %rsi, -0x8(%r15,%rdi,8)
decq %rcx
movq %rdx, %rsi
incq %rdx
jmp 0x1b9911
testq %rcx, %rcx
jne 0x1b9b7b
testq %rbx, %rbx
movq %r14, 0x18(%rsp)
je 0x1b9ab2
xorl %ecx, %ecx
movq %r15, (%rsp)
cmpq %rbx, %rcx
je 0x1b9ab9
movq (%r15,%rcx,8), %r15
movq %r15, %r14
shrq $0x20, %r14
movl (%rbp,%rcx,4), %esi
movq %rcx, 0x8(%rsp)
movl 0x4(%rbp,%rcx,4), %edx
movq %r13, %rdi
callq 0x1b932b
movl %r15d, %ecx
subl %r14d, %ecx
cmpl %ecx, %eax
jne 0x1b9b3d
movl %r15d, %eax
movq %rax, %rcx
subq %r14, %rcx
cmpq $0x1, %rcx
movl 0x70(%rsp), %r11d
jg 0x1b9acd
movq 0x8(%rsp), %rcx
incq %rcx
imulq $0x18, %r14, %rdx
addq $0x10, %rdx
decq %r14
movq (%rsp), %r15
leaq 0x18(%rdx), %rsi
incq %r14
cmpq %rax, %r14
jae 0x1b99a4
movq 0xd8(%r13), %rdi
cmpl %r11d, (%rdi,%rdx)
movq %rsi, %rdx
jne 0x1b9a0a
movq %r12, 0x10(%rsp)
xorl %r14d, %r14d
movq %rbx, %rax
subq %r14, %rax
je 0x1b9ac3
movq -0x8(%r15,%rax,8), %r12
movq %r12, %r15
shrq $0x20, %r15
movl -0x4(%rbp,%rax,4), %esi
movl (%rbp,%rax,4), %edx
movq %r13, %rdi
callq 0x1b932b
movl %r12d, %ecx
subl %r15d, %ecx
cmpl %ecx, %eax
jne 0x1b9b5c
movl %r12d, %eax
movq %rax, %rcx
subq %r15, %rcx
cmpq $0x1, %rcx
movl 0x70(%rsp), %r11d
jg 0x1b9ad6
imulq $0x18, %r15, %rcx
addq $0x10, %rcx
decq %r15
movq 0x10(%rsp), %r12
incq %r15
cmpq %rax, %r15
jae 0x1b9aa6
leaq 0x18(%rcx), %rdx
movq 0xd8(%r13), %rsi
cmpl %r11d, (%rsi,%rcx)
movq %rdx, %rcx
jne 0x1b9a88
jmp 0x1b9adb
incq %r14
movq (%rsp), %r15
jmp 0x1b9a2e
xorl %eax, %eax
xorl %r14d, %r14d
jmp 0x1b9ae4
movq %rbx, 0x8(%rsp)
jmp 0x1b9a26
movq %rbx, %r14
movq 0x10(%rsp), %r12
jmp 0x1b9adf
movq (%rsp), %r15
jmp 0x1b9a26
movq 0x10(%rsp), %r12
movq (%rsp), %r15
movq 0x8(%rsp), %rax
addq %rax, %r14
cmpq 0x18(%rsp), %r14
jae 0x1b9b2e
leaq (,%rax,4), %rdx
addq %rbp, %rdx
subl %r14d, %r12d
leaq (%r15,%rax,8), %rax
subq %r14, %rbx
movq %r13, %rdi
movq 0x20(%rsp), %rsi
movl %r12d, %ecx
movq 0x28(%rsp), %r8
movq 0x30(%rsp), %r9
pushq %rbx
pushq %rax
pushq 0x88(%rsp)
pushq %r11
callq 0x1b9363
addq $0x58, %rsp
jmp 0x1b9b32
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3f6d9(%rip), %rdi     # 0x1f921d
leaq 0x3d98e(%rip), %rsi     # 0x1f74d9
leaq 0x3f8b6(%rip), %rcx     # 0x1f9408
movl $0x191a, %edx           # imm = 0x191A
callq 0x2110
leaq 0x3f6ba(%rip), %rdi     # 0x1f921d
leaq 0x3d96f(%rip), %rsi     # 0x1f74d9
leaq 0x3f897(%rip), %rcx     # 0x1f9408
movl $0x1927, %edx           # imm = 0x1927
callq 0x2110
leaq 0x3f87e(%rip), %rdi     # 0x1f9400
leaq 0x3d950(%rip), %rsi     # 0x1f74d9
leaq 0x3f878(%rip), %rcx     # 0x1f9408
movl $0x190a, %edx           # imm = 0x190A
callq 0x2110