// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/Overlaps.cpp
// Function: detect_simple_bubble(asg_t*, unsigned int, unsigned int*, long long*, buf_t*)
int detect_simple_bubble(asg_t *g, uint32_t begNode, uint32_t* endNode, long long* minLen, buf_t* b)
{
    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(g, asg_arc_a(g, begNode)[0].v, &e1, &l1, b) == TWO_INPUT 
       && 
       detect_single_path(g, asg_arc_a(g, begNode)[1].v, &e2, &l2, b) == TWO_INPUT)
    {
        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 %rcx, %r13
movq 0x28(%rdi), %rax
movl %esi, %ebx
movq (%rax,%rbx,8), %rcx
cmpl $0x2, %ecx
jne 0xa3a48
movq %r8, %r15
movl %esi, %ebp
movq %rdi, %r12
movq 0x8(%rdi), %rdi
shrq $0x20, %rcx
leaq (%rcx,%rcx,2), %rcx
movl 0x8(%rdi,%rcx,8), %ecx
shrl %ebp
xorq $0x1, %rcx
movq (%rax,%rcx,8), %rax
xorl %r14d, %r14d
testl %eax, %eax
jle 0xa39d1
movq %rax, %rsi
shrq $0x20, %rsi
movl %eax, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
leaq (%rsi,%rsi,2), %rsi
leaq (%rdi,%rsi,8), %r8
addq $0x8, %r8
movl $0x1, %esi
movl (%r8), %edi
shrl %edi
cmpl %ebp, %edi
cmovel %esi, %r14d
addq $0x18, %r8
decq %rcx
jne 0xa39ae
testl %r14d, %r14d
sete %cl
cmpl $0x1, %eax
sete %r14b
jmp 0xa39d3
movb $0x1, %cl
testb %cl, %cl
jne 0xa3b64
testb %r14b, %r14b
je 0xa3a48
movq 0x8(%r12), %rdi
movq 0x28(%r12), %rax
movl 0x4(%rax,%rbx,8), %ecx
leaq (%rcx,%rcx,2), %rcx
movl 0x20(%rdi,%rcx,8), %ecx
xorq $0x1, %rcx
movq (%rax,%rcx,8), %rax
xorl %r14d, %r14d
testl %eax, %eax
jle 0xa3a5d
movq %rax, %rsi
shrq $0x20, %rsi
movl %eax, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
leaq (%rsi,%rsi,2), %rsi
leaq (%rdi,%rsi,8), %r8
addq $0x8, %r8
movl $0x1, %esi
movl (%r8), %edi
shrl %edi
cmpl %ebp, %edi
cmovel %esi, %r14d
addq $0x18, %r8
decq %rcx
jne 0xa3a25
testl %r14d, %r14d
sete %cl
cmpl $0x1, %eax
sete %r14b
jmp 0xa3a5f
xorl %r13d, %r13d
movl %r13d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x1, %cl
movq %r13, 0x8(%rsp)
testb %cl, %cl
jne 0xa3b78
xorl %r13d, %r13d
testb %r14b, %r14b
je 0xa3a4b
testq %r15, %r15
je 0xa3ac1
movq 0x40(%r15), %rax
cmpq %rax, 0x38(%r15)
jne 0xa3aae
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, %r14
callq 0x2370
movq %r14, %rdx
movq %rax, 0x48(%r15)
movq 0x38(%r15), %rax
movq 0x48(%r15), %rcx
leaq 0x1(%rax), %rsi
movq %rsi, 0x38(%r15)
movl %ebp, (%rcx,%rax,4)
movq %rdx, %r14
movq 0x8(%r12), %rax
movq 0x28(%r12), %rcx
movl 0x4(%rcx,%rbx,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
callq 0xa36ca
cmpl $0x1, %eax
jne 0xa3a4b
movq 0x8(%r12), %rax
movq 0x28(%r12), %rcx
movl 0x4(%rcx,%rbx,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
callq 0xa36ca
cmpl $0x1, %eax
jne 0xa3a4b
movl 0x14(%rsp), %eax
cmpl 0x10(%rsp), %eax
jne 0xa3a4b
movl %eax, (%r14)
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, %r13d
jmp 0xa3a4b
movq %rdx, 0x8(%rsp)
callq 0xfdfc
movq 0x8(%rsp), %rdx
jmp 0xa39db
movq %rdx, %r13
callq 0xfe18
movq %r13, %rdx
jmp 0xa3a6c