// File: /workspace/github_cpp_makefile_star2_O2/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, %r12
movq %rdi, %r15
movq 0x48(%rdi), %rax
xorl %ecx, %ecx
pushq $-0x1
popq %rbx
xorl %edx, %edx
movl %edx, %edx
cmpq %rdx, %rax
jbe 0x1b19b1
movq 0x10(%r15), %rsi
movq 0x58(%r15), %rdi
movl (%rdi,%rdx,4), %edi
shlq $0x5, %rdi
movq 0x8(%rsi,%rdi), %rsi
cmpq %rsi, %rcx
cmovbeq %rsi, %rcx
cmovbq %rdx, %rbx
incl %edx
jmp 0x1b1987
cmpq $-0x1, %rbx
je 0x1b1adc
movq (%r12), %rcx
movq (%rcx), %rdx
cmpq 0x8(%rcx), %rdx
movq %r12, (%rsp)
jne 0x1b19f8
leaq (%rdx,%rdx), %rax
testq %rdx, %rdx
pushq $0x2
popq %rdx
cmovneq %rax, %rdx
movq %rdx, 0x8(%rcx)
movq 0x10(%rcx), %rdi
imulq $0x28, %rdx, %rsi
callq 0x2370
movq (%r12), %rcx
movq %rax, 0x10(%rcx)
movq (%rcx), %rdx
jmp 0x1b19fc
movq 0x10(%rcx), %rax
leaq 0x1(%rdx), %rsi
movq %rsi, (%rcx)
imulq $0x28, %rdx, %rcx
andl $0x0, 0x10(%rax,%rcx)
movabsq $-0x100000000, %rdx     # imm = 0xFFFFFFFF00000000
movq %rdx, (%rax,%rcx)
orl $-0x1, 0x8(%rax,%rcx)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%rax,%rcx)
shlq $0x2, %rbx
addq 0x58(%r15), %rbx
leaq (%rax,%rcx), %r13
xorl %eax, %eax
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl (%rbx), %ebx
cmpq %rsi, %rbx
je 0x1b1aca
movq 0x10(%r15), %rcx
movq %rbx, %r12
shlq $0x5, %r12
orq 0x8(%rcx,%r12), %rax
je 0x1b1aca
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 0x1b1ab8
movl 0x10(%r13), %ecx
movq 0x18(%r13), %rax
cmpl 0xc(%r13), %ecx
jne 0x1b1aab
leal (%rcx,%rcx), %esi
testl %ecx, %ecx
pushq $0x2
popq %rcx
cmovel %ecx, %esi
movl %esi, 0xc(%r13)
shlq $0x3, %rsi
movq %rax, %rdi
callq 0x2370
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movq %rax, 0x18(%r13)
movl 0x10(%r13), %ecx
leal 0x1(%rcx), %edx
movl %edx, 0x10(%r13)
movl %ecx, %ecx
movq %rbx, (%rax,%rcx,8)
movq 0x10(%r15), %rax
leaq (%rax,%r12), %rbx
movq 0x8(%rax,%r12), %rax
jmp 0x1b1a3a
cmpl $0x0, 0x10(%r13)
movq (%rsp), %rax
jne 0x1b1adc
movq (%rax), %rax
andq $0x0, (%rax)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq