// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: get_ul_path_info(ul_resolve_t*, ma_ug_t*, unsigned int, unsigned int*, unsigned int*, unsigned int*, unsigned int*, unsigned int*, asg64_v*)
uint32_t get_ul_path_info(ul_resolve_t *uidx, ma_ug_t *ug, uint32_t s, uint32_t *e, uint32_t *occ, 
uint32_t *ul_cnt, uint32_t *bridge_w, uint32_t *bridge_am, asg64_v *b)
{
    uint32_t v = s, w = (uint32_t)-1, kv, kw, uv = (uint32_t)-1, uw = (uint32_t)-1, bv, bw, l; 
    ul_bg_t *bg = &(uidx->uovl.bg); 
    if(occ) (*occ) = 0; if(ul_cnt) (*ul_cnt) = 0; if(bridge_w) (*bridge_w) = 0; if(bridge_am) (*bridge_am) = 0;

    while (1) {
        if(occ) (*occ)++;
        kv = get_arcs(ug->g, v, &w, 1);        
        if(e) (*e) = v;

        ///if(b) kv_push(uint32_t, b->b, v>>1);
        if(b) kv_push(uint64_t, *b, v);
        if(ul_cnt) (*ul_cnt) += get_ul_occ(uidx, v>>1);
        if(bridge_w || bridge_am) {
            uw = v; 
            if(bridge_w) (*bridge_w) += bg->w_n[v>>1];
            if(bridge_am) (*bridge_am) += bg->a_n[v>>1];
            if(uv != (uint32_t)-1) {
                bv = uidx->uovl.cc.iug_a[uv>>1].a[((uv&1)?(0):(uidx->uovl.cc.iug_a[uv>>1].n-1))].v; if(uv&1) bv ^= 1;
                bw = uidx->uovl.cc.iug_a[uw>>1].a[((uw&1)?(uidx->uovl.cc.iug_a[uw>>1].n-1):(0))].v; if(uw&1) bw ^= 1;
                if((ulg_type(uidx->uovl, (bv>>1))) && (ulg_type(uidx->uovl, (bw>>1)))) {
                    l = get_bg_flag(uidx, bv, bw);
                    if(l == bg_wrong && bridge_w) (*bridge_w)++;
                    if(l == bg_ambiguous && bridge_am) (*bridge_am)++;
                }
            }
            uv = uw;
        }

        if(kv == 0) return END_TIPS;
        if(kv == 2) return TWO_OUTPUT;
        if(kv > 2) return MUL_OUTPUT;
        w = ug->g->arc[w].v;
        ///up to here, kv=1
        ///kw must >= 1
        kw = get_arcs(ug->g, w^1, NULL, 0);
        v = w;

        if(kw == 2) return TWO_INPUT;
        if(kw > 2) return MUL_INPUT;
        if(v == s) return LOOP;
    }

    return LONG_TIPS;  
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r8, %r12
movq %rcx, 0x20(%rsp)
movl %edx, 0xc(%rsp)
movq %rsi, 0x18(%rsp)
movq %rdi, %r13
orl $-0x1, 0x8(%rsp)
testq %r8, %r8
je 0x1c0ca8
andl $0x0, (%r12)
movq 0x60(%rsp), %rax
testq %r9, %r9
je 0x1c0cb6
andl $0x0, (%r9)
movq 0x68(%rsp), %rcx
testq %rax, %rax
je 0x1c0cc3
andl $0x0, (%rax)
movq %r9, 0x10(%rsp)
testq %rcx, %rcx
je 0x1c0cd0
andl $0x0, (%rcx)
movq 0x70(%rsp), %rbx
orq %rcx, %rax
setne 0x7(%rsp)
pushq $-0x1
popq %r14
movl 0xc(%rsp), %ebp
testq %r12, %r12
je 0x1c0cee
incl (%r12)
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rdi
movl %ebp, %esi
leaq 0x8(%rsp), %rdx
pushq $0x1
popq %rcx
callq 0x1a5422
movl %eax, %r15d
movq 0x20(%rsp), %rax
testq %rax, %rax
je 0x1c0d15
movl %ebp, (%rax)
testq %rbx, %rbx
movq 0x10(%rsp), %rdi
je 0x1c0d63
movq (%rbx), %rcx
movq 0x10(%rbx), %rax
cmpq 0x8(%rbx), %rcx
jne 0x1c0d56
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%rbx)
shlq $0x3, %rsi
movq %rax, %rdi
callq 0x2370
movq 0x10(%rsp), %rdi
movq %rax, 0x10(%rbx)
movq (%rbx), %rcx
movl %ebp, %edx
leaq 0x1(%rcx), %rsi
movq %rsi, (%rbx)
movq %rdx, (%rax,%rcx,8)
testq %rdi, %rdi
je 0x1c0d78
movl %ebp, %eax
shrl %eax
movq 0x248(%r13), %rcx
movl (%rcx,%rax,4), %eax
addl %eax, (%rdi)
cmpb $0x0, 0x7(%rsp)
je 0x1c0ddb
movq 0x60(%rsp), %rdx
testq %rdx, %rdx
je 0x1c0d99
movq 0x280(%r13), %rax
movl %ebp, %ecx
shrl %ecx
movl (%rax,%rcx,4), %eax
addl %eax, (%rdx)
movq 0x68(%rsp), %rdx
testq %rdx, %rdx
je 0x1c0db3
movq 0x288(%r13), %rax
movl %ebp, %ecx
shrl %ecx
movl (%rax,%rcx,4), %eax
addl %eax, (%rdx)
cmpl $-0x1, %r14d
je 0x1c0dde
movq 0x260(%r13), %rax
movl %r14d, %ecx
shrl %ecx
imulq $0x18, %rcx, %rdx
testb $0x1, %r14b
jne 0x1c0e4a
leaq (%rax,%rdx), %rcx
movq (%rcx), %rsi
decq %rsi
jmp 0x1c0e4c
movl %r14d, %ebp
testl %r15d, %r15d
je 0x1c0ee5
cmpl $0x2, %r15d
je 0x1c0ee9
ja 0x1c0eee
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x8(%rdi), %rax
movl 0x8(%rsp), %ecx
imulq $0x18, %rcx, %rcx
movl 0x8(%rax,%rcx), %r15d
movl %r15d, 0x8(%rsp)
movl %r15d, %esi
xorl $0x1, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x1a5422
cmpl $0x2, %eax
je 0x1c0ef2
ja 0x1c0ef6
movl %ebp, %r14d
movl %r15d, %ebp
cmpl 0xc(%rsp), %r15d
jne 0x1c0ce5
jmp 0x1c0efa
xorl %esi, %esi
movl %ebp, %ecx
shrl %ecx
imulq $0x18, %rcx, %rdi
movl %ebp, %ecx
andl $0x1, %ecx
jne 0x1c0e60
xorl %r8d, %r8d
jmp 0x1c0e6a
leaq (%rax,%rdi), %r8
movq (%r8), %r8
decq %r8
movq 0x10(%rax,%rdx), %rdx
shlq $0x4, %rsi
movl (%rdx,%rsi), %esi
movl %esi, %edx
shrl %edx
movq 0x208(%r13), %r9
cmpq %rdx, %r9
jbe 0x1c0dde
movq 0x10(%rax,%rdi), %rax
shlq $0x4, %r8
movl (%rax,%r8), %edx
movl %edx, %eax
shrl %eax
cmpq %rax, %r9
jbe 0x1c0dde
andl $0x1, %r14d
xorl %r14d, %esi
xorl %ecx, %edx
movq %r13, %rdi
callq 0x1dedb7
cmpq $0x0, 0x60(%rsp)
je 0x1c0ec7
movq 0x60(%rsp), %rcx
cmpl $0x2, %eax
je 0x1c0ede
movq 0x68(%rsp), %rcx
testq %rcx, %rcx
je 0x1c0dde
cmpl $0x3, %eax
jne 0x1c0dde
incl (%rcx)
jmp 0x1c0dde
pushq $0x5
jmp 0x1c0efc
movl %r15d, %eax
jmp 0x1c0efd
pushq $0x4
jmp 0x1c0efc
pushq $0x1
jmp 0x1c0efc
pushq $0x3
jmp 0x1c0efc
pushq $0x7
popq %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq