// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, %rbx
movq %rdx, %r12
movl %esi, %r10d
movq %rdi, %r11
movq $0x0, (%rcx)
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movl %esi, %ebp
movq %r8, 0x10(%rsp)
movl %esi, 0xc(%rsp)
incq (%rcx)
movq 0x28(%r11), %rax
movl %ebp, %r14d
movq (%rax,%r14,8), %rax
movq %rax, %rsi
movl $0x0, %r13d
andq %r15, %rsi
je 0xa929e
movq 0x8(%r11), %rdi
shrq $0x20, %rax
leaq (%rax,%rax,2), %rax
leaq (%rdi,%rax,8), %rax
addq $0xc, %rax
shlq $0x3, %rsi
leaq (%rsi,%rsi,2), %rdi
xorl %r8d, %r8d
xorl %r13d, %r13d
movl (%rax,%r8), %esi
notl %esi
shrl $0x1f, %esi
addl %esi, %r13d
addq $0x18, %r8
cmpq %r8, %rdi
jne 0xa9289
movl %ebp, (%r12)
testq %rbx, %rbx
je 0xa930a
movq 0x40(%rbx), %rax
cmpq %rax, 0x38(%rbx)
jne 0xa92f2
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x40(%rbx)
movq 0x48(%rbx), %rdi
shlq $0x2, %rsi
movq %rcx, %r15
movq %r11, %rbx
callq 0x2370
movq %rbx, %r11
movl 0xc(%rsp), %r10d
movq 0x10(%rsp), %rbx
movq %r15, %rcx
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movq %rax, 0x48(%rbx)
movl %ebp, %eax
shrl %eax
movq 0x38(%rbx), %rdi
movq 0x48(%rbx), %r8
leaq 0x1(%rdi), %rsi
movq %rsi, 0x38(%rbx)
movl %eax, (%r8,%rdi,4)
testl %r13d, %r13d
je 0xa93d3
cmpl $0x2, %r13d
je 0xa9440
ja 0xa93db
movq 0x28(%r11), %rax
movq (%rax,%r14,8), %r8
movq %r8, %rdi
andq %r15, %rdi
je 0xa9366
movq 0x8(%r11), %rsi
shrq $0x20, %r8
shlq $0x3, %rdi
leaq (%rdi,%rdi,2), %rdi
leaq (%r8,%r8,2), %r8
leaq (%rsi,%r8,8), %r8
addq $0xc, %r8
xorl %esi, %esi
cmpl $0x0, (%r8,%rsi)
js 0xa935d
movl -0x4(%r8,%rsi), %ebp
addq $0x18, %rsi
cmpq %rsi, %rdi
jne 0xa9351
movl %ebp, %esi
xorl $0x1, %esi
movq (%rax,%rsi,8), %rax
movq %rax, %rsi
andq %r15, %rsi
je 0xa93ae
movq 0x8(%r11), %rdi
shrq $0x20, %rax
leaq (%rax,%rax,2), %rax
leaq (%rdi,%rax,8), %rax
addq $0xc, %rax
shlq $0x3, %rsi
leaq (%rsi,%rsi,2), %r9
xorl %esi, %esi
xorl %r8d, %r8d
movl (%rax,%rsi), %edi
notl %edi
shrl $0x1f, %edi
addl %edi, %r8d
addq $0x18, %rsi
cmpq %rsi, %r9
jne 0xa9398
jmp 0xa93b1
xorl %r8d, %r8d
movl %ebp, (%r12)
cmpl $0x2, %r8d
je 0xa93e3
ja 0xa93ee
movl %ebp, %eax
xorl %r10d, %eax
cmpl $0x2, %eax
jae 0xa924b
movl $0x7, %r13d
jmp 0xa9440
movl $0x5, %r13d
jmp 0xa9440
movl $0x4, %r13d
jmp 0xa9440
incq (%rcx)
movl $0x1, %r13d
jmp 0xa93f7
incq (%rcx)
movl $0x3, %r13d
testq %rbx, %rbx
je 0xa9440
movq 0x40(%rbx), %rax
cmpq %rax, 0x38(%rbx)
jne 0xa942b
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %esi
cmovneq %rcx, %rsi
movq %rsi, 0x40(%rbx)
movq 0x48(%rbx), %rdi
shlq $0x2, %rsi
callq 0x2370
movq %rax, 0x48(%rbx)
shrl %ebp
movq 0x38(%rbx), %rax
movq 0x48(%rbx), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x38(%rbx)
movl %ebp, (%rcx,%rax,4)
movl %r13d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq