// File: /workspace/github_cpp_makefile_star2_O3/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, 0x8(%rsp)
movq 0x8(%rsi), %r13
leaq (,%r13,8), %rdx
movq %rbp, %rdi
xorl %esi, %esi
callq 0x20e0
movq %r15, %r8
testq %r14, %r14
je 0x21a39e
xorl %eax, %eax
movl (%r8,%rax,8), %ecx
movq (%r12,%rcx,8), %rdx
movl %edx, %ecx
shrq $0x20, %rdx
cmpq %rcx, %rdx
jae 0x21a41e
leaq 0x1(%rdx), %rsi
cmpq %rcx, %rsi
jae 0x21a382
movq (%rbx,%rsi,8), %rdi
incl (%rbp,%rdi,4)
xorq $0x1, %rdi
incl (%rbp,%rdi,4)
incq %rsi
cmpq %rsi, %rcx
jne 0x21a36a
movq (%rbx,%rdx,8), %rdx
incl (%rbp,%rdx,4)
movq (%rbx,%rcx,8), %rcx
xorq $0x1, %rcx
incl (%rbp,%rcx,4)
incq %rax
cmpq %r14, %rax
jne 0x21a34a
addq %r13, %r13
je 0x21a3bc
xorl %eax, %eax
cmpl $0x0, (%rbp,%rax,4)
jne 0x21a3b4
movl $0xffffffff, (%rbp,%rax,4) # imm = 0xFFFFFFFF
incq %rax
cmpq %rax, %r13
jne 0x21a3a5
testq %r14, %r14
movq 0x8(%rsp), %r15
je 0x21a40f
xorl %r13d, %r13d
movq %r14, 0x10(%rsp)
movl (%r8,%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 %r15, %rsi
movq %r12, %r14
movq %r8, %r12
movq %rbp, %r8
movq 0x58(%rsp), %r9
callq 0x219ad4
movq %r12, %r8
movq %r14, %r12
movq 0x10(%rsp), %r14
incq %r13
cmpq %r13, %r14
jne 0x21a3ce
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2e563(%rip), %rdi     # 0x248988
leaq 0x2b1dd(%rip), %rsi     # 0x245609
leaq 0x2e70f(%rip), %rcx     # 0x248b42
movl $0x30cb, %edx           # imm = 0x30CB
callq 0x2110