// File: /workspace/github_cpp_makefile_star2_O3/hitc8494[P]Matrix/matrix.cpp
// Function: Matrix::upperTriangular()
Matrix Matrix::upperTriangular(){
  if( _m == _n ){
    Matrix result = *this;
    //*****For each leading 1...
    for( uint i = 0; i < _m; i++ ){
      //*****Put a leading nonzero in the current row.
      if( result._data[i][i] == 0 ){
	for( uint j = i+1; j < _m; j++ ){
	  if( result._data[j][i] != 0 ){
	    result.SWITCHRows( i+1, j+1 );
	    break;
	  }
	}
      }
      if( result._data[i][i] == 0 ){ //All 0s in the column. Not possible.
	_error = 1;
	return *this;
      }
      //*****Multiply current row by 1/value to give it a leading 1.
      double value = result._data[i][i];
      result.MULTIPLYRow( 1/value, i+1 );
      //*****Clean the column so the leading 1 is the only number in the column.
      Matrix res( result, i );
      for( uint j = 0; j < _m; j++ ){
	if( i != j ){
	  double coeff = result._data[j][i];
	  result.ADDToRow( (res*-coeff), j+1 );
	}
      }
    }
    return result;
  }
  else {
    _error = 1;
    return *this;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movl 0x18(%rsi), %eax
cmpl 0x1c(%rsi), %eax
jne 0x31d0
movq %rbx, 0x8(%rsp)
leaq 0x18(%rsp), %rdi
movq %r14, %rsi
callq 0x2848
movl 0x18(%r14), %ecx
testl %ecx, %ecx
je 0x31bc
movl $0x2, 0x4(%rsp)
movl $0x18, %ebx
xorl %r15d, %r15d
leaq 0x98(%rsp), %rbp
movq 0x18(%rsp), %rdi
leaq (%r15,%r15,2), %r13
movq (%rdi,%r13,8), %rax
movsd (%rax,%r15,8), %xmm0
ucomisd 0x6024(%rip), %xmm0     # 0x9048
jne 0x307f
jp 0x307f
leaq 0x1(%r15), %rsi
movl %ecx, %edx
cmpq %rdx, %rsi
jae 0x307f
addq %rbx, %rdi
negl %ecx
movl 0x4(%rsp), %edx
movq (%rdi), %r8
movsd (%r8,%r15,8), %xmm1
ucomisd 0x5ffb(%rip), %xmm1     # 0x9048
jne 0x3066
jp 0x3066
addq $0x18, %rdi
leal (%rcx,%rdx), %r8d
incl %r8d
incl %edx
cmpl $0x1, %r8d
jne 0x303c
jmp 0x307f
leaq 0x18(%rsp), %rdi
callq 0x2e5e
movq 0x18(%rsp), %rax
movq (%rax,%r13,8), %rax
movsd (%rax,%r15,8), %xmm0
ucomisd 0x5fc1(%rip), %xmm0     # 0x9048
jne 0x308f
jnp 0x31e2
movl 0x30(%rsp), %ecx
cmpq %rcx, %r15
jae 0x30c7
movl 0x34(%rsp), %ecx
testq %rcx, %rcx
je 0x30cc
movsd 0x5f97(%rip), %xmm1     # 0x9040
divsd %xmm0, %xmm1
xorl %edx, %edx
movsd (%rax,%rdx,8), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rdx,8)
incq %rdx
cmpq %rdx, %rcx
jne 0x30af
jmp 0x30cc
movb $0x1, 0x49(%rsp)
leaq 0x58(%rsp), %rdi
leaq 0x18(%rsp), %rsi
movl %r15d, %edx
callq 0x27e0
movl 0x18(%r14), %eax
testl %eax, %eax
je 0x319a
xorl %r13d, %r13d
cmpq %r13, %r15
je 0x318c
movq 0x18(%rsp), %rax
leaq (,%r13,2), %r12
addq %r13, %r12
movq (%rax,%r12,8), %rax
movsd (%rax,%r15,8), %xmm0
xorpd 0x5f18(%rip), %xmm0     # 0x9030
movlpd %xmm0, 0x10(%rsp)
movq %rbp, %rdi
leaq 0x58(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x36ec
movl 0x30(%rsp), %eax
cmpq %rax, %r13
jb 0x314a
cmpl $0x1, 0xb0(%rsp)
jne 0x314a
movb $0x1, 0x49(%rsp)
jmp 0x3180
movl 0x34(%rsp), %eax
testq %rax, %rax
je 0x3180
movq 0x18(%rsp), %rcx
movq (%rcx,%r12,8), %rcx
movq 0x98(%rsp), %rdx
movq (%rdx), %rdx
xorl %esi, %esi
movsd (%rcx,%rsi,8), %xmm0
addsd (%rdx,%rsi,8), %xmm0
movsd %xmm0, (%rcx,%rsi,8)
incq %rsi
cmpq %rsi, %rax
jne 0x3169
movq %rbp, %rdi
callq 0x410a
movl 0x18(%r14), %eax
incq %r13
movl %eax, %ecx
cmpq %rcx, %r13
jb 0x30ed
incq %r15
leaq 0x58(%rsp), %rdi
callq 0x410a
movl 0x18(%r14), %ecx
incl 0x4(%rsp)
addq $0x18, %rbx
cmpq %rcx, %r15
jb 0x3009
leaq 0x18(%rsp), %rsi
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x2848
jmp 0x31f7
movb $0x1, 0x31(%r14)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2848
jmp 0x3201
movb $0x1, 0x31(%r14)
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2848
leaq 0x18(%rsp), %rdi
callq 0x410a
movq %rbx, %rax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x321c
jmp 0x321c
jmp 0x321c
movq %rax, %rbx
jmp 0x322e
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x410a
leaq 0x18(%rsp), %rdi
callq 0x410a
movq %rbx, %rdi
callq 0x21f0