// File: /workspace/github_c_makefile_star2_O3/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 0xba31(%rip), %rax      # 0x13ed8
movslq 0x14(%rax), %rcx
testq %rcx, %rcx
jle 0x864c
movl 0xbd76(%rip), %edx      # 0x14230
movslq %edi, %rsi
leaq (%rsi,%rsi,4), %rsi
leaq (%rax,%rsi,8), %rsi
addq $0x20, %rsi
addq $0x20, %rax
movq %rdx, %rdi
shlq $0x2, %rdi
xorl %r8d, %r8d
movsd 0x2de1(%rip), %xmm1     # 0xb2c0
leaq 0xbbba(%rip), %r9       # 0x140a0
leaq 0xd393(%rip), %r10      # 0x15880
xorpd %xmm7, %xmm7
movapd %xmm1, %xmm9
movapd %xmm1, %xmm5
movsd %xmm1, -0x38(%rbp)
movapd %xmm1, %xmm8
movapd %xmm1, %xmm0
movsd %xmm1, -0x40(%rbp)
movsd %xmm1, -0x30(%rbp)
xorl %ebx, %ebx
testl %edx, %edx
jle 0x8550
xorl %r11d, %r11d
movslq (%r11,%r9), %r14
leaq (%r14,%r14,4), %r14
movq 0x20(%rax,%r14,8), %r14
movsd (%r14,%r8,8), %xmm1
xorps %xmm2, %xmm2
cvtsi2sdl (%r11,%r10), %xmm2
ucomisd %xmm2, %xmm1
jne 0x85fe
jp 0x85fe
addq $0x4, %r11
cmpq %r11, %rdi
jne 0x851b
cmpq $0x0, 0x10(%rsi)
movq 0x20(%rsi), %r11
movsd (%r11,%r8,8), %xmm1
je 0x8574
ucomisd %xmm7, %xmm1
jne 0x856d
jnp 0x85fe
incl %ebx
jmp 0x85fe
ucomisd %xmm1, %xmm1
jp 0x85fe
testl %ebx, %ebx
jne 0x85a7
xorpd %xmm0, %xmm0
movsd %xmm1, -0x30(%rbp)
movapd %xmm1, %xmm8
movsd %xmm1, -0x38(%rbp)
xorpd %xmm5, %xmm5
xorpd %xmm9, %xmm9
xorpd %xmm2, %xmm2
movsd %xmm2, -0x40(%rbp)
incl %ebx
movapd %xmm1, %xmm2
movsd -0x30(%rbp), %xmm6
subsd %xmm6, %xmm2
xorps %xmm3, %xmm3
cvtsi2sd %ebx, %xmm3
movapd %xmm2, %xmm4
divsd %xmm3, %xmm4
addsd %xmm4, %xmm6
movapd %xmm1, %xmm3
movsd %xmm6, -0x30(%rbp)
subsd %xmm6, %xmm3
mulsd %xmm2, %xmm3
addsd %xmm3, %xmm0
movapd %xmm1, %xmm2
minsd %xmm8, %xmm2
movapd %xmm1, %xmm3
maxsd -0x38(%rbp), %xmm3
addsd %xmm1, %xmm5
movapd %xmm2, %xmm8
movsd %xmm3, -0x38(%rbp)
incq %r8
cmpq %rcx, %r8
jne 0x8514
movsd -0x38(%rbp), %xmm1
subsd %xmm8, %xmm1
movsd %xmm1, -0x68(%rbp)
cmpl $0x2, %ebx
movsd %xmm5, -0x78(%rbp)
movsd %xmm8, -0x70(%rbp)
jl 0x867b
leal -0x1(%rbx), %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
movsd %xmm0, -0x50(%rbp)
jb 0x8688
sqrtsd %xmm0, %xmm0
jmp 0x868d
xorl %ebx, %ebx
movsd 0x2c6a(%rip), %xmm0     # 0xb2c0
movsd %xmm0, -0x78(%rbp)
movsd %xmm0, -0x38(%rbp)
movsd %xmm0, -0x70(%rbp)
movsd %xmm0, -0x30(%rbp)
movsd %xmm0, -0x50(%rbp)
movsd %xmm0, -0x60(%rbp)
movsd %xmm0, -0x68(%rbp)
jmp 0x86a1
movsd %xmm9, -0x60(%rbp)
movsd %xmm0, -0x50(%rbp)
jmp 0x86a6
callq 0x2210
xorps %xmm1, %xmm1
cvtsi2sd %ebx, %xmm1
sqrtsd %xmm1, %xmm1
movsd %xmm0, -0x60(%rbp)
divsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
movsd 0x2c1a(%rip), %xmm0     # 0xb2c8
subsd 0xb832(%rip), %xmm0     # 0x13ee8
xorps %xmm2, %xmm2
cvtsi2sd %ebx, %xmm2
movsd 0x2c13(%rip), %xmm1     # 0xb2d8
movsd %xmm2, -0x90(%rbp)
addsd %xmm2, %xmm1
movsd %xmm1, -0x48(%rbp)
callq 0x7aad
movsd %xmm0, -0x58(%rbp)
movsd 0xb800(%rip), %xmm0     # 0x13ee8
mulsd 0x2c10(%rip), %xmm0     # 0xb300
addsd 0x2bd0(%rip), %xmm0     # 0xb2c8
movsd -0x48(%rbp), %xmm1
callq 0x7aad
movl 0xd097(%rip), %r12d     # 0x157a0
testl %r12d, %r12d
jle 0x88ac
movsd -0x40(%rbp), %xmm1
movsd -0x58(%rbp), %xmm2
mulsd %xmm1, %xmm2
movsd -0x30(%rbp), %xmm3
movapd %xmm3, %xmm4
subsd %xmm2, %xmm4
movsd %xmm4, -0x88(%rbp)
addsd %xmm3, %xmm2
movsd %xmm2, -0x58(%rbp)
mulsd %xmm1, %xmm0
movapd %xmm3, %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, -0x80(%rbp)
addsd %xmm3, %xmm0
movsd %xmm0, -0x48(%rbp)
movl 0xb791(%rip), %r13d     # 0x13ef0
xorl %r15d, %r15d
leaq 0x2a47(%rip), %rbx      # 0xb1b0
leaq -0x100(%rbp), %r14
leaq 0xd039(%rip), %rax      # 0x157b0
movl (%rax,%r15,4), %eax
movl $0xfffffecd, %ecx       # imm = 0xFFFFFECD
addl %ecx, %eax
cmpl $0x24, %eax
ja 0x886e
movslq (%rbx,%rax,4), %rcx
addq %rbx, %rcx
movsd -0x38(%rbp), %xmm1
movsd -0x90(%rbp), %xmm0
xorl %eax, %eax
jmpq *%rcx
movsd -0x60(%rbp), %xmm1
jmp 0x87f1
movsd -0x40(%rbp), %xmm1
jmp 0x87f1
movsd -0x58(%rbp), %xmm1
jmp 0x87f1
movsd -0x78(%rbp), %xmm1
jmp 0x87f1
movsd -0x80(%rbp), %xmm1
jmp 0x87f1
movsd -0x30(%rbp), %xmm1
jmp 0x87f1
movsd -0x70(%rbp), %xmm1
jmp 0x87f1
movsd -0x68(%rbp), %xmm1
jmp 0x87f1
movsd -0x50(%rbp), %xmm1
jmp 0x87f1
movsd -0x48(%rbp), %xmm1
jmp 0x87f1
movsd -0x88(%rbp), %xmm1
ucomisd %xmm1, %xmm1
jp 0x886e
movapd %xmm1, %xmm0
movl %r13d, %eax
cltq
leaq 0x6939(%rip), %rcx      # 0xf140
movq (%rcx,%rax,8), %rdx
movl $0x64, %esi
movq %r14, %rdi
movb $0x1, %al
callq 0x20e0
movq %r14, %rdi
callq 0x2220
movslq 0xcfc7(%rip), %rcx      # 0x157f0
movslq 0xc2d0(%rip), %rdx      # 0x14b00
imulq %rcx, %rdx
shlq $0x3, %rdx
addq 0xcfa9(%rip), %rdx      # 0x157e8
incq %r15
movl 0xb9e8(%rip), %ecx      # 0x14230
addl %r15d, %ecx
movslq %ecx, %rcx
movq %rax, (%rdx,%rcx,8)
movl 0xb697(%rip), %r13d     # 0x13ef0
movl 0xcf40(%rip), %r12d     # 0x157a0
movslq %r12d, %rax
cmpq %rax, %r15
jl 0x8770
jmp 0x88ac
leaq 0x3028(%rip), %rdi      # 0xb89d
callq 0x2220
movslq 0xcf6f(%rip), %rcx      # 0x157f0
movslq 0xc278(%rip), %rdx      # 0x14b00
imulq %rcx, %rdx
shlq $0x3, %rdx
addq 0xcf51(%rip), %rdx      # 0x157e8
incq %r15
movl 0xb990(%rip), %ecx      # 0x14230
addl %r15d, %ecx
movslq %ecx, %rcx
movq %rax, (%rdx,%rcx,8)
jmp 0x8860
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq