// File: /workspace/github_c_makefile_star2_O3/georgeweigt[P]eigenmath/eigenmath.c
// Function: eigenvec_step_nib
void
eigenvec_step_nib(double *D, double *Q, int n, int p, int q)
{
	int k;
	double t, theta;
	double c, cc, s, ss;

	// compute c and s

	// from Numerical Recipes (except they have a_qq - a_pp)

	theta = 0.5 * (D[n * p + p] - D[n * q + q]) / D[n * p + q];

	t = 1.0 / (fabs(theta) + sqrt(theta * theta + 1.0));

	if (theta < 0.0)
		t = -t;

	c = 1.0 / sqrt(t * t + 1.0);

	s = t * c;

	// D = GD

	// which means "add rows"

	for (k = 0; k < n; k++) {
		cc = D[n * p + k];
		ss = D[n * q + k];
		D[n * p + k] = c * cc + s * ss;
		D[n * q + k] = c * ss - s * cc;
	}

	// D = D transpose(G)

	// which means "add columns"

	for (k = 0; k < n; k++) {
		cc = D[n * k + p];
		ss = D[n * k + q];
		D[n * k + p] = c * cc + s * ss;
		D[n * k + q] = c * ss - s * cc;
	}

	// Q = GQ

	// which means "add rows"

	for (k = 0; k < n; k++) {
		cc = Q[n * p + k];
		ss = Q[n * q + k];
		Q[n * p + k] = c * cc + s * ss;
		Q[n * q + k] = c * ss - s * cc;
	}

	D[n * p + q] = 0.0;
	D[n * q + p] = 0.0;
}

// Assembly:
movl %ecx, %r10d
imull %edx, %r10d
movl %r8d, %eax
imull %edx, %eax
leal (%r10,%r8), %r9d
movslq %r9d, %r9
testl %edx, %edx
jle 0x139d6
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
leal (%r10,%rcx), %r11d
movslq %r11d, %r11
movsd (%rdi,%r11,8), %xmm0
leal (%rax,%r8), %r11d
movslq %r11d, %r11
subsd (%rdi,%r11,8), %xmm0
mulsd 0x16906(%rip), %xmm0    # 0x2a150
divsd (%rdi,%r9,8), %xmm0
movapd 0x168c8(%rip), %xmm2    # 0x2a120
andpd %xmm0, %xmm2
movapd %xmm0, %xmm3
mulsd %xmm0, %xmm3
movsd 0x168c4(%rip), %xmm1    # 0x2a130
addsd %xmm1, %xmm3
sqrtsd %xmm3, %xmm3
addsd %xmm2, %xmm3
movapd %xmm1, %xmm2
divsd %xmm3, %xmm2
movapd 0x16888(%rip), %xmm3    # 0x2a110
xorpd %xmm2, %xmm3
xorpd %xmm4, %xmm4
cmpltsd %xmm4, %xmm0
movapd %xmm0, %xmm4
andnpd %xmm2, %xmm4
andpd %xmm3, %xmm0
orpd %xmm4, %xmm0
movapd %xmm0, %xmm2
mulsd %xmm0, %xmm2
addsd %xmm1, %xmm2
sqrtsd %xmm2, %xmm2
divsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movapd 0x1684b(%rip), %xmm2    # 0x2a110
xorpd %xmm0, %xmm2
movslq %r10d, %r11
movslq %eax, %rbx
movl %edx, %r10d
leaq (%rdi,%r11,8), %r14
leaq (%rdi,%rbx,8), %r15
xorl %r12d, %r12d
movsd (%r14,%r12,8), %xmm3
movsd (%r15,%r12,8), %xmm4
movapd %xmm0, %xmm5
mulsd %xmm4, %xmm5
movapd %xmm1, %xmm6
mulsd %xmm3, %xmm6
addsd %xmm5, %xmm6
movsd %xmm6, (%r14,%r12,8)
mulsd %xmm2, %xmm3
mulsd %xmm1, %xmm4
addsd %xmm3, %xmm4
movsd %xmm4, (%r15,%r12,8)
incq %r12
cmpq %r12, %r10
jne 0x138dd
testl %edx, %edx
jle 0x139cc
movslq %ecx, %r14
movslq %r8d, %r8
leaq (,%r10,8), %r15
movq %r10, %r12
movq %rdi, %r13
movsd (%r13,%r14,8), %xmm3
movsd (%r13,%r8,8), %xmm4
movapd %xmm0, %xmm5
mulsd %xmm4, %xmm5
movapd %xmm1, %xmm6
mulsd %xmm3, %xmm6
addsd %xmm5, %xmm6
movsd %xmm6, (%r13,%r14,8)
mulsd %xmm2, %xmm3
mulsd %xmm1, %xmm4
addsd %xmm3, %xmm4
movsd %xmm4, (%r13,%r8,8)
addq %r15, %r13
decq %r12
jne 0x13939
testl %edx, %edx
jle 0x139cc
leaq (%rsi,%r11,8), %rdx
leaq (%rsi,%rbx,8), %rsi
xorl %r8d, %r8d
movsd (%rdx,%r8,8), %xmm3
movsd (%rsi,%r8,8), %xmm4
movapd %xmm0, %xmm5
mulsd %xmm4, %xmm5
movapd %xmm1, %xmm6
mulsd %xmm3, %xmm6
addsd %xmm5, %xmm6
movsd %xmm6, (%rdx,%r8,8)
mulsd %xmm2, %xmm3
mulsd %xmm1, %xmm4
addsd %xmm3, %xmm4
movsd %xmm4, (%rsi,%r8,8)
incq %r8
cmpq %r8, %r10
jne 0x1398c
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
xorl %edx, %edx
movq %rdx, (%rdi,%r9,8)
addl %ecx, %eax
cltq
movq %rdx, (%rdi,%rax,8)
retq