// File: /workspace/github_c_makefile_star2_O2/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 0xc0b4(%rip), %rax      # 0x13ec8
movl 0x14(%rax), %ecx
movl 0xc403(%rip), %edx      # 0x14220
movslq %edi, %rsi
imulq $0x28, %rsi, %rsi
addq %rax, %rsi
addq $0x20, %rsi
addq $0x20, %rax
xorl %edi, %edi
testl %edx, %edx
cmovlel %edi, %edx
testl %ecx, %ecx
cmovlel %edi, %ecx
shlq $0x2, %rdx
movsd 0x3479(%rip), %xmm5     # 0xb2c0
xorpd %xmm6, %xmm6
leaq 0xc23e(%rip), %r8       # 0x14090
leaq 0xda17(%rip), %r9       # 0x15870
xorl %ebx, %ebx
movapd %xmm5, %xmm0
movapd %xmm5, %xmm8
movsd %xmm5, -0x30(%rbp)
movapd %xmm5, %xmm7
movapd %xmm5, %xmm9
movapd %xmm5, %xmm10
cmpq %rcx, %rdi
je 0x7f4f
xorl %r10d, %r10d
cmpq %r10, %rdx
je 0x7eb6
movslq (%r10,%r8), %r11
imulq $0x28, %r11, %r11
movq 0x20(%rax,%r11), %r11
cvtsi2sdl (%r10,%r9), %xmm1
movsd (%r11,%rdi,8), %xmm2
addq $0x4, %r10
ucomisd %xmm1, %xmm2
jne 0x7f47
jnp 0x7e83
jmp 0x7f47
cmpq $0x0, 0x10(%rsi)
movq 0x20(%rsi), %r10
movsd (%r10,%rdi,8), %xmm1
je 0x7ed3
ucomisd %xmm6, %xmm1
jne 0x7ecf
jnp 0x7f47
incl %ebx
jmp 0x7f47
ucomisd %xmm1, %xmm1
jp 0x7f47
testl %ebx, %ebx
jne 0x7efd
xorpd %xmm0, %xmm0
movapd %xmm1, %xmm5
movapd %xmm1, %xmm8
movsd %xmm1, -0x30(%rbp)
xorpd %xmm7, %xmm7
xorpd %xmm9, %xmm9
xorpd %xmm10, %xmm10
incl %ebx
movapd %xmm1, %xmm2
subsd %xmm5, %xmm2
cvtsi2sd %ebx, %xmm3
movapd %xmm2, %xmm4
divsd %xmm3, %xmm4
addsd %xmm4, %xmm5
movapd %xmm1, %xmm3
subsd %xmm5, %xmm3
mulsd %xmm2, %xmm3
addsd %xmm3, %xmm0
movapd %xmm1, %xmm2
minsd %xmm8, %xmm2
movapd %xmm1, %xmm3
maxsd -0x30(%rbp), %xmm3
addsd %xmm1, %xmm7
movapd %xmm2, %xmm8
movsd %xmm3, -0x30(%rbp)
incq %rdi
jmp 0x7e77
cvtsi2sd %ebx, %xmm2
cmpl $0x2, %ebx
movsd %xmm5, -0x70(%rbp)
movsd %xmm7, -0x98(%rbp)
movsd %xmm8, -0x68(%rbp)
movsd %xmm2, -0x58(%rbp)
jl 0x7f90
leal -0x1(%rbx), %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
movsd %xmm0, -0x60(%rbp)
jb 0x7fa3
sqrtsd %xmm0, %xmm0
jmp 0x7fb3
movsd %xmm9, -0x78(%rbp)
movsd %xmm0, -0x60(%rbp)
movsd %xmm10, -0x48(%rbp)
jmp 0x7fc9
callq 0x2200
movsd -0x58(%rbp), %xmm2
movsd -0x68(%rbp), %xmm8
cvtsi2sd %ebx, %xmm1
sqrtsd %xmm1, %xmm1
movsd %xmm0, -0x78(%rbp)
divsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x30(%rbp), %xmm0
subsd %xmm8, %xmm0
movsd %xmm0, -0x90(%rbp)
movsd 0x32e5(%rip), %xmm0     # 0xb2c8
subsd 0xbeed(%rip), %xmm0     # 0x13ed8
movsd 0x32ed(%rip), %xmm1     # 0xb2e0
addsd %xmm2, %xmm1
movsd %xmm1, -0x38(%rbp)
callq 0x74c5
movsd %xmm0, -0x40(%rbp)
movsd 0xbeca(%rip), %xmm0     # 0x13ed8
mulsd 0x32ea(%rip), %xmm0     # 0xb300
addsd 0x32aa(%rip), %xmm0     # 0xb2c8
movsd -0x38(%rbp), %xmm1
callq 0x74c5
movsd -0x48(%rbp), %xmm3
movsd -0x40(%rbp), %xmm4
mulsd %xmm3, %xmm4
movsd -0x70(%rbp), %xmm1
movapd %xmm1, %xmm2
subsd %xmm4, %xmm2
movsd %xmm2, -0x88(%rbp)
addsd %xmm1, %xmm4
movsd %xmm4, -0x40(%rbp)
mulsd %xmm3, %xmm0
movapd %xmm1, %xmm2
subsd %xmm0, %xmm2
movsd %xmm2, -0x80(%rbp)
addsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
xorl %r12d, %r12d
leaq 0xd728(%rip), %rcx      # 0x157a0
movslq 0xd711(%rip), %r14      # 0x15790
movl 0xbe5b(%rip), %eax      # 0x13ee0
movl %eax, -0x4c(%rbp)
movslq 0xd751(%rip), %rax      # 0x157e0
movslq 0xca5a(%rip), %rbx      # 0x14af0
imulq %rax, %rbx
movl 0xc17f(%rip), %r15d     # 0x14220
leaq (%rcx,%r12,4), %r13
incq %r12
shlq $0x3, %rbx
leaq -0x1(%r12), %rax
cmpq %r14, %rax
jge 0x81cd
movl (%r13), %eax
movl $0xfffffecd, %ecx       # imm = 0xFFFFFECD
addl %ecx, %eax
cmpl $0x24, %eax
ja 0x8139
leaq 0x30df(%rip), %rcx      # 0xb1b0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
movsd -0x30(%rbp), %xmm0
jmpq *%rax
movsd -0x78(%rbp), %xmm0
jmp 0x8133
movsd -0x48(%rbp), %xmm0
jmp 0x8133
movsd -0x68(%rbp), %xmm0
jmp 0x8133
movsd -0x38(%rbp), %xmm0
jmp 0x8133
movsd -0x80(%rbp), %xmm0
jmp 0x8133
movsd -0x88(%rbp), %xmm0
jmp 0x8133
movsd -0x70(%rbp), %xmm0
jmp 0x8133
movsd -0x40(%rbp), %xmm0
jmp 0x8133
movsd -0x98(%rbp), %xmm0
jmp 0x8133
movsd -0x90(%rbp), %xmm0
jmp 0x8133
movsd -0x60(%rbp), %xmm0
ucomisd %xmm0, %xmm0
jnp 0x8166
leaq 0x375d(%rip), %rdi      # 0xb89d
callq 0x2210
movq 0xd68c(%rip), %rcx      # 0x157d8
addq %rbx, %rcx
leal (%r15,%r12), %edx
movslq %edx, %rdx
movq %rax, (%rcx,%rdx,8)
incq %r12
addq $0x4, %r13
jmp 0x80ac
movl -0x4c(%rbp), %eax
cltq
leaq 0x6fbe(%rip), %rcx      # 0xf130
movq (%rcx,%rax,8), %rdx
leaq -0x100(%rbp), %rbx
movq %rbx, %rdi
pushq $0x64
popq %rsi
movb $0x1, %al
callq 0x20e0
movq %rbx, %rdi
callq 0x2210
movslq 0xd647(%rip), %rcx      # 0x157e0
movslq 0xc950(%rip), %rdx      # 0x14af0
imulq %rcx, %rdx
shlq $0x3, %rdx
addq 0xd629(%rip), %rdx      # 0x157d8
movl 0xc06b(%rip), %ecx      # 0x14220
addl %r12d, %ecx
movslq %ecx, %rcx
movq %rax, (%rdx,%rcx,8)
jmp 0x8071
xorl %eax, %eax
movsd -0x58(%rbp), %xmm0
jmp 0x8169
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq