// File: Luthaf[P]zeopp/cluster.cc
// Function: ha_prune_within_atom(VORONOI_NETWORK*, ATOM_NETWORK*, float, VORONOI_NETWORK*)
void ha_prune_within_atom(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){
        double x2 = vh_it->x;
        double y2 = vh_it->y;
        double z2 = vh_it->z;
        bool near_flag = false;
        for (AtmIt ait = atmnet->atoms.begin(); ait != atmnet->atoms.end(); ++ait) {
            double x1 = ait->x;
            double y1 = ait->y;
            double z1 = ait->z;
            double dist = atmnet->calcDistanceXYZ(x1,y1,z1,x2,y2,z2); 
            if (dist < ait->radius-cutoff) {
                near_flag = true;
                break;
            }
        }
        if (not near_flag) 
            red_vornet->nodes.push_back(*vh_it);
    }

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

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %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 0x10c6b4
jmp 0x10c81b
leaq -0x28(%rbp), %rdi
callq 0x599f0
movsd (%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x599f0
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x40(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x599f0
movsd 0x10(%rax), %xmm0
movsd %xmm0, -0x48(%rbp)
movb $0x0, -0x49(%rbp)
movq -0x10(%rbp), %rdi
addq $0x2f0, %rdi            # imm = 0x2F0
callq 0xd0f0
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rdi
addq $0x2f0, %rdi            # imm = 0x2F0
callq 0xd160
movq %rax, -0x60(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0xd120
testb $0x1, %al
jne 0x10c72e
jmp 0x10c7de
leaq -0x58(%rbp), %rdi
callq 0xd190
movsd (%rax), %xmm0
movsd %xmm0, -0x68(%rbp)
leaq -0x58(%rbp), %rdi
callq 0xd190
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x70(%rbp)
leaq -0x58(%rbp), %rdi
callq 0xd190
movsd 0x10(%rax), %xmm0
movsd %xmm0, -0x78(%rbp)
movq -0x10(%rbp), %rdi
movsd -0x68(%rbp), %xmm0
movsd -0x70(%rbp), %xmm1
movsd -0x78(%rbp), %xmm2
movsd -0x38(%rbp), %xmm3
movsd -0x40(%rbp), %xmm4
movsd -0x48(%rbp), %xmm5
callq 0x97a10
movsd %xmm0, -0x80(%rbp)
movsd -0x80(%rbp), %xmm0
movsd %xmm0, -0x88(%rbp)
leaq -0x58(%rbp), %rdi
callq 0xd190
movsd -0x88(%rbp), %xmm1
movsd 0x30(%rax), %xmm0
movss -0x14(%rbp), %xmm2
cvtss2sd %xmm2, %xmm2
subsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x10c7ce
movb $0x1, -0x49(%rbp)
jmp 0x10c7de
jmp 0x10c7d0
leaq -0x58(%rbp), %rdi
callq 0xb16f0
jmp 0x10c704
testb $0x1, -0x49(%rbp)
jne 0x10c80b
movq -0x20(%rbp), %rax
addq $0x48, %rax
movq %rax, -0x90(%rbp)
leaq -0x28(%rbp), %rdi
callq 0xaed90
movq -0x90(%rbp), %rdi
movq %rax, %rsi
callq 0xf440
jmp 0x10c80d
leaq -0x28(%rbp), %rdi
callq 0xb4bd0
jmp 0x10c68d
movq 0x16679e(%rip), %rdi    # 0x272fc0
leaq 0xf0a4d(%rip), %rsi     # 0x1fd276
callq 0x5540
movq %rax, -0x98(%rbp)
movq -0x20(%rbp), %rdi
addq $0x48, %rdi
callq 0xf270
movq -0x98(%rbp), %rdi
movq %rax, %rsi
callq 0x5160
movq %rax, %rdi
movq 0x16673d(%rip), %rsi    # 0x272f98
callq 0x55b0
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax)