// File: /workspace/github_cpp_makefile_star2_O3/bothaynahazem[P]AsuMathLabG13/Matrix2017.cpp
// Function: Matrix::getInverse()
Matrix Matrix::getInverse() //inverse=(1/determinant)*transpose of cofactor matrix
{
	if(type=="complex")
	{

	if (nRows != nColumns) //inverse can only be done on square matrices
		throw("Invalid Matrix Dimension");
	Matrix n=*this;
Matrix m("complex",nRows, nColumns); //cofactor matrix
	complex<double> det_value = n.getcDeterminant(); //determinant value of the matrix

	if (det_value==0.0)
        {
		Matrix s("complex",nRows,nColumns,MI_VALUE,NAN);
		return s;
	}


	double sign_c =1;
	double sign_r=1;

	for (int iR = 0;iR<m.nRows;iR++)
    {
        sign_c=sign_r;
		for (int iC = 0;iC<m.nColumns;iC++)
		{
			m.cvalues[iR][iC] = sign_c * n.getCofactor(iR, iC).getcDeterminant();//getting detreminant values of cofactor matrix
			sign_c *=-1;//following sign rule in matrices
		}
        sign_r*=-1;
    }
	m=m.getTranspose();//transpose of cofactor matrix
	m *= (1.0 / det_value);
	return m;
 }

 if(type!="complex")
 {
 if (nRows != nColumns) //inverse can only be done on square matrices
	 throw("Invalid Matrix Dimension");
 Matrix n=*this;
 Matrix m(nRows, nColumns); //cofactor matrix
 double det_value = n.getDeterminant(); //determinant value of the matrix

 if (det_value==0.0)
        {
		Matrix s(nRows,nColumns,MI_VALUE,NAN);
		return s;
	}

 int sign_c =1;
 int sign_r=1;

 for (int iR = 0;iR<m.nRows;iR++)
	 {
			 sign_c=sign_r;
	 for (int iC = 0;iC<m.nColumns;iC++)
	 {
		 m.values[iR][iC] = sign_c * n.getCofactor(iR, iC).getDeterminant();//getting detreminant values of cofactor matrix
		 sign_c *=-1;//following sign rule in matrices
	 }
			 sign_r*=-1;
	 }
 m=m.getTranspose();//transpose of cofactor matrix
 m *= (1.0 / det_value);
 return m;
 }

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x18(%rsi), %r15
leaq 0x4614(%rip), %rsi      # 0x111f5
movq %r15, %rdi
callq 0x30e0
testl %eax, %eax
je 0xcc73
leaq 0x45fd(%rip), %rsi      # 0x111f5
movq %r15, %rdi
callq 0x30e0
movl (%r14), %eax
cmpl 0x4(%r14), %eax
jne 0xd066
leaq -0x158(%rbp), %rdi
movq %r14, %rsi
callq 0xa5a6
movl (%r14), %esi
movl 0x4(%r14), %edx
leaq -0x68(%rbp), %rdi
xorpd %xmm0, %xmm0
xorl %ecx, %ecx
callq 0xa262
leaq -0x158(%rbp), %rdi
callq 0xd9be
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xcdaa
jp 0xcdaa
movl (%r14), %esi
movl 0x4(%r14), %edx
movsd 0x4507(%rip), %xmm0     # 0x11168
movq %rbx, %rdi
movl $0x4, %ecx
callq 0xa262
jmp 0xd03c
movl (%r14), %eax
cmpl 0x4(%r14), %eax
jne 0xd066
leaq -0x158(%rbp), %rdi
movq %r14, %rsi
callq 0xa5a6
leaq -0xd8(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x4554(%rip), %rsi      # 0x111f5
leaq 0x4554(%rip), %rdx      # 0x111fc
leaq -0xe8(%rbp), %rdi
callq 0x93ea
movl (%r14), %edx
movl 0x4(%r14), %ecx
leaq -0x68(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
xorl %r8d, %r8d
callq 0x106da
movq -0xe8(%rbp), %rdi
cmpq %r15, %rdi
je 0xccf1
movq -0xd8(%rbp), %rsi
incq %rsi
callq 0x3300
leaq -0x158(%rbp), %rdi
callq 0xdbe6
movsd %xmm1, -0x88(%rbp)
xorpd %xmm2, %xmm2
movsd %xmm0, -0xa8(%rbp)
ucomisd %xmm2, %xmm0
jne 0xcee9
jp 0xcee9
movsd -0x88(%rbp), %xmm1
ucomisd %xmm2, %xmm1
jne 0xcee9
jp 0xcee9
leaq -0xb8(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x44aa(%rip), %rsi      # 0x111f5
leaq 0x44aa(%rip), %rdx      # 0x111fc
leaq -0xc8(%rbp), %rdi
callq 0x93ea
movl (%r14), %edx
movl 0x4(%r14), %ecx
leaq -0xc8(%rbp), %rsi
movsd 0x43f4(%rip), %xmm0     # 0x11168
xorpd %xmm1, %xmm1
movq %rbx, %rdi
movl $0x4, %r8d
callq 0x106da
movq -0xc8(%rbp), %rdi
cmpq %r15, %rdi
je 0xd03c
movq -0xb8(%rbp), %rsi
incq %rsi
callq 0x3300
jmp 0xd03c
movsd %xmm0, -0x80(%rbp)
movq %rbx, -0x30(%rbp)
movl -0x68(%rbp), %ecx
testl %ecx, %ecx
jle 0xce42
movl $0x1, %ebx
movl -0x64(%rbp), %eax
xorl %r14d, %r14d
leaq -0x120(%rbp), %r15
leaq -0x158(%rbp), %r12
testl %eax, %eax
jle 0xce35
xorl %r13d, %r13d
movl %ebx, -0xa0(%rbp)
movq %r15, %rdi
movq %r12, %rsi
movl %r14d, %edx
movl %r13d, %ecx
callq 0xd7c4
movq %r15, %rdi
callq 0xd9be
xorps %xmm1, %xmm1
cvtsi2sd %ebx, %xmm1
mulsd %xmm1, %xmm0
movq -0x60(%rbp), %rax
movq (%rax,%r14,8), %rax
movsd %xmm0, (%rax,%r13,8)
movq %r15, %rdi
callq 0xa186
negl %ebx
incq %r13
movslq -0x64(%rbp), %rax
cmpq %rax, %r13
jl 0xcde4
movl -0x68(%rbp), %ecx
movl -0xa0(%rbp), %ebx
negl %ebx
incq %r14
movslq %ecx, %rdx
cmpq %rdx, %r14
jl 0xcdd7
leaq -0x120(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0xe87a
leaq -0x68(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0xa5fe
movq -0x30(%rbp), %rbx
leaq -0x190(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0xa5a6
leaq -0x190(%rbp), %rdi
callq 0xa186
leaq -0x120(%rbp), %rdi
callq 0xa186
movslq -0x68(%rbp), %rax
testq %rax, %rax
jle 0xced8
movsd 0x42b9(%rip), %xmm0     # 0x11158
divsd -0x80(%rbp), %xmm0
movl -0x64(%rbp), %ecx
movq -0x60(%rbp), %rdx
xorl %esi, %esi
testl %ecx, %ecx
jle 0xced0
movq (%rdx,%rsi,8), %rdi
xorl %r8d, %r8d
movsd (%rdi,%r8,8), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, (%rdi,%r8,8)
incq %r8
cmpq %r8, %rcx
jne 0xceb8
incq %rsi
cmpq %rax, %rsi
jne 0xcead
leaq -0x68(%rbp), %rsi
movq %rbx, %rdi
callq 0xa7e4
jmp 0xd03c
movq %rbx, -0x30(%rbp)
movl -0x68(%rbp), %ecx
testl %ecx, %ecx
jle 0xcfba
movsd 0x4258(%rip), %xmm0     # 0x11158
movapd %xmm0, -0x80(%rbp)
movl -0x64(%rbp), %eax
xorl %r14d, %r14d
leaq -0x120(%rbp), %r15
leaq -0x158(%rbp), %r12
testl %eax, %eax
jle 0xcf99
movl $0x8, %ebx
xorl %r13d, %r13d
movapd -0x80(%rbp), %xmm0
movapd %xmm0, -0xa0(%rbp)
movq %r15, %rdi
movq %r12, %rsi
movl %r14d, %edx
movl %r13d, %ecx
callq 0xd7c4
movq %r15, %rdi
callq 0xdbe6
movapd -0xa0(%rbp), %xmm2
mulsd %xmm2, %xmm0
mulsd %xmm2, %xmm1
movq -0x58(%rbp), %rax
movq (%rax,%r14,8), %rax
movsd %xmm0, -0x8(%rax,%rbx)
movsd %xmm1, (%rax,%rbx)
movq %r15, %rdi
callq 0xa186
movapd -0xa0(%rbp), %xmm0
xorpd 0x423a(%rip), %xmm0     # 0x111c0
incq %r13
movslq -0x64(%rbp), %rax
addq $0x10, %rbx
cmpq %rax, %r13
jl 0xcf2a
movl -0x68(%rbp), %ecx
movapd -0x80(%rbp), %xmm0
xorpd 0x421a(%rip), %xmm0     # 0x111c0
movapd %xmm0, -0x80(%rbp)
incq %r14
movslq %ecx, %rdx
cmpq %rdx, %r14
jl 0xcf19
leaq -0x120(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0xe87a
leaq -0x68(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0xa5fe
movq -0x30(%rbp), %rbx
leaq -0x1c8(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0xa5a6
leaq -0x1c8(%rbp), %rdi
callq 0xa186
leaq -0x120(%rbp), %rdi
callq 0xa186
movsd 0x414a(%rip), %xmm0     # 0x11158
xorpd %xmm1, %xmm1
movsd -0xa8(%rbp), %xmm2
movsd -0x88(%rbp), %xmm3
callq 0x31f0
leaq -0x68(%rbp), %rdi
callq 0xc7e8
leaq -0x68(%rbp), %rsi
movq %rbx, %rdi
callq 0xa7e4
leaq -0x68(%rbp), %rdi
callq 0xa186
leaq -0x158(%rbp), %rdi
callq 0xa186
movq %rbx, %rax
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x8, %edi
callq 0x3170
leaq 0x4267(%rip), %rcx      # 0x112de
movq %rcx, (%rax)
movq 0x8f3f(%rip), %rsi      # 0x15fc0
movq %rax, %rdi
xorl %edx, %edx
callq 0x34d0
jmp 0xd0ea
jmp 0xd0ea
jmp 0xd0ea
movq %rax, %rbx
movq -0xc8(%rbp), %rdi
cmpq %r15, %rdi
je 0xd0fe
movq -0xb8(%rbp), %rsi
incq %rsi
callq 0x3300
jmp 0xd0fe
jmp 0xd0ea
jmp 0xd0ea
jmp 0xd0ea
jmp 0xd0ef
jmp 0xd0ea
movq %rax, %rbx
movq -0xe8(%rbp), %rdi
cmpq %r15, %rdi
je 0xd107
movq -0xd8(%rbp), %rsi
incq %rsi
callq 0x3300
jmp 0xd107
jmp 0xd0df
jmp 0xd0ef
movq %rax, %rbx
jmp 0xd107
jmp 0xd0ea
jmp 0xd0ea
jmp 0xd0ef
movq %rax, %rbx
jmp 0xd0fe
movq %rax, %rbx
leaq -0x120(%rbp), %rdi
callq 0xa186
leaq -0x68(%rbp), %rdi
callq 0xa186
leaq -0x158(%rbp), %rdi
callq 0xa186
movq %rbx, %rdi
callq 0x3520
nop