// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: extract_paths(ubuf_t*, ma_utg_v*, ul_path_t*, unsigned int, unsigned int)
void extract_paths(ubuf_t *b, ma_utg_v *gu, ul_path_t *res, uint32_t src, uint32_t dest)
{
    uint32_t i, v; uinfo_t *t; uint64_t m = 0, mi = (uint64_t)-1, avn; ///kv_resize(uinfo_srt_t, b->srt, b->b.n); b->srt.n = b->b.n;
    for (i = 0; i < b->b.n; ++i) { // clear the states of visited vertices
        t = &b->a.a[b->b.a[i]]; ///memset(t, 0, sizeof(*(t)));
        //b->srt.a[i].c = ((uint64_t)-1) - t->c; b->srt.a[i].i = i;
        if(m < t->c) {
            m = t->c; mi = i; ///b->b.a[i];
        }
    }
    //radix_sort_uinfo_srt_t_c(b->srt.a, b->srt.a + b->srt.n);
    // fprintf(stderr, "\n[M::%s::]->beg\n", __func__);
    if(mi != (uint64_t)-1) {
        ma_utg_t *p; kv_pushp(ma_utg_t, res->buf_ug->u, &p); 
        p->len = p->circ = p->n = 0; p->start = p->end = UINT32_MAX; p->a = NULL; p->s = NULL;
        for(v = b->b.a[mi], avn = 0; v != (uint32_t)-1; v = b->a.a[v].p) {
            if(b->a.a[v].c == 0 && avn == 0) break;
            b->us.a[v>>1] = 1; 
            if(v != src && v != dest) kv_push(uint64_t, (*p), v); 
            // fprintf(stderr, "[M::%s::] utg%.6d%c(%c)\tC::%lu\n", __func__, (v>>1)+1, "lc"[gu->a[v>>1].circ], "+-"[v&1], b->a.a[v].c);
            avn = b->a.a[v].c;
        }

        if(p->n == 0) res->buf_ug->u.n = 0;
    }
}

// Assembly:
movq 0x48(%rdi), %rax
testq %rax, %rax
je 0x1fd971
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %r8d, %ebp
movl %ecx, %r14d
movq %rdx, %rbx
movq %rdi, %r15
movq 0x10(%rdi), %rcx
movq 0x58(%rdi), %rdx
movq $-0x1, %r12
xorl %esi, %esi
xorl %edi, %edi
movl (%rdx,%rsi,4), %r8d
shlq $0x5, %r8
movq 0x8(%rcx,%r8), %r8
cmpq %r8, %rdi
cmovbeq %r8, %rdi
cmovbq %rsi, %r12
incq %rsi
movl %esi, %r8d
cmpq %r8, %rax
ja 0x1fd804
cmpq $-0x1, %r12
je 0x1fd963
movq (%rbx), %rcx
movq (%rcx), %rdx
cmpq 0x8(%rcx), %rdx
jne 0x1fd86e
leaq (%rdx,%rdx), %rax
testq %rdx, %rdx
movl $0x2, %edx
cmovneq %rax, %rdx
movq %rdx, 0x8(%rcx)
movq 0x10(%rcx), %rdi
shlq $0x3, %rdx
leaq (%rdx,%rdx,4), %rsi
callq 0x2370
movq (%rbx), %rcx
movq %rax, 0x10(%rcx)
movq (%rcx), %rdx
jmp 0x1fd872
movq 0x10(%rcx), %rax
leaq 0x1(%rdx), %rsi
movq %rsi, (%rcx)
leaq (%rdx,%rdx,4), %rdx
movl $0x0, 0x10(%rax,%rdx,8)
movabsq $-0x100000000, %rcx     # imm = 0xFFFFFFFF00000000
movq %rcx, (%rax,%rdx,8)
movl $0xffffffff, 0x8(%rax,%rdx,8) # imm = 0xFFFFFFFF
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%rax,%rdx,8)
movq 0x58(%r15), %rcx
movl (%rcx,%r12,4), %ecx
cmpl $-0x1, %ecx
je 0x1fd959
movq %rbx, (%rsp)
leaq (%rax,%rdx,8), %r12
movq 0x10(%r15), %rax
xorl %edx, %edx
movl %ecx, %ebx
movq %rbx, %r13
shlq $0x5, %r13
orq 0x8(%rax,%r13), %rdx
je 0x1fd94d
movq 0x88(%r15), %rax
movl %ebx, %ecx
shrl %ecx
movb $0x1, (%rax,%rcx)
cmpl %r14d, %ebx
sete %al
cmpl %ebp, %ebx
sete %cl
orb %al, %cl
jne 0x1fd937
movl 0x10(%r12), %ecx
movq 0x18(%r12), %rax
cmpl 0xc(%r12), %ecx
jne 0x1fd929
leal (%rcx,%rcx), %esi
testl %ecx, %ecx
movl $0x2, %ecx
cmovel %ecx, %esi
movl %esi, 0xc(%r12)
shlq $0x3, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x18(%r12)
movl 0x10(%r12), %ecx
leal 0x1(%rcx), %edx
movl %edx, 0x10(%r12)
movl %ecx, %ecx
movq %rbx, (%rax,%rcx,8)
movq 0x10(%r15), %rax
movq 0x8(%rax,%r13), %rdx
movl (%rax,%r13), %ecx
cmpl $-0x1, %ecx
jne 0x1fd8c2
cmpl $0x0, 0x10(%r12)
movq (%rsp), %rbx
jne 0x1fd963
movq (%rbx), %rax
movq $0x0, (%rax)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq