// File: /workspace/github_cpp_makefile_star2_O2/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x8(%rdi), %rax
movq 0x28(%rdi), %rdi
movl %edx, %edx
movq (%rdi,%rdx,8), %r8
movq %r8, %rdi
shrq $0x20, %rdi
testl %ecx, %ecx
je 0xa735c
movl %r8d, %ecx
imulq $0x18, %rcx, %r15
imulq $0x18, %rdi, %rcx
leaq (%rcx,%rax), %r12
addq $0x12, %r12
xorl %r13d, %r13d
pushq $0x1
popq %rbp
xorl %r14d, %r14d
cmpq %r13, %r15
je 0xa749f
movl -0x6(%r12,%r13), %eax
testl %eax, %eax
js 0xa7356
cmpb $0x0, (%r12,%r13)
jne 0xa7356
orl $0x80000000, %eax       # imm = 0x80000000
movl %eax, -0x6(%r12,%r13)
movl -0xe(%r12,%r13), %edx
movl -0xa(%r12,%r13), %esi
xorl $0x1, %esi
xorl $0x1, %edx
movq %rbx, %rdi
movl %ebp, %ecx
callq 0x6db50
incl %r14d
addq $0x18, %r13
jmp 0xa7316
movsd 0x13bf3c(%rip), %xmm1   # 0x1e32a0
ucomisd %xmm0, %xmm1
movl %r8d, %r8d
jbe 0xa73b4
movq 0x8(%rsi), %rcx
movq 0x28(%rsi), %rsi
movq (%rsi,%rdx,8), %rsi
movq %rsi, %rdx
shrq $0x20, %rdx
imulq $0x18, %r8, %r15
imulq $0x18, %rdi, %rdi
leaq (%rdi,%rax), %r12
addq $0xc, %r12
xorl %edi, %edi
xorl %eax, %eax
cmpq %rdi, %r15
je 0xa740a
movl (%r12,%rdi), %r8d
cmpl %r8d, %eax
movl %r8d, %r9d
cmoval %eax, %r9d
testl %r8d, %r8d
cmovnsl %r9d, %eax
addq $0x18, %rdi
jmp 0xa7394
imulq $0x18, %r8, %r15
imulq $0x18, %rdi, %rcx
leaq (%rcx,%rax), %r12
addq $0xc, %r12
xorl %r13d, %r13d
pushq $0x1
popq %rbp
xorl %r14d, %r14d
cmpq %r13, %r15
je 0xa749f
movl (%r12,%r13), %eax
testl %eax, %eax
js 0xa7404
orl $0x80000000, %eax       # imm = 0x80000000
movl %eax, (%r12,%r13)
movl -0x8(%r12,%r13), %edx
movl -0x4(%r12,%r13), %esi
xorl $0x1, %esi
xorl $0x1, %edx
movq %rbx, %rdi
movl %ebp, %ecx
callq 0x6db50
incl %r14d
addq $0x18, %r13
jmp 0xa73cd
movl %esi, %esi
imulq $0x18, %rsi, %rsi
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
addq $0xc, %rcx
xorl %edx, %edx
cmpq %rdx, %rsi
je 0xa743a
movl (%rcx,%rdx), %edi
cmpl %edi, %eax
movl %edi, %r8d
cmoval %eax, %r8d
testl %edi, %edi
cmovnsl %r8d, %eax
addq $0x18, %rdx
jmp 0xa741d
testl %eax, %eax
je 0xa749c
cvtsi2sd %eax, %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, (%rsp)
xorl %r13d, %r13d
pushq $0x1
popq %rbp
xorl %r14d, %r14d
cmpq %r13, %r15
je 0xa749f
movl (%r12,%r13), %eax
testl %eax, %eax
js 0xa7496
cvtsi2sd %eax, %xmm0
movsd (%rsp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0xa7496
orl $0x80000000, %eax       # imm = 0x80000000
movl %eax, (%r12,%r13)
movl -0x8(%r12,%r13), %edx
movl -0x4(%r12,%r13), %esi
xorl $0x1, %esi
xorl $0x1, %edx
movq %rbx, %rdi
movl %ebp, %ecx
callq 0x6db50
incl %r14d
addq $0x18, %r13
jmp 0xa7454
xorl %r14d, %r14d
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq