// File: /workspace/github_c_makefile_star2_O0/georgeweigt[P]eigenmath/eigenmath.c
// Function: indexfunc
void
indexfunc(struct atom *T, int h)
{
	int i, k, m, n, r, t, w;
	struct atom *p1;

	m = T->u.tensor->ndim;

	n = tos - h;

	r = m - n; // rank of result

	if (r < 0)
		stopf("index error");

	k = 0;

	for (i = 0; i < n; i++) {
		push(stack[h + i]);
		t = pop_integer();
		if (t < 1 || t > T->u.tensor->dim[i]) {
			if (shuntflag) {
				errorflag = 1;
				t = 1;
			} else
				stopf("index error");
		}
		k = k * T->u.tensor->dim[i] + t - 1;
	}

	tos = h; // pop all

	if (r == 0) {
		push(T->u.tensor->elem[k]); // scalar result
		return;
	}

	w = 1;

	for (i = n; i < m; i++)
		w *= T->u.tensor->dim[i];

	k *= w;

	p1 = alloc_tensor(w);

	for (i = 0; i < w; i++)
		p1->u.tensor->elem[i] = T->u.tensor->elem[k + i];

	p1->u.tensor->ndim = r;

	for (i = 0; i < r; i++)
		p1->u.tensor->dim[i] = T->u.tensor->dim[n + i];

	push(p1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl (%rax), %eax
movl %eax, -0x18(%rbp)
movl 0x396d7(%rip), %eax     # 0x582b8
subl -0xc(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x18(%rbp), %eax
subl -0x1c(%rbp), %eax
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jge 0x1ec02
leaq 0x2af5a(%rip), %rdi     # 0x49b57
callq 0x78d0
movl $0x0, -0x14(%rbp)
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x1ecab
movl -0xc(%rbp), %eax
addl -0x10(%rbp), %eax
movslq %eax, %rcx
leaq 0x42994(%rip), %rax     # 0x615c0
movq (%rax,%rcx,8), %rdi
callq 0x9110
callq 0x13520
movl %eax, -0x24(%rbp)
cmpl $0x1, -0x24(%rbp)
jl 0x1ec57
movl -0x24(%rbp), %eax
movq -0x8(%rbp), %rcx
movq (%rcx), %rcx
movslq -0x10(%rbp), %rdx
cmpl 0x4(%rcx,%rdx,4), %eax
jle 0x1ec81
cmpl $0x0, 0x110766(%rip)    # 0x12f3c4
je 0x1ec73
movl $0x1, 0x110756(%rip)    # 0x12f3c0
movl $0x1, -0x24(%rbp)
jmp 0x1ec7f
leaq 0x2aedd(%rip), %rdi     # 0x49b57
callq 0x78d0
jmp 0x1ec81
movl -0x14(%rbp), %eax
movq -0x8(%rbp), %rcx
movq (%rcx), %rcx
movslq -0x10(%rbp), %rdx
imull 0x4(%rcx,%rdx,4), %eax
addl -0x24(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x14(%rbp)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x1ec10
movl -0xc(%rbp), %eax
movl %eax, 0x39604(%rip)     # 0x582b8
cmpl $0x0, -0x20(%rbp)
jne 0x1ecd4
movq -0x8(%rbp), %rax
movq (%rax), %rax
movslq -0x14(%rbp), %rcx
movq 0x68(%rax,%rcx,8), %rdi
callq 0x9110
jmp 0x1edb1
movl $0x1, -0x28(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x1ed0a
movq -0x8(%rbp), %rax
movq (%rax), %rax
movslq -0x10(%rbp), %rcx
movl 0x4(%rax,%rcx,4), %eax
imull -0x28(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x1ece1
movl -0x28(%rbp), %eax
imull -0x14(%rbp), %eax
movl %eax, -0x14(%rbp)
movl -0x28(%rbp), %edi
callq 0x79b0
movq %rax, -0x30(%rbp)
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x1ed5f
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl -0x14(%rbp), %ecx
addl -0x10(%rbp), %ecx
movslq %ecx, %rcx
movq 0x68(%rax,%rcx,8), %rdx
movq -0x30(%rbp), %rax
movq (%rax), %rax
movslq -0x10(%rbp), %rcx
movq %rdx, 0x68(%rax,%rcx,8)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x1ed27
movl -0x20(%rbp), %ecx
movq -0x30(%rbp), %rax
movq (%rax), %rax
movl %ecx, (%rax)
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x1eda8
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl -0x1c(%rbp), %ecx
addl -0x10(%rbp), %ecx
movslq %ecx, %rcx
movl 0x4(%rax,%rcx,4), %edx
movq -0x30(%rbp), %rax
movq (%rax), %rax
movslq -0x10(%rbp), %rcx
movl %edx, 0x4(%rax,%rcx,4)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x1ed72
movq -0x30(%rbp), %rdi
callq 0x9110
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)