// File: bothaynahazem[P]AsuMathLabG13/Matrix2017.cpp
// Function: Matrix::getCofactor(int, int)
Matrix Matrix::getCofactor(int r, int c)
{
	//valid only for (2*2) matrices.
	if (nRows <= 1 && nColumns <= 1)
		throw("Invalid matrix dimension");
		if(this->type=="complex")
        {
          Matrix m("complex",nRows - 1, nColumns - 1);
	for (int iR = 0;iR<m.nRows;iR++)
		for (int iC = 0;iC<m.nColumns;iC++)
		{
			int sR = (iR<r) ? iR : iR + 1;
			int sC = (iC<c) ? iC : iC + 1;
			m.cvalues[iR][iC] = cvalues[sR][sC];
		}
		return m;
        }
        else
        {
	Matrix m(nRows - 1, nColumns - 1);
	for (int iR = 0;iR<m.nRows;iR++)
		for (int iC = 0;iC<m.nColumns;iC++)
		{
			int sR = (iR<r) ? iR : iR + 1;
			int sC = (iC<c) ? iC : iC + 1;
			m.values[iR][iC] = values[sR][sC];
		}
		return m;
        }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0xa8(%rbp)
movq %rdi, %rax
movq %rax, -0xa0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x98(%rbp)
cmpl $0x1, (%rax)
jg 0x1404e
movq -0x98(%rbp), %rax
cmpl $0x1, 0x4(%rax)
jg 0x1404e
movl $0x8, %edi
callq 0x31c0
movq %rax, %rdi
leaq 0x741a(%rip), %rax      # 0x1b455
movq %rax, (%rdi)
movq 0xdf83(%rip), %rsi      # 0x21fc8
xorl %eax, %eax
movl %eax, %edx
callq 0x35f0
movq -0x98(%rbp), %rdi
addq $0x18, %rdi
leaq 0x73a5(%rip), %rsi      # 0x1b405
callq 0xafa0
testb $0x1, %al
jne 0x1406e
jmp 0x1423c
movb $0x0, -0x19(%rbp)
leaq -0x41(%rbp), %rdi
movq %rdi, -0xb0(%rbp)
callq 0x3640
movq -0xb0(%rbp), %rdx
leaq 0x7375(%rip), %rsi      # 0x1b405
leaq -0x40(%rbp), %rdi
callq 0xab40
jmp 0x1409b
movq -0x98(%rbp), %rax
movl (%rax), %ecx
movl 0x4(%rax), %eax
decl %ecx
movl %ecx, -0xb8(%rbp)
decl %eax
movl %eax, -0xb4(%rbp)
leaq -0x68(%rbp), %rdi
xorps %xmm1, %xmm1
movaps %xmm1, %xmm0
callq 0x19810
jmp 0x140c8
movl -0xb4(%rbp), %ecx
movl -0xb8(%rbp), %edx
movq -0xa8(%rbp), %rdi
movsd -0x68(%rbp), %xmm0
movsd -0x60(%rbp), %xmm1
leaq -0x40(%rbp), %rsi
xorl %r8d, %r8d
callq 0x19470
jmp 0x140f3
leaq -0x40(%rbp), %rdi
callq 0x3270
leaq -0x41(%rbp), %rdi
callq 0x3410
movl $0x0, -0x6c(%rbp)
movq -0xa8(%rbp), %rcx
movl -0x6c(%rbp), %eax
cmpl (%rcx), %eax
jge 0x14221
movl $0x0, -0x70(%rbp)
movq -0xa8(%rbp), %rcx
movl -0x70(%rbp), %eax
cmpl 0x4(%rcx), %eax
jge 0x14211
movl -0x6c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x1414b
movl -0x6c(%rbp), %eax
movl %eax, -0xbc(%rbp)
jmp 0x14157
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xbc(%rbp)
movl -0xbc(%rbp), %eax
movl %eax, -0x74(%rbp)
movl -0x70(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x14173
movl -0x70(%rbp), %eax
movl %eax, -0xc0(%rbp)
jmp 0x1417f
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc0(%rbp)
movq -0xa8(%rbp), %rax
movq -0x98(%rbp), %rcx
movl -0xc0(%rbp), %edx
movl %edx, -0x78(%rbp)
movq 0x10(%rcx), %rcx
movslq -0x74(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq -0x78(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movq 0x10(%rax), %rax
movslq -0x6c(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movslq -0x70(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0x8(%rax)
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0x14125
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x14203
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x3270
leaq -0x41(%rbp), %rdi
callq 0x3410
jmp 0x14388
jmp 0x14213
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x1410c
movb $0x1, -0x19(%rbp)
testb $0x1, -0x19(%rbp)
jne 0x14237
movq -0xa8(%rbp), %rdi
callq 0xe650
jmp 0x14378
movq -0xa8(%rbp), %rdi
movq -0x98(%rbp), %rax
movb $0x0, -0x79(%rbp)
movl (%rax), %esi
subl $0x1, %esi
movl 0x4(%rax), %edx
subl $0x1, %edx
xorl %ecx, %ecx
xorps %xmm0, %xmm0
callq 0xe7c0
movl $0x0, -0x80(%rbp)
movq -0xa8(%rbp), %rcx
movl -0x80(%rbp), %eax
cmpl (%rcx), %eax
jge 0x14360
movl $0x0, -0x84(%rbp)
movq -0xa8(%rbp), %rcx
movl -0x84(%rbp), %eax
cmpl 0x4(%rcx), %eax
jge 0x14350
movl -0x80(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x142af
movl -0x80(%rbp), %eax
movl %eax, -0xc4(%rbp)
jmp 0x142bb
movl -0x80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc4(%rbp)
movl -0xc4(%rbp), %eax
movl %eax, -0x88(%rbp)
movl -0x84(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x142e0
movl -0x84(%rbp), %eax
movl %eax, -0xc8(%rbp)
jmp 0x142ef
movl -0x84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc8(%rbp)
movq -0xa8(%rbp), %rax
movq -0x98(%rbp), %rcx
movl -0xc8(%rbp), %edx
movl %edx, -0x8c(%rbp)
movq 0x8(%rcx), %rcx
movslq -0x88(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq -0x8c(%rbp), %rdx
movsd (%rcx,%rdx,8), %xmm0
movq 0x8(%rax), %rax
movslq -0x80(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x84(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
jmp 0x14286
jmp 0x14352
movl -0x80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80(%rbp)
jmp 0x1426a
movb $0x1, -0x79(%rbp)
testb $0x1, -0x79(%rbp)
jne 0x14376
movq -0xa8(%rbp), %rdi
callq 0xe650
jmp 0x14378
movq -0xa0(%rbp), %rax
addq $0xd0, %rsp
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0x3630
nopw %cs:(%rax,%rax)