// File: 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
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movss %xmm0, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x8(%rbp), %rdi
addq $0x48, %rdi
callq 0x25230
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
addq $0x48, %rdi
callq 0x250b0
movq %rax, -0x30(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x599b0
testb $0x1, %al
jne 0x10c3d4
jmp 0x10c5fd
movq -0x20(%rbp), %rdi
addq $0x48, %rdi
callq 0xf270
cmpq $0x0, %rax
jne 0x10c413
movq -0x20(%rbp), %rax
addq $0x48, %rax
movq %rax, -0xb8(%rbp)
leaq -0x28(%rbp), %rdi
callq 0xaed90
movq -0xb8(%rbp), %rdi
movq %rax, %rsi
callq 0xf440
jmp 0x10c5ed
leaq -0x48(%rbp), %rdi
callq 0xf650
leaq -0x28(%rbp), %rdi
callq 0x599f0
movsd (%rax), %xmm0
movsd %xmm0, -0x50(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x599f0
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x599f0
movsd 0x10(%rax), %xmm0
movsd %xmm0, -0x60(%rbp)
movq -0x20(%rbp), %rdi
addq $0x48, %rdi
callq 0x25230
movq %rax, -0x68(%rbp)
movq -0x20(%rbp), %rdi
addq $0x48, %rdi
callq 0x250b0
movq %rax, -0x70(%rbp)
leaq -0x68(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x599b0
testb $0x1, %al
jne 0x10c48c
jmp 0x10c55a
leaq -0x68(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
callq 0x599f0
movq -0xc8(%rbp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, -0x78(%rbp)
callq 0x599f0
movq -0xc8(%rbp), %rdi
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x80(%rbp)
callq 0x599f0
movsd 0x10(%rax), %xmm0
movsd %xmm0, -0x88(%rbp)
movq -0x10(%rbp), %rdi
movsd -0x50(%rbp), %xmm0
movsd -0x58(%rbp), %xmm1
movsd -0x60(%rbp), %xmm2
movsd -0x78(%rbp), %xmm3
movsd -0x80(%rbp), %xmm4
movsd -0x88(%rbp), %xmm5
callq 0x97a10
movsd %xmm0, -0xc0(%rbp)
jmp 0x10c508
movsd -0xc0(%rbp), %xmm0
movsd %xmm0, -0x90(%rbp)
leaq -0x48(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x105c0
jmp 0x10c52a
jmp 0x10c52c
leaq -0x68(%rbp), %rdi
callq 0xb4bd0
jmp 0x10c465
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
leaq -0x48(%rbp), %rdi
callq 0xf9d0
jmp 0x10c64b
leaq -0x48(%rbp), %rdi
movq %rdi, -0xd0(%rbp)
callq 0x26bb0
movq -0xd0(%rbp), %rdi
movq %rax, -0xa8(%rbp)
callq 0x269f0
movq %rax, -0xb0(%rbp)
movq -0xa8(%rbp), %rdi
movq -0xb0(%rbp), %rsi
callq 0x65a10
jmp 0x10c599
leaq -0x48(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xedb0
movsd (%rax), %xmm0
movss -0x14(%rbp), %xmm1
cvtss2sd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x10c5e4
movq -0x20(%rbp), %rax
addq $0x48, %rax
movq %rax, -0xd8(%rbp)
leaq -0x28(%rbp), %rdi
callq 0xaed90
movq -0xd8(%rbp), %rdi
movq %rax, %rsi
callq 0xf440
jmp 0x10c5e2
jmp 0x10c5e4
leaq -0x48(%rbp), %rdi
callq 0xf9d0
jmp 0x10c5ef
leaq -0x28(%rbp), %rdi
callq 0xb4bd0
jmp 0x10c3ad
movq 0x1669bc(%rip), %rdi    # 0x272fc0
leaq 0xf0c6b(%rip), %rsi     # 0x1fd276
callq 0x5540
movq %rax, -0xe0(%rbp)
movq -0x20(%rbp), %rdi
addq $0x48, %rdi
callq 0xf270
movq -0xe0(%rbp), %rdi
movq %rax, %rsi
callq 0x5160
movq %rax, %rdi
movq 0x16695b(%rip), %rsi    # 0x272f98
callq 0x55b0
addq $0xe0, %rsp
popq %rbp
retq
movq -0x98(%rbp), %rdi
callq 0x58f0
nopw (%rax,%rax)