// File: /workspace/github_c_makefile_star2_O2/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:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %ecx, %r10d
imull %edx, %r10d
leal (%r10,%rcx), %eax
cltq
movsd (%rdi,%rax,8), %xmm3
movl %r8d, %eax
imull %edx, %eax
leal (%rax,%r8), %r9d
movslq %r9d, %r9
subsd (%rdi,%r9,8), %xmm3
mulsd 0x12509(%rip), %xmm3    # 0x23160
leal (%r10,%r8), %r9d
movslq %r9d, %r9
divsd (%rdi,%r9,8), %xmm3
movapd 0x124b4(%rip), %xmm1    # 0x23120
andpd %xmm3, %xmm1
movapd %xmm3, %xmm2
mulsd %xmm3, %xmm2
movsd 0x124c0(%rip), %xmm0    # 0x23140
addsd %xmm0, %xmm2
sqrtsd %xmm2, %xmm2
addsd %xmm1, %xmm2
movapd %xmm0, %xmm1
divsd %xmm2, %xmm1
movapd 0x12474(%rip), %xmm2    # 0x23110
xorpd %xmm4, %xmm4
cmpltsd %xmm4, %xmm3
movapd %xmm3, %xmm4
andnpd %xmm1, %xmm4
xorpd %xmm2, %xmm1
andpd %xmm3, %xmm1
orpd %xmm4, %xmm1
movapd %xmm1, %xmm3
mulsd %xmm1, %xmm3
addsd %xmm0, %xmm3
sqrtsd %xmm3, %xmm3
divsd %xmm3, %xmm0
mulsd %xmm0, %xmm1
xorpd %xmm1, %xmm2
movslq %eax, %r11
movslq %r10d, %rbx
xorl %r14d, %r14d
testl %edx, %edx
movl $0x0, %r10d
cmovgl %edx, %r10d
leaq (%rdi,%rbx,8), %r15
leaq (%rdi,%r11,8), %r12
cmpq %r14, %r10
je 0x10d34
movsd (%r15,%r14,8), %xmm3
movsd (%r12,%r14,8), %xmm4
movapd %xmm1, %xmm5
mulsd %xmm4, %xmm5
movapd %xmm0, %xmm6
mulsd %xmm3, %xmm6
addsd %xmm5, %xmm6
movsd %xmm6, (%r15,%r14,8)
mulsd %xmm2, %xmm3
mulsd %xmm0, %xmm4
addsd %xmm3, %xmm4
movsd %xmm4, (%r12,%r14,8)
incq %r14
jmp 0x10cf2
movslq %edx, %rdx
movslq %ecx, %r14
movslq %r8d, %r8
shlq $0x3, %rdx
movq %rdi, %r15
movq %r10, %r12
subq $0x1, %r12
jb 0x10d8a
movsd (%r15,%r14,8), %xmm3
movsd (%r15,%r8,8), %xmm4
movapd %xmm1, %xmm5
mulsd %xmm4, %xmm5
movapd %xmm0, %xmm6
mulsd %xmm3, %xmm6
addsd %xmm5, %xmm6
movsd %xmm6, (%r15,%r14,8)
mulsd %xmm2, %xmm3
mulsd %xmm0, %xmm4
addsd %xmm3, %xmm4
movsd %xmm4, (%r15,%r8,8)
addq %rdx, %r15
jmp 0x10d47
leaq (%rsi,%rbx,8), %rdx
leaq (%rsi,%r11,8), %rsi
xorl %r8d, %r8d
cmpq %r8, %r10
je 0x10dd7
movsd (%rdx,%r8,8), %xmm3
movsd (%rsi,%r8,8), %xmm4
movapd %xmm1, %xmm5
mulsd %xmm4, %xmm5
movapd %xmm0, %xmm6
mulsd %xmm3, %xmm6
addsd %xmm5, %xmm6
movsd %xmm6, (%rdx,%r8,8)
mulsd %xmm2, %xmm3
mulsd %xmm0, %xmm4
addsd %xmm3, %xmm4
movsd %xmm4, (%rsi,%r8,8)
incq %r8
jmp 0x10d95
andq $0x0, (%rdi,%r9,8)
addl %ecx, %eax
cltq
andq $0x0, (%rdi,%rax,8)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq