// File: /workspace/github_c_makefile_star2_O3/georgeweigt[P]sassafras/sassafras.c
// Function: proc_reg_regress
void
proc_reg_regress(void)
{
	int i, x;

	nrow = dataset->nobs;

	// determine the number of design matrix columns

	if (noint)
		ncol = 0;
	else
		ncol = 1;

	for (i = 0; i < num_x; i++) {
		x = xtab[i];
		if (dataset->spec[x].ltab == NULL)
			ncol++;
		else
			ncol += dataset->spec[x].num_levels;
	}

	xfree(Z);
	xfree(Y);
	xfree(Yhat);
	xfree(B);
	xfree(SE);
	xfree(TVAL);
	xfree(PVAL);
	xfree(GG);
	xfree(TT);
	xfree(XX);

	Z = xmalloc(ncol * sizeof (int));
	Y = xmalloc(nrow * sizeof (double));
	Yhat = xmalloc(nrow * sizeof (double));
	B = xmalloc(ncol * sizeof (double));
	SE = xmalloc(ncol * sizeof (double));
	TVAL = xmalloc(ncol * sizeof (double));
	PVAL = xmalloc(ncol * sizeof (double));
	GG = xmalloc(ncol * ncol * sizeof (double));
	TT = xmalloc(ncol * ncol * sizeof (double));
	XX = xmalloc(nrow * ncol * sizeof (double));

	proc_reg_compute_X();

	npar = ncol;

	for (i = 0; i < ncol; i++)
		Z[i] = 0;

	proc_reg_compute_T();

	// if singular then put in columns one by one

	if (proc_reg_compute_G() == -1) {
		npar = 0;
		for (i = 0; i < ncol; i++)
			Z[i] = 1;
		for (i = 0; i < ncol; i++) {
			npar++;
			Z[i] = 0;
			proc_reg_compute_T();
			if (proc_reg_compute_G() == -1) {
				npar--;
				Z[i] = 1;
			}
		}

		// did last column get zapped?

		if (Z[ncol - 1]) {
			proc_reg_compute_T();
			proc_reg_compute_G();
		}
	}

	// sanity check

	if (npar < 1 || npar >= nrow) {
		snprintf(errbuf, ERRBUFLEN, "Regression model kaput, p = %d, n = %d, must have 0 < p < n", npar, nrow);
		stop(errbuf);
	}

	proc_reg_compute_B();

	proc_reg_compute_Yhat();

	proc_reg_compute_mse();

	proc_reg_compute_SE();

	proc_reg_compute_TVAL();

	proc_reg_compute_PVAL();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq 0xb11b(%rip), %rax      # 0x13ed8
movl 0x14(%rax), %ecx
movl %ecx, 0xca1a(%rip)      # 0x157e0
xorl %ecx, %ecx
cmpl $0x0, 0xcc49(%rip)      # 0x15a18
sete %cl
movl %ecx, 0xbd28(%rip)      # 0x14b00
movslq 0xcc31(%rip), %rdx      # 0x15a10
testq %rdx, %rdx
jle 0x8e27
addq $0x20, %rax
shlq $0x2, %rdx
xorl %esi, %esi
leaq 0xb93b(%rip), %rdi      # 0x14730
movslq (%rsi,%rdi), %r8
leaq (%r8,%r8,4), %r8
cmpq $0x0, 0x10(%rax,%r8,8)
je 0x8e0f
leaq (%rax,%r8,8), %r8
movl 0xc(%r8), %r8d
jmp 0x8e15
movl $0x1, %r8d
addl %r8d, %ecx
movl %ecx, 0xbce2(%rip)      # 0x14b00
addq $0x4, %rsi
cmpq %rsi, %rdx
jne 0x8df5
movq 0xcd82(%rip), %rdi      # 0x15bb0
testq %rdi, %rdi
je 0x8e38
callq 0x2040
movq 0xbcb1(%rip), %rdi      # 0x14af0
testq %rdi, %rdi
je 0x8e49
callq 0x2040
movq 0xbca8(%rip), %rdi      # 0x14af8
testq %rdi, %rdi
je 0x8e5a
callq 0x2040
movq 0xbc6f(%rip), %rdi      # 0x14ad0
testq %rdi, %rdi
je 0x8e6b
callq 0x2040
movq 0xcd46(%rip), %rdi      # 0x15bb8
testq %rdi, %rdi
je 0x8e7c
callq 0x2040
movq 0xcd3d(%rip), %rdi      # 0x15bc0
testq %rdi, %rdi
je 0x8e8d
callq 0x2040
movq 0xcd34(%rip), %rdi      # 0x15bc8
testq %rdi, %rdi
je 0x8e9e
callq 0x2040
movq 0xbc33(%rip), %rdi      # 0x14ad8
testq %rdi, %rdi
je 0x8eaf
callq 0x2040
movq 0xbc2a(%rip), %rdi      # 0x14ae0
testq %rdi, %rdi
je 0x8ec0
callq 0x2040
movq 0xbc21(%rip), %rdi      # 0x14ae8
testq %rdi, %rdi
je 0x8ed1
callq 0x2040
movl 0xbc29(%rip), %edi      # 0x14b00
shll $0x2, %edi
callq 0x2bd8
movq %rax, 0xccca(%rip)      # 0x15bb0
movl 0xc8f4(%rip), %edi      # 0x157e0
shll $0x3, %edi
callq 0x2bd8
movq %rax, 0xbbf5(%rip)      # 0x14af0
movl 0xc8df(%rip), %edi      # 0x157e0
shll $0x3, %edi
callq 0x2bd8
movq %rax, 0xbbe8(%rip)      # 0x14af8
movl 0xbbea(%rip), %edi      # 0x14b00
shll $0x3, %edi
callq 0x2bd8
movq %rax, 0xbbab(%rip)      # 0x14ad0
movl 0xbbd5(%rip), %edi      # 0x14b00
shll $0x3, %edi
callq 0x2bd8
movq %rax, 0xcc7e(%rip)      # 0x15bb8
movl 0xbbc0(%rip), %edi      # 0x14b00
shll $0x3, %edi
callq 0x2bd8
movq %rax, 0xcc71(%rip)      # 0x15bc0
movl 0xbbab(%rip), %edi      # 0x14b00
shll $0x3, %edi
callq 0x2bd8
movq %rax, 0xcc64(%rip)      # 0x15bc8
movl 0xbb96(%rip), %edi      # 0x14b00
imull %edi, %edi
shll $0x3, %edi
callq 0x2bd8
movq %rax, 0xbb5c(%rip)      # 0x14ad8
movl 0xbb7e(%rip), %edi      # 0x14b00
imull %edi, %edi
shll $0x3, %edi
callq 0x2bd8
movq %rax, 0xbb4c(%rip)      # 0x14ae0
movl 0xc846(%rip), %edi      # 0x157e0
imull 0xbb5f(%rip), %edi      # 0x14b00
shll $0x3, %edi
callq 0x2bd8
movq %rax, 0xbb38(%rip)      # 0x14ae8
callq 0x9b8e
movl 0xbb45(%rip), %eax      # 0x14b00
movl %eax, 0xba97(%rip)      # 0x14a58
testl %eax, %eax
jle 0x8fe4
movq 0xcbe4(%rip), %rax      # 0x15bb0
xorl %ecx, %ecx
movl $0x0, (%rax,%rcx,4)
incq %rcx
movslq 0xbb21(%rip), %rdx      # 0x14b00
cmpq %rdx, %rcx
jl 0x8fce
callq 0x9d25
callq 0x9def
cmpl $-0x1, %eax
jne 0x9092
movl $0x0, 0xba57(%rip)      # 0x14a58
movl 0xbaf9(%rip), %eax      # 0x14b00
testl %eax, %eax
jle 0x9078
movq 0xcb9e(%rip), %rcx      # 0x15bb0
xorl %edx, %edx
movl $0x1, (%rcx,%rdx,4)
incq %rdx
movslq 0xbadb(%rip), %rax      # 0x14b00
cmpq %rax, %rdx
jl 0x9014
testl %eax, %eax
jle 0x9078
xorl %ebx, %ebx
incl 0xba22(%rip)            # 0x14a58
movq 0xcb73(%rip), %rax      # 0x15bb0
movl $0x0, (%rax,%rbx,4)
callq 0x9d25
callq 0x9def
cmpl $-0x1, %eax
jne 0x9067
decl 0xb9ff(%rip)            # 0x14a58
movq 0xcb50(%rip), %rax      # 0x15bb0
movl $0x1, (%rax,%rbx,4)
incq %rbx
movslq 0xba8f(%rip), %rax      # 0x14b00
cmpq %rax, %rbx
jl 0x9030
jmp 0x907a
cltq
movq 0xcb2f(%rip), %rcx      # 0x15bb0
cmpl $0x0, -0x4(%rcx,%rax,4)
je 0x9092
callq 0x9d25
callq 0x9def
movl 0xb9c0(%rip), %ecx      # 0x14a58
movl 0xc741(%rip), %r8d      # 0x157e0
testl %ecx, %ecx
jle 0x9101
cmpl %r8d, %ecx
jge 0x9101
callq 0xa19e
callq 0xa284
callq 0xa31f
callq 0xa53e
movslq 0xb995(%rip), %rax      # 0x14a58
testq %rax, %rax
jle 0x90f6
movq 0xba01(%rip), %rcx      # 0x14ad0
movq 0xcae2(%rip), %rdx      # 0x15bb8
movq 0xcae3(%rip), %rsi      # 0x15bc0
xorl %edi, %edi
movsd (%rcx,%rdi,8), %xmm0
divsd (%rdx,%rdi,8), %xmm0
movsd %xmm0, (%rsi,%rdi,8)
incq %rdi
cmpq %rdi, %rax
jne 0x90df
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0xa5f0
leaq 0x67b8(%rip), %rbx      # 0xf8c0
leaq 0x2905(%rip), %rdx      # 0xba14
movl $0x7d0, %esi            # imm = 0x7D0
movq %rbx, %rdi
xorl %eax, %eax
callq 0x20e0
callq 0xa7e0
movq %rbx, %rdi
callq 0x4039
leaq 0xcabe(%rip), %rdi      # 0x15bf0
movl $0x1, %esi
callq 0x21c0