// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/Overlaps.cpp
// Function: detect_bubble_with_bubbles(asg_t*, unsigned int, unsigned int*, long long*, buf_t*, unsigned int)
int detect_bubble_with_bubbles(asg_t *g, uint32_t begNode, uint32_t* endNode, long long* minLen, 
buf_t* b, uint32_t max_ext)
{
    uint32_t e1, e2;
    long long l1, l2;

    if(asg_arc_n(g, begNode) != 2)
    {
        return 0;
    }

    if(asg_is_single_edge(g, asg_arc_a(g, begNode)[0].v, begNode>>1)!=1
      || 
       asg_is_single_edge(g, asg_arc_a(g, begNode)[1].v, begNode>>1)!=1)
    {
        return 0;
    }

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


    if(detect_single_path_with_single_bubbles(g, asg_arc_a(g, begNode)[0].v, &e1, &l1, b, max_ext) == TWO_INPUT)
    {
        b->b.n--;
        if(detect_single_path_with_single_bubbles(g, asg_arc_a(g, begNode)[1].v, &e2, &l2, b, max_ext) == TWO_INPUT)
        {
            b->b.n--;
            if(e1 == e2)
            {
                (*endNode) = e1;
                (*minLen) = (l1 <= l2)? l1: l2;
                (*minLen)++;
                return 1;
            }
        }
    }

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r8, %r15
movq %rdx, %r8
movq 0x28(%rdi), %rax
movl %esi, %r14d
movq (%rax,%r14,8), %rdx
cmpl $0x2, %edx
jne 0xa51ff
movq %rcx, %rbp
movl %esi, %r13d
movq %rdi, %r12
movq 0x8(%rdi), %rcx
shrq $0x20, %rdx
leaq (%rdx,%rdx,2), %rdx
movl 0x8(%rcx,%rdx,8), %edx
shrl %r13d
xorq $0x1, %rdx
movq (%rax,%rdx,8), %rbx
testl %ebx, %ebx
jle 0xa52d1
movq %rbx, %rdx
shrq $0x20, %rdx
movl %ebx, %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
leaq (%rdx,%rdx,2), %rdx
leaq (%rcx,%rdx,8), %rdx
addq $0x8, %rdx
xorl %ecx, %ecx
movl $0x1, %esi
movl (%rdx), %edi
shrl %edi
cmpl %r13d, %edi
cmovel %esi, %ecx
addq $0x18, %rdx
decq %rax
jne 0xa5124
testl %ecx, %ecx
je 0xa52d3
cmpl $0x1, %ebx
jne 0xa51ff
movq %rbp, 0x8(%rsp)
movq 0x8(%r12), %rcx
movq 0x28(%r12), %rax
movl 0x4(%rax,%r14,8), %edx
leaq (%rdx,%rdx,2), %rdx
movl 0x20(%rcx,%rdx,8), %edx
xorq $0x1, %rdx
movq (%rax,%rdx,8), %rbp
testl %ebp, %ebp
jle 0xa530a
movq %rbp, %rdx
shrq $0x20, %rdx
movl %ebp, %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
leaq (%rdx,%rdx,2), %rdx
leaq (%rcx,%rdx,8), %rdx
addq $0x8, %rdx
xorl %ecx, %ecx
movl $0x1, %esi
movl (%rdx), %edi
shrl %edi
cmpl %r13d, %edi
cmovel %esi, %ecx
addq $0x18, %rdx
decq %rax
jne 0xa5195
testl %ecx, %ecx
je 0xa530c
xorl %ebx, %ebx
cmpl $0x1, %ebp
jne 0xa5201
testq %r15, %r15
je 0xa5222
movq 0x38(%r15), %rcx
cmpq 0x40(%r15), %rcx
jne 0xa5212
leaq (%rcx,%rcx), %rax
testq %rcx, %rcx
movl $0x2, %esi
cmovneq %rax, %rsi
movq %rsi, 0x40(%r15)
movq 0x48(%r15), %rdi
shlq $0x2, %rsi
movq %r8, (%rsp)
movl %r9d, %ebp
callq 0x2370
movl %ebp, %r9d
movq (%rsp), %r8
movq %rax, 0x48(%r15)
movq 0x38(%r15), %rcx
jmp 0xa5216
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x48(%r15), %rax
leaq 0x1(%rcx), %rdx
movq %rdx, 0x38(%r15)
movl %r13d, (%rax,%rcx,4)
movq %r8, %r13
movq 0x8(%r12), %rax
movq 0x28(%r12), %rcx
movl 0x4(%rcx,%r14,8), %ecx
leaq (%rcx,%rcx,2), %rcx
movl 0x8(%rax,%rcx,8), %esi
leaq 0x14(%rsp), %rdx
leaq 0x20(%rsp), %rcx
movq %r12, %rdi
movq %r15, %r8
movl %r9d, %ebp
callq 0xa4c16
cmpl $0x1, %eax
jne 0xa5201
decq 0x38(%r15)
movq 0x8(%r12), %rax
movq 0x28(%r12), %rcx
movl 0x4(%rcx,%r14,8), %ecx
leaq (%rcx,%rcx,2), %rcx
movl 0x20(%rax,%rcx,8), %esi
leaq 0x10(%rsp), %rdx
leaq 0x18(%rsp), %rcx
movq %r12, %rdi
movq %r15, %r8
movl %ebp, %r9d
callq 0xa4c16
cmpl $0x1, %eax
jne 0xa5201
decq 0x38(%r15)
movl 0x14(%rsp), %eax
cmpl 0x10(%rsp), %eax
jne 0xa5201
movl %eax, (%r13)
movq 0x20(%rsp), %rax
movq 0x18(%rsp), %rcx
cmpq %rcx, %rax
cmovlq %rax, %rcx
incq %rcx
movq 0x8(%rsp), %rax
movq %rcx, (%rax)
movl $0x1, %ebx
jmp 0xa5201
xorl %ebx, %ebx
movq 0x1efd06(%rip), %rax    # 0x294fe0
movq (%rax), %rcx
leaq 0x193e36(%rip), %rdi    # 0x23911a
movl $0xa, %esi
movl $0x1, %edx
movq %r8, (%rsp)
movl %r9d, 0x8(%rsp)
callq 0x2410
movl 0x8(%rsp), %r9d
movq (%rsp), %r8
jmp 0xa513f
xorl %ebp, %ebp
movq 0x1efccd(%rip), %rax    # 0x294fe0
movq (%rax), %rcx
leaq 0x193dfd(%rip), %rdi    # 0x23911a
movl $0xa, %esi
movl $0x1, %edx
movq %r8, (%rsp)
movl %r9d, %ebx
callq 0x2410
movl %ebx, %r9d
movq (%rsp), %r8
jmp 0xa51b0