// File: 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
movq %rsp, %rbp
subq $0x90, %rsp
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl $0xffffffff, -0x40(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x4c(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x50(%rbp) # imm = 0xFFFFFFFF
movq -0x10(%rbp), %rax
addq $0x1f0, %rax            # imm = 0x1F0
addq $0x88, %rax
movq %rax, -0x68(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x34489e
movq -0x30(%rbp), %rax
movl $0x0, (%rax)
cmpq $0x0, -0x38(%rbp)
je 0x3448af
movq -0x38(%rbp), %rax
movl $0x0, (%rax)
cmpq $0x0, 0x10(%rbp)
je 0x3448c0
movq 0x10(%rbp), %rax
movl $0x0, (%rax)
cmpq $0x0, 0x18(%rbp)
je 0x3448d1
movq 0x18(%rbp), %rax
movl $0x0, (%rax)
jmp 0x3448d3
cmpq $0x0, -0x30(%rbp)
je 0x3448e5
movq -0x30(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rdi
movl -0x3c(%rbp), %esi
leaq -0x40(%rbp), %rdx
movl $0x1, %ecx
callq 0x311ba0
movl %eax, -0x44(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x344911
movl -0x3c(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
cmpq $0x0, 0x20(%rbp)
je 0x3449aa
jmp 0x34491e
movq 0x20(%rbp), %rax
movq (%rax), %rax
movq 0x20(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x344986
movq 0x20(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x34494b
movq 0x20(%rbp), %rax
movq 0x8(%rax), %rax
shlq %rax
movq %rax, -0x70(%rbp)
jmp 0x344956
movl $0x2, %eax
movq %rax, -0x70(%rbp)
jmp 0x344956
movq -0x70(%rbp), %rcx
movq 0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
movq 0x20(%rbp), %rax
movq 0x10(%rax), %rdi
movq 0x20(%rbp), %rax
movq 0x8(%rax), %rsi
shlq $0x3, %rsi
callq 0x2360
movq %rax, %rcx
movq 0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movl -0x3c(%rbp), %eax
movl %eax, %edx
movq 0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x20(%rbp), %rsi
movq (%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, (%rsi)
movq %rdx, (%rax,%rcx,8)
jmp 0x3449aa
cmpq $0x0, -0x38(%rbp)
je 0x3449d1
movq -0x10(%rbp), %rdi
movl -0x3c(%rbp), %eax
shrl %eax
movl %eax, %eax
movl %eax, %esi
callq 0x37be90
movq %rax, %rdx
movq -0x38(%rbp), %rax
movl (%rax), %ecx
addq %rdx, %rcx
movl %ecx, (%rax)
cmpq $0x0, 0x10(%rbp)
jne 0x3449e3
cmpq $0x0, 0x18(%rbp)
je 0x344bde
movl -0x3c(%rbp), %eax
movl %eax, -0x50(%rbp)
cmpq $0x0, 0x10(%rbp)
je 0x344a0a
movq -0x68(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x3c(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %ecx
movq 0x10(%rbp), %rax
addl (%rax), %ecx
movl %ecx, (%rax)
cmpq $0x0, 0x18(%rbp)
je 0x344a2b
movq -0x68(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x3c(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %ecx
movq 0x18(%rbp), %rax
addl (%rax), %ecx
movl %ecx, (%rax)
cmpl $-0x1, -0x4c(%rbp)
je 0x344bd8
movq -0x10(%rbp), %rax
movq 0x260(%rax), %rax
movl -0x4c(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movq %rax, -0x78(%rbp)
movl -0x4c(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x344a69
xorl %eax, %eax
movq %rax, -0x80(%rbp)
jmp 0x344a8d
movq -0x10(%rbp), %rax
movq 0x260(%rax), %rax
movl -0x4c(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
subq $0x1, %rax
movq %rax, -0x80(%rbp)
movq -0x78(%rbp), %rax
movq -0x80(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, -0x54(%rbp)
movl -0x4c(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x344ab5
movl -0x54(%rbp), %eax
xorl $0x1, %eax
movl %eax, -0x54(%rbp)
movq -0x10(%rbp), %rax
movq 0x260(%rax), %rax
movl -0x50(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movq %rax, -0x88(%rbp)
movl -0x50(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x344b0d
movq -0x10(%rbp), %rax
movq 0x260(%rax), %rax
movl -0x50(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
subq $0x1, %rax
movq %rax, -0x90(%rbp)
jmp 0x344b18
xorl %eax, %eax
movq %rax, -0x90(%rbp)
jmp 0x344b18
movq -0x88(%rbp), %rax
movq -0x90(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, -0x58(%rbp)
movl -0x50(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x344b46
movl -0x58(%rbp), %eax
xorl $0x1, %eax
movl %eax, -0x58(%rbp)
movl -0x54(%rbp), %eax
shrl %eax
movl %eax, %eax
movl %eax, %edx
movq -0x10(%rbp), %rax
movq 0x208(%rax), %rsi
movl $0x1, %eax
xorl %ecx, %ecx
cmpq %rsi, %rdx
cmovael %ecx, %eax
cmpl $0x0, %eax
je 0x344bd6
movl -0x58(%rbp), %eax
shrl %eax
movl %eax, %eax
movl %eax, %edx
movq -0x10(%rbp), %rax
movq 0x208(%rax), %rsi
movl $0x1, %eax
xorl %ecx, %ecx
cmpq %rsi, %rdx
cmovael %ecx, %eax
cmpl $0x0, %eax
je 0x344bd6
movq -0x10(%rbp), %rdi
movl -0x54(%rbp), %esi
movl -0x58(%rbp), %edx
callq 0x37d2c0
movl %eax, -0x5c(%rbp)
cmpl $0x2, -0x5c(%rbp)
jne 0x344bbc
cmpq $0x0, 0x10(%rbp)
je 0x344bbc
movq 0x10(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
cmpl $0x3, -0x5c(%rbp)
jne 0x344bd4
cmpq $0x0, 0x18(%rbp)
je 0x344bd4
movq 0x18(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x344bd6
jmp 0x344bd8
movl -0x50(%rbp), %eax
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x44(%rbp)
jne 0x344bf0
movl $0x5, -0x4(%rbp)
jmp 0x344c83
cmpl $0x2, -0x44(%rbp)
jne 0x344c02
movl $0x2, -0x4(%rbp)
jmp 0x344c83
cmpl $0x2, -0x44(%rbp)
jbe 0x344c11
movl $0x4, -0x4(%rbp)
jmp 0x344c83
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x8(%rax), %rax
movl -0x40(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x40(%rbp)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rdi
movl -0x40(%rbp), %esi
xorl $0x1, %esi
xorl %eax, %eax
movl %eax, %edx
xorl %ecx, %ecx
callq 0x311ba0
movl %eax, -0x48(%rbp)
movl -0x40(%rbp), %eax
movl %eax, -0x3c(%rbp)
cmpl $0x2, -0x48(%rbp)
jne 0x344c5e
movl $0x1, -0x4(%rbp)
jmp 0x344c83
cmpl $0x2, -0x48(%rbp)
jbe 0x344c6d
movl $0x3, -0x4(%rbp)
jmp 0x344c83
movl -0x3c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jne 0x344c7e
movl $0x7, -0x4(%rbp)
jmp 0x344c83
jmp 0x3448d3
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nop