// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/Overlaps.cpp
// Function: rd_hm_drop0(asg_t*, asg_t*, unsigned int, double, unsigned int)
uint64_t rd_hm_drop0(asg_t *g, asg_t *ref, uint32_t v, double cutoff, uint32_t drop_inexact)
{
    uint32_t nv0, nv1, mol = 0, i0, i1, ncut = 0; asg_arc_t *av0, *av1;
    nv0 = asg_arc_n(g, v); av0 = asg_arc_a(g, v);
    nv1 = asg_arc_n(ref, v); av1 = asg_arc_a(ref, v);
    if(drop_inexact) {
        for (i0 = 0; i0 < nv0; ++i0) { // loop through v's neighbors
            if (av0[i0].del) continue;
            if (av0[i0].el) continue;
            av0[i0].del = 1; asg_arc_del(g, av0[i0].v^1, (av0[i0].ul>>32)^1, 1);
            ncut++;
        }
    } else if(cutoff < 1) {
        for (i0 = 0; i0 < nv0; ++i0) { // loop through v's neighbors
            if (av0[i0].del) continue;
            if(mol < av0[i0].ol) mol = av0[i0].ol;
        }
        for (i1 = 0; i1 < nv1; ++i1) { // loop through v's neighbors
            if (av1[i1].del) continue;
            if(mol < av1[i1].ol) mol = av1[i1].ol;
        }
        if(mol > 0) {
            for (i0 = 0; i0 < nv0; ++i0) { // loop through v's neighbors
                if (av0[i0].del) continue;
                if(av0[i0].ol < (mol*cutoff)) {
                    av0[i0].del = 1; asg_arc_del(g, av0[i0].v^1, (av0[i0].ul>>32)^1, 1);
                    ncut++;
                }
            }
        }
    } else {
        for (i0 = 0; i0 < nv0; ++i0) { // loop through v's neighbors
            if (av0[i0].del) continue;
            av0[i0].del = 1; asg_arc_del(g, av0[i0].v^1, (av0[i0].ul>>32)^1, 1);
            ncut++;
        }
    }
    return ncut;
}

// Assembly:
pushq %rbp
pushq %rbx
movq 0x8(%rdi), %r8
movq 0x28(%rdi), %rax
movl %edx, %r10d
movq (%rax,%r10,8), %rdx
movq %rdx, %rax
shrq $0x20, %rax
leaq (%rax,%rax,2), %r9
leaq (%r8,%r9,8), %rax
testl %ecx, %ecx
je 0xe50c6
testl %edx, %edx
je 0xe51b6
movl %edx, %edx
xorl %esi, %esi
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
leaq (%rsi,%rsi,2), %r9
movl 0xc(%rax,%r9,8), %r10d
testl %r10d, %r10d
js 0xe50b5
leaq (%rax,%r9,8), %r9
cmpb $0x0, 0x12(%r9)
jne 0xe50b5
orl $0x80000000, %r10d      # imm = 0x80000000
movl %r10d, 0xc(%r9)
movl 0x8(%r9), %r10d
xorq $0x1, %r10
movq 0x28(%rdi), %r11
movq (%r11,%r10,8), %r11
movq %r11, %r10
andq %r8, %r10
je 0xe50b3
movl 0x4(%r9), %r9d
movq 0x8(%rdi), %rbx
shrq $0x20, %r11
shlq $0x3, %r10
leaq (%r10,%r10,2), %r10
leaq (%r11,%r11,2), %r11
leaq (%rbx,%r11,8), %r11
addq $0xc, %r11
xorl %ebx, %ebx
movl -0x4(%r11,%rbx), %ebp
xorl %r9d, %ebp
cmpl $0x1, %ebp
jne 0xe50aa
orb $-0x80, 0x3(%r11,%rbx)
addq $0x18, %rbx
cmpq %rbx, %r10
jne 0xe5097
incl %ecx
incq %rsi
cmpq %rdx, %rsi
jne 0xe5039
jmp 0xe52c2
movsd 0x14c242(%rip), %xmm1   # 0x231310
ucomisd %xmm0, %xmm1
jbe 0xe5120
movq 0x28(%rsi), %rcx
movq (%rcx,%r10,8), %rcx
testl %edx, %edx
je 0xe51bd
movl %edx, %r10d
leaq (%r8,%r9,8), %r9
addq $0xc, %r9
shlq $0x3, %r10
leaq (%r10,%r10,2), %r10
xorl %r11d, %r11d
xorl %ebx, %ebx
movl (%r9,%r11), %ebp
cmpl %ebp, %ebx
movl %ebp, %r8d
cmoval %ebx, %r8d
testl %ebp, %ebp
cmovsl %ebx, %r8d
addq $0x18, %r11
movl %r8d, %ebx
cmpq %r11, %r10
jne 0xe50fc
jmp 0xe51c0
testl %edx, %edx
je 0xe51b6
movl %edx, %edx
xorl %esi, %esi
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
leaq (%rsi,%rsi,2), %r9
movl 0xc(%rax,%r9,8), %r10d
testl %r10d, %r10d
js 0xe51a9
leaq (%rax,%r9,8), %r9
orl $0x80000000, %r10d      # imm = 0x80000000
movl %r10d, 0xc(%r9)
movl 0x8(%r9), %r10d
xorq $0x1, %r10
movq 0x28(%rdi), %r11
movq (%r11,%r10,8), %r11
movq %r11, %r10
andq %r8, %r10
je 0xe51a7
movl 0x4(%r9), %r9d
movq 0x8(%rdi), %rbx
shrq $0x20, %r11
shlq $0x3, %r10
leaq (%r10,%r10,2), %r10
leaq (%r11,%r11,2), %r11
leaq (%rbx,%r11,8), %r11
addq $0xc, %r11
xorl %ebx, %ebx
movl -0x4(%r11,%rbx), %ebp
xorl %r9d, %ebp
cmpl $0x1, %ebp
jne 0xe519e
orb $-0x80, 0x3(%r11,%rbx)
addq $0x18, %rbx
cmpq %rbx, %r10
jne 0xe518b
incl %ecx
incq %rsi
cmpq %rdx, %rsi
jne 0xe5134
jmp 0xe52c2
xorl %ecx, %ecx
jmp 0xe52c2
xorl %r8d, %r8d
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
andq %rcx, %r9
je 0xe5208
movq 0x8(%rsi), %rsi
shrq $0x20, %rcx
leaq (%rcx,%rcx,2), %rcx
leaq (%rsi,%rcx,8), %rcx
addq $0xc, %rcx
shlq $0x3, %r9
leaq (%r9,%r9,2), %rsi
xorl %r9d, %r9d
movl (%rcx,%r9), %r10d
cmpl %r10d, %r8d
movl %r10d, %r11d
cmoval %r8d, %r11d
testl %r10d, %r10d
cmovnsl %r11d, %r8d
addq $0x18, %r9
cmpq %r9, %rsi
jne 0xe51ea
xorl %ecx, %ecx
testl %r8d, %r8d
je 0xe52c2
testl %edx, %edx
je 0xe52c2
xorps %xmm1, %xmm1
cvtsi2sd %r8d, %xmm1
mulsd %xmm0, %xmm1
movl %edx, %edx
xorl %esi, %esi
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
leaq (%rsi,%rsi,2), %r9
movl 0xc(%rax,%r9,8), %r10d
testl %r10d, %r10d
js 0xe52b6
xorps %xmm0, %xmm0
cvtsi2sd %r10d, %xmm0
ucomisd %xmm0, %xmm1
jbe 0xe52b6
leaq (%rax,%r9,8), %r9
orl $0x80000000, %r10d      # imm = 0x80000000
movl %r10d, 0xc(%r9)
movl 0x8(%r9), %r10d
xorq $0x1, %r10
movq 0x28(%rdi), %r11
movq (%r11,%r10,8), %r11
movq %r11, %r10
andq %r8, %r10
je 0xe52b4
movl 0x4(%r9), %r9d
movq 0x8(%rdi), %rbx
shrq $0x20, %r11
shlq $0x3, %r10
leaq (%r10,%r10,2), %r10
leaq (%r11,%r11,2), %r11
leaq (%rbx,%r11,8), %r11
addq $0xc, %r11
xorl %ebx, %ebx
movl -0x4(%r11,%rbx), %ebp
xorl %r9d, %ebp
cmpl $0x1, %ebp
jne 0xe52ab
orb $-0x80, 0x3(%r11,%rbx)
addq $0x18, %rbx
cmpq %rbx, %r10
jne 0xe5298
incl %ecx
incq %rsi
cmpq %rdx, %rsi
jne 0xe5233
movl %ecx, %eax
popq %rbx
popq %rbp
retq