// File: 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
movq %rsp, %rbp
subq $0x60, %rsp
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
shlq %rax
movq %rax, -0x58(%rbp)
movq 0x10(%rbp), %rdi
movq -0x58(%rbp), %rdx
shlq $0x2, %rdx
xorl %esi, %esi
callq 0x2100
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0x359b96
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
movq -0x38(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
movq -0x38(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
movl %eax, %eax
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x50(%rbp), %rax
jae 0x359ad6
jmp 0x359af5
leaq 0x3fb9b(%rip), %rdi     # 0x399678
leaq 0x3c6d5(%rip), %rsi     # 0x3961b9
movl $0x30cb, %edx           # imm = 0x30CB
leaq 0x3fd42(%rip), %rcx     # 0x399832
callq 0x2130
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x50(%rbp), %rax
jae 0x359b4f
movq 0x10(%rbp), %rax
movq -0x30(%rbp), %rcx
movq -0x40(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movq 0x10(%rbp), %rax
movq -0x30(%rbp), %rcx
movq -0x40(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
xorq $0x1, %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x359b01
movq 0x10(%rbp), %rax
movq -0x30(%rbp), %rcx
movq -0x48(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movq 0x10(%rbp), %rax
movq -0x30(%rbp), %rcx
movq -0x50(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
xorq $0x1, %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x359a82
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x58(%rbp), %rax
jae 0x359bd5
movq 0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jne 0x359bc5
movq 0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
jmp 0x359bc7
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x359b9e
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0x359c62
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
movq -0x38(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
movq -0x38(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
movl %eax, %eax
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq -0x48(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdx
movq -0x50(%rbp), %rcx
addq $0x1, %rcx
subq -0x48(%rbp), %rcx
movq 0x10(%rbp), %r8
movq 0x18(%rbp), %r9
callq 0x3588f0
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x359bdd
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax,%rax)