// File: 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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movl %r9d, -0x34(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x14(%rbp), %ecx
movq (%rax,%rcx,8), %rax
cmpl $0x2, %eax
je 0xd543f
movl $0x0, -0x4(%rbp)
jmp 0xd565a
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x28(%rcx), %rcx
movl -0x14(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %esi
movl -0x14(%rbp), %edx
shrl %edx
callq 0xd4770
cmpl $0x1, %eax
jne 0xd54af
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x28(%rcx), %rcx
movl -0x14(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x20(%rax), %esi
movl -0x14(%rbp), %edx
shrl %edx
callq 0xd4770
cmpl $0x1, %eax
je 0xd54bb
movl $0x0, -0x4(%rbp)
jmp 0xd565a
cmpq $0x0, -0x30(%rbp)
je 0xd5556
jmp 0xd54c8
movq -0x30(%rbp), %rax
movq 0x38(%rax), %rax
movq -0x30(%rbp), %rcx
cmpq 0x40(%rcx), %rax
jne 0xd5531
movq -0x30(%rbp), %rax
cmpq $0x0, 0x40(%rax)
je 0xd54f6
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rax
shlq %rax
movq %rax, -0x58(%rbp)
jmp 0xd5501
movl $0x2, %eax
movq %rax, -0x58(%rbp)
jmp 0xd5501
movq -0x58(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x48(%rax)
movl -0x14(%rbp), %edx
shrl %edx
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x30(%rbp), %rsi
movq 0x38(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x38(%rsi)
movl %edx, (%rax,%rcx,4)
jmp 0xd5556
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x28(%rcx), %rcx
movl -0x14(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %esi
movq -0x30(%rbp), %r8
movl -0x34(%rbp), %r9d
leaq -0x38(%rbp), %rdx
leaq -0x48(%rbp), %rcx
callq 0xd4e50
cmpl $0x1, %eax
jne 0xd5653
movq -0x30(%rbp), %rax
movq 0x38(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0x38(%rax)
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x28(%rcx), %rcx
movl -0x14(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x20(%rax), %esi
movq -0x30(%rbp), %r8
movl -0x34(%rbp), %r9d
leaq -0x3c(%rbp), %rdx
leaq -0x50(%rbp), %rcx
callq 0xd4e50
cmpl $0x1, %eax
jne 0xd5651
movq -0x30(%rbp), %rax
movq 0x38(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0x38(%rax)
movl -0x38(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jne 0xd564f
movl -0x38(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x48(%rbp), %rax
cmpq -0x50(%rbp), %rax
jg 0xd5625
movq -0x48(%rbp), %rax
movq %rax, -0x60(%rbp)
jmp 0xd562d
movq -0x50(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
movl $0x1, -0x4(%rbp)
jmp 0xd565a
jmp 0xd5651
jmp 0xd5653
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)