// File: /workspace/github_cpp_makefile_star2_O1/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 0x31e6
movq %rbx, 0x8(%rsp)
leaq 0x18(%rsp), %rdi
movq %r14, %rsi
callq 0x2870
movl 0x18(%r14), %eax
testl %eax, %eax
je 0x31d2
movl $0x2, 0x4(%rsp)
movl $0x18, %ebx
xorl %r15d, %r15d
leaq 0x98(%rsp), %rbp
movq 0x18(%rsp), %rcx
leaq (%r15,%r15,2), %r13
movq (%rcx,%r13,8), %rdx
movsd (%rdx,%r15,8), %xmm0
ucomisd 0x5fd0(%rip), %xmm0     # 0x9010
jne 0x3089
jp 0x3089
leaq 0x1(%r15), %rsi
movl %eax, %edx
cmpq %rdx, %rsi
jae 0x3089
addq %rbx, %rcx
negl %eax
movl 0x4(%rsp), %edx
movq (%rcx), %rdi
movsd (%rdi,%r15,8), %xmm0
ucomisd 0x5fa7(%rip), %xmm0     # 0x9010
jne 0x307f
jp 0x307f
addq $0x18, %rcx
leal (%rax,%rdx), %edi
incl %edi
incl %edx
cmpl $0x1, %edi
jne 0x3058
jmp 0x3089
leaq 0x18(%rsp), %rdi
callq 0x2e78
movq 0x18(%rsp), %rax
movq (%rax,%r13,8), %rax
movsd (%rax,%r15,8), %xmm0
ucomisd 0x5f70(%rip), %xmm0     # 0x9010
jne 0x30a8
jnp 0x31f8
movl 0x30(%rsp), %ecx
cmpq %rcx, %r15
jae 0x30e0
movl 0x34(%rsp), %ecx
testq %rcx, %rcx
je 0x30e5
movsd 0x5f46(%rip), %xmm1     # 0x9008
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 0x30c8
jmp 0x30e5
movb $0x1, 0x49(%rsp)
leaq 0x58(%rsp), %rdi
leaq 0x18(%rsp), %rsi
movl %r15d, %edx
callq 0x2808
cmpl $0x0, 0x18(%r14)
je 0x31b0
xorl %r13d, %r13d
cmpq %r13, %r15
je 0x31a0
movq 0x18(%rsp), %rax
leaq (,%r13,2), %r12
addq %r13, %r12
movq (%rax,%r12,8), %rax
movsd (%rax,%r15,8), %xmm0
xorpd 0x5ef0(%rip), %xmm0     # 0x9020
movlpd %xmm0, 0x10(%rsp)
movq %rbp, %rdi
leaq 0x58(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x3702
movl 0x30(%rsp), %eax
cmpq %rax, %r13
jb 0x3162
cmpl $0x1, 0xb0(%rsp)
jne 0x3162
movb $0x1, 0x49(%rsp)
jmp 0x3198
movl 0x34(%rsp), %eax
testq %rax, %rax
je 0x3198
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 0x3181
movq %rbp, %rdi
callq 0x4106
incq %r13
movl 0x18(%r14), %eax
cmpq %rax, %r13
jb 0x3105
incq %r15
leaq 0x58(%rsp), %rdi
callq 0x4106
movl 0x18(%r14), %eax
incl 0x4(%rsp)
addq $0x18, %rbx
cmpq %rax, %r15
jb 0x3025
leaq 0x18(%rsp), %rsi
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x2870
jmp 0x320d
movb $0x1, 0x31(%r14)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2870
jmp 0x3217
movb $0x1, 0x31(%r14)
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2870
leaq 0x18(%rsp), %rdi
callq 0x4106
movq %rbx, %rax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3232
jmp 0x3232
jmp 0x3232
movq %rax, %rbx
jmp 0x3244
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x4106
leaq 0x18(%rsp), %rdi
callq 0x4106
movq %rbx, %rdi
callq 0x21f0