// File: /workspace/github_c_makefile_star2_O1/georgeweigt[P]sassafras/sassafras.c
// Function: h
void
h(int varnum)
{
	int i, j, k, w;
	double m, t1, t2, x;
	char buf[100];

	int n = 0;

	double mean = NAN;
	double variance = NAN;

	double min = NAN;
	double max = NAN;
	double sum = NAN;

	double stddev = NAN;
	double stderror = NAN;

	double range = NAN;

	for (i = 0; i < dataset->nobs; i++) {

		// filter

		for (j = 0; j < nclass; j++) {
			k = class[j];
			if (dataset->spec[k].v[i] != filtertab[j])
				break;
		}

		if (j < nclass)
			continue;

		// if categorical variable then only N makes sense

		if (dataset->spec[varnum].ltab) {
			if (dataset->spec[varnum].v[i])
				n++;
			continue;
		}

		x = dataset->spec[varnum].v[i];

		if (isnan(x))
			continue;

		n++;

		if (n == 1) {
			mean = x;
			variance = 0.0;
			min = x;
			max = x;
			sum = 0.0;
			stddev = 0.0;
			stderror = 0.0;
		}

		m = mean;

		mean += (x - m) / n;

		variance += (x - m) * (x - mean);

		if (x < min)
			min = x;

		if (x > max)
			max = x;

		sum += x;
	}

	range = max - min;

	if (n > 1) {
		variance /= (n - 1);
		stddev = sqrt(variance);
		stderror = stddev / sqrt(n);
	}

	t1 = qt(1 - alpha, n - 1.0);
	t2 = qt(1 - alpha / 2, n - 1.0);

	for (i = 0; i < nstats; i++) {
		w = maxdec;
		switch (stats[i]) {
		case KCLM1:
			x = mean - t2 * stderror;
			break;
		case KCLM2:
			x = mean + t2 * stderror;
			break;
		case KLCLM:
			x = mean - t1 * stderror;
			break;
		case KMAX:
			x = max;
			break;
		case KMEAN:
			x = mean;
			break;
		case KMIN:
			x = min;
			break;
		case KN:
			x = n;
			w = 0;
			break;
		case KRANGE:
			x = range;
			break;
		case KSUM:
			x = sum;
			break;
		case KSTD:
		case KSTDDEV:
			x = stddev;
			break;
		case KSTDERR:
		case KSTDMEAN:
			x = stderror;
			break;
		case KUCLM:
			x = mean + t1 * stderror;
			break;
		case KVAR:
			x = variance;
			break;
		default:
			x = NAN;
			break;
		}
		if (isnan(x))
			A(row, nclass + 1 + i) = strdup(".");
		else {
			snprintf(buf, sizeof buf, fmt[w], x);
			A(row, nclass + 1 + i) = strdup(buf);
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq 0xba57(%rip), %r9       # 0x13ec8
movslq 0x14(%r9), %rax
testq %rax, %rax
jle 0x8627
movslq 0xbd9b(%rip), %rcx      # 0x14220
testq %rcx, %rcx
setg %dl
leaq 0x20(%r9), %rsi
movslq %edi, %rdi
leaq (%rdi,%rdi,4), %rdi
leaq 0x20(%r9,%rdi,8), %rdi
movl %ecx, %r8d
movslq 0xbbeb(%rip), %r10      # 0x14090
leaq (%r10,%r10,4), %r10
leaq (%r9,%r10,8), %r9
addq $0x40, %r9
cvtsi2sdl 0xd3b7(%rip), %xmm7 # 0x15870
decq %r8
xorl %r10d, %r10d
movsd 0x2e29(%rip), %xmm2     # 0xb2f0
leaq 0xbbc2(%rip), %r11      # 0x14090
leaq 0xd39b(%rip), %r14      # 0x15870
xorpd %xmm1, %xmm1
movsd %xmm2, -0x30(%rbp)
movsd %xmm2, -0x58(%rbp)
movsd %xmm2, -0x40(%rbp)
movsd %xmm2, -0x38(%rbp)
movapd %xmm2, %xmm0
movsd %xmm2, -0x50(%rbp)
movsd %xmm2, -0x48(%rbp)
xorl %ebx, %ebx
testl %ecx, %ecx
jle 0x8556
movq (%r9), %r15
movsd (%r15,%r10,8), %xmm2
ucomisd %xmm7, %xmm2
movl %edx, %r15d
jne 0x854d
jp 0x854d
xorl %r15d, %r15d
cmpq %r15, %r8
je 0x8556
movslq 0x4(%r11,%r15,4), %r12
leaq (%r12,%r12,4), %r12
movq 0x20(%rsi,%r12,8), %r12
xorps %xmm2, %xmm2
cvtsi2sdl 0x4(%r14,%r15,4), %xmm2
movsd (%r12,%r10,8), %xmm3
incq %r15
ucomisd %xmm2, %xmm3
jne 0x8546
jnp 0x8518
cmpq %rcx, %r15
setl %r15b
testb %r15b, %r15b
jne 0x8619
cmpq $0x0, 0x10(%rdi)
je 0x857a
movq 0x20(%rdi), %r15
movsd (%r15,%r10,8), %xmm2
ucomisd %xmm1, %xmm2
jne 0x8573
jnp 0x8619
incl %ebx
jmp 0x8619
movq 0x20(%rdi), %r15
movsd (%r15,%r10,8), %xmm2
ucomisd %xmm2, %xmm2
jp 0x8619
testl %ebx, %ebx
jne 0x85b8
xorpd %xmm0, %xmm0
movsd %xmm2, -0x48(%rbp)
movsd %xmm2, -0x38(%rbp)
movsd %xmm2, -0x40(%rbp)
xorpd %xmm3, %xmm3
movsd %xmm3, -0x58(%rbp)
movsd %xmm3, -0x30(%rbp)
movsd %xmm3, -0x50(%rbp)
incl %ebx
movapd %xmm2, %xmm3
movsd -0x48(%rbp), %xmm6
subsd %xmm6, %xmm3
xorps %xmm4, %xmm4
cvtsi2sd %ebx, %xmm4
movapd %xmm3, %xmm5
divsd %xmm4, %xmm5
addsd %xmm5, %xmm6
movapd %xmm2, %xmm4
movsd %xmm6, -0x48(%rbp)
subsd %xmm6, %xmm4
mulsd %xmm3, %xmm4
addsd %xmm4, %xmm0
movapd %xmm2, %xmm3
minsd -0x38(%rbp), %xmm3
movapd %xmm2, %xmm4
maxsd -0x40(%rbp), %xmm4
movsd -0x58(%rbp), %xmm5
addsd %xmm2, %xmm5
movsd %xmm5, -0x58(%rbp)
movsd %xmm3, -0x38(%rbp)
movsd %xmm4, -0x40(%rbp)
incq %r10
cmpq %rax, %r10
jne 0x84fd
jmp 0x8653
xorl %ebx, %ebx
movsd 0x2cbf(%rip), %xmm1     # 0xb2f0
movapd %xmm1, %xmm0
movsd %xmm1, -0x38(%rbp)
movsd %xmm1, -0x40(%rbp)
movsd %xmm1, -0x58(%rbp)
movsd %xmm1, -0x30(%rbp)
movsd %xmm1, -0x48(%rbp)
movsd %xmm1, -0x50(%rbp)
xorps %xmm1, %xmm1
cvtsi2sd %ebx, %xmm1
movsd %xmm1, -0x78(%rbp)
cmpl $0x2, %ebx
jl 0x8687
leal -0x1(%rbx), %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
movsd %xmm0, -0x70(%rbp)
jb 0x868e
sqrtsd %xmm0, %xmm0
jmp 0x8697
movsd %xmm0, -0x70(%rbp)
jmp 0x86c2
callq 0x2200
xorpd %xmm1, %xmm1
movsd %xmm0, -0x30(%rbp)
xorps %xmm0, %xmm0
cvtsi2sd %ebx, %xmm0
ucomisd %xmm1, %xmm0
jb 0x86af
sqrtsd %xmm0, %xmm0
jmp 0x86b4
callq 0x2200
movsd -0x30(%rbp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, -0x50(%rbp)
movsd 0x2c2e(%rip), %xmm0     # 0xb2f8
subsd 0xb806(%rip), %xmm0     # 0x13ed8
movsd 0x2c2e(%rip), %xmm1     # 0xb308
addsd -0x78(%rbp), %xmm1
movsd %xmm1, -0x60(%rbp)
callq 0x7a76
movsd %xmm0, -0x68(%rbp)
movsd 0xb7e2(%rip), %xmm0     # 0x13ed8
mulsd 0x2c32(%rip), %xmm0     # 0xb330
addsd 0x2bf2(%rip), %xmm0     # 0xb2f8
movsd -0x60(%rbp), %xmm1
callq 0x7a76
cmpl $0x0, 0xd079(%rip)      # 0x15790
movsd -0x70(%rbp), %xmm1
jle 0x889b
movsd -0x40(%rbp), %xmm2
subsd -0x38(%rbp), %xmm2
movsd %xmm2, -0x90(%rbp)
movsd -0x50(%rbp), %xmm2
movsd -0x68(%rbp), %xmm3
mulsd %xmm2, %xmm3
movsd -0x48(%rbp), %xmm4
movapd %xmm4, %xmm5
subsd %xmm3, %xmm5
movsd %xmm5, -0x88(%rbp)
addsd %xmm4, %xmm3
movsd %xmm3, -0x68(%rbp)
mulsd %xmm2, %xmm0
movapd %xmm4, %xmm2
subsd %xmm0, %xmm2
movsd %xmm2, -0x80(%rbp)
addsd %xmm4, %xmm0
movsd %xmm0, -0x60(%rbp)
leaq 0xd01f(%rip), %r15      # 0x157a0
xorl %r12d, %r12d
leaq 0x69a5(%rip), %rbx      # 0xf130
leaq -0x100(%rbp), %r14
leaq 0x2a17(%rip), %r13      # 0xb1b0
movl 0xb741(%rip), %eax      # 0x13ee0
movl (%r15), %ecx
movl $0xfffffecd, %edx       # imm = 0xFFFFFECD
addl %edx, %ecx
cmpl $0x24, %ecx
ja 0x87e5
movslq (%r13,%rcx,4), %rcx
addq %r13, %rcx
jmpq *%rcx
movsd -0x30(%rbp), %xmm0
jmp 0x8822
movsd -0x50(%rbp), %xmm0
jmp 0x8822
movsd -0x68(%rbp), %xmm0
jmp 0x8822
movsd -0x58(%rbp), %xmm0
jmp 0x8822
movsd -0x88(%rbp), %xmm0
jmp 0x8822
movsd -0x38(%rbp), %xmm0
jmp 0x8822
movsd 0x2b03(%rip), %xmm0     # 0xb2f0
jmp 0x8822
movsd -0x80(%rbp), %xmm0
jmp 0x8822
movsd -0x60(%rbp), %xmm0
jmp 0x8822
xorl %eax, %eax
movsd -0x78(%rbp), %xmm0
jmp 0x8822
movsd -0x90(%rbp), %xmm0
jmp 0x8822
movapd %xmm1, %xmm0
jmp 0x8822
movsd -0x40(%rbp), %xmm0
jmp 0x8822
movsd -0x48(%rbp), %xmm0
ucomisd %xmm0, %xmm0
jp 0x8892
cltq
movq (%rbx,%rax,8), %rdx
movl $0x64, %esi
movq %r14, %rdi
movb $0x1, %al
callq 0x20e0
movq %r14, %rdi
callq 0x2210
movslq 0xcf94(%rip), %rcx      # 0x157e0
movslq 0xc29d(%rip), %rdx      # 0x14af0
imulq %rcx, %rdx
shlq $0x3, %rdx
addq 0xcf76(%rip), %rdx      # 0x157d8
movl 0xb9b8(%rip), %ecx      # 0x14220
addl %r12d, %ecx
incl %ecx
movslq %ecx, %rcx
movq %rax, (%rdx,%rcx,8)
incq %r12
movslq 0xcf12(%rip), %rax      # 0x15790
addq $0x4, %r15
cmpq %rax, %r12
movsd -0x70(%rbp), %xmm1
jl 0x8799
jmp 0x889b
leaq 0x3034(%rip), %rdi      # 0xb8cd
jmp 0x8840
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq