// File: /workspace/github_cpp_makefile_star2_O1/Luthaf[P]zeopp/networkanalysis.cc
// Function: CAGE::reconstructCage(std::set<int, std::less<int>, std::allocator<int>>, ATOM_NETWORK*, VORONOI_NETWORK*)
void CAGE::reconstructCage(set<int> ids, ATOM_NETWORK *atmnet, VORONOI_NETWORK *vornet){
  int idCount = 0;
  set<int>::iterator iter = ids.begin();
  Point pivot = atmnet->xyz_to_abc(vornet->nodes[*iter].x, vornet->nodes[*iter].y, vornet->nodes[*iter].z);
  vector<Point> nodeXYZCoords;   nodeXYZCoords.push_back(Point(vornet->nodes[*iter].x, vornet->nodes[*iter].y, vornet->nodes[*iter].z));
  nodeIDs.push_back(*iter); 
  nodeOffsets.push_back(DELTA_POS(0,0,0));
  nodeIndices.insert(pair<int,int>(*iter, idCount));
  iter++;
  idCount++;
  
  // Calculate and store the closest positions of other points to pivot point
  while(iter != ids.end()) {
    double minDa = DBL_MAX, minDb = DBL_MAX, minDc = DBL_MAX;
    Point other = atmnet->xyz_to_abc(vornet->nodes[*iter].x,  vornet->nodes[*iter].y, vornet->nodes[*iter].z);
    atmnet->getDistCalc().minimum_periodic_distance(pivot[0], pivot[1], pivot[2], other[0], other[1], other[2], minDa, minDb, minDc);
    Point shifted = Point(minDa, minDb, minDc).add(pivot);
    nodeXYZCoords.push_back(atmnet->abc_to_xyz(shifted));
    
    Point offset = shifted.subtract(other);
    nodeIDs.push_back(*iter);  
    nodeOffsets.push_back(DELTA_POS((int)(floor(offset[0] + 0.5)), (int)(floor(offset[1] + 0.5)), (int)(floor(offset[2] + 0.5))));
    nodeIndices.insert(pair<int,int>(*iter, idCount));
    iter++;
    idCount++;
  }
  
  // Compute the center point of the cage
  cx = cy = cz = 0;
  for(unsigned int i = 0; i < nodeXYZCoords.size(); i++){
    cx += nodeXYZCoords[i][0]; cy += nodeXYZCoords[i][1]; cz += nodeXYZCoords[i][2];
  }
  cx /= nodeXYZCoords.size(); cy /= nodeXYZCoords.size(); cz /= nodeXYZCoords.size();
  
  // Compute the radius of the cage
  iter = ids.begin();
  radius = DBL_MAX;
  for(unsigned int i = 0; i < nodeXYZCoords.size(); i++){
    radius = min(radius, calcEuclideanDistance(cx, cy, cz, nodeXYZCoords[i][0], nodeXYZCoords[i][1], nodeXYZCoords[i][2]) + vornet->nodes[*iter].rad_stat_sphere);
    iter++;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movq %rcx, %r15
movq %rdi, %r14
movq %rsi, 0x78(%rsp)
movq 0x18(%rsi), %rbx
movslq 0x20(%rbx), %rax
movq 0x48(%rcx), %rcx
shlq $0x6, %rax
movsd (%rcx,%rax), %xmm0
movsd 0x8(%rcx,%rax), %xmm1
movsd 0x10(%rcx,%rax), %xmm2
leaq 0xe0(%rsp), %rdi
movq %rdx, 0x58(%rsp)
movq %rdx, %rsi
callq 0x531ea
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
movslq 0x20(%rbx), %rax
movq %r15, 0x80(%rsp)
movq 0x48(%r15), %rcx
shlq $0x6, %rax
movsd (%rcx,%rax), %xmm0
movsd 0x8(%rcx,%rax), %xmm1
movsd 0x10(%rcx,%rax), %xmm2
leaq 0xf8(%rsp), %rdi
callq 0x85436
movq 0x28(%rsp), %rsi
cmpq 0x30(%rsp), %rsi
je 0x35db4
movq 0x108(%rsp), %rax
movq %rax, 0x10(%rsi)
movupd 0xf8(%rsp), %xmm0
movupd %xmm0, (%rsi)
addq $0x18, 0x28(%rsp)
jmp 0x35dc6
leaq 0x20(%rsp), %rdi
leaq 0xf8(%rsp), %rdx
callq 0x12d92
leaq 0x20(%rbx), %r15
leaq 0x30(%r14), %rdi
movq 0x38(%r14), %rsi
cmpq 0x40(%r14), %rsi
movq %rdi, 0xa8(%rsp)
je 0x35def
movl (%r15), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x38(%r14)
jmp 0x35df7
movq %r15, %rdx
callq 0xf7b4
leaq 0xf8(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x509d8
leaq 0x48(%r14), %r13
movq 0x50(%r14), %rsi
cmpq 0x58(%r14), %rsi
je 0x35e34
movl 0x100(%rsp), %eax
movl %eax, 0x8(%rsi)
movq 0xf8(%rsp), %rax
movq %rax, (%rsi)
addq $0xc, 0x50(%r14)
jmp 0x35e44
leaq 0xf8(%rsp), %rdx
movq %r13, %rdi
callq 0x3bac4
movl (%r15), %eax
leaq 0xf8(%rsp), %rsi
movl %eax, (%rsi)
movl $0x0, 0x4(%rsi)
movq %r14, %rdi
callq 0x13690
movq %r13, 0xa0(%rsp)
movq %rbx, %rdi
callq 0x44f0
movq %rax, %rbx
movq 0x78(%rsp), %rax
addq $0x8, %rax
movq %rax, 0xb0(%rsp)
cmpq %rax, %rbx
je 0x36262
movl $0x1, 0x60(%rsp)
leaq 0x170(%rsp), %r13
leaq 0xf8(%rsp), %r15
leaq 0xe0(%rsp), %r12
leaq 0xc8(%rsp), %rbp
movabsq $0x7fefffffffffffff, %rax # imm = 0x7FEFFFFFFFFFFFFF
movq %rax, 0x98(%rsp)
movq %rax, 0x90(%rsp)
movq %rax, 0x88(%rsp)
movslq 0x20(%rbx), %rax
movq 0x80(%rsp), %rcx
movq 0x48(%rcx), %rcx
shlq $0x6, %rax
movsd (%rcx,%rax), %xmm0
movsd 0x8(%rcx,%rax), %xmm1
movsd 0x10(%rcx,%rax), %xmm2
movq %r13, %rdi
movq 0x58(%rsp), %rsi
callq 0x531ea
movq %r15, %rdi
movq 0x58(%rsp), %rsi
callq 0x52aea
movq %r12, %rdi
xorl %esi, %esi
callq 0x85478
movsd (%rax), %xmm0
movsd %xmm0, 0x50(%rsp)
movq %r12, %rdi
movl $0x1, %esi
callq 0x85478
movsd (%rax), %xmm0
movsd %xmm0, 0x40(%rsp)
movq %r12, %rdi
movl $0x2, %esi
callq 0x85478
movsd (%rax), %xmm0
movsd %xmm0, 0x48(%rsp)
movq %r13, %rdi
xorl %esi, %esi
callq 0x85478
movsd (%rax), %xmm0
movsd %xmm0, 0xc0(%rsp)
movq %r13, %rdi
movl $0x1, %esi
callq 0x85478
movsd (%rax), %xmm0
movsd %xmm0, 0xb8(%rsp)
movq %r13, %rdi
movl $0x2, %esi
callq 0x85478
movsd (%rax), %xmm5
movq %r15, %rdi
movsd 0x50(%rsp), %xmm0
movsd 0x40(%rsp), %xmm1
movsd 0x48(%rsp), %xmm2
movsd 0xc0(%rsp), %xmm3
movsd 0xb8(%rsp), %xmm4
leaq 0x98(%rsp), %rsi
leaq 0x90(%rsp), %rdx
leaq 0x88(%rsp), %rcx
callq 0x78b00
movq 0x128(%rsp), %rdi
testq %rdi, %rdi
je 0x35ffb
movq 0x138(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x110(%rsp), %rdi
testq %rdi, %rdi
je 0x36018
movq 0x120(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0xf8(%rsp), %rdi
testq %rdi, %rdi
je 0x36035
movq 0x108(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movsd 0x98(%rsp), %xmm0
movsd 0x90(%rsp), %xmm1
movsd 0x88(%rsp), %xmm2
movq %rbp, %rdi
callq 0x85436
movq 0xf0(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0xe0(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r15, %rdi
movq %rbp, %rsi
callq 0x85446
movq 0x108(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0xf8(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %rbp, %rdi
movq 0x58(%rsp), %rsi
callq 0x52144
movq 0x28(%rsp), %rsi
cmpq 0x30(%rsp), %rsi
je 0x360cd
movq 0xd8(%rsp), %rax
movq %rax, 0x10(%rsi)
movups 0xc8(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x18, 0x28(%rsp)
jmp 0x360da
leaq 0x20(%rsp), %rdi
movq %rbp, %rdx
callq 0x3012c
movq 0x180(%rsp), %rax
movq %rax, 0x10(%rsp)
movupd 0x170(%rsp), %xmm0
movupd %xmm0, (%rsp)
movq %rbp, %rdi
movq %r15, %rsi
callq 0x85528
leaq 0x20(%rbx), %rdx
movq 0x38(%r14), %rsi
cmpq 0x40(%r14), %rsi
movq %rdx, 0x50(%rsp)
je 0x36121
movl (%rdx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x38(%r14)
jmp 0x3612e
movq 0xa8(%rsp), %rdi
callq 0xf7b4
movq %rbp, %rdi
xorl %esi, %esi
callq 0x85478
movsd (%rax), %xmm0
addsd 0x118ef4(%rip), %xmm0   # 0x14f038
callq 0x4700
movsd %xmm0, 0x40(%rsp)
leaq 0xc8(%rsp), %rdi
movl $0x1, %esi
callq 0x85478
movsd (%rax), %xmm0
movsd %xmm0, 0x48(%rsp)
leaq 0xc8(%rsp), %rdi
movl $0x2, %esi
callq 0x85478
movq %rax, %rbp
cvttsd2si 0x40(%rsp), %eax
movl %eax, 0x40(%rsp)
movsd 0x118ea6(%rip), %xmm1   # 0x14f038
movsd 0x48(%rsp), %xmm0
addsd %xmm1, %xmm0
callq 0x4700
movq %r15, %r12
movq %r13, %r15
movq %r14, %r13
movq %rbx, %r14
cvttsd2si %xmm0, %ebx
movsd (%rbp), %xmm0
addsd 0x118e7a(%rip), %xmm0   # 0x14f038
callq 0x4700
cvttsd2si %xmm0, %ecx
leaq 0x6c(%rsp), %rdi
movl 0x40(%rsp), %esi
movl %ebx, %edx
movq %r14, %rbx
movq %r13, %r14
movq %r15, %r13
movq %r12, %r15
leaq 0xe0(%rsp), %r12
callq 0x509d8
movq 0x50(%r14), %rsi
cmpq 0x58(%r14), %rsi
je 0x3620b
movl 0x74(%rsp), %eax
movl %eax, 0x8(%rsi)
movq 0x6c(%rsp), %rax
movq %rax, (%rsi)
addq $0xc, 0x50(%r14)
jmp 0x3621d
movq 0xa0(%rsp), %rdi
leaq 0x6c(%rsp), %rdx
callq 0x3bac4
movq 0x50(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x6c(%rsp)
movl 0x60(%rsp), %eax
movl %eax, 0x70(%rsp)
movq %r14, %rdi
leaq 0x6c(%rsp), %rsi
callq 0x13690
movq %rbx, %rdi
callq 0x44f0
movq %rax, %rbx
incl 0x60(%rsp)
cmpq 0xb0(%rsp), %rax
leaq 0xc8(%rsp), %rbp
jne 0x35eb5
xorpd %xmm0, %xmm0
movupd %xmm0, 0x60(%r14)
movq $0x0, 0x70(%r14)
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rcx
movabsq $-0x5555555555555555, %r12 # imm = 0xAAAAAAAAAAAAAAAB
subq %rax, %rcx
je 0x36325
leaq 0x60(%r14), %r15
movl $0x1, %ebp
xorl %edx, %edx
leaq (%rdx,%rdx,2), %rbx
leaq (%rax,%rbx,8), %rdi
xorl %esi, %esi
callq 0x85478
movsd (%rax), %xmm0
addsd (%r15), %xmm0
movsd %xmm0, (%r15)
shlq $0x3, %rbx
movq 0x20(%rsp), %rdi
addq %rbx, %rdi
movl $0x1, %esi
callq 0x85478
movsd (%rax), %xmm0
addsd 0x68(%r14), %xmm0
movsd %xmm0, 0x68(%r14)
addq 0x20(%rsp), %rbx
movq %rbx, %rdi
movl $0x2, %esi
callq 0x85478
movsd (%rax), %xmm0
addsd 0x70(%r14), %xmm0
movsd %xmm0, 0x70(%r14)
movl %ebp, %edx
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
imulq %r12, %rcx
incl %ebp
cmpq %rdx, %rcx
ja 0x3629c
jmp 0x3632d
sarq $0x3, %rcx
imulq %r12, %rcx
movq %rcx, %xmm0
punpckldq 0x11cf66(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x11cf6e(%rip), %xmm0   # 0x1532b0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd 0x60(%r14), %xmm0
movsd 0x68(%r14), %xmm2
divsd %xmm1, %xmm0
movsd %xmm0, 0x60(%r14)
divsd %xmm1, %xmm2
movsd %xmm2, 0x68(%r14)
movsd 0x70(%r14), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, 0x70(%r14)
movq 0x78(%rsp), %rax
movq 0x18(%rax), %rbx
movabsq $0x7fefffffffffffff, %rax # imm = 0x7FEFFFFFFFFFFFFF
movq %rax, 0x78(%r14)
movq 0x20(%rsp), %rdi
cmpq %rdi, 0x28(%rsp)
je 0x36495
movl $0x1, %ebp
xorl %eax, %eax
movsd 0x60(%r14), %xmm0
movsd %xmm0, 0x58(%rsp)
movsd 0x68(%r14), %xmm0
movsd %xmm0, 0x60(%rsp)
movsd 0x70(%r14), %xmm0
movsd %xmm0, 0x50(%rsp)
leaq (%rax,%rax,2), %r15
leaq (%rdi,%r15,8), %rdi
xorl %esi, %esi
callq 0x85478
movsd (%rax), %xmm0
movsd %xmm0, 0x40(%rsp)
shlq $0x3, %r15
movq 0x20(%rsp), %rdi
addq %r15, %rdi
movl $0x1, %esi
callq 0x85478
movsd (%rax), %xmm0
movsd %xmm0, 0x48(%rsp)
addq 0x20(%rsp), %r15
movq %r15, %rdi
movl $0x2, %esi
callq 0x85478
movsd (%rax), %xmm5
movsd 0x58(%rsp), %xmm0
movsd 0x60(%rsp), %xmm1
movsd 0x50(%rsp), %xmm2
movsd 0x40(%rsp), %xmm3
movsd 0x48(%rsp), %xmm4
callq 0x868fa
movslq 0x20(%rbx), %rax
movq 0x80(%rsp), %rcx
movq 0x48(%rcx), %rcx
shlq $0x6, %rax
addsd 0x18(%rcx,%rax), %xmm0
minsd 0x78(%r14), %xmm0
movsd %xmm0, 0x78(%r14)
movq %rbx, %rdi
callq 0x44f0
movq %rax, %rbx
movl %ebp, %eax
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rcx
subq %rdi, %rcx
sarq $0x3, %rcx
imulq %r12, %rcx
incl %ebp
cmpq %rax, %rcx
ja 0x363ac
testq %rdi, %rdi
je 0x364a7
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x364d1
jmp 0x364d1
jmp 0x364d1
jmp 0x364d1
jmp 0x364d1
jmp 0x364d1
jmp 0x364d1
jmp 0x364d1
jmp 0x364d1
jmp 0x364d1
jmp 0x364d1
jmp 0x364d1
movq %rax, %rbx
jmp 0x364e6
movq %rax, %rbx
leaq 0xf8(%rsp), %rdi
callq 0x38a78
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x364fd
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq %rbx, %rdi
callq 0x4780
nop