// File: /workspace/github_c_makefile_star2_O1/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 $0x28, %rsp
movl %edi, %r15d
movl %edi, %r14d
movl %edi, -0x2c(%rbp)
testl %edi, %edi
jle 0x6279
movq 0xdc87(%rip), %r12      # 0x13ec8
addq $0x20, %r12
leaq (,%r15,4), %rbx
xorl %r13d, %r13d
movl -0x2c(%rbp), %r14d
leaq 0xe335(%rip), %rax      # 0x14590
movslq (%r13,%rax), %rax
leaq (%rax,%rax,4), %rax
movq (%r12,%rax,8), %rdi
callq 0x20b0
addl %eax, %r14d
addq $0x4, %r13
cmpq %r13, %rbx
jne 0x6254
movl %r14d, %edi
callq 0x2bda
movq %rax, %r14
movb $0x0, (%rax)
cmpl $0x0, -0x2c(%rbp)
jle 0x62da
movq 0xdc34(%rip), %r12      # 0x13ec8
addq $0x20, %r12
leaq (,%r15,4), %r13
xorl %ebx, %ebx
testq %rbx, %rbx
je 0x62b6
movq %r14, %rdi
callq 0x20b0
movw $0x2a, (%r14,%rax)
leaq 0xe2d3(%rip), %rax      # 0x14590
movslq (%rbx,%rax), %rax
leaq (%rax,%rax,4), %rax
movq (%r12,%rax,8), %rsi
movq %r14, %rdi
callq 0x21e0
addq $0x4, %rbx
cmpq %rbx, %r13
jne 0x62a2
movq 0xdbe7(%rip), %rax      # 0x13ec8
movq %rax, -0x40(%rbp)
movslq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
testq %rax, %rax
setg %bl
jle 0x6352
movq -0x40(%rbp), %r12
movq 0x20(%r12), %rsi
movq %r14, %rdi
callq 0x2160
testl %eax, %eax
je 0x633e
leaq 0x48(%r12), %rbx
movq -0x38(%rbp), %rax
leaq -0x1(%rax), %r12
xorl %r13d, %r13d
cmpq %r13, %r12
je 0x6352
movq (%rbx), %rsi
movq %r14, %rdi
callq 0x2160
addq $0x28, %rbx
incq %r13
testl %eax, %eax
jne 0x631a
cmpq -0x38(%rbp), %r13
setb %bl
jmp 0x6341
xorl %r13d, %r13d
testb %bl, %bl
je 0x6352
movq %r14, %rdi
callq 0x2040
jmp 0x6494
movq -0x38(%rbp), %r13
cmpl $0x64, %r13d
je 0x64e1
leal 0x1(%r13), %eax
movq -0x40(%rbp), %rcx
movl %eax, 0x10(%rcx)
leaq (,%r13,4), %rax
addq %r13, %rax
movq %rax, -0x48(%rbp)
movq %r14, 0x20(%rcx,%rax,8)
movl -0x2c(%rbp), %r12d
testl %r12d, %r12d
jle 0x63c3
movq 0xdb39(%rip), %rax      # 0x13ec8
addq $0x20, %rax
leaq (,%r15,4), %rcx
movl $0x1, %r14d
xorl %edx, %edx
leaq 0xe1e6(%rip), %rsi      # 0x14590
movslq (%rdx,%rsi), %rdi
leaq (%rdi,%rdi,4), %rdi
imull 0xc(%rax,%rdi,8), %r14d
addq $0x4, %rdx
cmpq %rdx, %rcx
jne 0x63aa
jmp 0x63c9
movl $0x1, %r14d
leal (,%r14,8), %edi
callq 0x2bda
movq 0xdaeb(%rip), %rcx      # 0x13ec8
movq %r13, %rdx
shlq $0x3, %rdx
leaq (%rdx,%rdx,4), %rbx
movq %rax, 0x30(%rcx,%rbx)
movq 0xdad4(%rip), %rax      # 0x13ec8
movl %r14d, 0x28(%rax,%rbx)
movl %r14d, 0x2c(%rax,%rbx)
movl 0x18(%rax), %edi
shll $0x3, %edi
callq 0x2bda
movq 0xdab8(%rip), %rcx      # 0x13ec8
movq %rax, 0x40(%rcx,%rbx)
movl %r12d, %edi
callq 0x651d
movq 0xdaa4(%rip), %rax      # 0x13ec8
movslq 0x14(%rax), %rcx
testq %rcx, %rcx
jle 0x6494
movq -0x48(%rbp), %rdx
movq 0x40(%rax,%rdx,8), %rdx
addq $0x20, %rax
shlq $0x2, %r15
xorl %esi, %esi
leaq 0xe149(%rip), %rdi      # 0x14590
testl %r12d, %r12d
jle 0x6483
xorpd %xmm1, %xmm1
xorl %r8d, %r8d
movslq (%r8,%rdi), %r9
leaq (%r9,%r9,4), %r9
xorps %xmm0, %xmm0
cvtsi2sdl 0xc(%rax,%r9,8), %xmm0
mulsd %xmm1, %xmm0
movq 0x20(%rax,%r9,8), %r9
addsd (%r9,%rsi,8), %xmm0
addq $0x4, %r8
movapd %xmm0, %xmm1
cmpq %r8, %r15
jne 0x6453
jmp 0x6487
xorpd %xmm0, %xmm0
movsd %xmm0, (%rdx,%rsi,8)
incq %rsi
cmpq %rcx, %rsi
jne 0x6447
movslq 0xdf4d(%rip), %rax      # 0x143e8
leaq 0xe27e(%rip), %rcx      # 0x14720
testq %rax, %rax
jle 0x64c0
leaq (,%rax,4), %rdx
xorl %esi, %esi
cmpl %r13d, (%rsi,%rcx)
je 0x64d2
addq $0x4, %rsi
cmpq %rsi, %rdx
jne 0x64b1
cmpl $0x64, %eax
je 0x64ef
leal 0x1(%rax), %edx
movl %edx, 0xdf1a(%rip)      # 0x143e8
movl %r13d, (%rcx,%rax,4)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0xa74a
leaq 0x5314(%rip), %rdi      # 0xb801
jmp 0x64fb
callq 0xa74a
leaq 0x526d(%rip), %rdi      # 0xb768
callq 0x4081
leaq 0xf6d9(%rip), %rdi      # 0x15be0
movl $0x1, %esi
callq 0x21b0