// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/hic.cpp
// Function: is_simple_broken_bubble(ma_ug_t*, unsigned int, unsigned int, unsigned int, unsigned int*)
int is_simple_broken_bubble(ma_ug_t *unitig_ug, uint32_t x, uint32_t beg, uint32_t sink, uint32_t* new_het)
{
    uint32_t nv, v = (uint32_t)-1, u_s = (uint32_t)-1, u_e = (uint32_t)-1, i;
    asg_arc_t *av = NULL;
    (*new_het) = (uint32_t)-1;

    if((asg_arc_n(unitig_ug->g, x) == 1) 
                        && (asg_arc_n(unitig_ug->g, x^1) == 0))
    {
        v = x;
    }

    if((asg_arc_n(unitig_ug->g, x^1) == 1) 
                        && (asg_arc_n(unitig_ug->g, x) == 0))
    {
        v = x^1;
    }

    if(v == (uint32_t)-1) return 0;

    
    av = asg_arc_a(unitig_ug->g, v);
    nv = asg_arc_n(unitig_ug->g, v);
    for (i = 0; i < nv; i++)
    {
        if(av[i].del) continue;
        if((av[i].v>>1) == (beg>>1)) u_s = beg, u_e = sink;
        if((av[i].v>>1) == (sink>>1)) u_s = sink, u_e = beg;
    }

    if(u_s == (uint32_t)-1 || u_e == (uint32_t)-1) return 0;

    av = asg_arc_a(unitig_ug->g, u_s);
    nv = asg_arc_n(unitig_ug->g, u_s);
    if(nv != 2) return 0;
    for (i = 0; i < nv; i++)
    {
        if(av[i].del) continue;
        if(av[i].v == (v^1)) continue;
        if(av[i].v == (u_e^1))
        {
            (*new_het) = u_e;
            return 1;
        }
    }

    return 0;
}

// Assembly:
movl $0xffffffff, (%r8)      # imm = 0xFFFFFFFF
movq 0x18(%rdi), %r9
movq 0x28(%r9), %rdi
movl %esi, %eax
movl (%rdi,%rax,8), %eax
movl $0xffffffff, %r10d      # imm = 0xFFFFFFFF
cmpq $0x1, %rax
jne 0x1457a0
movl %esi, %r11d
xorl $0x1, %r11d
xorl %r10d, %r10d
cmpl (%rdi,%r11,8), %r10d
sbbl %r10d, %r10d
orl %esi, %r10d
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
xorl $0x1, %esi
movl (%rdi,%rsi,8), %r11d
xorq $0x1, %r11
orq %r11, %rax
cmovnel %r10d, %esi
xorl %eax, %eax
cmpl $-0x1, %esi
je 0x14589f
movq 0x8(%r9), %r10
movl %esi, %r9d
movq (%rdi,%r9,8), %r9
testl %r9d, %r9d
je 0x145838
movq %r9, %r11
shrq $0x20, %r11
movl %r9d, %r9d
leaq (%r11,%r11,2), %r11
leaq (%r10,%r11,8), %rbx
addq $0xc, %rbx
shlq $0x3, %r9
leaq (%r9,%r9,2), %r14
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
xorl %r15d, %r15d
movl $0xffffffff, %r11d      # imm = 0xFFFFFFFF
cmpl $0x0, (%rbx,%r15)
js 0x14582d
movl -0x4(%rbx,%r15), %ebp
movl %ebp, %r12d
xorl %edx, %r12d
cmpl $0x2, %r12d
cmovbl %edx, %r11d
cmovbl %ecx, %r9d
xorl %ecx, %ebp
cmpl $0x2, %ebp
cmovbl %ecx, %r11d
cmovbl %edx, %r9d
addq $0x18, %r15
cmpq %r15, %r14
jne 0x145802
jmp 0x145844
movl $0xffffffff, %r11d      # imm = 0xFFFFFFFF
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
cmpl $-0x1, %r11d
je 0x14589f
cmpl $-0x1, %r9d
je 0x14589f
movl %r11d, %ecx
movq (%rdi,%rcx,8), %rcx
cmpl $0x2, %ecx
jne 0x14589f
shrq $0x20, %rcx
leaq (%rcx,%rcx,2), %rax
leaq (%r10,%rax,8), %rax
addq $0xc, %rax
xorl %ecx, %ecx
cmpl $0x0, (%rax,%rcx)
js 0x145889
movl -0x4(%rax,%rcx), %edx
movl %edx, %edi
xorl %esi, %edi
cmpl $0x1, %edi
je 0x145889
xorl %r9d, %edx
cmpl $0x1, %edx
je 0x145897
addq $0x18, %rcx
cmpq $0x18, %rcx
je 0x14586e
xorl %eax, %eax
jmp 0x14589f
movl %r9d, (%r8)
movl $0x1, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq