// File: istellartech[P]OpenTsiolkovsky/src/../lib/Eigen/src/Geometry/Quaternion.h
// Function: Eigen::QuaternionBase<Eigen::Quaternion<double, 0>>::toRotationMatrix() const
inline typename QuaternionBase<Derived>::Matrix3
QuaternionBase<Derived>::toRotationMatrix(void) const
{
  // NOTE if inlined, then gcc 4.2 and 4.4 get rid of the temporary (not gcc 4.3 !!)
  // if not inlined then the cost of the return by value is huge ~ +35%,
  // however, not inlining this function is an order of magnitude slower, so
  // it has to be inlined, and so the return by value is not an issue
  Matrix3 res;

  const Scalar tx  = Scalar(2)*this->x();
  const Scalar ty  = Scalar(2)*this->y();
  const Scalar tz  = Scalar(2)*this->z();
  const Scalar twx = tx*this->w();
  const Scalar twy = ty*this->w();
  const Scalar twz = tz*this->w();
  const Scalar txx = tx*this->x();
  const Scalar txy = ty*this->x();
  const Scalar txz = tz*this->x();
  const Scalar tyy = ty*this->y();
  const Scalar tyz = tz*this->y();
  const Scalar tzz = tz*this->z();

  res.coeffRef(0,0) = Scalar(1)-(tyy+tzz);
  res.coeffRef(0,1) = txy-twz;
  res.coeffRef(0,2) = txz+twy;
  res.coeffRef(1,0) = txy+twz;
  res.coeffRef(1,1) = Scalar(1)-(txx+tzz);
  res.coeffRef(1,2) = tyz-twx;
  res.coeffRef(2,0) = txz-twy;
  res.coeffRef(2,1) = tyz+twx;
  res.coeffRef(2,2) = Scalar(1)-(txx+tyy);

  return res;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x88(%rbp)
movq %rdi, %rax
movq %rax, -0x78(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xe0(%rbp)
callq 0x1dbe0
movq -0xe0(%rbp), %rdi
callq 0x37110
movq -0xe0(%rbp), %rdi
movaps %xmm0, %xmm1
movsd 0x32651(%rip), %xmm0    # 0x52e80
mulsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
callq 0x37150
movq -0xe0(%rbp), %rdi
movaps %xmm0, %xmm1
movsd 0x32631(%rip), %xmm0    # 0x52e80
mulsd %xmm1, %xmm0
movsd %xmm0, -0x20(%rbp)
callq 0x37190
movq -0xe0(%rbp), %rdi
movaps %xmm0, %xmm1
movsd 0x32611(%rip), %xmm0    # 0x52e80
mulsd %xmm1, %xmm0
movsd %xmm0, -0x28(%rbp)
movsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x118(%rbp)
callq 0x371d0
movq -0xe0(%rbp), %rdi
movaps %xmm0, %xmm1
movsd -0x118(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x110(%rbp)
callq 0x371d0
movq -0xe0(%rbp), %rdi
movaps %xmm0, %xmm1
movsd -0x110(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
movsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x108(%rbp)
callq 0x371d0
movq -0xe0(%rbp), %rdi
movaps %xmm0, %xmm1
movsd -0x108(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x100(%rbp)
callq 0x37110
movq -0xe0(%rbp), %rdi
movaps %xmm0, %xmm1
movsd -0x100(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x20(%rbp), %xmm0
movsd %xmm0, -0xf8(%rbp)
callq 0x37110
movq -0xe0(%rbp), %rdi
movaps %xmm0, %xmm1
movsd -0xf8(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x50(%rbp)
movsd -0x28(%rbp), %xmm0
movsd %xmm0, -0xf0(%rbp)
callq 0x37110
movq -0xe0(%rbp), %rdi
movaps %xmm0, %xmm1
movsd -0xf0(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x58(%rbp)
movsd -0x20(%rbp), %xmm0
movsd %xmm0, -0xe8(%rbp)
callq 0x37150
movq -0xe0(%rbp), %rdi
movaps %xmm0, %xmm1
movsd -0xe8(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x60(%rbp)
movsd -0x28(%rbp), %xmm0
movsd %xmm0, -0xd8(%rbp)
callq 0x37150
movq -0xe0(%rbp), %rdi
movaps %xmm0, %xmm1
movsd -0xd8(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x68(%rbp)
movsd -0x28(%rbp), %xmm0
movsd %xmm0, -0xd0(%rbp)
callq 0x37190
movq -0x88(%rbp), %rdi
movaps %xmm0, %xmm1
movsd -0xd0(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x70(%rbp)
movsd -0x60(%rbp), %xmm1
addsd -0x70(%rbp), %xmm1
movsd 0x31621(%rip), %xmm0    # 0x52040
subsd %xmm1, %xmm0
movsd %xmm0, -0xc8(%rbp)
xorl %eax, %eax
movl %eax, %edx
movq %rdx, %rsi
callq 0x33a20
movsd -0xc8(%rbp), %xmm0
movq -0x88(%rbp), %rdi
movsd %xmm0, (%rax)
movsd -0x50(%rbp), %xmm0
subsd -0x40(%rbp), %xmm0
movsd %xmm0, -0xc0(%rbp)
xorl %eax, %eax
movl %eax, %esi
movl $0x1, %edx
callq 0x33a20
movsd -0xc0(%rbp), %xmm0
movq -0x88(%rbp), %rdi
movsd %xmm0, (%rax)
movsd -0x58(%rbp), %xmm0
addsd -0x38(%rbp), %xmm0
movsd %xmm0, -0xb8(%rbp)
xorl %eax, %eax
movl %eax, %esi
movl $0x2, %edx
callq 0x33a20
movsd -0xb8(%rbp), %xmm0
movq -0x88(%rbp), %rdi
movsd %xmm0, (%rax)
movsd -0x50(%rbp), %xmm0
addsd -0x40(%rbp), %xmm0
movsd %xmm0, -0xb0(%rbp)
movl $0x1, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x33a20
movsd -0xb0(%rbp), %xmm0
movq -0x88(%rbp), %rdi
movsd %xmm0, (%rax)
movsd -0x48(%rbp), %xmm1
addsd -0x70(%rbp), %xmm1
movsd 0x3154b(%rip), %xmm0    # 0x52040
subsd %xmm1, %xmm0
movsd %xmm0, -0xa8(%rbp)
movl $0x1, %edx
movq %rdx, %rsi
callq 0x33a20
movsd -0xa8(%rbp), %xmm0
movq -0x88(%rbp), %rdi
movsd %xmm0, (%rax)
movsd -0x68(%rbp), %xmm0
subsd -0x30(%rbp), %xmm0
movsd %xmm0, -0xa0(%rbp)
movl $0x1, %esi
movl $0x2, %edx
callq 0x33a20
movsd -0xa0(%rbp), %xmm0
movq -0x88(%rbp), %rdi
movsd %xmm0, (%rax)
movsd -0x58(%rbp), %xmm0
subsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x98(%rbp)
movl $0x2, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x33a20
movsd -0x98(%rbp), %xmm0
movq -0x88(%rbp), %rdi
movsd %xmm0, (%rax)
movsd -0x68(%rbp), %xmm0
addsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x90(%rbp)
movl $0x2, %esi
movl $0x1, %edx
callq 0x33a20
movsd -0x90(%rbp), %xmm0
movq -0x88(%rbp), %rdi
movsd %xmm0, (%rax)
movsd -0x48(%rbp), %xmm1
addsd -0x60(%rbp), %xmm1
movsd 0x31472(%rip), %xmm0    # 0x52040
subsd %xmm1, %xmm0
movsd %xmm0, -0x80(%rbp)
movl $0x2, %edx
movq %rdx, %rsi
callq 0x33a20
movsd -0x80(%rbp), %xmm0
movq %rax, %rcx
movq -0x78(%rbp), %rax
movsd %xmm0, (%rcx)
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
nopl (%rax)