// File: /workspace/github_cpp_makefile_star2_O2/icemiliang[P]vot/src/vot/../../include/Eigen/src/IterativeLinearSolvers/LeastSquareConjugateGradient.h
// Function: void Eigen::internal::least_square_conjugate_gradient<Eigen::Ref<Eigen::SparseMatrix<double, 0, int> const, 0, Eigen::OuterStride<-1>>, Eigen::Block<Eigen::Matrix<double, -1, 1, 0, -1, 1> const, -1, 1, true>, Eigen::Block<Eigen::Matrix<double, -1, 1, 0, -1, 1>, -1, 1, true>, Eigen::LeastSquareDiagonalPreconditioner<double>>(Eigen::Ref<Eigen::SparseMatrix<double, 0, int> const, 0, Eigen::OuterStride<-1>> const&, Eigen::Block<Eigen::Matrix<double, -1, 1, 0, -1, 1> const, -1, 1, true> const&, Eigen::Block<Eigen::Matrix<double, -1, 1, 0, -1, 1>, -1, 1, true>&, Eigen::LeastSquareDiagonalPreconditioner<double> const&, long&, Eigen::Block<Eigen::Matrix<double, -1, 1, 0, -1, 1>, -1, 1, true>::RealScalar&)
EIGEN_DONT_INLINE
void least_square_conjugate_gradient(const MatrixType& mat, const Rhs& rhs, Dest& x,
                                     const Preconditioner& precond, Index& iters,
                                     typename Dest::RealScalar& tol_error)
{
  using std::sqrt;
  using std::abs;
  typedef typename Dest::RealScalar RealScalar;
  typedef typename Dest::Scalar Scalar;
  typedef Matrix<Scalar,Dynamic,1> VectorType;
  
  RealScalar tol = tol_error;
  Index maxIters = iters;
  
  Index m = mat.rows(), n = mat.cols();

  VectorType residual        = rhs - mat * x;
  VectorType normal_residual = mat.adjoint() * residual;

  RealScalar rhsNorm2 = (mat.adjoint()*rhs).squaredNorm();
  if(rhsNorm2 == 0) 
  {
    x.setZero();
    iters = 0;
    tol_error = 0;
    return;
  }
  RealScalar threshold = tol*tol*rhsNorm2;
  RealScalar residualNorm2 = normal_residual.squaredNorm();
  if (residualNorm2 < threshold)
  {
    iters = 0;
    tol_error = sqrt(residualNorm2 / rhsNorm2);
    return;
  }
  
  VectorType p(n);
  p = precond.solve(normal_residual);                         // initial search direction

  VectorType z(n), tmp(m);
  RealScalar absNew = numext::real(normal_residual.dot(p));  // the square of the absolute value of r scaled by invM
  Index i = 0;
  while(i < maxIters)
  {
    tmp.noalias() = mat * p;

    Scalar alpha = absNew / tmp.squaredNorm();      // the amount we travel on dir
    x += alpha * p;                                 // update solution
    residual -= alpha * tmp;                        // update residual
    normal_residual = mat.adjoint() * residual;     // update residual of the normal equation
    
    residualNorm2 = normal_residual.squaredNorm();
    if(residualNorm2 < threshold)
      break;
    
    z = precond.solve(normal_residual);             // approximately solve for "A'A z = normal_residual"

    RealScalar absOld = absNew;
    absNew = numext::real(normal_residual.dot(z));  // update the absolute value of r
    RealScalar beta = absNew / absOld;              // calculate the Gram-Schmidt value used to create the new search direction
    p = z + beta * p;                               // update search direction
    i++;
  }
  tol_error = sqrt(residualNorm2 / rhsNorm2);
  iters = i;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movq %r9, %rbp
movq %rcx, 0x58(%rsp)
movq %rsi, %rbx
movq %rdi, %r13
movsd (%r9), %xmm0
movsd %xmm0, 0x28(%rsp)
movq %r8, 0x20(%rsp)
movq (%r8), %rax
movq %rax, 0x8(%rsp)
movq 0x10(%rdi), %rax
movq %rax, 0xc0(%rsp)
movq 0x8(%rdi), %rax
movq %rax, 0x70(%rsp)
leaq 0xc8(%rsp), %r14
movq %r14, %rdi
movq %r13, %rsi
movq %rdx, 0x60(%rsp)
callq 0x14358
leaq 0x108(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x14102
leaq 0xb0(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x1439c
movb $0x0, (%r14)
movq %r13, 0x8(%r14)
leaq 0x108(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
movq %r12, %rdx
callq 0x146d0
leaq 0x38(%rsp), %rdi
leaq 0x108(%rsp), %rsi
callq 0x14708
leaq 0xc8(%rsp), %rsi
movb $0x0, (%rsi)
movq %r13, 0x8(%rsi)
leaq 0x108(%rsp), %rdi
movq %rbx, %rdx
callq 0x1492a
leaq 0x108(%rsp), %rdi
callq 0x1411e
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x13cdb
jp 0x13cdb
movq 0x60(%rsp), %rdi
callq 0x14150
movq 0x20(%rsp), %rax
andq $0x0, (%rax)
andq $0x0, (%rbp)
jmp 0x13fc2
movsd %xmm0, 0x48(%rsp)
leaq 0x38(%rsp), %rdi
callq 0x13478
movsd 0x28(%rsp), %xmm2
mulsd %xmm2, %xmm2
movsd 0x48(%rsp), %xmm1
mulsd %xmm1, %xmm2
movsd %xmm2, 0x28(%rsp)
ucomisd %xmm0, %xmm2
jbe 0x13d2f
movq 0x20(%rsp), %rax
andq $0x0, (%rax)
divsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x13f7c
sqrtsd %xmm0, %xmm0
jmp 0x13f81
movsd %xmm0, 0x50(%rsp)
leaq 0x10(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x14160
leaq 0x38(%rsp), %rsi
movq 0x58(%rsp), %rdi
callq 0x14190
leaq 0x108(%rsp), %rsi
movq %rax, (%rsi)
movq %rdx, 0x8(%rsi)
leaq 0x10(%rsp), %rdi
callq 0x14f1c
leaq 0x88(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x14160
leaq 0x78(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x14160
movq %rbp, 0x98(%rsp)
leaq 0x38(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x141e0
movsd %xmm0, 0x30(%rsp)
xorl %ebp, %ebp
movq 0x8(%rsp), %rax
testq %rax, %rax
cmovleq %rbp, %rax
movq %rax, 0x8(%rsp)
leaq 0xc8(%rsp), %r14
leaq 0x108(%rsp), %r12
leaq 0x38(%rsp), %r15
cmpq %rbp, 0x8(%rsp)
je 0x13f5b
movq %r13, %rdi
leaq 0x10(%rsp), %rsi
callq 0x1420c
movq %rax, 0x108(%rsp)
movq %rdx, 0x110(%rsp)
leaq 0x78(%rsp), %rbx
movq %rbx, 0xc8(%rsp)
movq %r14, %rdi
movq %r12, %rsi
callq 0x14230
movq %rbx, %rdi
callq 0x13478
movsd 0x30(%rsp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0x68(%rsp)
movq %r12, %rdi
leaq 0x68(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x1424e
movq 0x60(%rsp), %rdi
movq %r12, %rsi
callq 0x142a2
movq %r12, %rdi
leaq 0x68(%rsp), %rsi
leaq 0x78(%rsp), %rdx
callq 0x1424e
leaq 0xb0(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x142be
movb $0x0, 0xc8(%rsp)
movq %r13, 0xd0(%rsp)
movq %r12, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x146d0
movq %r15, %rdi
movq %r12, %rsi
callq 0x1583b
movq %r15, %rdi
callq 0x13478
movapd %xmm0, %xmm1
movsd 0x28(%rsp), %xmm0
movsd %xmm1, 0x50(%rsp)
ucomisd %xmm1, %xmm0
ja 0x13f60
movq 0x58(%rsp), %rdi
movq %r15, %rsi
callq 0x14190
leaq 0x88(%rsp), %rbx
movq %rax, 0x108(%rsp)
movq %rdx, 0x110(%rsp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x14f1c
movq %r15, %rdi
movq %rbx, %rsi
callq 0x141e0
movsd %xmm0, 0xa0(%rsp)
divsd 0x30(%rsp), %xmm0
movsd %xmm0, 0xa8(%rsp)
movq %r14, %rdi
leaq 0xa8(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x1424e
movq %r12, %rdi
leaq 0x88(%rsp), %rsi
movq %r14, %rdx
callq 0x142da
leaq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0x15a0a
incq %rbp
movsd 0xa0(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
jmp 0x13dd5
movq 0x8(%rsp), %rbp
movsd 0x50(%rsp), %xmm0
divsd 0x48(%rsp), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x13f88
sqrtsd %xmm0, %xmm0
jmp 0x13f8d
callq 0x72e0
movsd %xmm0, (%rbp)
jmp 0x13fc2
callq 0x72e0
movq 0x98(%rsp), %rax
movsd %xmm0, (%rax)
movq 0x20(%rsp), %rax
movq %rbp, (%rax)
movq 0x78(%rsp), %rdi
callq 0x7410
movq 0x88(%rsp), %rdi
callq 0x7410
movq 0x10(%rsp), %rdi
callq 0x7410
movq 0x38(%rsp), %rdi
callq 0x7410
movq 0xb0(%rsp), %rdi
callq 0x7410
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x14019
movq %rax, %rbx
jmp 0x14026
jmp 0x13ff6
jmp 0x13fff
movq %rax, %rbx
jmp 0x14033
jmp 0x13fff
jmp 0x13fff
movq %rax, %rbx
jmp 0x1403d
movq %rax, %rbx
jmp 0x14047
jmp 0x14019
jmp 0x14019
jmp 0x14019
jmp 0x14019
jmp 0x14019
jmp 0x14019
jmp 0x14019
jmp 0x14019
movq %rax, %rbx
movq 0x78(%rsp), %rdi
callq 0x7410
movq 0x88(%rsp), %rdi
callq 0x7410
movq 0x10(%rsp), %rdi
callq 0x7410
movq 0x38(%rsp), %rdi
callq 0x7410
movq 0xb0(%rsp), %rdi
callq 0x7410
movq %rbx, %rdi
callq 0x76c0