// File: /workspace/github_cpp_makefile_star2_O2/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 0x14923
movq %rsi, %r15
movq %rdi, %rbx
leaq -0x68(%rbp), %r14
movq %r14, %rdi
callq 0x12d48
movl (%r14), %edx
movl 0x8(%r14), %esi
xorpd %xmm0, %xmm0
movq %rbx, %rdi
callq 0x12d02
movq %r15, -0x48(%rbp)
leaq -0x68(%rbp), %rdi
xorpd %xmm0, %xmm0
callq 0x14150
movq -0x40(%rbp), %rcx
movb %al, (%rcx)
testb %al, %al
je 0x14908
pushq $0x1
popq %r15
xorl %r12d, %r12d
movq -0x48(%rbp), %rax
movslq 0x8(%rax), %rax
cmpq %rax, %r12
jge 0x14908
xorl %r14d, %r14d
cmpq %r15, %r14
je 0x148dd
xorpd %xmm0, %xmm0
movsd %xmm0, -0x30(%rbp)
xorl %r13d, %r13d
cmpq %r13, %r14
je 0x14830
movq %rbx, %rdi
movl %r12d, %esi
callq 0x1324e
movsd (%rax,%r13,8), %xmm0
movsd %xmm0, -0x38(%rbp)
movq %rbx, %rdi
movl %r14d, %esi
callq 0x1324e
movsd -0x38(%rbp), %xmm1
mulsd (%rax,%r13,8), %xmm1
movsd -0x30(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
incq %r13
jmp 0x147ec
cmpq %r14, %r12
jne 0x1485c
leaq -0x68(%rbp), %rdi
movl %r12d, %esi
callq 0x1324e
movsd (%rax,%r12,8), %xmm0
subsd -0x30(%rbp), %xmm0
ucomisd 0xd74(%rip), %xmm0      # 0x155c8
jb 0x148ab
sqrtsd %xmm0, %xmm0
jmp 0x148b0
leaq -0x68(%rbp), %rdi
movl %r12d, %esi
callq 0x1324e
movsd (%rax,%r14,8), %xmm0
movsd %xmm0, -0x38(%rbp)
movq %rbx, %rdi
movl %r14d, %esi
callq 0x1324e
movsd (%rax,%r14,8), %xmm0
movsd %xmm0, -0x50(%rbp)
movq %rbx, %rdi
movl %r12d, %esi
callq 0x1324e
movsd -0x38(%rbp), %xmm0
subsd -0x30(%rbp), %xmm0
divsd -0x50(%rbp), %xmm0
movsd %xmm0, (%rax,%r14,8)
jmp 0x148d5
callq 0x3150
movsd %xmm0, -0x30(%rbp)
ucomisd 0xd0b(%rip), %xmm0      # 0x155c8
jb 0x148e8
movq %rbx, %rdi
movl %r12d, %esi
callq 0x1324e
movsd -0x30(%rbp), %xmm0
movsd %xmm0, (%rax,%r12,8)
incq %r14
jmp 0x147d7
incq %r12
incq %r15
jmp 0x147c3
movq -0x40(%rbp), %rax
movb $0x0, (%rax)
leaq -0x80(%rbp), %rdi
xorpd %xmm0, %xmm0
movq %rbx, %rsi
callq 0x132f0
leaq -0x80(%rbp), %rdi
callq 0x12dd8
leaq -0x68(%rbp), %rdi
callq 0x12dd8
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x8
popq %rdi
callq 0x30e0
leaq 0x8416(%rip), %rcx      # 0x1cd48
movq %rcx, (%rax)
leaq 0x83b4(%rip), %rsi      # 0x1ccf0
movq 0x869d(%rip), %rdx      # 0x1cfe0
movq %rax, %rdi
callq 0x3300
movq %rax, %r14
jmp 0x1495f
jmp 0x14954
jmp 0x14954
movq %rax, %r14
movq %rbx, %rdi
callq 0x12dd8
leaq -0x68(%rbp), %rdi
callq 0x12dd8
movq %r14, %rdi
callq 0x3320