// File: 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
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
movsd %xmm0, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
movq %r9, -0x38(%rbp)
movl $0x0, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x1c(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x138d71
movq $0x0, -0x8(%rbp)
jmp 0x13915d
movq -0x38(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x38(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jne 0x138de6
movq -0x38(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x138dab
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
shlq %rax
movq %rax, -0x60(%rbp)
jmp 0x138db6
movl $0x2, %eax
movq %rax, -0x60(%rbp)
jmp 0x138db6
movq -0x60(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x18(%rax)
movl -0x1c(%rbp), %edx
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x38(%rbp), %rsi
movq 0x8(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x8(%rsi)
movl %edx, (%rax,%rcx,4)
jmp 0x138e09
movq -0x38(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x13904c
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x38(%rbp), %rdx
movq 0x8(%rdx), %rcx
movq %rcx, %rsi
addq $-0x1, %rsi
movq %rsi, 0x8(%rdx)
movl -0x4(%rax,%rcx,4), %eax
movl %eax, -0x44(%rbp)
movq -0x38(%rbp), %rax
movq (%rax), %rax
movl -0x44(%rbp), %ecx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x138e58
jmp 0x138e09
movq -0x38(%rbp), %rax
movq (%rax), %rax
movl -0x44(%rbp), %ecx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl 0x18(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
orl $0x80000000, %ecx       # imm = 0x80000000
movl %ecx, 0x18(%rax)
movq -0x38(%rbp), %rax
movq 0x38(%rax), %rax
movq -0x38(%rbp), %rcx
cmpq 0x40(%rcx), %rax
jne 0x138ee4
movq -0x38(%rbp), %rax
cmpq $0x0, 0x40(%rax)
je 0x138ea9
movq -0x38(%rbp), %rax
movq 0x40(%rax), %rax
shlq %rax
movq %rax, -0x68(%rbp)
jmp 0x138eb4
movl $0x2, %eax
movq %rax, -0x68(%rbp)
jmp 0x138eb4
movq -0x68(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x38(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x38(%rbp), %rax
movq 0x40(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x48(%rax)
movl -0x44(%rbp), %edx
movq -0x38(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x38(%rbp), %rsi
movq 0x38(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x38(%rsi)
movl %edx, (%rax,%rcx,4)
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x44(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x4c(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x18(%rbp), %rcx
movq 0x28(%rcx), %rcx
movl -0x44(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jae 0x139047
movq -0x58(%rbp), %rax
movl -0x3c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x138f6e
jmp 0x139039
movq -0x58(%rbp), %rax
movl -0x3c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x48(%rbp)
movq -0x38(%rbp), %rax
movq (%rax), %rax
movl -0x48(%rbp), %ecx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
jne 0x138fa6
movl -0x48(%rbp), %eax
cmpl -0x20(%rbp), %eax
jne 0x138fab
jmp 0x139039
jmp 0x138fad
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x38(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jne 0x139016
movq -0x38(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x138fdb
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
shlq %rax
movq %rax, -0x70(%rbp)
jmp 0x138fe6
movl $0x2, %eax
movq %rax, -0x70(%rbp)
jmp 0x138fe6
movq -0x70(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x18(%rax)
movl -0x48(%rbp), %edx
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x38(%rbp), %rsi
movq 0x8(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x8(%rsi)
movl %edx, (%rax,%rcx,4)
jmp 0x139039
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x138f44
jmp 0x138e09
movl $0x0, -0x50(%rbp)
movl -0x50(%rbp), %eax
movq -0x38(%rbp), %rcx
cmpq 0x38(%rcx), %rax
jae 0x13910b
movq -0x38(%rbp), %rax
movq 0x48(%rax), %rax
movl -0x50(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, -0x44(%rbp)
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq -0x38(%rbp), %rcx
movq 0x48(%rcx), %rcx
movl -0x50(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl 0x18(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
orl $0x0, %ecx
movl %ecx, 0x18(%rax)
movl -0x44(%rbp), %eax
cmpl -0x1c(%rbp), %eax
je 0x1390b0
movl -0x44(%rbp), %eax
cmpl -0x20(%rbp), %eax
jne 0x1390b2
jmp 0x1390fd
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x44(%rbp), %edx
movsd -0x28(%rbp), %xmm0
movl -0x2c(%rbp), %ecx
callq 0x138930
movq %rax, %rcx
movl -0x40(%rbp), %eax
addq %rcx, %rax
movl %eax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x44(%rbp), %edx
xorl $0x1, %edx
movsd -0x28(%rbp), %xmm0
movl -0x2c(%rbp), %ecx
callq 0x138930
movq %rax, %rcx
movl -0x40(%rbp), %eax
addq %rcx, %rax
movl %eax, -0x40(%rbp)
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x139053
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
movsd -0x28(%rbp), %xmm0
movl -0x2c(%rbp), %ecx
callq 0x138930
movq %rax, %rcx
movl -0x40(%rbp), %eax
addq %rcx, %rax
movl %eax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x20(%rbp), %edx
xorl $0x1, %edx
movsd -0x28(%rbp), %xmm0
movl -0x2c(%rbp), %ecx
callq 0x138930
movq %rax, %rcx
movl -0x40(%rbp), %eax
addq %rcx, %rax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x70, %rsp
popq %rbp
retq
nopw (%rax,%rax)