// File: /workspace/github_c_makefile_star2_O0/georgeweigt[P]eigenmath/eigenmath.c
// Function: set_component
void
set_component(struct atom *LVAL, struct atom *RVAL, int h)
{
	int i, k, m, n, t;

	if (!istensor(LVAL))
		stopf("index error");

	// n is the number of indices

	n = tos - h;

	if (n < 1 || n > LVAL->u.tensor->ndim)
		stopf("index error");

	// k is the combined index

	k = 0;

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

	tos = h; // pop all

	if (istensor(RVAL)) {
		m = RVAL->u.tensor->ndim;
		if (n + m != LVAL->u.tensor->ndim)
			stopf("index error");
		for (i = 0; i < m; i++)
			if (LVAL->u.tensor->dim[n + i] != RVAL->u.tensor->dim[i])
				stopf("index error");
		m = RVAL->u.tensor->nelem;
		for (i = 0; i < m; i++)
			LVAL->u.tensor->elem[m * k + i] = RVAL->u.tensor->elem[i];
	} else {
		if (n != LVAL->u.tensor->ndim)
			stopf("index error");
		LVAL->u.tensor->elem[k] = RVAL;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x7, %eax
je 0x3187c
leaq 0x182e0(%rip), %rdi     # 0x49b57
callq 0x78d0
movl 0x26a36(%rip), %eax     # 0x582b8
subl -0x14(%rbp), %eax
movl %eax, -0x24(%rbp)
cmpl $0x1, -0x24(%rbp)
jl 0x3189c
movl -0x24(%rbp), %eax
movq -0x8(%rbp), %rcx
movq (%rcx), %rcx
cmpl (%rcx), %eax
jle 0x318a8
leaq 0x182b4(%rip), %rdi     # 0x49b57
callq 0x78d0
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x3192c
movl -0x14(%rbp), %eax
addl -0x18(%rbp), %eax
movslq %eax, %rcx
leaq 0x2fcf2(%rip), %rax     # 0x615c0
movq (%rax,%rcx,8), %rdi
callq 0x9110
callq 0x13520
movl %eax, -0x28(%rbp)
cmpl $0x1, -0x28(%rbp)
jl 0x318f9
movl -0x28(%rbp), %eax
movq -0x8(%rbp), %rcx
movq (%rcx), %rcx
movslq -0x18(%rbp), %rdx
cmpl 0x4(%rcx,%rdx,4), %eax
jle 0x31905
leaq 0x18257(%rip), %rdi     # 0x49b57
callq 0x78d0
movl -0x1c(%rbp), %eax
movq -0x8(%rbp), %rcx
movq (%rcx), %rcx
movslq -0x18(%rbp), %rdx
imull 0x4(%rcx,%rdx,4), %eax
addl -0x28(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x1c(%rbp)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x318b6
movl -0x14(%rbp), %eax
movl %eax, 0x26983(%rip)     # 0x582b8
movq -0x10(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x7, %eax
jne 0x31a0e
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl (%rax), %eax
movl %eax, -0x20(%rbp)
movl -0x24(%rbp), %eax
addl -0x20(%rbp), %eax
movq -0x8(%rbp), %rcx
movq (%rcx), %rcx
cmpl (%rcx), %eax
je 0x3196f
leaq 0x181ed(%rip), %rdi     # 0x49b57
callq 0x78d0
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x319bc
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl -0x24(%rbp), %ecx
addl -0x18(%rbp), %ecx
movslq %ecx, %rcx
movl 0x4(%rax,%rcx,4), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
movslq -0x18(%rbp), %rdx
cmpl 0x4(%rcx,%rdx,4), %eax
je 0x319af
leaq 0x181ad(%rip), %rdi     # 0x49b57
callq 0x78d0
jmp 0x319b1
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x31976
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl 0x64(%rax), %eax
movl %eax, -0x20(%rbp)
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x31a0c
movq -0x10(%rbp), %rax
movq (%rax), %rax
movslq -0x18(%rbp), %rcx
movq 0x68(%rax,%rcx,8), %rdx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl -0x20(%rbp), %ecx
imull -0x1c(%rbp), %ecx
addl -0x18(%rbp), %ecx
movslq %ecx, %rcx
movq %rdx, 0x68(%rax,%rcx,8)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x319d0
jmp 0x31a3c
movl -0x24(%rbp), %eax
movq -0x8(%rbp), %rcx
movq (%rcx), %rcx
cmpl (%rcx), %eax
je 0x31a28
leaq 0x18134(%rip), %rdi     # 0x49b57
callq 0x78d0
movq -0x10(%rbp), %rdx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
movq %rdx, 0x68(%rax,%rcx,8)
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)