// File: /workspace/github_cpp_makefile_star2_O1/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 %rcx, %r8
movq 0x28(%rdi), %rax
movl %esi, %r14d
movq (%rax,%r14,8), %rcx
cmpl $0x2, %ecx
jne 0xa4124
movl %esi, %r13d
movq %rdi, %r12
movq 0x8(%rdi), %rdi
shrq $0x20, %rcx
leaq (%rcx,%rcx,2), %rcx
movl 0x8(%rdi,%rcx,8), %ecx
shrl %r13d
xorq $0x1, %rcx
movq (%rax,%rcx,8), %rax
xorl %ebx, %ebx
testl %eax, %eax
jle 0xa40af
movq %rax, %rsi
shrq $0x20, %rsi
movl %eax, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
leaq (%rsi,%rsi,2), %rsi
leaq (%rdi,%rsi,8), %r10
addq $0x8, %r10
movl $0x1, %esi
movl (%r10), %edi
shrl %edi
cmpl %r13d, %edi
cmovel %esi, %ebx
addq $0x18, %r10
decq %rcx
jne 0xa408e
testl %ebx, %ebx
sete %cl
cmpl $0x1, %eax
sete %bl
jmp 0xa40b1
movb $0x1, %cl
testb %cl, %cl
jne 0xa4257
testb %bl, %bl
je 0xa4124
movq 0x8(%r12), %rdi
movq 0x28(%r12), %rax
movl 0x4(%rax,%r14,8), %ecx
leaq (%rcx,%rcx,2), %rcx
movl 0x20(%rdi,%rcx,8), %ecx
xorq $0x1, %rcx
movq (%rax,%rcx,8), %rax
xorl %ebp, %ebp
testl %eax, %eax
jle 0xa4137
movq %rax, %rsi
shrq $0x20, %rsi
movl %eax, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
leaq (%rsi,%rsi,2), %rsi
leaq (%rdi,%rsi,8), %r10
addq $0x8, %r10
movl $0x1, %esi
movl (%r10), %edi
shrl %edi
cmpl %r13d, %edi
cmovel %esi, %ebp
addq $0x18, %r10
decq %rcx
jne 0xa4102
testl %ebp, %ebp
sete %cl
cmpl $0x1, %eax
sete %bpl
jmp 0xa4139
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x1, %cl
testb %cl, %cl
jne 0xa427b
xorl %ebx, %ebx
testb %bpl, %bpl
je 0xa4126
testq %r15, %r15
movq %r8, 0x8(%rsp)
je 0xa41a5
movq 0x40(%r15), %rax
cmpq %rax, 0x38(%r15)
jne 0xa4191
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %esi
cmovneq %rcx, %rsi
movq %rsi, 0x40(%r15)
movq 0x48(%r15), %rdi
shlq $0x2, %rsi
movq %rdx, %rbp
movl %r9d, 0x4(%rsp)
callq 0x2370
movl 0x4(%rsp), %r9d
movq %rbp, %rdx
movq %rax, 0x48(%r15)
movq 0x38(%r15), %rax
movq 0x48(%r15), %rcx
leaq 0x1(%rax), %rsi
movq %rsi, 0x38(%r15)
movl %r13d, (%rcx,%rax,4)
movq %rdx, %rbp
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, %r13d
callq 0xa3b88
cmpl $0x1, %eax
jne 0xa4126
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 %r13d, %r9d
callq 0xa3b88
cmpl $0x1, %eax
jne 0xa4126
decq 0x38(%r15)
movl 0x14(%rsp), %eax
cmpl 0x10(%rsp), %eax
jne 0xa4126
movl %eax, (%rbp)
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 0xa4126
movq %r8, 0x8(%rsp)
movq %rdx, %rbp
movl %r9d, 0x4(%rsp)
callq 0xfe50
movl 0x4(%rsp), %r9d
movq %rbp, %rdx
movq 0x8(%rsp), %r8
jmp 0xa40b9
movq %r8, 0x8(%rsp)
movq %rdx, %rbx
movl %r9d, 0x4(%rsp)
callq 0xfe6c
movl 0x4(%rsp), %r9d
movq %rbx, %rdx
movq 0x8(%rsp), %r8
jmp 0xa4141