// File: /workspace/github_cpp_makefile_star2_O2/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 0x2e8a
movq %rbx, 0x8(%rsp)
leaq 0x18(%rsp), %rdi
movq %r14, %rsi
callq 0x2708
pushq $0x1
popq %r8
pushq $0x2
popq %r9
xorl %ebx, %ebx
xorpd %xmm2, %xmm2
leaq 0x58(%rsp), %r12
leaq 0x98(%rsp), %r13
movl 0x18(%r14), %eax
cmpq %rax, %rbx
jae 0x2e9c
movq 0x18(%rsp), %rcx
imulq $0x18, %rbx, %r15
movq (%rcx,%r15), %rdx
movsd (%rdx,%rbx,8), %xmm1
ucomisd %xmm2, %xmm1
movl %r9d, 0x4(%rsp)
jne 0x2dc8
jp 0x2dc8
movl %r8d, %esi
imulq $0x18, %rsi, %rdx
addq %rdx, %rcx
movl %r9d, %edx
cmpq %rax, %rsi
jae 0x2dc8
movq (%rcx), %rdi
movsd (%rdi,%rbx,8), %xmm0
ucomisd %xmm2, %xmm0
jne 0x2da3
jp 0x2da3
incq %rsi
incl %edx
addq $0x18, %rcx
jmp 0x2d83
movl %r8d, %ebp
leal 0x1(%rbx), %esi
leaq 0x18(%rsp), %rdi
callq 0x2bd6
movq 0x18(%rsp), %rax
movq (%rax,%r15), %rax
movsd (%rax,%rbx,8), %xmm1
movl %ebp, %r8d
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm1
jne 0x2dd4
jnp 0x2eb0
movl %r8d, (%rsp)
movsd 0x5228(%rip), %xmm0     # 0x8008
divsd %xmm1, %xmm0
leaq 0x1(%rbx), %rbp
leaq 0x18(%rsp), %r15
movq %r15, %rdi
movl %ebp, %esi
callq 0x2cc2
movq %r12, %rdi
movq %r15, %rsi
movl %ebx, %edx
callq 0x26aa
xorl %r15d, %r15d
movl 0x18(%r14), %eax
cmpq %rax, %r15
jae 0x2e67
cmpq %r15, %rbx
jne 0x2e1a
incq %r15
jmp 0x2e07
movq 0x18(%rsp), %rax
imulq $0x18, %r15, %rcx
movq (%rax,%rcx), %rax
movsd (%rax,%rbx,8), %xmm0
xorpd 0x51dc(%rip), %xmm0     # 0x8010
movlpd %xmm0, 0x10(%rsp)
movq %r13, %rdi
movq %r12, %rsi
leaq 0x10(%rsp), %rdx
callq 0x3340
incq %r15
leaq 0x18(%rsp), %rdi
movq %r13, %rsi
movl %r15d, %edx
callq 0x2afe
movq %r13, %rdi
callq 0x3bc8
jmp 0x2e07
movq %r12, %rdi
callq 0x3bc8
movl (%rsp), %r8d
incl %r8d
movl 0x4(%rsp), %r9d
incl %r9d
movq %rbp, %rbx
xorpd %xmm2, %xmm2
jmp 0x2d4a
movb $0x1, 0x31(%r14)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2708
jmp 0x2ecf
leaq 0x18(%rsp), %rsi
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x2708
jmp 0x2ec5
movb $0x1, 0x31(%r14)
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2708
leaq 0x18(%rsp), %rdi
callq 0x3bc8
movq %rbx, %rax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2eea
jmp 0x2eea
jmp 0x2eea
movq %rax, %rbx
jmp 0x2efc
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x3bc8
leaq 0x18(%rsp), %rdi
callq 0x3bc8
movq %rbx, %rdi
callq 0x21f0