// File: /workspace/github_cpp_makefile_star2_O1/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, 0x38(%rsp)
cmpq 0x50(%rdi), %r12
je 0x9de61
movq %rsi, %r14
leaq 0x48(%rbx), %rax
movq %rax, 0x20(%rsp)
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x30(%rsp)
movq %rsp, %rbp
leaq 0x28(%rsp), %r13
movq 0x48(%rbx), %r15
cmpq %r15, 0x50(%rbx)
je 0x9de41
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
cmpq 0x50(%rbx), %r15
je 0x9ddc6
movsd (%r12), %xmm0
movsd %xmm0, 0x50(%rsp)
movsd 0x8(%r12), %xmm0
movsd %xmm0, 0x48(%rsp)
movsd 0x10(%r12), %xmm0
movsd %xmm0, 0x40(%rsp)
movsd (%r15), %xmm3
movsd 0x8(%r15), %xmm4
movsd 0x10(%r15), %xmm5
movq %r14, %rdi
movsd 0x50(%rsp), %xmm0
movsd 0x48(%rsp), %xmm1
movsd 0x40(%rsp), %xmm2
callq 0x5394a
movsd %xmm0, 0x28(%rsp)
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x9ddb1
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%rsp)
jmp 0x9ddbc
movq %rbp, %rdi
movq %r13, %rdx
callq 0x148c4
addq $0x40, %r15
cmpq 0x50(%rbx), %r15
jne 0x9dd65
movq %rbp, %r13
movq (%rsp), %r15
movq 0x8(%rsp), %rbp
cmpq %rbp, %r15
je 0x9de04
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 0x3c033
movq %r15, %rdi
movq %rbp, %rsi
callq 0x3c12c
movq (%rsp), %rax
movsd (%rax), %xmm0
ucomisd 0x30(%rsp), %xmm0
jbe 0x9de21
movq 0x20(%rsp), %rdi
movq %r12, %rsi
callq 0xe962
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x9de37
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq %r13, %rbp
leaq 0x28(%rsp), %r13
jmp 0x9de4e
movq 0x20(%rsp), %rdi
movq %r12, %rsi
callq 0xe962
addq $0x40, %r12
movq 0x38(%rsp), %rax
cmpq 0x50(%rax), %r12
jne 0x9dd17
movq 0xf9158(%rip), %r14     # 0x196fc0
leaq 0xba647(%rip), %rsi     # 0x1584b6
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 0x9decb
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x9dee4
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq %rbx, %rdi
callq 0x4780