// File: /workspace/github_cpp_makefile_star2_O3/Luthaf[P]zeopp/cluster.cc
// Function: geometry_pruning(VORONOI_NETWORK*, ATOM_NETWORK*, float, VORONOI_NETWORK*)
void geometry_pruning(VORONOI_NETWORK* ha_vornet, ATOM_NETWORK* atmnet, 
                      float cutoff, VORONOI_NETWORK* red_vornet)
{
    for (VnIt vh_it = ha_vornet->nodes.begin(); vh_it != ha_vornet->nodes.end(); ++vh_it){
        if (red_vornet->nodes.size() == 0) {
            red_vornet->nodes.push_back(*vh_it);
        }
        else {
            vector<double> dists;
            double x1 = vh_it->x;
            double y1 = vh_it->y;
            double z1 = vh_it->z;
            for (VnIt vit = red_vornet->nodes.begin(); vit != red_vornet->nodes.end(); ++vit){
                double x2 = vit->x;
                double y2 = vit->y;
                double z2 = vit->z;
                double dist = atmnet->calcDistanceXYZ(x1,y1,z1,x2,y2,z2); 
                dists.push_back(dist);
            }
            sort(dists.begin(), dists.end());
            if (dists[0] > cutoff) {
                red_vornet->nodes.push_back(*vh_it);
            }
        }
    }

    cout << "size of reduced vornet " << red_vornet->nodes.size() << endl;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdx, %rbx
movq 0x48(%rdi), %r12
movq %rdi, 0x30(%rsp)
cmpq 0x50(%rdi), %r12
je 0x9c326
movq %rsi, %r14
leaq 0x48(%rbx), %rax
movq %rax, 0x20(%rsp)
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x28(%rsp)
leaq 0x50(%rsp), %r13
movq 0x48(%rbx), %r15
cmpq %r15, 0x50(%rbx)
je 0x9c306
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movsd (%r12), %xmm0
movsd %xmm0, 0x48(%rsp)
movsd 0x8(%r12), %xmm0
movsd %xmm0, 0x40(%rsp)
movsd 0x10(%r12), %xmm0
movsd %xmm0, 0x38(%rsp)
movsd (%r15), %xmm3
movsd 0x8(%r15), %xmm4
movsd 0x10(%r15), %xmm5
movq %r14, %rdi
movsd 0x48(%rsp), %xmm0
movsd 0x40(%rsp), %xmm1
movsd 0x38(%rsp), %xmm2
callq 0x5364c
movsd %xmm0, 0x50(%rsp)
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x9c27d
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%rsp)
jmp 0x9c288
movq %rsp, %rdi
movq %r13, %rdx
callq 0x1481e
addq $0x40, %r15
cmpq 0x50(%rbx), %r15
jne 0x9c231
movq (%rsp), %r15
movq 0x8(%rsp), %rbp
cmpq %rbp, %r15
je 0x9c2d1
movq %rbp, %rax
subq %r15, %rax
sarq $0x3, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r15, %rdi
movq %rbp, %rsi
callq 0x3bc39
movq %r15, %rdi
movq %rbp, %rsi
callq 0x3bd32
movq (%rsp), %r15
movsd (%r15), %xmm0
ucomisd 0x28(%rsp), %xmm0
jbe 0x9c2f4
movq 0x20(%rsp), %rdi
movq %r12, %rsi
callq 0xe9d4
movq (%rsp), %r15
testq %r15, %r15
je 0x9c313
movq 0x10(%rsp), %rsi
subq %r15, %rsi
movq %r15, %rdi
callq 0x4470
jmp 0x9c313
movq 0x20(%rsp), %rdi
movq %r12, %rsi
callq 0xe9d4
addq $0x40, %r12
movq 0x30(%rsp), %rax
cmpq 0x50(%rax), %r12
jne 0x9c1ed
movq 0xf8c93(%rip), %r14     # 0x194fc0
leaq 0xba342(%rip), %rsi     # 0x156676
movl $0x17, %edx
movq %r14, %rdi
callq 0x44e0
movq 0x50(%rbx), %rsi
subq 0x48(%rbx), %rsi
sarq $0x6, %rsi
movq %r14, %rdi
callq 0x42b0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4420
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x42c0
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x9c390
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x9c3a9
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq %rbx, %rdi
callq 0x4780