// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: new_path_ext(ul_resolve_t*, usg_t*, asg64_v*, asg64_v*, unsigned long, unsigned long, unsigned long*, unsigned long*, unsigned char*, unsigned int*, unsigned int)
void new_path_ext(ul_resolve_t *uidx, usg_t *ng, asg64_v *b64, asg64_v *ub64, uint64_t a_n, uint64_t n_clus, uint64_t *i_idx, uint64_t *int_a, 
uint8_t *ff, uint32_t *ng_occ, uint32_t max_ext)
{
    asg64_v res; kv_init(res); uint64_t k, i, s, e, nvtx = ng->n<<1;
    for (k = a_n + 1, i = a_n, res.n = 0; k <= b64->n; k++) {
        if(k == b64->n || (b64->a[k]>>32) != (b64->a[i]>>32)) {
            update_thread_path(ng, b64, ub64, i, k, int_a, ng_occ, i_idx, ff, max_ext, &res);
            i = k; n_clus--;
        }
    }
    assert(n_clus == 0);
    

    if(res.n > 0) {
        memset(ng_occ, 0, sizeof((*ng_occ))*nvtx);
        for (i = 0; i < res.n; i++) {
            s = res.a[i]>>32; e = ((uint32_t)res.a[i]); assert(s < e);
            for (k = s + 1; k < e; k++) {///note: here is [s, e]
                ng_occ[int_a[k]]++; ng_occ[int_a[k]^1]++; 
            }
            ng_occ[int_a[s]]++; ng_occ[int_a[e]^1]++;
        }
        for (i = 0; i < nvtx; i++) {
            if(!ng_occ[i]) ng_occ[i] = (uint32_t)-1;        
        }

        for (i = 0, ub64->n = 0; i < res.n; i++) {
            s = res.a[i]>>32; e = ((uint32_t)res.a[i]); 
            update_usg_t_threading_0(uidx, ng, int_a + s, e + 1 - s, ng_occ, ub64);
        }
    }
    kv_destroy(res);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %r9, %r13
movq %rcx, %r9
movl 0xc0(%rsp), %ecx
movq 0xb8(%rsp), %r15
movq 0xb0(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0xa8(%rsp), %r12
xorps %xmm0, %xmm0
movups %xmm0, 0x58(%rsp)
movq 0x8(%rsi), %rax
movq %rax, 0x40(%rsp)
movq $0x0, 0x50(%rsp)
leaq 0x1(%r8), %rbx
movq (%rdx), %rax
cmpq %rax, %rbx
movq %r9, %r14
movq %rsi, 0x38(%rsp)
ja 0x21c133
movq %rdx, %rbp
movq %rsi, %rdi
movl %ecx, %ecx
movq %rcx, 0x48(%rsp)
cmpq %rax, %rbx
je 0x21c0e3
movq 0x10(%rbp), %rcx
movq (%rcx,%r8,8), %rdx
xorq (%rcx,%rbx,8), %rdx
shrq $0x20, %rdx
je 0x21c12b
leaq 0x50(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x48(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
movq %r15, (%rsp)
movq %rbp, %rsi
movq %r9, %rdx
movq %r8, %rcx
movq %rbx, %r8
movq %r12, %r9
callq 0x21b80d
movq 0x38(%rsp), %rdi
movq %r14, %r9
decq %r13
movq (%rbp), %rax
movq %rbx, %r8
incq %rbx
cmpq %rax, %rbx
jbe 0x21c0cc
testq %r13, %r13
jne 0x21c24f
movq 0x50(%rsp), %rbx
movq 0x60(%rsp), %r13
testq %rbx, %rbx
je 0x21c21a
movq 0x40(%rsp), %rdx
leaq (%rdx,%rdx), %rax
movq %rax, 0x30(%rsp)
shlq $0x3, %rdx
xorl %ebp, %ebp
movq %r15, %rdi
xorl %esi, %esi
callq 0x20e0
movq (%r13,%rbp,8), %rcx
movl %ecx, %eax
shrq $0x20, %rcx
cmpq %rax, %rcx
jae 0x21c230
leaq 0x1(%rcx), %rdx
cmpq %rax, %rdx
jae 0x21c1a2
movq (%r12,%rdx,8), %rsi
incl (%r15,%rsi,4)
xorq $0x1, %rsi
incl (%r15,%rsi,4)
incq %rdx
cmpq %rdx, %rax
jne 0x21c18a
movq (%r12,%rcx,8), %rcx
incl (%r15,%rcx,4)
movq (%r12,%rax,8), %rax
xorq $0x1, %rax
incl (%r15,%rax,4)
incq %rbp
cmpq %rbx, %rbp
jne 0x21c16d
movq 0x30(%rsp), %rdx
testq %rdx, %rdx
movq %r14, %rcx
je 0x21c1e4
xorl %eax, %eax
cmpl $0x0, (%r15,%rax,4)
jne 0x21c1dc
movl $0xffffffff, (%r15,%rax,4) # imm = 0xFFFFFFFF
incq %rax
cmpq %rax, %rdx
jne 0x21c1cd
movq $0x0, (%rcx)
xorl %ebp, %ebp
movq (%r13,%rbp,8), %rax
movl %eax, %ecx
shrq $0x20, %rax
leaq (%r12,%rax,8), %rdx
subq %rax, %rcx
incq %rcx
movq 0x38(%rsp), %rsi
movq %r15, %r8
movq %r14, %r9
callq 0x219ad4
incq %rbp
cmpq %rbp, %rbx
jne 0x21c1ed
movq %r13, %rdi
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2220
leaq 0x2c751(%rip), %rdi     # 0x248988
leaq 0x293cb(%rip), %rsi     # 0x245609
leaq 0x2ccc3(%rip), %rcx     # 0x248f08
movl $0x3412, %edx           # imm = 0x3412
callq 0x2110
leaq 0x2cca6(%rip), %rdi     # 0x248efc
leaq 0x293ac(%rip), %rsi     # 0x245609
leaq 0x2cca4(%rip), %rcx     # 0x248f08
movl $0x340c, %edx           # imm = 0x340C
callq 0x2110