// File: 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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movq $0x0, -0x38(%rbp)
movq $-0x1, -0x40(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpq 0x48(%rcx), %rax
jae 0x325cbe
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x58(%rcx), %rcx
movl -0x24(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x38(%rbp), %rax
movq -0x30(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jae 0x325cb1
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x38(%rbp)
movl -0x24(%rbp), %eax
movq %rax, -0x40(%rbp)
jmp 0x325cb3
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x325c62
cmpq $-0x1, -0x40(%rbp)
je 0x325f1b
jmp 0x325ccb
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
movq (%rcx), %rcx
cmpq 0x8(%rcx), %rax
jne 0x325d48
movq -0x18(%rbp), %rax
movq (%rax), %rax
cmpq $0x0, 0x8(%rax)
je 0x325d04
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
shlq %rax
movq %rax, -0x58(%rbp)
jmp 0x325d0f
movl $0x2, %eax
movq %rax, -0x58(%rbp)
jmp 0x325d0f
movq -0x58(%rbp), %rcx
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rax
imulq $0x28, 0x8(%rax), %rsi
callq 0x2360
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rcx, 0x10(%rax)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rcx
movq (%rcx), %rdx
movq (%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, (%rdx)
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movl $0x0, 0x10(%rax)
movq -0x50(%rbp), %rax
movl (%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
orl $0x0, %ecx
movl %ecx, (%rax)
movq -0x50(%rbp), %rax
movl (%rax), %ecx
andl $0x80000000, %ecx       # imm = 0x80000000
orl $0x0, %ecx
movl %ecx, (%rax)
movq -0x50(%rbp), %rax
movl $0xffffffff, 0x8(%rax)  # imm = 0xFFFFFFFF
movq -0x50(%rbp), %rax
movl $0xffffffff, 0x4(%rax)  # imm = 0xFFFFFFFF
movq -0x50(%rbp), %rax
movq $0x0, 0x18(%rax)
movq -0x50(%rbp), %rax
movq $0x0, 0x20(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x40(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x28(%rbp)
movq $0x0, -0x48(%rbp)
cmpl $-0x1, -0x28(%rbp)
je 0x325f01
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x28(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
cmpq $0x0, 0x8(%rax)
jne 0x325e16
cmpq $0x0, -0x48(%rbp)
jne 0x325e16
jmp 0x325f01
movq -0x8(%rbp), %rax
movq 0x88(%rax), %rax
movl -0x28(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movb $0x1, (%rax,%rcx)
movl -0x28(%rbp), %eax
cmpl -0x1c(%rbp), %eax
je 0x325ecb
movl -0x28(%rbp), %eax
cmpl -0x20(%rbp), %eax
je 0x325ecb
jmp 0x325e46
movq -0x50(%rbp), %rax
movl 0x10(%rax), %eax
movq -0x50(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jne 0x325ea7
movq -0x50(%rbp), %rax
cmpl $0x0, 0xc(%rax)
je 0x325e6e
movq -0x50(%rbp), %rax
movl 0xc(%rax), %eax
shll %eax
movl %eax, -0x5c(%rbp)
jmp 0x325e78
movl $0x2, %eax
movl %eax, -0x5c(%rbp)
jmp 0x325e78
movl -0x5c(%rbp), %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x50(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x50(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, %esi
shlq $0x3, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x18(%rax)
movl -0x28(%rbp), %eax
movl %eax, %edx
movq -0x50(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x50(%rbp), %rsi
movl 0x10(%rsi), %ecx
movl %ecx, %edi
addl $0x1, %edi
movl %edi, 0x10(%rsi)
movl %ecx, %ecx
movq %rdx, (%rax,%rcx,8)
jmp 0x325ecb
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x28(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x28(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, -0x28(%rbp)
jmp 0x325de7
movq -0x50(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jne 0x325f19
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq $0x0, (%rax)
jmp 0x325f1b
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)