// File: bothaynahazem[P]AsuMathLabG13/Matrix2017.cpp
// Function: Matrix::setSubMatrix(int, int, Matrix&)
void Matrix::setSubMatrix(int r, int c, Matrix& m)
{
	if ((r + m.nRows)>nRows || (c + m.nColumns)>nColumns)
		throw("Invalid matrix dimension");
	for (int iR = 0;iR<m.nRows;iR++)
		for (int iC = 0;iC<m.nColumns;iC++)
		{   if(this->type=="complex"&&m.type!="complex")
		    cvalues[r + iR][c + iC] = m.values[iR][iC];
		    else if(this->type!="complex"&&m.type=="complex")
            {
            //copy from values to cvalues first
            if(values)
            {
            for (int rows = 0;iR<this->nRows;iR++)
            for (int columns = 0;iC<this->nColumns;iC++)
            cvalues[rows][columns] = values[rows][columns];
            }
        //copy from values to cvalues first
            cvalues[r + iR][c + iC] = m.cvalues[iR][iC];
            }
            else if(this->type=="complex"&&m.type=="complex")
              cvalues[r + iR][c + iC] = m.cvalues[iR][iC];
            else
			values[r + iR][c + iC] = m.values[iR][iC];
		}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movq -0x8(%rbp), %rcx
movq %rcx, -0x30(%rbp)
movl -0xc(%rbp), %eax
movq -0x18(%rbp), %rdx
addl (%rdx), %eax
cmpl (%rcx), %eax
jg 0x13a0e
movq -0x30(%rbp), %rcx
movl -0x10(%rbp), %eax
movq -0x18(%rbp), %rdx
addl 0x4(%rdx), %eax
cmpl 0x4(%rcx), %eax
jle 0x13a35
movl $0x8, %edi
callq 0x31c0
movq %rax, %rdi
leaq 0x7a33(%rip), %rax      # 0x1b455
movq %rax, (%rdi)
movq 0xe59c(%rip), %rsi      # 0x21fc8
xorl %eax, %eax
movl %eax, %edx
callq 0x35f0
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x13ccd
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jge 0x13cbd
movq -0x30(%rbp), %rdi
addq $0x18, %rdi
leaq 0x7994(%rip), %rsi      # 0x1b405
callq 0xafa0
testb $0x1, %al
jne 0x13a7c
jmp 0x13add
movq -0x18(%rbp), %rdi
addq $0x18, %rdi
leaq 0x797a(%rip), %rsi      # 0x1b405
callq 0xaca0
testb $0x1, %al
jne 0x13a96
jmp 0x13add
movq -0x30(%rbp), %rax
movq -0x18(%rbp), %rcx
movq 0x8(%rcx), %rcx
movslq -0x1c(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq -0x20(%rbp), %rdx
movsd (%rcx,%rdx,8), %xmm0
movq 0x10(%rax), %rax
movl -0xc(%rbp), %ecx
addl -0x1c(%rbp), %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
movl -0x10(%rbp), %eax
addl -0x20(%rbp), %eax
cltq
shlq $0x4, %rax
addq %rax, %rdi
callq 0x19840
jmp 0x13cad
movq -0x30(%rbp), %rdi
addq $0x18, %rdi
leaq 0x7919(%rip), %rsi      # 0x1b405
callq 0xaca0
testb $0x1, %al
jne 0x13afa
jmp 0x13be9
movq -0x18(%rbp), %rdi
addq $0x18, %rdi
leaq 0x78fc(%rip), %rsi      # 0x1b405
callq 0xafa0
testb $0x1, %al
jne 0x13b17
jmp 0x13be9
movq -0x30(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x13b96
movl $0x0, -0x24(%rbp)
movq -0x30(%rbp), %rcx
movl -0x1c(%rbp), %eax
cmpl (%rcx), %eax
jge 0x13b94
movl $0x0, -0x28(%rbp)
movq -0x30(%rbp), %rcx
movl -0x20(%rbp), %eax
cmpl 0x4(%rcx), %eax
jge 0x13b87
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rcx
movslq -0x24(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq -0x28(%rbp), %rdx
movsd (%rcx,%rdx,8), %xmm0
movq 0x10(%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movslq -0x28(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rdi
callq 0x19840
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x13b3b
jmp 0x13b89
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x13b29
jmp 0x13b96
movq -0x30(%rbp), %rax
movq -0x18(%rbp), %rcx
movq 0x10(%rcx), %rcx
movslq -0x1c(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq -0x20(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movq 0x10(%rax), %rax
movl -0xc(%rbp), %edx
addl -0x1c(%rbp), %edx
movslq %edx, %rdx
movq (%rax,%rdx,8), %rax
movl -0x10(%rbp), %edx
addl -0x20(%rbp), %edx
movslq %edx, %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0x8(%rax)
jmp 0x13cab
movq -0x30(%rbp), %rdi
addq $0x18, %rdi
leaq 0x780d(%rip), %rsi      # 0x1b405
callq 0xafa0
testb $0x1, %al
jne 0x13c03
jmp 0x13c6d
movq -0x18(%rbp), %rdi
addq $0x18, %rdi
leaq 0x77f3(%rip), %rsi      # 0x1b405
callq 0xafa0
testb $0x1, %al
jne 0x13c1d
jmp 0x13c6d
movq -0x30(%rbp), %rax
movq -0x18(%rbp), %rcx
movq 0x10(%rcx), %rcx
movslq -0x1c(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq -0x20(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movq 0x10(%rax), %rax
movl -0xc(%rbp), %edx
addl -0x1c(%rbp), %edx
movslq %edx, %rdx
movq (%rax,%rdx,8), %rax
movl -0x10(%rbp), %edx
addl -0x20(%rbp), %edx
movslq %edx, %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0x8(%rax)
jmp 0x13ca9
movq -0x30(%rbp), %rax
movq -0x18(%rbp), %rcx
movq 0x8(%rcx), %rcx
movslq -0x1c(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq -0x20(%rbp), %rdx
movsd (%rcx,%rdx,8), %xmm0
movq 0x8(%rax), %rax
movl -0xc(%rbp), %ecx
addl -0x1c(%rbp), %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movl -0x10(%rbp), %ecx
addl -0x20(%rbp), %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x13cab
jmp 0x13cad
jmp 0x13caf
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x13a52
jmp 0x13cbf
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x13a3c
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)