// File: /workspace/github_c_makefile_star2_O2/georgeweigt[P]sassafras/sassafras.c
// Function: proc_anova_add_interaction
void
proc_anova_add_interaction(int n)
{
	int i, j, k, len, m, x;
	char *name, *s;
	double d;

	len = n; // accommodate n - 1 asterisks and 1 end of line

	for (i = 0; i < n; i++) {
		x = xx[i];
		s = dataset->spec[x].name;
		len += strlen(s);
	}

	name = (char *) xmalloc(len);

	name[0] = 0;

	for (i = 0; i < n; i++) {
		if (i > 0)
			strcat(name, "*");
		x = xx[i];
		s = dataset->spec[x].name;
		strcat(name, s);
	}

	// is it already in the data set?

	for (m = 0; m < dataset->nvar; m++)
		if (strcmp(name, dataset->spec[m].name) == 0)
			break;

	if (m < dataset->nvar)
		free(name);
	else {
		if (dataset->nvar == MAXVAR)
			stop("Too many variable names");

		m = dataset->nvar++;

		dataset->spec[m].name = name;

		// number of levels

		k = 1;
		for (i = 0; i < n; i++) {
			x = xx[i];
			k *= dataset->spec[x].num_levels;
		}

		dataset->spec[m].ltab = (char **) xmalloc(k * sizeof (char *));
		dataset->spec[m].max_levels = k;
		dataset->spec[m].num_levels = k;
		dataset->spec[m].v = (double *) xmalloc(dataset->max * sizeof (double));

		proc_anova_create_interaction_level_names(n);

		// data values

		for (i = 0; i < dataset->nobs; i++) {
			d = 0;
			for (j = 0; j < n; j++) {
				x = xx[j];
				d = d * dataset->spec[x].num_levels + dataset->spec[x].v[i];
			}
			dataset->spec[m].v[i] = d;
		}
	}

	// is it already an explanatory variable?

	for (i = 0; i < nx; i++)
		if (xtab[i] == m)
			return;

	if (nx == MAXVAR)
		stop("Too many explanatory variables");

	xtab[nx++] = m;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %edi, %r14d
movq 0xe14e(%rip), %rbx      # 0x13ec8
addq $0x20, %rbx
xorl %r13d, %r13d
testl %edi, %edi
movl $0x0, %r15d
cmovgl %edi, %r15d
shlq $0x2, %r15
leaq 0xe7f8(%rip), %r12      # 0x14590
movl %edi, -0x2c(%rbp)
cmpq %r13, %r15
je 0x5dbb
movslq (%r13,%r12), %rax
imulq $0x28, %rax, %rax
movq (%rbx,%rax), %rdi
callq 0x20b0
addl %eax, %r14d
addq $0x4, %r13
jmp 0x5d9b
movl %r14d, %edi
callq 0x2a9b
movq %rax, %r14
movb $0x0, (%rax)
movq 0xe0f8(%rip), %rax      # 0x13ec8
movq %rax, -0x38(%rbp)
leaq 0x20(%rax), %r13
xorl %ebx, %ebx
cmpq %rbx, %r15
je 0x5e0e
testq %rbx, %rbx
je 0x5df3
movq %r14, %rdi
callq 0x20b0
movw $0x2a, (%r14,%rax)
movslq (%rbx,%r12), %rax
imulq $0x28, %rax, %rax
movq (%r13,%rax), %rsi
movq %r14, %rdi
callq 0x21e0
addq $0x4, %rbx
jmp 0x5dda
movq -0x38(%rbp), %rax
movl 0x10(%rax), %eax
movslq %eax, %rcx
movq %r13, %rbx
xorl %r13d, %r13d
movq %rcx, -0x40(%rbp)
testl %ecx, %ecx
movl $0x0, %ecx
movq %rax, -0x50(%rbp)
cmovgl %eax, %ecx
movq %rcx, -0x58(%rbp)
movq %rbx, -0x48(%rbp)
cmpq %r13, -0x58(%rbp)
je 0x5e5a
movq (%rbx), %rsi
movq %r14, %rdi
callq 0x2160
testl %eax, %eax
je 0x5f51
incq %r13
addq $0x28, %rbx
jmp 0x5e38
movq -0x50(%rbp), %r13
cmpl $0x64, %r13d
je 0x5fac
leal 0x1(%r13), %eax
movq -0x38(%rbp), %rcx
movl %eax, 0x10(%rcx)
imulq $0x28, -0x40(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %r14, (%rax,%rcx)
movq %rcx, %r14
movq 0xe03e(%rip), %rax      # 0x13ec8
addq $0x20, %rax
pushq $0x1
popq %rbx
xorl %ecx, %ecx
cmpq %rcx, %r15
je 0x5eab
movslq (%rcx,%r12), %rdx
imulq $0x28, %rdx, %rdx
imull 0xc(%rax,%rdx), %ebx
addq $0x4, %rcx
jmp 0x5e93
leal (,%rbx,8), %edi
callq 0x2a9b
movq 0xe00a(%rip), %rcx      # 0x13ec8
movq %rax, 0x30(%rcx,%r14)
movq 0xdffe(%rip), %rax      # 0x13ec8
movl %ebx, 0x28(%rax,%r14)
movl %ebx, 0x2c(%rax,%r14)
movl 0x18(%rax), %edi
shll $0x3, %edi
callq 0x2a9b
movq 0xdfe2(%rip), %rcx      # 0x13ec8
movq %rax, 0x40(%rcx,%r14)
movl -0x2c(%rbp), %edi
callq 0x5fd0
movq 0xdfce(%rip), %rax      # 0x13ec8
movl 0x14(%rax), %ecx
leaq (%rax,%r14), %rdx
addq $0x40, %rdx
addq $0x20, %rax
xorl %esi, %esi
testl %ecx, %ecx
cmovlel %esi, %ecx
cmpq %rcx, %rsi
je 0x5f59
xorpd %xmm0, %xmm0
xorl %edi, %edi
cmpq %rdi, %r15
je 0x5f44
movslq (%rdi,%r12), %r8
imulq $0x28, %r8, %r8
cvtsi2sdl 0xc(%rax,%r8), %xmm1
movq 0x20(%rax,%r8), %r8
mulsd %xmm1, %xmm0
addsd (%r8,%rsi,8), %xmm0
addq $0x4, %rdi
jmp 0x5f1b
movq (%rdx), %rdi
movsd %xmm0, (%rdi,%rsi,8)
incq %rsi
jmp 0x5f10
movq %r14, %rdi
callq 0x2040
movslq 0xe488(%rip), %rax      # 0x143e8
xorl %edx, %edx
testl %eax, %eax
movl $0x0, %esi
cmovgl %eax, %esi
shlq $0x2, %rsi
leaq 0xe7a9(%rip), %rcx      # 0x14720
cmpq %rdx, %rsi
je 0x5f8b
leaq 0x4(%rdx), %rdi
cmpl %r13d, (%rdx,%rcx)
movq %rdi, %rdx
jne 0x5f77
jmp 0x5f9d
cmpl $0x64, %eax
je 0x5fb8
leal 0x1(%rax), %edx
movl %edx, 0xe44f(%rip)      # 0x143e8
movl %r13d, (%rcx,%rax,4)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x581e(%rip), %rdi      # 0xb7d1
callq 0x267a
leaq 0x5779(%rip), %rdi      # 0xb738
callq 0x267a