// File: 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
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0xa0, %rsp
movl 0x30(%rbp), %eax
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
movq %rdx, -0x28(%rbp)
movq %rcx, -0x30(%rbp)
movq %r8, -0x38(%rbp)
movq %r9, -0x40(%rbp)
movq $0x0, -0x50(%rbp)
movq $0x0, -0x58(%rbp)
movq $0x0, -0x48(%rbp)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
shlq %rax
movq %rax, -0x80(%rbp)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x68(%rbp)
movq $0x0, -0x58(%rbp)
movq -0x60(%rbp), %rax
movq -0x28(%rbp), %rcx
cmpq (%rcx), %rax
ja 0x35cb29
movq -0x60(%rbp), %rax
movq -0x28(%rbp), %rcx
cmpq (%rcx), %rax
je 0x35cab7
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x60(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movq -0x28(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x68(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
cmpq %rcx, %rax
je 0x35cb16
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq -0x68(%rbp), %rcx
movq -0x60(%rbp), %r8
movq 0x18(%rbp), %r9
movq 0x28(%rbp), %r14
movq 0x10(%rbp), %rbx
movq 0x20(%rbp), %r11
movl 0x30(%rbp), %eax
movl %eax, %r10d
leaq -0x58(%rbp), %rax
movq %r14, (%rsp)
movq %rbx, 0x8(%rsp)
movq %r11, 0x10(%rsp)
movq %r10, 0x18(%rsp)
movq %rax, 0x20(%rsp)
callq 0x35bbb0
movq -0x60(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x40(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x35cb18
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0x35ca6c
cmpq $0x0, -0x40(%rbp)
jne 0x35cb32
jmp 0x35cb51
leaq 0x3d0b3(%rip), %rdi     # 0x399bec
leaq 0x39679(%rip), %rsi     # 0x3961b9
movl $0x340c, %edx           # imm = 0x340C
leaq 0x3d0ac(%rip), %rcx     # 0x399bf8
callq 0x2130
cmpq $0x0, -0x58(%rbp)
jbe 0x35cd39
movq 0x28(%rbp), %rdi
movq -0x80(%rbp), %rdx
shlq $0x2, %rdx
xorl %esi, %esi
callq 0x2100
movq $0x0, -0x68(%rbp)
movq -0x68(%rbp), %rax
cmpq -0x58(%rbp), %rax
jae 0x35cc77
movq -0x48(%rbp), %rax
movq -0x68(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movq %rax, -0x70(%rbp)
movq -0x48(%rbp), %rax
movq -0x68(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, %eax
movq %rax, -0x78(%rbp)
movq -0x70(%rbp), %rax
cmpq -0x78(%rbp), %rax
jae 0x35cbb7
jmp 0x35cbd6
leaq 0x3caba(%rip), %rdi     # 0x399678
leaq 0x395f4(%rip), %rsi     # 0x3961b9
movl $0x3412, %edx           # imm = 0x3412
leaq 0x3d027(%rip), %rcx     # 0x399bf8
callq 0x2130
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
cmpq -0x78(%rbp), %rax
jae 0x35cc30
movq 0x28(%rbp), %rax
movq 0x18(%rbp), %rcx
movq -0x60(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movq 0x28(%rbp), %rax
movq 0x18(%rbp), %rcx
movq -0x60(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
xorq $0x1, %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0x35cbe2
movq 0x28(%rbp), %rax
movq 0x18(%rbp), %rcx
movq -0x70(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movq 0x28(%rbp), %rax
movq 0x18(%rbp), %rcx
movq -0x78(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
xorq $0x1, %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
jmp 0x35cb77
movq $0x0, -0x68(%rbp)
movq -0x68(%rbp), %rax
cmpq -0x80(%rbp), %rax
jae 0x35ccb6
movq 0x28(%rbp), %rax
movq -0x68(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jne 0x35cca6
movq 0x28(%rbp), %rax
movq -0x68(%rbp), %rcx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
jmp 0x35cca8
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
jmp 0x35cc7f
movq $0x0, -0x68(%rbp)
movq -0x30(%rbp), %rax
movq $0x0, (%rax)
movq -0x68(%rbp), %rax
cmpq -0x58(%rbp), %rax
jae 0x35cd37
movq -0x48(%rbp), %rax
movq -0x68(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movq %rax, -0x70(%rbp)
movq -0x48(%rbp), %rax
movq -0x68(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, %eax
movq %rax, -0x78(%rbp)
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq 0x18(%rbp), %rdx
movq -0x70(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdx
movq -0x78(%rbp), %rcx
addq $0x1, %rcx
subq -0x70(%rbp), %rcx
movq 0x28(%rbp), %r8
movq -0x30(%rbp), %r9
callq 0x3588f0
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
jmp 0x35ccc9
jmp 0x35cd39
movq -0x48(%rbp), %rdi
callq 0x2210
addq $0xa0, %rsp
popq %rbx
popq %r14
popq %rbp
retq
nop