// File: /workspace/github_cpp_makefile_star2_O1/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:
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 0x48(%rdi), %rax
testq %rax, %rax
je 0x1f229b
movq 0x10(%r15), %rcx
movq 0x58(%r15), %rdx
movq $-0x1, %r13
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, %r13
incq %rsi
movl %esi, %r8d
cmpq %r8, %rax
ja 0x1f2276
jmp 0x1f22a2
movq $-0x1, %r13
cmpq $-0x1, %r13
je 0x1f23e2
movq (%rbx), %rax
movq 0x8(%rax), %rcx
cmpq %rcx, (%rax)
jne 0x1f22e4
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
movl $0x2, %ecx
cmovneq %rdx, %rcx
movq %rcx, 0x8(%rax)
movq 0x10(%rax), %rdi
shlq $0x3, %rcx
leaq (%rcx,%rcx,4), %rsi
callq 0x2370
movq (%rbx), %rcx
movq %rax, 0x10(%rcx)
movq %rbx, (%rsp)
movq (%rbx), %rax
movq (%rax), %rcx
movq 0x10(%rax), %rdx
leaq 0x1(%rcx), %rsi
movq %rsi, (%rax)
leaq (%rcx,%rcx,4), %rax
leaq (%rdx,%rax,8), %r12
movl $0x0, 0x10(%r12)
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
movq %rax, (%r12)
movl $0xffffffff, 0x8(%r12)  # imm = 0xFFFFFFFF
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%r12)
movq 0x58(%r15), %rax
movl (%rax,%r13,4), %ecx
cmpl $-0x1, %ecx
je 0x1f23cc
xorl %eax, %eax
movq 0x10(%r15), %rdx
movl %ecx, %ebx
movq %rbx, %r13
shlq $0x5, %r13
orq 0x8(%rdx,%r13), %rax
je 0x1f23cc
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 0x1f23b6
movl 0xc(%r12), %eax
cmpl %eax, 0x10(%r12)
jne 0x1f23a0
leal (%rax,%rax), %esi
testl %eax, %eax
movl $0x2, %eax
cmovel %eax, %esi
movl %esi, 0xc(%r12)
movq 0x18(%r12), %rdi
shlq $0x3, %rsi
callq 0x2370
movq %rax, 0x18(%r12)
movq 0x18(%r12), %rax
movl 0x10(%r12), %ecx
leal 0x1(%rcx), %edx
movl %edx, 0x10(%r12)
movq %rbx, (%rax,%rcx,8)
movq 0x10(%r15), %rcx
movq 0x8(%rcx,%r13), %rax
movl (%rcx,%r13), %ecx
cmpl $-0x1, %ecx
jne 0x1f233d
cmpl $0x0, 0x10(%r12)
movq (%rsp), %rax
jne 0x1f23e2
movq (%rax), %rax
movq $0x0, (%rax)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq