// File: /workspace/github_cpp_makefile_star2_O2/Luthaf[P]zeopp/networkstorage.cc
// Function: ATOM_NETWORK::randomlyAdjustCoordsAndCell()
void ATOM_NETWORK::randomlyAdjustCoordsAndCell() {
  double shiftMagnitude = TOLERANCE;
  printf("NOTICE: attempting random vector shift of all atom coordinates by %e (and unit cell parameters by up to this amount) to overcome Voronoi volume check failure (this option can be disabled by not using the -allowAdjustCoordsAndCell flag)\n", shiftMagnitude);
  printf("NOTICE: original cell dimensions and angles: %e %e %e; %e %e %e\n", a, b, c, alpha, beta, gamma);
  make(
(((rand()*1.0/RAND_MAX)-0.5)*2.0*shiftMagnitude)+a,
(((rand()*1.0/RAND_MAX)-0.5)*2.0*shiftMagnitude)+b,
(((rand()*1.0/RAND_MAX)-0.5)*2.0*shiftMagnitude)+c,
(((rand()*1.0/RAND_MAX)-0.5)*2.0*shiftMagnitude)+alpha,
(((rand()*1.0/RAND_MAX)-0.5)*2.0*shiftMagnitude)+beta,
(((rand()*1.0/RAND_MAX)-0.5)*2.0*shiftMagnitude)+gamma
);
  printf("NOTICE: randomly adjusted cell dimensions and angles: %e %e %e; %e %e %e\n", a, b, c, alpha, beta, gamma);
  for(int at=0; at<numAtoms; at++) {
    //shift each Cartesian coord in some direction, by distance TOLERANCE
    Point smallShift = genRandomVec().scale(shiftMagnitude);
    Point resultOfShiftInABCNoPBC = xyz_to_abc(Point(
      atoms.at(at).x+smallShift[0],
      atoms.at(at).y+smallShift[1],
      atoms.at(at).z+smallShift[2]
    ));
//    Point resultOfShiftInABC = Point(trans_to_origuc(resultOfShiftInABCNoPBC[0]),trans_to_origuc(resultOfShiftInABCNoPBC[1]),trans_to_origuc(resultOfShiftInABCNoPBC[2]));
    Point resultOfShiftInABC = resultOfShiftInABCNoPBC;
    Point resultOfShiftInXYZ = abc_to_xyz(resultOfShiftInABC);
    //now write the new coords to the atmnet
//printf("DEBUG: atom %d was at %e %e %e, now at %e %e %e\n", at, atoms.at(at).x, atoms.at(at).y, atoms.at(at).z, resultOfShiftInXYZ[0], resultOfShiftInXYZ[1], resultOfShiftInXYZ[2]);
    atoms.at(at).x = resultOfShiftInXYZ[0];
    atoms.at(at).y = resultOfShiftInXYZ[1];
    atoms.at(at).z = resultOfShiftInXYZ[2];
    atoms.at(at).a_coord = resultOfShiftInABC[0];
    atoms.at(at).b_coord = resultOfShiftInABC[1];
    atoms.at(at).c_coord = resultOfShiftInABC[2];
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rdi, %rbx
leaq 0xc36ef(%rip), %rdi     # 0x1017a8
movsd 0xc35ff(%rip), %xmm0    # 0x1016c0
movb $0x1, %al
callq 0x4050
movsd 0x8(%rbx), %xmm0
movsd 0x10(%rbx), %xmm1
movsd 0x18(%rbx), %xmm2
movsd 0x20(%rbx), %xmm3
movsd 0x28(%rbx), %xmm4
movsd 0x30(%rbx), %xmm5
leaq 0xc37a8(%rip), %rdi     # 0x101895
movb $0x6, %al
callq 0x4050
callq 0x4170
movl %eax, %ebp
movups 0x8(%rbx), %xmm0
movaps %xmm0, 0x20(%rsp)
callq 0x4170
movd %ebp, %xmm0
movd %eax, %xmm1
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
cvtdq2pd %xmm0, %xmm0
divpd 0xc35ff(%rip), %xmm0    # 0x101720
addpd 0xc3607(%rip), %xmm0    # 0x101730
movapd 0x20(%rsp), %xmm1
movhpd 0x10(%rbx), %xmm1       # xmm1 = xmm1[0],mem[0]
addpd %xmm0, %xmm0
mulpd 0xc3600(%rip), %xmm0    # 0x101740
addpd %xmm1, %xmm0
movapd %xmm0, 0x20(%rsp)
callq 0x4170
movl %eax, %ebp
movups 0x18(%rbx), %xmm0
movaps %xmm0, 0x30(%rsp)
callq 0x4170
movd %ebp, %xmm0
movd %eax, %xmm1
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
cvtdq2pd %xmm0, %xmm0
divpd 0xc35a9(%rip), %xmm0    # 0x101720
addpd 0xc35b1(%rip), %xmm0    # 0x101730
addpd %xmm0, %xmm0
movapd 0x30(%rsp), %xmm1
movhpd 0x20(%rbx), %xmm1       # xmm1 = xmm1[0],mem[0]
mulpd 0xc35aa(%rip), %xmm0    # 0x101740
addpd %xmm1, %xmm0
movapd %xmm0, 0x30(%rsp)
callq 0x4170
movl %eax, %ebp
movups 0x28(%rbx), %xmm0
movaps %xmm0, 0x40(%rsp)
callq 0x4170
movd %ebp, %xmm0
movd %eax, %xmm1
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
cvtdq2pd %xmm0, %xmm0
divpd 0xc3553(%rip), %xmm0    # 0x101720
addpd 0xc355b(%rip), %xmm0    # 0x101730
addpd %xmm0, %xmm0
movapd 0x40(%rsp), %xmm1
movhpd 0x30(%rbx), %xmm1       # xmm1 = xmm1[0],mem[0]
mulpd 0xc3554(%rip), %xmm0    # 0x101740
addpd %xmm1, %xmm0
movaps 0x20(%rsp), %xmm1
movups %xmm1, 0x8(%rbx)
movaps 0x30(%rsp), %xmm1
movups %xmm1, 0x18(%rbx)
movupd %xmm0, 0x28(%rbx)
movq %rbx, %rdi
callq 0x3e5a4
movsd 0x8(%rbx), %xmm0
movsd 0x10(%rbx), %xmm1
movsd 0x18(%rbx), %xmm2
movsd 0x20(%rbx), %xmm3
movsd 0x28(%rbx), %xmm4
movsd 0x30(%rbx), %xmm5
leaq 0xc36a2(%rip), %rdi     # 0x1018d6
movb $0x6, %al
callq 0x4050
leaq 0x2f0(%rbx), %r14
xorl %r15d, %r15d
pushq $0x1
popq %r13
movslq 0x110(%rbx), %rax
cmpq %rax, %r15
jge 0x3e492
leaq 0x58(%rsp), %r12
movq %r12, %rdi
callq 0x39c71
leaq 0xc0(%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rsi
movsd 0xc3444(%rip), %xmm0    # 0x1016c0
callq 0x63d70
movq %r14, %rdi
movq %r15, %rsi
callq 0xa73a
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movq %rbp, %rdi
xorl %esi, %esi
callq 0x63c78
movsd 0x20(%rsp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0xa73a
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x30(%rsp)
movq %rbp, %rdi
movl %r13d, %esi
callq 0x63c78
movsd 0x30(%rsp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, 0x30(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0xa73a
movsd 0x10(%rax), %xmm0
movsd %xmm0, 0x40(%rsp)
movq %rbp, %rdi
pushq $0x2
popq %rbp
movl %ebp, %esi
callq 0x63c78
movsd 0x40(%rsp), %xmm2
addsd (%rax), %xmm2
leaq 0x90(%rsp), %rdi
movsd 0x20(%rsp), %xmm0
movsd 0x30(%rsp), %xmm1
callq 0x63c46
movq 0xa0(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x90(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r12, %rdi
movq %rbx, %rsi
callq 0x3e4c8
movq 0x68(%rsp), %rax
movq %rax, 0x80(%rsp)
movups 0x58(%rsp), %xmm0
movaps %xmm0, 0x70(%rsp)
movq 0x68(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x58(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0xa8(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rsi
callq 0x3e536
movq %r12, %rdi
xorl %esi, %esi
callq 0x63c78
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0xa73a
movsd 0x20(%rsp), %xmm0
movsd %xmm0, (%rax)
movq %r12, %rdi
movl %r13d, %esi
callq 0x63c78
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0xa73a
movsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x8(%rax)
movq %r12, %rdi
movl %ebp, %esi
callq 0x63c78
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0xa73a
movsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x10(%rax)
leaq 0x70(%rsp), %r12
movq %r12, %rdi
xorl %esi, %esi
callq 0x63c78
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0xa73a
movsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x18(%rax)
movq %r12, %rdi
movl %r13d, %esi
callq 0x63c78
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0xa73a
movsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x20(%rax)
movq %r12, %rdi
movl %ebp, %esi
callq 0x63c78
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0xa73a
movsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x28(%rax)
incq %r15
jmp 0x3e249
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq