// File: /workspace/github_c_makefile_star2_O3/georgeweigt[P]sassafras/sassafras.c
// Function: proc_anova_print_ttest
void
proc_anova_print_ttest(int x)
{
	int dfe, i, j, k, n, ncol, nrow;
	char **a, *s;
	double d, mse, pval, se, sse, t, tval;

	emit_line_center("Two Sample t-Test");
	emit_line("");

	n = dataset->spec[x].num_levels;

	nrow = 1 + n * (n - 1);

	ncol = 7;

	a = (char **) xmalloc(nrow * ncol * sizeof (char *));

	s = dataset->spec[x].name;
	A(0, 0) = strdup(s);
	A(0, 1) = strdup(s);

	s = dataset->spec[yvar].name;
	snprintf(bigbuf, BIGBUFLEN, "Delta %s", s);
	A(0, 2) = strdup(bigbuf);

	snprintf(bigbuf, BIGBUFLEN, "%g%% CI MIN", 100 * (1 - alpha));
	A(0, 3) = strdup(bigbuf);

	snprintf(bigbuf, BIGBUFLEN, "%g%% CI MAX", 100 * (1 - alpha));
	A(0, 4) = strdup(bigbuf);

	A(0, 5) = strdup("t Value");
	A(0, 6) = strdup("Pr > |t|  ");

	k = 0;

	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {

			if (i == j)
				continue;

			k++;

			// Level

			s = dataset->spec[x].ltab[i];
			A(k, 0) = strdup(s);

			// Level

			s = dataset->spec[x].ltab[j];
			A(k, 1) = strdup(s);

			// Sanity check

			if (count[i] == 0 || count[j] == 0) {
				A(k, 2) = strdup(".");
				A(k, 3) = strdup(".");
				A(k, 4) = strdup(".");
				A(k, 5) = strdup(".");
				A(k, 6) = strdup(".  ");
				continue;
			}

			// Difference

			d = mean[i] - mean[j];
			snprintf(bigbuf, BIGBUFLEN, "%0.6f", d);
			A(k, 2) = strdup(bigbuf);

			// confidence interval

			if (count[i] + count[j] < 3) {
				A(k, 3) = strdup(".");
				A(k, 4) = strdup(".");
				A(k, 5) = strdup(".");
				A(k, 6) = strdup(".  ");
				continue;
			}

			sse = variance[i] * (count[i] - 1) + variance[j] * (count[j] - 1);

			dfe = count[i] + count[j] - 2;

			mse = sse / dfe;

			se = sqrt(mse * (1.0 / count[i] + 1.0 / count[j]));

			tval = d / se;

			pval = 2 * (1 - tdist(fabs(tval), dfe));

			t = qt(1 - alpha / 2, dfe) * se;

			snprintf(bigbuf, BIGBUFLEN, "%0.6f", d - t);
			A(k, 3) = strdup(bigbuf);

			snprintf(bigbuf, BIGBUFLEN, "%0.6f", d + t);
			A(k, 4) = strdup(bigbuf);

			snprintf(bigbuf, BIGBUFLEN, "%0.2f", tval);
			A(k, 5) = strdup(bigbuf);

			if (pval > alpha)
				snprintf(bigbuf, BIGBUFLEN, "%0.4f  ", pval);
			else
				snprintf(bigbuf, BIGBUFLEN, "%0.4f *", pval);
			A(k, 6) = strdup(bigbuf);
		}
	}

	bigbuf[0] = 1; // left justify
	bigbuf[1] = 1;
	bigbuf[2] = 0;
	bigbuf[3] = 0;
	bigbuf[4] = 0;
	bigbuf[5] = 0;
	bigbuf[6] = 0;

	print_table_and_free(a, nrow, ncol, bigbuf);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %edi, %ebx
leaq 0x5ece(%rip), %rdi      # 0xb92f
callq 0x4043
movl $0xa, %edi
callq 0x2050
movq 0xe461(%rip), %rax      # 0x13ed8
movslq %ebx, %r12
leaq (,%r12,8), %rcx
leaq (%rcx,%rcx,4), %rbx
movslq 0x2c(%rax,%rbx), %r13
leal -0x1(%r13), %eax
imull %r13d, %eax
incl %eax
movl %eax, -0x4c(%rbp)
imull $0x38, %eax, %edi
callq 0x2bd8
movq %rax, %r14
movq 0xe42e(%rip), %r15      # 0x13ed8
movq 0x20(%r15,%rbx), %rbx
movq %rbx, %rdi
callq 0x2220
movq %rax, (%r14)
movq %rbx, %rdi
callq 0x2220
movq %rax, 0x8(%r14)
movslq 0xeac3(%rip), %rax      # 0x14590
leaq (%rax,%rax,4), %rax
movq 0x20(%r15,%rax,8), %rcx
leaq 0xd3f3(%rip), %r15      # 0x12ed0
leaq 0x5e1b(%rip), %rdx      # 0xb8ff
movl $0xfa0, %esi            # imm = 0xFA0
movq %r15, %rdi
xorl %eax, %eax
callq 0x20e0
movq %r15, %rdi
callq 0x2220
movq %rax, 0x10(%r14)
movsd 0x57c1(%rip), %xmm0     # 0xb2c8
subsd 0xe3d9(%rip), %xmm0     # 0x13ee8
mulsd 0x57f1(%rip), %xmm0     # 0xb308
leaq 0x5da7(%rip), %rdx      # 0xb8c5
movl $0xfa0, %esi            # imm = 0xFA0
movq %r15, %rdi
movb $0x1, %al
callq 0x20e0
movq %r15, %rdi
callq 0x2220
movq %rax, 0x18(%r14)
movsd 0x5787(%rip), %xmm0     # 0xb2c8
subsd 0xe39f(%rip), %xmm0     # 0x13ee8
mulsd 0x57b7(%rip), %xmm0     # 0xb308
leaq 0x5d79(%rip), %rdx      # 0xb8d1
movl $0xfa0, %esi            # imm = 0xFA0
movq %r15, %rdi
movb $0x1, %al
callq 0x20e0
movq %r15, %rdi
callq 0x2220
movq %rax, 0x20(%r14)
leaq 0x5d8e(%rip), %rdi      # 0xb908
callq 0x2220
movq %rax, 0x28(%r14)
leaq 0x5d86(%rip), %rdi      # 0xb910
callq 0x2220
xorl %ecx, %ecx
movq %rax, 0x30(%r14)
movq %r13, -0x58(%rbp)
testq %r13, %r13
jle 0x5f31
movq -0x58(%rbp), %rax
leaq (,%rax,8), %rax
leaq (%r12,%r12,4), %rdx
movq %rdx, -0x78(%rbp)
xorl %esi, %esi
xorl %edx, %edx
movq %rax, -0x80(%rbp)
movq %r14, -0x70(%rbp)
movq %rdx, -0x48(%rbp)
leaq 0xfa43(%rip), %r12      # 0x15610
xorl %r13d, %r13d
movl %ecx, %ebx
movq %rsi, -0x88(%rbp)
cmpq %r13, %rsi
jne 0x5be5
movl %ebx, %ecx
jmp 0x5f0b
leal 0x1(%rbx), %r14d
movq 0xe2e8(%rip), %rax      # 0x13ed8
movq -0x78(%rbp), %rcx
movq 0x30(%rax,%rcx,8), %r15
movq %r12, -0x38(%rbp)
movq -0x48(%rbp), %r12
movq (%r15,%r12,8), %rdi
callq 0x2220
leal 0x8(,%rbx,8), %ecx
movq %r14, -0x90(%rbp)
subl %r14d, %ecx
movq -0x70(%rbp), %r14
movslq %ecx, %rbx
movq %rax, (%r14,%rbx,8)
movq (%r15,%r13), %rdi
callq 0x2220
movq %rax, 0x8(%r14,%rbx,8)
leaq 0xf9d5(%rip), %rax      # 0x15610
cmpl $0x0, (%rax,%r12,4)
movq -0x38(%rbp), %r12
je 0x5cf3
cmpl $0x0, (%r12)
je 0x5cf3
leaq 0xf374(%rip), %rax      # 0x14fd0
movq -0x48(%rbp), %r12
movsd (%rax,%r12,8), %xmm0
subsd (%r13,%rax), %xmm0
movl $0xfa0, %esi            # imm = 0xFA0
leaq 0xd257(%rip), %r15      # 0x12ed0
movq %r15, %rdi
leaq 0x56e9(%rip), %rdx      # 0xb36c
movsd %xmm0, -0x40(%rbp)
movb $0x1, %al
callq 0x20e0
movq %r15, %rdi
callq 0x2220
movq %rax, 0x10(%r14,%rbx,8)
leaq 0xf96d(%rip), %rax      # 0x15610
movl (%rax,%r12,4), %ecx
movq -0x38(%rbp), %rax
movl (%rax), %eax
leal (%rax,%rcx), %edx
cmpl $0x2, %edx
jg 0x5d3f
leaq 0x5bdd(%rip), %r15      # 0xb89d
movq %r15, %rdi
callq 0x2220
movq %rax, 0x18(%r14,%rbx,8)
movq %r15, %rdi
callq 0x2220
movq %rax, 0x20(%r14,%rbx,8)
movq %r15, %rdi
callq 0x2220
movq %rax, 0x28(%r14,%rbx,8)
leaq 0x5c2d(%rip), %rdi      # 0xb91b
jmp 0x5ee9
leaq 0x5ba3(%rip), %r15      # 0xb89d
movq %r15, %rdi
callq 0x2220
movq %rax, 0x10(%r14,%rbx,8)
movq %r15, %rdi
callq 0x2220
movq %rax, 0x18(%r14,%rbx,8)
movq %r15, %rdi
callq 0x2220
movq %rax, 0x20(%r14,%rbx,8)
movq %r15, %rdi
callq 0x2220
movq %rax, 0x28(%r14,%rbx,8)
leaq 0x5be6(%rip), %rdi      # 0xb91b
callq 0x2220
jmp 0x5ef2
leal -0x1(%rcx), %esi
cvtsi2sd %esi, %xmm1
leal -0x1(%rax), %esi
xorps %xmm0, %xmm0
cvtsi2sd %esi, %xmm0
leaq 0xf599(%rip), %rsi      # 0x152f0
mulsd (%r13,%rsi), %xmm0
mulsd (%rsi,%r12,8), %xmm1
addsd %xmm0, %xmm1
addl $-0x2, %edx
xorps %xmm0, %xmm0
cvtsi2sd %edx, %xmm0
movsd %xmm0, -0x30(%rbp)
divsd %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
movsd 0x553e(%rip), %xmm4     # 0xb2c8
movapd %xmm4, %xmm2
divsd %xmm0, %xmm2
cvtsi2sd %eax, %xmm3
movapd %xmm4, %xmm0
divsd %xmm3, %xmm0
addsd %xmm2, %xmm0
mulsd %xmm1, %xmm0
ucomisd 0x5562(%rip), %xmm0     # 0xb310
jb 0x5db9
xorps %xmm1, %xmm1
sqrtsd %xmm0, %xmm1
jmp 0x5dc2
callq 0x2210
movapd %xmm0, %xmm1
movsd %xmm1, -0x60(%rbp)
movsd -0x40(%rbp), %xmm0
divsd %xmm1, %xmm0
movapd %xmm0, -0xa0(%rbp)
andpd 0x54c0(%rip), %xmm0     # 0xb2a0
movsd -0x30(%rbp), %xmm1
callq 0x7c2b
movsd 0x54d6(%rip), %xmm1     # 0xb2c8
movapd %xmm1, %xmm2
subsd %xmm0, %xmm2
addsd %xmm2, %xmm2
movsd %xmm2, -0x68(%rbp)
movsd 0xe0dd(%rip), %xmm0     # 0x13ee8
mulsd 0x54ed(%rip), %xmm0     # 0xb300
addsd %xmm1, %xmm0
movsd -0x30(%rbp), %xmm1
callq 0x7aad
movapd %xmm0, %xmm1
mulsd -0x60(%rbp), %xmm1
movsd %xmm1, -0x30(%rbp)
movsd -0x40(%rbp), %xmm0
subsd %xmm1, %xmm0
movl $0xfa0, %esi            # imm = 0xFA0
leaq 0xd08c(%rip), %r15      # 0x12ed0
movq %r15, %rdi
leaq 0x551e(%rip), %r12      # 0xb36c
movq %r12, %rdx
movb $0x1, %al
callq 0x20e0
movq %r15, %rdi
callq 0x2220
movq %rax, 0x18(%r14,%rbx,8)
movsd -0x30(%rbp), %xmm0
addsd -0x40(%rbp), %xmm0
movl $0xfa0, %esi            # imm = 0xFA0
movq %r15, %rdi
movq %r12, %rdx
movb $0x1, %al
callq 0x20e0
movq %r15, %rdi
callq 0x2220
movq %rax, 0x20(%r14,%rbx,8)
movl $0xfa0, %esi            # imm = 0xFA0
movq %r15, %rdi
leaq 0x54b7(%rip), %rdx      # 0xb354
movaps -0xa0(%rbp), %xmm0
movb $0x1, %al
callq 0x20e0
movq %r15, %rdi
callq 0x2220
movq %rax, 0x28(%r14,%rbx,8)
movsd -0x68(%rbp), %xmm0
ucomisd 0xe023(%rip), %xmm0     # 0x13ee8
leaq 0x5a5b(%rip), %rdx      # 0xb927
leaq 0x5a4c(%rip), %rax      # 0xb91f
cmovaq %rax, %rdx
movl $0xfa0, %esi            # imm = 0xFA0
movq %r15, %rdi
movb $0x1, %al
callq 0x20e0
movq %r15, %rdi
callq 0x2220
movq -0x38(%rbp), %r12
movq %rax, 0x30(%r14,%rbx,8)
movq -0x90(%rbp), %rcx
movl %ecx, %ebx
movq -0x80(%rbp), %rax
movq -0x88(%rbp), %rsi
addq $0x8, %r13
addq $0x4, %r12
cmpq %r13, %rax
jne 0x5bd9
movq -0x48(%rbp), %rdx
incq %rdx
addq $0x8, %rsi
cmpq -0x58(%rbp), %rdx
jne 0x5bc2
movw $0x101, 0xcf96(%rip)    # imm = 0x101
leaq 0xcf8f(%rip), %rcx      # 0x12ed0
movl $0x0, 0xcf87(%rip)      # 0x12ed2
movb $0x0, 0xcf84(%rip)      # 0x12ed6
movq %r14, %rdi
movl -0x4c(%rbp), %esi
movl $0x7, %edx
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x470d