// File: /workspace/github_cpp_makefile_star2_O3/DavidLBruce[P]sim3dof/Matrix/build/../../Matrix/src/Matrix.cpp
// Function: Matrix::Chol_UtU(bool&)
Matrix Matrix::Chol_UtU(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 = row; col < cols; ++col)
      {
        sum = 0.0;
        for (idx = 0; idx < cols-1; ++idx)
        {
          sum += Lmat[idx][row] * Lmat[idx][col];
        }

        if (row == col)
        {
          test = Amat[row][col] - sum;
          if (test > 0.0)
          {
            Lmat[row][col] = sqrt(test);
          }
          else
          {
            posDef = false;
            Lmat = 0.0;
            return Lmat;
          }
        }
        else
        {
          Lmat[row][col] = (Amat[row][col] - sum) / Lmat[row][row];
        }
      }  // 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
movl 0x8(%rsi), %eax
cmpl (%rsi), %eax
jne 0x15058
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %rbx
leaq -0x60(%rbp), %r14
movq %r14, %rdi
callq 0x133e2
movl (%r14), %edx
movl 0x8(%r14), %esi
xorpd %xmm0, %xmm0
movq %rbx, %rdi
callq 0x13382
leaq -0x60(%rbp), %rdi
xorpd %xmm0, %xmm0
callq 0x149b0
movq %r12, -0x40(%rbp)
movb %al, (%r12)
movl 0x8(%r15), %ecx
testl %ecx, %ecx
setg %dl
andb %al, %dl
cmpb $0x1, %dl
jne 0x15038
movl (%r15), %eax
xorl %r13d, %r13d
movslq %eax, %rdx
cmpq %rdx, %r13
jge 0x14ff5
movq %r13, %r12
xorpd %xmm0, %xmm0
movsd %xmm0, -0x30(%rbp)
cmpl $0x2, %eax
jl 0x14f41
xorl %r14d, %r14d
movsd %xmm0, -0x30(%rbp)
movq %rbx, %rdi
movl %r14d, %esi
callq 0x139a6
movsd (%rax,%r13,8), %xmm0
movsd %xmm0, -0x38(%rbp)
movq %rbx, %rdi
movl %r14d, %esi
callq 0x139a6
movsd -0x38(%rbp), %xmm1
mulsd (%rax,%r12,8), %xmm1
movsd -0x30(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
incl %r14d
movl (%r15), %eax
decl %eax
cmpl %eax, %r14d
jl 0x14efa
cmpq %r12, %r13
jne 0x14f73
leaq -0x60(%rbp), %rdi
movl %r13d, %esi
callq 0x139a6
movsd (%rax,%r13,8), %xmm0
subsd -0x30(%rbp), %xmm0
ucomisd 0x1663(%rip), %xmm0     # 0x165c8
jbe 0x15006
jb 0x14fc2
sqrtsd %xmm0, %xmm0
jmp 0x14fc7
leaq -0x60(%rbp), %rdi
movl %r13d, %esi
callq 0x139a6
movsd (%rax,%r12,8), %xmm0
movsd %xmm0, -0x38(%rbp)
movq %rbx, %rdi
movl %r13d, %esi
callq 0x139a6
movsd (%rax,%r13,8), %xmm0
movsd %xmm0, -0x48(%rbp)
movq %rbx, %rdi
movl %r13d, %esi
callq 0x139a6
movsd -0x38(%rbp), %xmm0
subsd -0x30(%rbp), %xmm0
divsd -0x48(%rbp), %xmm0
movsd %xmm0, (%rax,%r12,8)
jmp 0x14fe2
callq 0x3120
movsd %xmm0, -0x30(%rbp)
movq %rbx, %rdi
movl %r13d, %esi
callq 0x139a6
movsd -0x30(%rbp), %xmm0
movsd %xmm0, (%rax,%r13,8)
incq %r12
movl (%r15), %eax
cmpl %r12d, %eax
jg 0x14ee4
movl 0x8(%r15), %ecx
incq %r13
movslq %ecx, %rdx
cmpq %rdx, %r13
jl 0x14ed5
jmp 0x15038
movq -0x40(%rbp), %rax
movb $0x0, (%rax)
movl (%rbx), %edx
movl 0x8(%rbx), %esi
xorpd %xmm0, %xmm0
movq %rbx, %rdi
callq 0x13382
leaq -0x78(%rbp), %rdi
movq %rbx, %rsi
callq 0x133e2
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
je 0x15038
callq 0x3200
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x15046
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 0x8cdf(%rip), %rcx      # 0x1dd48
movq %rcx, (%rax)
leaq 0x8c7d(%rip), %rsi      # 0x1dcf0
movq 0x8f66(%rip), %rdx      # 0x1dfe0
movq %rax, %rdi
callq 0x32b0
movq %rax, %r14
jmp 0x150a4
jmp 0x1508b
jmp 0x1508b
movq %rax, %r14
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x1509c
callq 0x3200
movq $0x0, 0x10(%rbx)
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x150b2
callq 0x3200
movq %r14, %rdi
callq 0x32d0