// File: /workspace/github_cpp_makefile_star2_O3/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 0x1010e9(%rip), %rdi    # 0x152848
movsd 0x100fe9(%rip), %xmm0   # 0x152750
movb $0x1, %al
callq 0x4060
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 0x1011a2(%rip), %rdi    # 0x152935
movb $0x6, %al
callq 0x4060
callq 0x4150
movl %eax, %ebp
movups 0x8(%rbx), %xmm0
movaps %xmm0, 0x30(%rsp)
callq 0x4150
movd %ebp, %xmm0
movd %eax, %xmm1
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
cvtdq2pd %xmm0, %xmm0
divpd 0x100ff9(%rip), %xmm0   # 0x1527c0
addpd 0x101001(%rip), %xmm0   # 0x1527d0
movapd 0x30(%rsp), %xmm1
movhpd 0x10(%rbx), %xmm1       # xmm1 = xmm1[0],mem[0]
addpd %xmm0, %xmm0
mulpd 0x100ffa(%rip), %xmm0   # 0x1527e0
addpd %xmm1, %xmm0
movapd %xmm0, 0x30(%rsp)
callq 0x4150
movl %eax, %ebp
movups 0x18(%rbx), %xmm0
movaps %xmm0, 0x20(%rsp)
callq 0x4150
movd %ebp, %xmm0
movd %eax, %xmm1
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
cvtdq2pd %xmm0, %xmm0
divpd 0x100fa3(%rip), %xmm0   # 0x1527c0
addpd 0x100fab(%rip), %xmm0   # 0x1527d0
addpd %xmm0, %xmm0
movapd 0x20(%rsp), %xmm1
movhpd 0x20(%rbx), %xmm1       # xmm1 = xmm1[0],mem[0]
mulpd 0x100fa4(%rip), %xmm0   # 0x1527e0
addpd %xmm1, %xmm0
movapd %xmm0, 0x20(%rsp)
callq 0x4150
movl %eax, %ebp
movups 0x28(%rbx), %xmm0
movaps %xmm0, 0x40(%rsp)
callq 0x4150
movd %ebp, %xmm0
movd %eax, %xmm1
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
cvtdq2pd %xmm0, %xmm0
divpd 0x100f4d(%rip), %xmm0   # 0x1527c0
addpd 0x100f55(%rip), %xmm0   # 0x1527d0
addpd %xmm0, %xmm0
movapd 0x40(%rsp), %xmm1
movhpd 0x30(%rbx), %xmm1       # xmm1 = xmm1[0],mem[0]
mulpd 0x100f4e(%rip), %xmm0   # 0x1527e0
addpd %xmm1, %xmm0
movaps 0x30(%rsp), %xmm1
movups %xmm1, 0x8(%rbx)
movaps 0x20(%rsp), %xmm1
movups %xmm1, 0x18(%rbx)
movupd %xmm0, 0x28(%rbx)
movq %rbx, %rdi
callq 0x51db4
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 0x10109c(%rip), %rdi    # 0x152976
movb $0x6, %al
callq 0x4060
cmpl $0x0, 0x110(%rbx)
jle 0x51bfb
xorl %r15d, %r15d
leaq 0xc0(%rsp), %rbp
xorl %r14d, %r14d
movq %rbp, %r13
leaq 0xa8(%rsp), %rbp
leaq 0x58(%rsp), %r12
movq %r12, %rdi
callq 0x4c4cd
movq %rbp, %rdi
movq %r12, %rsi
movsd 0x100e2e(%rip), %xmm0   # 0x152750
callq 0x84096
movq 0x2f0(%rbx), %rax
movq 0x2f8(%rbx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x79435e50d79435e5, %r12 # imm = 0x86BCA1AF286BCA1B
imulq %r12, %rdx
cmpq %r14, %rdx
jbe 0x51c0d
movsd (%rax,%r15), %xmm0
movsd %xmm0, 0x30(%rsp)
movq %rbp, %rdi
xorl %esi, %esi
callq 0x83f9a
movq 0x2f0(%rbx), %rcx
movq 0x2f8(%rbx), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
imulq %r12, %rdx
cmpq %r14, %rdx
jbe 0x51c0d
movsd 0x30(%rsp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, 0x30(%rsp)
movsd 0x8(%rcx,%r15), %xmm0
movsd %xmm0, 0x20(%rsp)
leaq 0xa8(%rsp), %rdi
movl $0x1, %esi
callq 0x83f9a
movq 0x2f0(%rbx), %rcx
movq 0x2f8(%rbx), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
imulq %r12, %rdx
cmpq %r14, %rdx
jbe 0x51c0d
movq %r13, %rbp
movsd 0x20(%rsp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x10(%rcx,%r15), %xmm0
movsd %xmm0, 0x40(%rsp)
leaq 0xa8(%rsp), %rdi
movl $0x2, %esi
callq 0x83f9a
movsd 0x40(%rsp), %xmm2
addsd (%rax), %xmm2
leaq 0x90(%rsp), %rdi
movsd 0x30(%rsp), %xmm0
movsd 0x20(%rsp), %xmm1
callq 0x83f68
movq 0xa0(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x90(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x58(%rsp), %rdi
movq %rbx, %rsi
callq 0x51c42
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)
movq %r13, %rdi
movq %rbx, %rsi
callq 0x51d04
movq %r13, %rdi
xorl %esi, %esi
callq 0x83f9a
movq 0x2f0(%rbx), %rcx
movq 0x2f8(%rbx), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
imulq %r12, %rdx
cmpq %r14, %rdx
jbe 0x51c0d
movq %r12, %r13
movsd (%rax), %xmm0
movsd %xmm0, (%rcx,%r15)
movq %rbp, %rdi
movl $0x1, %esi
callq 0x83f9a
movq 0x2f0(%rbx), %rcx
movq 0x2f8(%rbx), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
imulq %r12, %rdx
cmpq %r14, %rdx
leaq 0x70(%rsp), %r12
jbe 0x51c0d
movsd (%rax), %xmm0
movsd %xmm0, 0x8(%rcx,%r15)
movq %rbp, %rdi
movl $0x2, %esi
callq 0x83f9a
movq 0x2f0(%rbx), %rcx
movq 0x2f8(%rbx), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
imulq %r13, %rdx
cmpq %r14, %rdx
jbe 0x51c0d
movsd (%rax), %xmm0
movsd %xmm0, 0x10(%rcx,%r15)
movq %r12, %rdi
xorl %esi, %esi
callq 0x83f9a
movq 0x2f0(%rbx), %rcx
movq 0x2f8(%rbx), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
imulq %r13, %rdx
cmpq %r14, %rdx
jbe 0x51c0d
movsd (%rax), %xmm0
movsd %xmm0, 0x18(%rcx,%r15)
movq %r12, %rdi
movl $0x1, %esi
callq 0x83f9a
movq 0x2f0(%rbx), %rcx
movq 0x2f8(%rbx), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
imulq %r13, %rdx
cmpq %r14, %rdx
jbe 0x51c0d
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rcx,%r15)
movq %r12, %rdi
movl $0x2, %esi
callq 0x83f9a
movq 0x2f0(%rbx), %rcx
movq 0x2f8(%rbx), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
imulq %r13, %rdx
cmpq %r14, %rdx
jbe 0x51c0d
movsd (%rax), %xmm0
movsd %xmm0, 0x28(%rcx,%r15)
incq %r14
movslq 0x110(%rbx), %rax
addq $0x98, %r15
cmpq %rax, %r14
jl 0x518fc
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xfbae1(%rip), %rdi     # 0x14d6f5
movq %r14, %rsi
xorl %eax, %eax
callq 0x4630