// File: /workspace/github_cpp_makefile_star2_O3/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 %rcx, 0x20(%rsp)
movl %edx, 0x14(%rsp)
movq %rdi, %r13
movl $0xffffffff, 0x10(%rsp) # imm = 0xFFFFFFFF
testq %r8, %r8
je 0x20d6a9
movl $0x0, (%r8)
movq 0x60(%rsp), %rax
testq %r9, %r9
je 0x20d6ba
movl $0x0, (%r9)
movq 0x68(%rsp), %rcx
testq %rax, %rax
je 0x20d6ca
movl $0x0, (%rax)
testq %rcx, %rcx
je 0x20d6d5
movl $0x0, (%rcx)
orq %rcx, %rax
setne 0xf(%rsp)
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
movl 0x14(%rsp), %eax
movl %eax, %ebp
movq %r8, 0x18(%rsp)
movq %r9, %r12
testq %r8, %r8
je 0x20d6f9
incl (%r8)
movq %rsi, %rbx
movq 0x18(%rsi), %rdi
movl %ebp, %esi
leaq 0x10(%rsp), %rdx
movl $0x1, %ecx
callq 0x1efacc
movl %eax, %r15d
movq 0x20(%rsp), %rax
testq %rax, %rax
je 0x20d720
movl %ebp, (%rax)
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
movq %r12, %r9
je 0x20d776
movq (%rdi), %rcx
movq 0x10(%rdi), %rax
cmpq 0x8(%rdi), %rcx
jne 0x20d769
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%rdi)
shlq $0x3, %rsi
movq %rax, %rdi
callq 0x2370
movq 0x70(%rsp), %rdi
movq %r12, %r9
movq %rax, 0x10(%rdi)
movq (%rdi), %rcx
movl %ebp, %edx
leaq 0x1(%rcx), %rsi
movq %rsi, (%rdi)
movq %rdx, (%rax,%rcx,8)
testq %r9, %r9
je 0x20d78c
movl %ebp, %eax
shrl %eax
movq 0x248(%r13), %rcx
movl (%rcx,%rax,4), %eax
addl %eax, (%r9)
cmpb $0x0, 0xf(%rsp)
je 0x20d90e
movq 0x60(%rsp), %rdx
testq %rdx, %rdx
je 0x20d7b1
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 0x20d7cb
movq 0x288(%r13), %rax
movl %ebp, %ecx
shrl %ecx
movl (%rax,%rcx,4), %eax
addl %eax, (%rdx)
cmpl $-0x1, %r14d
je 0x20d90b
movq 0x260(%r13), %rcx
movl %r14d, %eax
shrl %eax
leaq (%rax,%rax,2), %rdx
testb $0x1, %r14b
jne 0x20d7f7
leaq (%rcx,%rdx,8), %rax
movq (%rax), %rsi
decq %rsi
jmp 0x20d7f9
xorl %esi, %esi
movl %ebp, %eax
shrl %eax
leaq (%rax,%rax,2), %r11
movl %ebp, %eax
andl $0x1, %eax
jne 0x20d80d
xorl %r8d, %r8d
jmp 0x20d817
leaq (%rcx,%r11,8), %r8
movq (%r8), %r8
decq %r8
movq 0x10(%rcx,%rdx,8), %rdx
shlq $0x4, %rsi
movl (%rdx,%rsi), %edx
movl %edx, %r10d
shrl %r10d
movq 0x208(%r13), %rsi
cmpq %r10, %rsi
jbe 0x20d90b
movq 0x10(%rcx,%r11,8), %rcx
shlq $0x4, %r8
movl (%rcx,%r8), %ecx
movl %ecx, %r11d
shrl %r11d
cmpq %r11, %rsi
jbe 0x20d90b
movq 0x278(%r13), %rsi
movq 0x20(%rsi), %r8
cmpl $0x0, (%r8,%r10,8)
js 0x20d90b
cmpl $0x0, (%r8,%r11,8)
js 0x20d90b
andl $0x1, %r14d
xorl %r14d, %edx
movq 0x28(%rsi), %r8
movl %edx, %edx
movq (%r8,%rdx,8), %rdx
movq %rdx, %r8
movl $0xffffffff, %r10d      # imm = 0xFFFFFFFF
andq %r10, %r8
je 0x20d90b
xorl %eax, %ecx
movq 0x8(%rsi), %rax
shrq $0x20, %rdx
leaq (%rdx,%rdx,2), %rdx
leaq (%rax,%rdx,8), %rsi
addq $0x10, %rsi
shlq $0x3, %r8
leaq (%r8,%r8,2), %r8
xorl %r10d, %r10d
cmpl %ecx, -0x8(%rsi,%r10)
je 0x20d8c8
addq $0x18, %r10
cmpq %r10, %r8
jne 0x20d8b6
jmp 0x20d90b
leaq (%rax,%rdx,8), %rax
movzwl 0x10(%r10,%rax), %eax
andl $0x3fff, %eax           # imm = 0x3FFF
cmpq $0x0, 0x60(%rsp)
je 0x20d8ea
movq 0x60(%rsp), %rcx
cmpw $0x2, %ax
je 0x20d909
cmpw $0x2, %ax
sete %cl
cmpw $0x3, %ax
setne %al
movq 0x68(%rsp), %rdx
testq %rdx, %rdx
je 0x20d90b
xorb %al, %cl
movq %rdx, %rcx
je 0x20d90b
incl (%rcx)
movl %ebp, %r14d
testl %r15d, %r15d
je 0x20d9a3
cmpl $0x2, %r15d
je 0x20d9c1
ja 0x20d9ab
movq %rbx, %rsi
movq 0x18(%rbx), %rcx
movq 0x8(%rcx), %rax
movl 0x10(%rsp), %edx
leaq (%rdx,%rdx,2), %rdx
movl 0x8(%rax,%rdx,8), %ebp
movl %ebp, 0x10(%rsp)
movq %rbp, %rdx
xorq $0x1, %rdx
movq 0x28(%rcx), %rcx
movq (%rcx,%rdx,8), %rcx
movq %rcx, %rdx
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
andq %r8, %rdx
movq 0x18(%rsp), %r8
je 0x20d991
shrq $0x20, %rcx
xorl %r10d, %r10d
movl %ecx, %r11d
leaq (%r11,%r11,2), %r11
movl 0xc(%rax,%r11,8), %r11d
notl %r11d
shrl $0x1f, %r11d
addl %r11d, %r10d
incq %rcx
decq %rdx
jne 0x20d96b
cmpl $0x2, %r10d
je 0x20d9b3
ja 0x20d9bb
cmpl 0x14(%rsp), %ebp
jne 0x20d6ee
movl $0x7, %r15d
jmp 0x20d9c1
movl $0x5, %r15d
jmp 0x20d9c1
movl $0x4, %r15d
jmp 0x20d9c1
movl $0x1, %r15d
jmp 0x20d9c1
movl $0x3, %r15d
movl %r15d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq