// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/Overlaps.cpp
// Function: rd_hm_drop(asg_t*, asg_t*, unsigned int, unsigned int, double, unsigned int, buf_t*)
uint64_t rd_hm_drop(asg_t *g, asg_t *ref, uint32_t v0, uint32_t v1, double cutoff, uint32_t drop_inexact, buf_t *b)
{
    uint32_t i1, ncut = 0;
    uint32_t v, w, nv1, i; asg_arc_t *av1; 
    if (g->seq[v0>>1].del) return 0; // already deleted    
    ///b->S is the nodes with all incoming edges visited
    b->S.n = 0;
    kv_push(uint32_t, b->S, v0);    
    while(b->S.n) {
        v = kv_pop(b->S); 
        if(b->a[v].s) continue;
        b->a[v].s = 1; 
        kv_push(uint32_t, b->b, v); // save it for revert
        nv1 = asg_arc_n(ref, v); av1 = asg_arc_a(ref, v);
        for (i1 = 0; i1 < nv1; ++i1) { // loop through v's neighbors
            if (av1[i1].del) continue;
            w = av1[i1].v;
            if(b->a[w].s || w == v1) continue;
            kv_push(uint32_t, b->S, w);
        }
    }
    for (i = 0; i < b->b.n; ++i) { // clear the states of visited vertices
        v = b->b.a[i]; b->a[b->b.a[i]].s = 0;
        if(v == v0 || v == v1) continue;
        ncut += rd_hm_drop0(g, ref, v, cutoff, drop_inexact);
        ncut += rd_hm_drop0(g, ref, v^1, cutoff, drop_inexact);
    }
    ncut += rd_hm_drop0(g, ref, v0, cutoff, drop_inexact);
    ncut += rd_hm_drop0(g, ref, v1^1, cutoff, drop_inexact);
    return ncut;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movsd %xmm0, 0x10(%rsp)
movl %ecx, %ebp
movq %rsi, 0x20(%rsp)
movq %rdi, 0x18(%rsp)
movq 0x20(%rdi), %rax
movl %edx, 0xc(%rsp)
movl %edx, %ecx
shrl %ecx
cmpl $0x0, (%rax,%rcx,8)
js 0xa74fd
movq %r9, %r13
movl %r8d, %ebx
andq $0x0, 0x8(%r9)
cmpq $0x0, 0x10(%r9)
je 0xa7504
movq 0x18(%r13), %rax
xorl %edx, %edx
jmp 0xa7520
xorl %eax, %eax
jmp 0xa7710
movq $0x2, 0x10(%r13)
movq 0x18(%r13), %rdi
pushq $0x8
popq %rsi
callq 0x2370
movq %rax, 0x18(%r13)
movq 0x8(%r13), %rdx
movl %ebx, 0x8(%rsp)
leaq 0x1(%rdx), %rcx
movq %rcx, 0x8(%r13)
movl 0xc(%rsp), %esi
movl %esi, (%rax,%rdx,4)
testq %rcx, %rcx
je 0xa764b
movq (%r13), %rax
movq 0x18(%r13), %rdx
leaq -0x1(%rcx), %rdi
movq %rdi, 0x8(%r13)
movl -0x4(%rdx,%rcx,4), %r14d
imulq $0x1c, %r14, %rsi
movl 0x18(%rax,%rsi), %edx
movq %rdi, %rcx
testl %edx, %edx
js 0xa7533
addq %rsi, %rax
addq $0x18, %rax
orl $0x80000000, %edx       # imm = 0x80000000
movl %edx, (%rax)
movq 0x38(%r13), %rcx
movq 0x48(%r13), %rax
cmpq 0x40(%r13), %rcx
jne 0xa75a3
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x40(%r13)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x48(%r13)
movq 0x38(%r13), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x38(%r13)
movl %r14d, (%rax,%rcx,4)
movq 0x20(%rsp), %rcx
movq 0x8(%rcx), %rax
movq 0x28(%rcx), %rcx
movq (%rcx,%r14,8), %rcx
movl %ecx, %edx
shrq $0x20, %rcx
imulq $0x18, %rdx, %r15
imulq $0x18, %rcx, %rcx
leaq (%rax,%rcx), %r12
addq $0xc, %r12
xorl %r14d, %r14d
cmpq %r14, %r15
je 0xa7642
cmpl $0x0, (%r12,%r14)
js 0xa763c
movl -0x4(%r12,%r14), %ebx
cmpl %ebp, %ebx
je 0xa763c
movq (%r13), %rax
imulq $0x1c, %rbx, %rcx
cmpl $0x0, 0x18(%rax,%rcx)
js 0xa763c
movq 0x8(%r13), %rcx
movq 0x18(%r13), %rax
cmpq 0x10(%r13), %rcx
jne 0xa7631
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x10(%r13)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x18(%r13)
movq 0x8(%r13), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%r13)
movl %ebx, (%rax,%rcx,4)
addq $0x18, %r14
jmp 0xa75d9
movq 0x8(%r13), %rcx
jmp 0xa7533
xorl %r15d, %r15d
xorl %r12d, %r12d
movq 0x20(%rsp), %r14
movl %r12d, %r12d
cmpq %r12, 0x38(%r13)
jbe 0xa76ca
movq (%r13), %rax
movq 0x48(%r13), %rcx
movl (%rcx,%r12,4), %ebx
imulq $0x1c, %rbx, %rcx
andl $0x7fffffff, 0x18(%rax,%rcx) # imm = 0x7FFFFFFF
cmpl 0xc(%rsp), %ebx
sete %al
cmpl %ebp, %ebx
sete %cl
orb %al, %cl
jne 0xa76c5
movq 0x18(%rsp), %rdi
movq %r14, %rsi
movl %ebx, %edx
movsd 0x10(%rsp), %xmm0
movl 0x8(%rsp), %ecx
callq 0xa72d3
addl %eax, %r15d
xorl $0x1, %ebx
movq 0x18(%rsp), %rdi
movq %r14, %rsi
movl %ebx, %edx
movsd 0x10(%rsp), %xmm0
movl 0x8(%rsp), %ecx
callq 0xa72d3
addl %r15d, %eax
movl %eax, %r15d
incl %r12d
jmp 0xa7656
movq 0x18(%rsp), %r14
movq %r14, %rdi
movq 0x20(%rsp), %rbx
movq %rbx, %rsi
movl 0xc(%rsp), %edx
movsd 0x10(%rsp), %xmm0
movl 0x8(%rsp), %r12d
movl %r12d, %ecx
callq 0xa72d3
addl %eax, %r15d
xorl $0x1, %ebp
movq %r14, %rdi
movq %rbx, %rsi
movl %ebp, %edx
movsd 0x10(%rsp), %xmm0
movl %r12d, %ecx
callq 0xa72d3
addl %r15d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq