// File: /workspace/github_c_makefile_star2_O0/georgeweigt[P]eigenmath/eigenmath.c
// Function: kronecker
void
kronecker(void)
{
	int h, i, j, k, l, m, n, p, q;
	struct atom *p1, *p2, *p3;

	p2 = pop();
	p1 = pop();

	if (!istensor(p1) || !istensor(p2)) {
		push(p1);
		push(p2);
		multiply();
		return;
	}

	if (p1->u.tensor->ndim > 2 || p2->u.tensor->ndim > 2)
		stopf("kronecker");

	m = p1->u.tensor->dim[0];
	n = p1->u.tensor->ndim == 1 ? 1 : p1->u.tensor->dim[1];

	p = p2->u.tensor->dim[0];
	q = p2->u.tensor->ndim == 1 ? 1 : p2->u.tensor->dim[1];

	p3 = alloc_tensor(m * n * p * q);

	// result matrix has (m * p) rows and (n * q) columns

	h = 0;

	for (i = 0; i < m; i++)
		for (j = 0; j < p; j++)
			for (k = 0; k < n; k++)
				for (l = 0; l < q; l++) {
					push(p1->u.tensor->elem[n * i + k]);
					push(p2->u.tensor->elem[q * j + l]);
					multiply();
					p3->u.tensor->elem[h++] = pop();
				}

	// dim info

	p3->u.tensor->ndim = n * q == 1 ? 1 : 2;

	p3->u.tensor->dim[0] = m * p;

	if (n * q > 1)
		p3->u.tensor->dim[1] = n * q;

	push(p3);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
callq 0x91d0
movq %rax, -0x38(%rbp)
callq 0x91d0
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x7, %eax
jne 0x24374
movq -0x38(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x7, %eax
je 0x24390
movq -0x30(%rbp), %rdi
callq 0x9110
movq -0x38(%rbp), %rdi
callq 0x9110
callq 0xc280
jmp 0x2457c
movq -0x30(%rbp), %rax
movq (%rax), %rax
cmpl $0x2, (%rax)
jg 0x243a8
movq -0x38(%rbp), %rax
movq (%rax), %rax
cmpl $0x2, (%rax)
jle 0x243b4
leaq 0x25480(%rip), %rdi     # 0x4982f
callq 0x78d0
movq -0x30(%rbp), %rax
movq (%rax), %rax
movl 0x4(%rax), %eax
movl %eax, -0x18(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rax
cmpl $0x1, (%rax)
jne 0x243d7
movl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x243e4
movq -0x30(%rbp), %rax
movq (%rax), %rax
movl 0x8(%rax), %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
movl %eax, -0x1c(%rbp)
movq -0x38(%rbp), %rax
movq (%rax), %rax
movl 0x4(%rax), %eax
movl %eax, -0x20(%rbp)
movq -0x38(%rbp), %rax
movq (%rax), %rax
cmpl $0x1, (%rax)
jne 0x2440d
movl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x2441a
movq -0x38(%rbp), %rax
movq (%rax), %rax
movl 0x8(%rax), %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x18(%rbp), %edi
imull -0x1c(%rbp), %edi
imull -0x20(%rbp), %edi
imull -0x24(%rbp), %edi
callq 0x79b0
movq %rax, -0x40(%rbp)
movl $0x0, -0x4(%rbp)
movl $0x0, -0x8(%rbp)
movl -0x8(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x24525
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x24515
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x24505
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x244f5
movq -0x30(%rbp), %rax
movq (%rax), %rax
movl -0x1c(%rbp), %ecx
imull -0x8(%rbp), %ecx
addl -0x10(%rbp), %ecx
movslq %ecx, %rcx
movq 0x68(%rax,%rcx,8), %rdi
callq 0x9110
movq -0x38(%rbp), %rax
movq (%rax), %rax
movl -0x24(%rbp), %ecx
imull -0xc(%rbp), %ecx
addl -0x14(%rbp), %ecx
movslq %ecx, %rcx
movq 0x68(%rax,%rcx,8), %rdi
callq 0x9110
callq 0xc280
callq 0x91d0
movq %rax, %rdx
movq -0x40(%rbp), %rax
movq (%rax), %rax
movl -0x4(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x4(%rbp)
movslq %ecx, %rcx
movq %rdx, 0x68(%rax,%rcx,8)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x2447f
jmp 0x244f7
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x2446c
jmp 0x24507
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x24459
jmp 0x24517
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x24446
movl -0x1c(%rbp), %edx
imull -0x24(%rbp), %edx
movl $0x2, %ecx
movl $0x1, %eax
cmpl $0x1, %edx
cmovel %eax, %ecx
movq -0x40(%rbp), %rax
movq (%rax), %rax
movl %ecx, (%rax)
movl -0x18(%rbp), %ecx
imull -0x20(%rbp), %ecx
movq -0x40(%rbp), %rax
movq (%rax), %rax
movl %ecx, 0x4(%rax)
movl -0x1c(%rbp), %eax
imull -0x24(%rbp), %eax
cmpl $0x1, %eax
jle 0x24573
movl -0x1c(%rbp), %ecx
imull -0x24(%rbp), %ecx
movq -0x40(%rbp), %rax
movq (%rax), %rax
movl %ecx, 0x8(%rax)
movq -0x40(%rbp), %rdi
callq 0x9110
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)