// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/Overlaps.cpp
// Function: detect_single_path_with_dels_by_length(asg_t*, unsigned int, unsigned int*, long long*, buf_t*, long long)
uint32_t detect_single_path_with_dels_by_length
(asg_t *g, uint32_t begNode, uint32_t* endNode, long long* Len, buf_t* b, long long maxLen)
{
    
    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(b) kv_push(uint32_t, b->b, v);

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

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

        if(kv > 2)
        {
            return MUL_OUTPUT;
        }

        if((*Len) > maxLen)
        {
            return LONG_TIPS;
        }

        ///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);
            if(b) kv_push(uint32_t, b->b, v);
            return TWO_INPUT;
        }

        if(kw > 2)
        {
            (*Len)++;
            ///if(b) kv_push(uint32_t, b->b, v>>1);
            if(b) kv_push(uint32_t, b->b, v);
            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 %r9, 0x10(%rsp)
movq %r8, %r14
movq %rcx, %r15
movq %rdx, %r13
movl %esi, %ebp
movq %rdi, %r12
andq $0x0, (%rcx)
movl %esi, 0xc(%rsp)
incq (%r15)
movq %r12, %rdi
movl %ebp, %esi
xorl %edx, %edx
callq 0xc2e7a
movl %eax, %ebx
movl %ebp, (%r13)
testq %r14, %r14
je 0xaacf0
movq 0x38(%r14), %rcx
movq 0x48(%r14), %rax
cmpq 0x40(%r14), %rcx
jne 0xaace5
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x40(%r14)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x48(%r14)
movq 0x38(%r14), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x38(%r14)
movl %ebp, (%rax,%rcx,4)
testl %ebx, %ebx
je 0xaad4b
cmpl $0x2, %ebx
je 0xaada9
ja 0xaad4f
movq 0x10(%rsp), %rax
cmpq %rax, (%r15)
jg 0xaad54
movq %r12, %rdi
movl %ebp, %esi
leaq 0x8(%rsp), %rdx
callq 0xc2e7a
movl 0x8(%rsp), %esi
xorl $0x1, %esi
movq %r12, %rdi
xorl %edx, %edx
callq 0xc2e7a
movl 0x8(%rsp), %ebp
movl %ebp, (%r13)
cmpl $0x2, %eax
je 0xaad58
ja 0xaad5f
movl %ebp, %eax
xorl 0xc(%rsp), %eax
cmpl $0x2, %eax
jae 0xaac97
pushq $0x7
jmp 0xaad51
pushq $0x5
jmp 0xaad51
pushq $0x4
popq %rbx
jmp 0xaada9
xorl %ebx, %ebx
jmp 0xaada9
incq (%r15)
pushq $0x1
jmp 0xaad64
incq (%r15)
pushq $0x3
popq %rbx
testq %r14, %r14
je 0xaada9
movq 0x38(%r14), %rcx
movq 0x48(%r14), %rax
cmpq 0x40(%r14), %rcx
jne 0xaad9e
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x40(%r14)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x48(%r14)
movq 0x38(%r14), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x38(%r14)
movl %ebp, (%rax,%rcx,4)
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq