// File: /workspace/github_cpp_makefile_star2_O2/Luthaf[P]zeopp/geometry.cc
// Function: RotatePointAboutLine(XYZ, double, XYZ, XYZ)
XYZ RotatePointAboutLine(XYZ p, double theta, XYZ p1, XYZ p2) {
  XYZ u, q1, q2;
  double d;
  // Step 1
  q1 = p - p1;
  u = (p2 - p1).unit();
  d = sqrt(u.y*u.y + u.z*u.z);
  // Step 2
  if (d!=0) {
    q2.x = q1.x;
    q2.y = q1.y * u.z / d - q1.z * u.y / d;
    q2.z = q1.y * u.y / d + q1.z * u.z / d;
  } else {
    q2 = q1;
  }
  // Step 3
  q1.x = q2.x * d - q2.z * u.x;
  q1.y = q2.y;
  q1.z = q2.x * u.x + q2.z * d;
  // Step 4
  q2.x = q1.x * cos(theta) - q1.y * sin(theta);
  q2.y = q1.x * sin(theta) + q1.y * cos(theta);
  q2.z = q1.z;
  // Inverse of step 3
  q1.x = q2.x * d + q2.z * u.x;
  q1.y = q2.y;
  q1.z = - q2.x * u.x + q2.z * d;
  // Inverse of step 2
  if (d!=0) {
    q2.x =   q1.x;
    q2.y =   q1.y * u.z / d + q1.z * u.y / d;
    q2.z = - q1.y * u.y / d + q1.z * u.z / d;
  } else {
    q2 = q1;
  }
  // Inverse of step 1
  q1 = q2 + p1;
  return(q1);
}

// Assembly:
pushq %rbx
subq $0xa0, %rsp
movaps %xmm0, %xmm7
movq %rdi, %rbx
movsd 0xb0(%rsp), %xmm2
movupd 0xc8(%rsp), %xmm1
movupd 0xd0(%rsp), %xmm0
subsd %xmm1, %xmm2
movupd 0xb8(%rsp), %xmm4
subpd %xmm0, %xmm4
movsd 0xe0(%rsp), %xmm3
movapd %xmm1, 0x90(%rsp)
subsd %xmm1, %xmm3
movupd 0xe8(%rsp), %xmm5
subpd %xmm0, %xmm5
movapd %xmm5, %xmm0
mulsd %xmm5, %xmm0
movapd %xmm3, %xmm1
mulsd %xmm3, %xmm1
addsd %xmm0, %xmm1
movapd %xmm5, %xmm0
unpckhpd %xmm5, %xmm0            # xmm0 = xmm0[1],xmm5[1]
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
sqrtsd %xmm0, %xmm0
divsd %xmm0, %xmm3
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
divpd %xmm0, %xmm5
movapd %xmm5, %xmm0
mulpd %xmm5, %xmm0
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
movapd %xmm5, %xmm1
mulsd %xmm5, %xmm1
addsd %xmm0, %xmm1
sqrtsd %xmm1, %xmm6
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm6
movapd %xmm2, 0x80(%rsp)
movapd %xmm3, 0x70(%rsp)
movapd %xmm5, 0x30(%rsp)
movapd %xmm6, 0x60(%rsp)
jne 0x6471f
jnp 0x64761
movapd %xmm4, %xmm0
unpcklpd %xmm4, %xmm0            # xmm0 = xmm0[0],xmm4[0]
mulpd %xmm5, %xmm0
movapd %xmm6, %xmm1
unpcklpd %xmm6, %xmm1            # xmm1 = xmm1[0],xmm6[0]
divpd %xmm1, %xmm0
shufpd $0x1, %xmm0, %xmm0      # xmm0 = xmm0[1,0]
unpckhpd %xmm4, %xmm4            # xmm4 = xmm4[1,1]
mulpd %xmm5, %xmm4
divpd %xmm1, %xmm4
movapd %xmm0, %xmm1
addpd %xmm4, %xmm1
subpd %xmm4, %xmm0
shufpd $0x2, %xmm1, %xmm0      # xmm0 = xmm0[0],xmm1[1]
movapd %xmm0, 0x20(%rsp)
jmp 0x64767
movapd %xmm4, 0x20(%rsp)
movsd 0xd8(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
movaps %xmm7, %xmm0
movsd %xmm7, 0x8(%rsp)
callq 0x47e0
movaps %xmm0, 0x40(%rsp)
movsd 0x8(%rsp), %xmm0
callq 0x4110
movsd %xmm0, 0x10(%rsp)
movsd 0x8(%rsp), %xmm0
callq 0x4110
movaps %xmm0, 0x50(%rsp)
movsd 0x8(%rsp), %xmm0
callq 0x47e0
movapd 0x40(%rsp), %xmm7
movapd 0x60(%rsp), %xmm8
ucomisd 0x9bb15(%rip), %xmm8    # 0x1002e0
movapd 0x20(%rsp), %xmm6
movapd %xmm6, %xmm1
unpckhpd %xmm6, %xmm1            # xmm1 = xmm1[1],xmm6[1]
movapd 0x70(%rsp), %xmm5
movapd %xmm5, %xmm2
mulsd %xmm1, %xmm2
movapd 0x80(%rsp), %xmm4
movapd %xmm4, %xmm3
mulsd %xmm8, %xmm3
subsd %xmm2, %xmm3
mulsd %xmm8, %xmm1
mulsd %xmm5, %xmm4
addsd %xmm1, %xmm4
movsd 0x10(%rsp), %xmm1
mulsd %xmm6, %xmm1
mulsd %xmm3, %xmm7
subsd %xmm1, %xmm7
movapd 0x9bdac(%rip), %xmm1    # 0x1005d0
xorpd %xmm7, %xmm1
unpcklpd %xmm8, %xmm6            # xmm6 = xmm6[0],xmm8[0]
unpcklpd %xmm4, %xmm0            # xmm0 = xmm0[0],xmm4[0]
mulpd %xmm6, %xmm0
unpcklpd %xmm1, %xmm3            # xmm3 = xmm3[0],xmm1[0]
movapd 0x50(%rsp), %xmm1
unpcklpd %xmm5, %xmm1            # xmm1 = xmm1[0],xmm5[0]
mulpd %xmm3, %xmm1
movapd %xmm1, %xmm3
addpd %xmm0, %xmm3
movapd %xmm6, %xmm2
movapd %xmm8, %xmm6
jne 0x6485c
jnp 0x6489b
movapd 0x9bd6c(%rip), %xmm0    # 0x1005d0
xorpd %xmm3, %xmm0
unpcklpd %xmm3, %xmm0            # xmm0 = xmm0[0],xmm3[0]
movapd %xmm3, %xmm1
unpckhpd %xmm3, %xmm1            # xmm1 = xmm1[1],xmm3[1]
movapd 0x30(%rsp), %xmm3
mulpd %xmm3, %xmm1
mulpd %xmm3, %xmm0
unpckhpd %xmm2, %xmm2            # xmm2 = xmm2[1,1]
divpd %xmm2, %xmm0
shufpd $0x1, %xmm0, %xmm0      # xmm0 = xmm0[1,0]
divpd %xmm2, %xmm1
addpd %xmm0, %xmm1
movapd %xmm1, %xmm3
mulsd %xmm4, %xmm5
mulsd %xmm6, %xmm7
addsd %xmm5, %xmm7
unpcklpd %xmm3, %xmm7            # xmm7 = xmm7[0],xmm3[0]
unpckhpd %xmm3, %xmm3            # xmm3 = xmm3[1,1]
movsd 0x18(%rsp), %xmm1
addsd %xmm3, %xmm1
movapd 0x90(%rsp), %xmm0
addpd %xmm7, %xmm0
movupd %xmm0, (%rbx)
movsd %xmm1, 0x10(%rbx)
movq %rbx, %rax
addq $0xa0, %rsp
popq %rbx
retq