// File: Luthaf[P]zeopp/networkstorage.cc
// Function: getNodeID(Point, ATOM_NETWORK*, VORONOI_NETWORK*)
int getNodeID(Point pt, ATOM_NETWORK *atmnet, VORONOI_NETWORK *vornet){
    double minDist = DBL_MAX;
    int minID = -1;
    for(unsigned int i = 0; i < vornet->nodes.size(); i++){
        VOR_NODE curNode = vornet->nodes.at(i);
        double dist = atmnet->calcDistanceXYZ(pt[0], pt[1], pt[2], curNode.x, curNode.y, curNode.z);
        if(dist < threshold)
            return i;
        else {
            if(dist < minDist){
                minDist = dist;
                minID = i;
            }
        }
    }
    
    cerr << "Warning : When identifying Voronoi node, the distance exceeded the threshold of " << threshold << "\n"
    << "Occurred during analysis of " << atmnet->name << "\n"
    << "Closest node was within " << minDist << "\n"
    << "Proceeding with analysis" << "\n";
    return minID;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
leaq 0x10(%rbp), %rax
movq %rax, -0x88(%rbp)
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movsd 0x156e62(%rip), %xmm0   # 0x1f6348
movsd %xmm0, -0x20(%rbp)
movl $0xffffffff, -0x24(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
movq %rax, -0x90(%rbp)
movq -0x18(%rbp), %rdi
addq $0x48, %rdi
callq 0xf270
movq %rax, %rcx
movq -0x90(%rbp), %rax
cmpq %rcx, %rax
jae 0x9f692
movq -0x18(%rbp), %rdi
addq $0x48, %rdi
movl -0x28(%rbp), %eax
movl %eax, %esi
callq 0xf390
movq %rax, %rsi
leaq -0x68(%rbp), %rdi
callq 0xf3d0
movq -0x88(%rbp), %rdi
movq -0x10(%rbp), %rax
movq %rax, -0xa0(%rbp)
xorl %esi, %esi
callq 0xe9d70
movq %rax, -0x98(%rbp)
jmp 0x9f563
movq -0x88(%rbp), %rdi
movq -0x98(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0xb0(%rbp)
movl $0x1, %esi
callq 0xe9d70
movq %rax, -0xa8(%rbp)
jmp 0x9f590
movq -0x88(%rbp), %rdi
movq -0xa8(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0xc0(%rbp)
movl $0x2, %esi
callq 0xe9d70
movq %rax, -0xb8(%rbp)
jmp 0x9f5bd
movsd -0xc0(%rbp), %xmm1
movsd -0xb0(%rbp), %xmm0
movq -0xa0(%rbp), %rdi
movq -0xb8(%rbp), %rax
movsd (%rax), %xmm2
movsd -0x68(%rbp), %xmm3
movsd -0x60(%rbp), %xmm4
movsd -0x58(%rbp), %xmm5
callq 0x97a10
movsd %xmm0, -0xc8(%rbp)
jmp 0x9f5fd
movsd -0xc8(%rbp), %xmm0
movsd %xmm0, -0x70(%rbp)
movsd 0x157d86(%rip), %xmm0   # 0x1f7398
ucomisd -0x70(%rbp), %xmm0
jbe 0x9f642
movl -0x28(%rbp), %eax
movl %eax, -0x4(%rbp)
movl $0x1, -0x80(%rbp)
jmp 0x9f66b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x68(%rbp), %rdi
callq 0xf5c0
jmp 0x9f750
movsd -0x70(%rbp), %xmm1
movsd -0x20(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x9f662
movsd -0x70(%rbp), %xmm0
movsd %xmm0, -0x20(%rbp)
movl -0x28(%rbp), %eax
movl %eax, -0x24(%rbp)
jmp 0x9f664
movl $0x0, -0x80(%rbp)
leaq -0x68(%rbp), %rdi
callq 0xf5c0
movl -0x80(%rbp), %eax
testl %eax, %eax
je 0x9f682
jmp 0x9f67d
jmp 0x9f744
jmp 0x9f684
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x9f4f9
movq 0x1d3957(%rip), %rdi    # 0x272ff0
leaq 0x158c1f(%rip), %rsi    # 0x1f82bf
callq 0x5540
movq %rax, %rdi
movsd 0x157ce8(%rip), %xmm0   # 0x1f7398
callq 0x5980
movq %rax, %rdi
leaq 0x159f66(%rip), %rsi    # 0x1f9625
callq 0x5540
movq %rax, %rdi
leaq 0x158c42(%rip), %rsi    # 0x1f8310
callq 0x5540
movq %rax, %rdi
movq -0x10(%rbp), %rsi
addq $0x320, %rsi            # imm = 0x320
callq 0x5480
movq %rax, %rdi
leaq 0x159f35(%rip), %rsi    # 0x1f9625
callq 0x5540
movq %rax, %rdi
leaq 0x158c2e(%rip), %rsi    # 0x1f832d
callq 0x5540
movq %rax, %rdi
movsd -0x20(%rbp), %xmm0
callq 0x5980
movq %rax, %rdi
leaq 0x159f0a(%rip), %rsi    # 0x1f9625
callq 0x5540
movq %rax, %rdi
leaq 0x158c1c(%rip), %rsi    # 0x1f8346
callq 0x5540
movq %rax, %rdi
leaq 0x159eec(%rip), %rsi    # 0x1f9625
callq 0x5540
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xd0, %rsp
popq %rbp
retq
movq -0x78(%rbp), %rdi
callq 0x58f0
nopl (%rax)