// File: /workspace/github_cpp_makefile_star2_O1/DavidLBruce[P]sim3dof/Matrix/build/../../Matrix/src/Matrix.cpp
// Function: Matrix::Chol_LLt(bool&)
Matrix Matrix::Chol_LLt(bool &posDef)
{
  if (rows != cols)
  {
    throw(DIMERR());
  }

  Matrix Amat = *this; 
  int    col;
  int    idx;
  Matrix Lmat(Amat.NumRows(), Amat.NumCols());
  int    row;
  double sum;
  double test;

  posDef = Amat.IsSymmetric();

  if (posDef)
  {
    for (row = 0; row < rows; ++row)
    {
      for (col = 0; col < row+1; ++col)
      {
        sum = 0.0;
        for (idx = 0; idx < col; ++idx)
        {
          if (row != 0)
          {
            sum += Lmat[row][idx] * Lmat[col][idx];
          }
        }

        if (row == col)
        {
          test = sqrt(Amat[row][col] - sum);
          if (test >= 0.0)
          {
            Lmat[row][col] = test;
          }
          else
          {
            posDef = false;
            Lmat = 0.0;
            return Lmat;
          }
        }
        else
        {
          Lmat[row][col] = (Amat[row][col] - sum) / Lmat[col][col];
        }
      }  // end for (col = 0; col < row+1; ++col)
    }  // end for (row = 0; row < rows; ++row)
  }  // end if (posDef)

  return Lmat;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdx, -0x40(%rbp)
movl 0x8(%rsi), %eax
cmpl (%rsi), %eax
jne 0x15422
movq %rsi, %r15
movq %rdi, %rbx
leaq -0x68(%rbp), %r14
movq %r14, %rdi
callq 0x13576
movl (%r14), %edx
movl 0x8(%r14), %esi
xorpd %xmm0, %xmm0
movq %rbx, %rdi
callq 0x1350e
leaq -0x68(%rbp), %rdi
xorpd %xmm0, %xmm0
callq 0x14b26
movq -0x40(%rbp), %rcx
movb %al, (%rcx)
movq %r15, -0x48(%rbp)
cmpl $0x0, 0x8(%r15)
setg %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x15402
movl $0x1, %r15d
xorl %r12d, %r12d
xorl %r14d, %r14d
xorpd %xmm0, %xmm0
testq %r14, %r14
je 0x152ff
movsd %xmm0, -0x38(%rbp)
xorl %r13d, %r13d
testq %r12, %r12
je 0x152f5
movq %rbx, %rdi
movl %r12d, %esi
callq 0x13b48
movsd (%rax,%r13,8), %xmm0
movsd %xmm0, -0x30(%rbp)
movq %rbx, %rdi
movl %r14d, %esi
callq 0x13b48
movsd -0x30(%rbp), %xmm1
mulsd (%rax,%r13,8), %xmm1
movsd -0x38(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
incq %r13
cmpq %r13, %r14
jne 0x152b6
jmp 0x15304
movsd %xmm0, -0x38(%rbp)
cmpq %r14, %r12
jne 0x15330
leaq -0x68(%rbp), %rdi
movl %r12d, %esi
callq 0x13b48
movsd (%rax,%r14,8), %xmm0
subsd -0x38(%rbp), %xmm0
ucomisd 0x12a0(%rip), %xmm0     # 0x165c8
jb 0x15379
sqrtsd %xmm0, %xmm0
jmp 0x1537e
leaq -0x68(%rbp), %rdi
movl %r12d, %esi
callq 0x13b48
movsd (%rax,%r14,8), %xmm0
movsd %xmm0, -0x30(%rbp)
movq %rbx, %rdi
movl %r14d, %esi
callq 0x13b48
movsd (%rax,%r14,8), %xmm0
movsd %xmm0, -0x50(%rbp)
movq %rbx, %rdi
movl %r12d, %esi
callq 0x13b48
movsd -0x30(%rbp), %xmm0
subsd -0x38(%rbp), %xmm0
divsd -0x50(%rbp), %xmm0
jmp 0x1539d
callq 0x3120
movsd %xmm0, -0x30(%rbp)
ucomisd 0x123d(%rip), %xmm0     # 0x165c8
jb 0x153c8
movq %rbx, %rdi
movl %r12d, %esi
callq 0x13b48
movsd -0x30(%rbp), %xmm0
movsd %xmm0, (%rax,%r14,8)
incq %r14
cmpq %r15, %r14
jne 0x152a5
incq %r12
movq -0x48(%rbp), %rax
movslq 0x8(%rax), %rax
incq %r15
cmpq %rax, %r12
jl 0x152a2
jmp 0x15402
movq -0x40(%rbp), %rax
movb $0x0, (%rax)
movl (%rbx), %edx
movl 0x8(%rbx), %esi
xorpd %xmm0, %xmm0
movq %rbx, %rdi
callq 0x1350e
leaq -0x80(%rbp), %rdi
movq %rbx, %rsi
callq 0x13576
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0x153fa
callq 0x3200
movq $0x0, -0x70(%rbp)
movq -0x58(%rbp), %rdi
testq %rdi, %rdi
je 0x15410
callq 0x3200
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x8, %edi
callq 0x30b0
leaq 0x8915(%rip), %rcx      # 0x1dd48
movq %rcx, (%rax)
leaq 0x88b3(%rip), %rsi      # 0x1dcf0
movq 0x8b9c(%rip), %rdx      # 0x1dfe0
movq %rax, %rdi
callq 0x32b0
movq %rax, %r14
jmp 0x1546e
jmp 0x15455
jmp 0x15455
movq %rax, %r14
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x15466
callq 0x3200
movq $0x0, 0x10(%rbx)
movq -0x58(%rbp), %rdi
testq %rdi, %rdi
je 0x1547c
callq 0x3200
movq %r14, %rdi
callq 0x32d0