// File: IlanPrice[P]Linear-Algebra-Library-in-Cplusplus/Matrix.cpp
// Function: kron(Matrix const&, Matrix const&)
Matrix kron(const Matrix& A, const Matrix& B)
{
	int m = A.mRows; int n = A.mColumns;
	int p = B.mRows; int q = B.mColumns;
	int r = m*p; int c = n*q;
	Matrix M(r,c);
	Vector rowpos(m);
	Vector colpos(n);
	for (int i=0;i<m;i++)
	{
		rowpos(i+1) = i*p;
	}
	for (int i=0;i<n;i++)
	{
		colpos(i+1) = i*q;
	}
	for (int i=1;i<=m;i++)
	{
		for (int j = 1;j<=n;j++)
		{
			M.setElements(rowpos(i)+1, rowpos(i)+p, colpos(j)+1, colpos(j)+q, A(i,j)*B);
		}
	}
	return M;

}

// Assembly:
subq $0x108, %rsp            # imm = 0x108
movq %rdi, 0x70(%rsp)
movq %rdi, %rax
movq %rax, 0x78(%rsp)
movq %rdi, 0x100(%rsp)
movq %rsi, 0xf8(%rsp)
movq %rdx, 0xf0(%rsp)
movq 0xf8(%rsp), %rax
movl 0x8(%rax), %eax
movl %eax, 0xec(%rsp)
movq 0xf8(%rsp), %rax
movl 0xc(%rax), %eax
movl %eax, 0xe8(%rsp)
movq 0xf0(%rsp), %rax
movl 0x8(%rax), %eax
movl %eax, 0xe4(%rsp)
movq 0xf0(%rsp), %rax
movl 0xc(%rax), %eax
movl %eax, 0xe0(%rsp)
movl 0xec(%rsp), %eax
movl 0xe4(%rsp), %ecx
imull %ecx, %eax
movl %eax, 0xdc(%rsp)
movl 0xe8(%rsp), %eax
movl 0xe0(%rsp), %ecx
imull %ecx, %eax
movl %eax, 0xd8(%rsp)
movb $0x0, 0xd7(%rsp)
movl 0xdc(%rsp), %esi
movl 0xd8(%rsp), %edx
callq 0x4e80
movl 0xec(%rsp), %esi
leaq 0xc0(%rsp), %rdi
callq 0x2d70
jmp 0x9d85
movl 0xe8(%rsp), %esi
leaq 0xa0(%rsp), %rdi
callq 0x2d70
jmp 0x9d9b
movl $0x0, 0x9c(%rsp)
movl 0x9c(%rsp), %eax
cmpl 0xec(%rsp), %eax
jge 0x9e5a
movl 0x9c(%rsp), %esi
movl 0xe4(%rsp), %ecx
movl %esi, %eax
imull %ecx, %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x60(%rsp)
incl %esi
leaq 0xc0(%rsp), %rdi
callq 0x3ee0
movq %rax, 0x68(%rsp)
jmp 0x9ded
movq 0x68(%rsp), %rax
movsd 0x60(%rsp), %xmm0
movsd %xmm0, (%rax)
movl 0x9c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x9c(%rsp)
jmp 0x9da6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb8(%rsp)
movl %eax, 0xb4(%rsp)
jmp 0xa110
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb8(%rsp)
movl %eax, 0xb4(%rsp)
jmp 0xa0ea
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb8(%rsp)
movl %eax, 0xb4(%rsp)
jmp 0xa0dd
movl $0x0, 0x98(%rsp)
movl 0x98(%rsp), %eax
cmpl 0xe8(%rsp), %eax
jge 0x9eca
movl 0x98(%rsp), %esi
movl 0xe0(%rsp), %ecx
movl %esi, %eax
imull %ecx, %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x50(%rsp)
incl %esi
leaq 0xa0(%rsp), %rdi
callq 0x3ee0
movq %rax, 0x58(%rsp)
jmp 0x9ea8
movq 0x58(%rsp), %rax
movsd 0x50(%rsp), %xmm0
movsd %xmm0, (%rax)
movl 0x98(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x98(%rsp)
jmp 0x9e65
movl $0x1, 0x94(%rsp)
movl 0x94(%rsp), %eax
cmpl 0xec(%rsp), %eax
jg 0xa0af
movl $0x1, 0x90(%rsp)
movl 0x90(%rsp), %eax
cmpl 0xe8(%rsp), %eax
jg 0xa097
movl 0x94(%rsp), %esi
leaq 0xc0(%rsp), %rdi
callq 0x3ee0
movq %rax, 0x48(%rsp)
jmp 0x9f23
movq 0x48(%rsp), %rax
movsd (%rax), %xmm0
movsd 0x80dc(%rip), %xmm1     # 0x12010
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x3c(%rsp)
movl 0x94(%rsp), %esi
leaq 0xc0(%rsp), %rdi
callq 0x3ee0
movq %rax, 0x40(%rsp)
jmp 0x9f5b
movq 0x40(%rsp), %rax
movsd (%rax), %xmm0
cvtsi2sdl 0xe4(%rsp), %xmm1
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x2c(%rsp)
movl 0x90(%rsp), %esi
leaq 0xa0(%rsp), %rdi
callq 0x3ee0
movq %rax, 0x30(%rsp)
jmp 0x9f94
movq 0x30(%rsp), %rax
movsd (%rax), %xmm0
movsd 0x806b(%rip), %xmm1     # 0x12010
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x1c(%rsp)
movl 0x90(%rsp), %esi
leaq 0xa0(%rsp), %rdi
callq 0x3ee0
movq %rax, 0x20(%rsp)
jmp 0x9fcc
movq 0x20(%rsp), %rax
movsd (%rax), %xmm0
cvtsi2sdl 0xe0(%rsp), %xmm1
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0xc(%rsp)
movq 0xf8(%rsp), %rdi
movl 0x94(%rsp), %esi
movl 0x90(%rsp), %edx
callq 0x7250
movq %rax, 0x10(%rsp)
jmp 0xa00c
movq 0x10(%rsp), %rax
movsd (%rax), %xmm0
movq 0xf0(%rsp), %rsi
leaq 0x80(%rsp), %rdi
callq 0x6ba0
jmp 0xa02c
movl 0xc(%rsp), %r8d
movl 0x1c(%rsp), %ecx
movl 0x2c(%rsp), %edx
movl 0x3c(%rsp), %esi
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %r9
callq 0x5f20
jmp 0xa051
leaq 0x80(%rsp), %rdi
callq 0x5230
movl 0x90(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x90(%rsp)
jmp 0x9ef4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb8(%rsp)
movl %eax, 0xb4(%rsp)
leaq 0x80(%rsp), %rdi
callq 0x5230
jmp 0xa0dd
jmp 0xa099
movl 0x94(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x94(%rsp)
jmp 0x9ed5
movb $0x1, 0xd7(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x2ea0
leaq 0xc0(%rsp), %rdi
callq 0x2ea0
testb $0x1, 0xd7(%rsp)
jne 0xa103
jmp 0xa0f9
leaq 0xa0(%rsp), %rdi
callq 0x2ea0
leaq 0xc0(%rsp), %rdi
callq 0x2ea0
jmp 0xa110
movq 0x70(%rsp), %rdi
callq 0x5230
movq 0x78(%rsp), %rax
addq $0x108, %rsp            # imm = 0x108
retq
movq 0x70(%rsp), %rdi
callq 0x5230
movq 0xb8(%rsp), %rdi
callq 0x21b0
nopw (%rax,%rax)