// File: /workspace/github_cpp_makefile_star2_O1/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, 0x8(%rsp)
movl $0xffffffff, 0x4(%rsp)  # imm = 0xFFFFFFFF
testq %r8, %r8
je 0x202040
movl $0x0, (%r8)
movq 0x60(%rsp), %r13
testq %r9, %r9
je 0x202051
movl $0x0, (%r9)
movq 0x68(%rsp), %rbx
testq %r13, %r13
je 0x202063
movl $0x0, (%r13)
testq %rbx, %rbx
je 0x20206e
movl $0x0, (%rbx)
movq %r13, %rax
orq %rbx, %rax
setne 0x3(%rsp)
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
movl 0x8(%rsp), %eax
movl %eax, %ebp
movq %r8, 0x10(%rsp)
movq %rsi, 0x18(%rsp)
movl %r14d, 0xc(%rsp)
movq %rbx, %r14
movq %r13, %rbx
movq %rdi, %r13
movq %r9, %r12
testq %r8, %r8
je 0x2020a8
incl (%r8)
movq 0x18(%rsi), %rdi
movl %ebp, %esi
leaq 0x4(%rsp), %rdx
movl $0x1, %ecx
callq 0x1e50d4
movl %eax, %r15d
movq 0x20(%rsp), %rax
testq %rax, %rax
je 0x2020cc
movl %ebp, (%rax)
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
movq %r12, %r9
je 0x202128
movq 0x8(%rdi), %rax
cmpq %rax, (%rdi)
jne 0x202114
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x8(%rdi)
movq 0x70(%rsp), %rax
movq 0x10(%rax), %rdi
shlq $0x3, %rsi
callq 0x2370
movq 0x70(%rsp), %rdi
movq %r12, %r9
movq %rax, 0x10(%rdi)
movl %ebp, %eax
movq (%rdi), %rcx
movq 0x10(%rdi), %rdx
leaq 0x1(%rcx), %rsi
movq %rsi, (%rdi)
movq %rax, (%rdx,%rcx,8)
testq %r9, %r9
movq %r13, %rdi
je 0x202141
movl %ebp, %eax
shrl %eax
movq 0x248(%rdi), %rcx
movl (%rcx,%rax,4), %eax
addl %eax, (%r9)
cmpb $0x0, 0x3(%rsp)
movq %rbx, %r13
je 0x2021ab
testq %r13, %r13
movq %r14, %rbx
je 0x202165
movq 0x280(%rdi), %rax
movl %ebp, %ecx
shrl %ecx
movl (%rax,%rcx,4), %eax
addl %eax, (%r13)
testq %rbx, %rbx
movl 0xc(%rsp), %r14d
je 0x20217f
movq 0x288(%rdi), %rax
movl %ebp, %ecx
shrl %ecx
movl (%rax,%rcx,4), %eax
addl %eax, (%rbx)
cmpl $-0x1, %r14d
je 0x2022ed
movq 0x260(%rdi), %rax
movl %r14d, %ecx
shrl %ecx
leaq (%rcx,%rcx,2), %rcx
testb $0x1, %r14b
jne 0x2021b8
leaq (%rax,%rcx,8), %rdx
movq (%rdx), %rsi
decq %rsi
jmp 0x2021ba
movq %r14, %rbx
movl 0xc(%rsp), %r14d
jmp 0x2022f0
xorl %esi, %esi
movl %ebp, %edx
shrl %edx
leaq (%rdx,%rdx,2), %r12
movl %ebp, %edx
andl $0x1, %edx
jne 0x2021ce
xorl %r8d, %r8d
jmp 0x2021d8
leaq (%rax,%r12,8), %r8
movq (%r8), %r8
decq %r8
movq 0x10(%rax,%rcx,8), %rcx
shlq $0x4, %rsi
movl (%rcx,%rsi), %esi
movl %esi, %r11d
shrl %r11d
movq 0x208(%rdi), %r10
cmpq %r11, %r10
jbe 0x2022ed
movq 0x10(%rax,%r12,8), %rax
shlq $0x4, %r8
movl (%rax,%r8), %ecx
movl %ecx, %r8d
shrl %r8d
cmpq %r8, %r10
jbe 0x2022ed
movq 0x278(%rdi), %r12
movq 0x20(%r12), %r10
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl $0x0, (%r10,%r11,8)
js 0x2022d3
cmpl $0x0, (%r10,%r8,8)
js 0x2022d3
andl $0x1, %r14d
xorl %r14d, %esi
movq 0x28(%r12), %r8
movl %esi, %esi
movq (%r8,%rsi,8), %rsi
movq %rsi, %r8
shlq $0x20, %r8
setne %r8b
je 0x2022d3
xorl %edx, %ecx
movq 0x8(%r12), %r11
movq %rsi, %rdx
shrq $0x20, %rdx
leaq (%rdx,%rdx,2), %r10
leaq (%r11,%r10,8), %rdx
cmpl %ecx, 0x8(%rdx)
jne 0x20227b
xorl %esi, %esi
jmp 0x2022a7
movl %esi, %r14d
leaq (%r11,%r10,8), %r11
addq $0x20, %r11
leaq -0x1(%r14), %r8
xorl %esi, %esi
cmpq %rsi, %r8
je 0x2022d3
leaq 0x18(%r11), %r10
incq %rsi
cmpl %ecx, (%r11)
movq %r10, %r11
jne 0x20228c
cmpq %r14, %rsi
setb %r8b
testb %r8b, %r8b
je 0x2022d3
leaq (%rsi,%rsi,2), %rax
movzwl 0x10(%rdx,%rax,8), %ecx
andl $0x3fff, %ecx           # imm = 0x3FFF
xorl %eax, %eax
cmpw $0x2, %cx
sete %al
xorl $0x3, %eax
cmpw $0x3, %cx
movl $0x1, %ecx
cmovel %ecx, %eax
testq %r13, %r13
je 0x2022e1
cmpl $0x2, %eax
jne 0x2022e1
incl (%r13)
testq %rbx, %rbx
je 0x2022ed
cmpl $0x3, %eax
jne 0x2022ed
incl (%rbx)
movl %ebp, %r14d
testl %r15d, %r15d
je 0x202391
cmpl $0x2, %r15d
je 0x2023af
ja 0x202399
movq 0x18(%rsp), %rsi
movq 0x18(%rsi), %rcx
movq 0x8(%rcx), %rax
movl 0x4(%rsp), %edx
leaq (%rdx,%rdx,2), %rdx
movl 0x8(%rax,%rdx,8), %ebp
movl %ebp, 0x4(%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
je 0x20236f
shrq $0x20, %rcx
xorl %r10d, %r10d
movq 0x10(%rsp), %r8
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 0x20234f
jmp 0x202377
xorl %r10d, %r10d
movq 0x10(%rsp), %r8
cmpl $0x2, %r10d
je 0x2023a1
ja 0x2023a9
cmpl 0x8(%rsp), %ebp
jne 0x20208f
movl $0x7, %r15d
jmp 0x2023af
movl $0x5, %r15d
jmp 0x2023af
movl $0x4, %r15d
jmp 0x2023af
movl $0x1, %r15d
jmp 0x2023af
movl $0x3, %r15d
movl %r15d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq