// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: update_usg_t_threading(ul_resolve_t*, usg_t*, unsigned long*, unsigned long*, unsigned long, unsigned long*, unsigned int*, asg64_v*)
void update_usg_t_threading(ul_resolve_t *uidx, usg_t *ng, uint64_t *arcs, uint64_t *arcs_g, uint64_t arcs_gn, uint64_t *integ_seq, uint32_t *occ, asg64_v *b)
{
    uint64_t i, k, s, e, nvtx = ng->n<<1; memset(occ, 0, sizeof((*occ))*nvtx);
    for (i = 0; i < arcs_gn; i++) {///set cluster
        // prt = 0;
        s = arcs[((uint32_t)arcs_g[i])]>>32; e = ((uint32_t)arcs[((uint32_t)arcs_g[i])]); assert(s < e);
        for (k = s + 1; k < e; k++) {///note: here is [s, e]
            occ[integ_seq[k]]++; occ[integ_seq[k]^1]++; 
            // if((integ_seq[k]>>1) == 2736) prt = 1;
        }
        occ[integ_seq[s]]++; occ[integ_seq[e]^1]++;
        // if((integ_seq[s]>>1) == 2736) prt = 1;
        // if(((integ_seq[e]^1)>>1) == 2736) prt = 1;
        // if(occ[integ_seq[s]] > 1 || occ[integ_seq[e]^1] > 1) {
        //     fprintf(stderr, "s::utg%.6dl(%c)(occ::%u), e::utg%.6dl(%c)(occ::%u)\n", 
        //         (int32_t)(integ_seq[s]>>1)+1, "+-"[integ_seq[s]&1], occ[integ_seq[s]],
        //         (int32_t)((integ_seq[e]^1)>>1)+1, "+-"[((integ_seq[e]^1)&1)], occ[integ_seq[e]^1]);
        // }
        // if(prt) {
        //     fprintf(stderr, "[M::%s::] a_n::%lu\n", __func__, e + 1 - s);
        //     for (k = s; k <= e; k++) {
        //         fprintf(stderr, "utg%.6dl(%c)(hom::%u)\t", 
        //             (int32_t)(integ_seq[k]>>1)+1, "+-"[integ_seq[k]&1], 
        //             (IF_HOM((integ_seq[k]>>1), (*(uidx->bub)))));
        //     }
        //     fprintf(stderr, "\n");
        // }
    }

    for (i = 0; i < nvtx; i++) {
        if(!occ[i]) occ[i] = (uint32_t)-1;        
    }
    for (i = 0; i < arcs_gn; i++) {///arcs_g[]>>32 is the group id; (uint32_t)arcs_g[]
        s = arcs[((uint32_t)arcs_g[i])]>>32; e = ((uint32_t)arcs[((uint32_t)arcs_g[i])]); 
        update_usg_t_threading_0(uidx, ng, integ_seq + s, e + 1 - s, occ, b);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r9, %rbx
movq %r8, %r14
movq %rcx, %r15
movq %rdx, %r12
movq 0x50(%rsp), %rbp
movq %rsi, 0x10(%rsp)
movq 0x8(%rsi), %rdx
leaq (%rdx,%rdx), %rax
movq %rax, 0x8(%rsp)
shlq $0x3, %rdx
xorl %r13d, %r13d
movq %rbp, %rdi
xorl %esi, %esi
callq 0x20e0
cmpq %r14, %r13
je 0x1cbb3b
movl (%r15,%r13,8), %eax
movq (%r12,%rax,8), %rcx
movl %ecx, %eax
shrq $0x20, %rcx
cmpq %rax, %rcx
jae 0x1cbb9e
leaq 0x1(%rcx), %rdx
cmpq %rax, %rdx
jae 0x1cbb22
movq (%rbx,%rdx,8), %rsi
incl (%rbp,%rsi,4)
xorq $0x1, %rsi
incl (%rbp,%rsi,4)
incq %rdx
jmp 0x1cbb08
movq (%rbx,%rcx,8), %rcx
incl (%rbp,%rcx,4)
movq (%rbx,%rax,8), %rax
xorq $0x1, %rax
incl (%rbp,%rax,4)
incq %r13
jmp 0x1cbae8
xorl %eax, %eax
movq 0x8(%rsp), %rcx
cmpq %rax, %rcx
je 0x1cbb58
cmpl $0x0, (%rbp,%rax,4)
jne 0x1cbb53
orl $-0x1, (%rbp,%rax,4)
incq %rax
jmp 0x1cbb42
xorl %r13d, %r13d
cmpq %r13, %r14
je 0x1cbb8f
movl (%r15,%r13,8), %eax
movq (%r12,%rax,8), %rax
movl %eax, %ecx
shrq $0x20, %rax
leaq (%rbx,%rax,8), %rdx
subq %rax, %rcx
incq %rcx
movq 0x10(%rsp), %rsi
movq %rbp, %r8
movq 0x58(%rsp), %r9
callq 0x1cb332
incq %r13
jmp 0x1cbb5b
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2eda2(%rip), %rdi     # 0x1fa947
leaq 0x2b92d(%rip), %rsi     # 0x1f74d9
leaq 0x2ef4e(%rip), %rcx     # 0x1fab01
movl $0x30cb, %edx           # imm = 0x30CB
callq 0x2110