// File: chhylp123[P]hifiasm/Overlaps.cpp
// Function: detect_single_path_with_dels(asg_t*, unsigned int, unsigned int*, long long*, buf_t*)
uint32_t detect_single_path_with_dels(asg_t *g, uint32_t begNode, uint32_t* endNode, long long* Len, buf_t* b)
{
    uint32_t v = begNode, w;
    uint32_t kv, kw;
    (*Len) = 0;

    while (1)
    {
        (*Len)++;
        kv = get_real_length(g, v, NULL);
        (*endNode) = v;

        if(b) kv_push(uint32_t, b->b, v>>1);

        if(kv == 0)
        {
            return END_TIPS;
        }

        if(kv == 2)
        {
            return TWO_OUTPUT;
        }

        if(kv > 2)
        {
            return MUL_OUTPUT;
        }

        ///up to here, kv=1
        ///kw must >= 1
        get_real_length(g, v, &w);
        kw = get_real_length(g, w^1, NULL);
        v = w;
        (*endNode) = v;


        if(kw == 2)
        {
            (*Len)++;
            if(b) kv_push(uint32_t, b->b, v>>1);
            return TWO_INPUT;
        }

        if(kw > 2)
        {
            (*Len)++;
            if(b) kv_push(uint32_t, b->b, v>>1);
            return MUL_INPUT;
        }   


        if((v>>1) == (begNode>>1))
        {
            return LOOP;
        } 
    }

    return LONG_TIPS;   
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x34(%rbp)
movq -0x28(%rbp), %rax
movq $0x0, (%rax)
movq -0x28(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
movq -0x10(%rbp), %rdi
movl -0x34(%rbp), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x166b50
movl %eax, -0x3c(%rbp)
movl -0x34(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
cmpq $0x0, -0x30(%rbp)
je 0xdb231
jmp 0xdb1a3
movq -0x30(%rbp), %rax
movq 0x38(%rax), %rax
movq -0x30(%rbp), %rcx
cmpq 0x40(%rcx), %rax
jne 0xdb20c
movq -0x30(%rbp), %rax
cmpq $0x0, 0x40(%rax)
je 0xdb1d1
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rax
shlq %rax
movq %rax, -0x48(%rbp)
jmp 0xdb1dc
movl $0x2, %eax
movq %rax, -0x48(%rbp)
jmp 0xdb1dc
movq -0x48(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x48(%rax)
movl -0x34(%rbp), %edx
shrl %edx
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x30(%rbp), %rsi
movq 0x38(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x38(%rsi)
movl %edx, (%rax,%rcx,4)
jmp 0xdb231
cmpl $0x0, -0x3c(%rbp)
jne 0xdb243
movl $0x5, -0x4(%rbp)
jmp 0xdb433
cmpl $0x2, -0x3c(%rbp)
jne 0xdb255
movl $0x2, -0x4(%rbp)
jmp 0xdb433
cmpl $0x2, -0x3c(%rbp)
jbe 0xdb267
movl $0x4, -0x4(%rbp)
jmp 0xdb433
movq -0x10(%rbp), %rdi
movl -0x34(%rbp), %esi
leaq -0x38(%rbp), %rdx
callq 0x166b50
movq -0x10(%rbp), %rdi
movl -0x38(%rbp), %esi
xorl $0x1, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x166b50
movl %eax, -0x40(%rbp)
movl -0x38(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
cmpl $0x2, -0x40(%rbp)
jne 0xdb35b
movq -0x28(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
cmpq $0x0, -0x30(%rbp)
je 0xdb34f
jmp 0xdb2c1
movq -0x30(%rbp), %rax
movq 0x38(%rax), %rax
movq -0x30(%rbp), %rcx
cmpq 0x40(%rcx), %rax
jne 0xdb32a
movq -0x30(%rbp), %rax
cmpq $0x0, 0x40(%rax)
je 0xdb2ef
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rax
shlq %rax
movq %rax, -0x50(%rbp)
jmp 0xdb2fa
movl $0x2, %eax
movq %rax, -0x50(%rbp)
jmp 0xdb2fa
movq -0x50(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x48(%rax)
movl -0x34(%rbp), %edx
shrl %edx
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x30(%rbp), %rsi
movq 0x38(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x38(%rsi)
movl %edx, (%rax,%rcx,4)
jmp 0xdb34f
movl $0x1, -0x4(%rbp)
jmp 0xdb433
cmpl $0x2, -0x40(%rbp)
jbe 0xdb417
movq -0x28(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
cmpq $0x0, -0x30(%rbp)
je 0xdb40e
jmp 0xdb380
movq -0x30(%rbp), %rax
movq 0x38(%rax), %rax
movq -0x30(%rbp), %rcx
cmpq 0x40(%rcx), %rax
jne 0xdb3e9
movq -0x30(%rbp), %rax
cmpq $0x0, 0x40(%rax)
je 0xdb3ae
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rax
shlq %rax
movq %rax, -0x58(%rbp)
jmp 0xdb3b9
movl $0x2, %eax
movq %rax, -0x58(%rbp)
jmp 0xdb3b9
movq -0x58(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x48(%rax)
movl -0x34(%rbp), %edx
shrl %edx
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x30(%rbp), %rsi
movq 0x38(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x38(%rsi)
movl %edx, (%rax,%rcx,4)
jmp 0xdb40e
movl $0x3, -0x4(%rbp)
jmp 0xdb433
movl -0x34(%rbp), %eax
shrl %eax
movl -0x14(%rbp), %ecx
shrl %ecx
cmpl %ecx, %eax
jne 0xdb42e
movl $0x7, -0x4(%rbp)
jmp 0xdb433
jmp 0xdb16c
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)