// File: /workspace/github_c_makefile_star2_O1/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 %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %ecx, %r12d
movl %edx, %r15d
movq %rdi, %r14
movl %ecx, %ebx
imull %edx, %ebx
leal (%rbx,%r12), %eax
cltq
movsd (%rdi,%rax,8), %xmm3
movl %r8d, %r13d
imull %edx, %r13d
leal (%r8,%r13), %eax
cltq
subsd (%rdi,%rax,8), %xmm3
mulsd 0x13cad(%rip), %xmm3    # 0x26130
leal (%rbx,%r8), %eax
cltq
divsd (%rdi,%rax,8), %xmm3
movapd 0x13c6a(%rip), %xmm1    # 0x26100
movapd %xmm3, %xmm0
mulsd %xmm3, %xmm0
addsd 0x13c6a(%rip), %xmm0    # 0x26110
andpd %xmm3, %xmm1
xorpd %xmm4, %xmm4
ucomisd %xmm4, %xmm0
movq %rax, -0x58(%rbp)
movq %rsi, -0x50(%rbp)
movq %r8, -0x48(%rbp)
jb 0x124c6
sqrtsd %xmm0, %xmm0
jmp 0x124e3
movapd %xmm3, -0x40(%rbp)
movapd %xmm1, -0x70(%rbp)
callq 0x7350
movapd -0x70(%rbp), %xmm1
xorpd %xmm4, %xmm4
movapd -0x40(%rbp), %xmm3
addsd %xmm1, %xmm0
movsd 0x13c21(%rip), %xmm6    # 0x26110
movapd %xmm6, %xmm1
divsd %xmm0, %xmm1
movapd 0x13bf1(%rip), %xmm0    # 0x260f0
xorpd %xmm1, %xmm0
cmpltsd %xmm4, %xmm3
movapd %xmm3, %xmm2
andnpd %xmm1, %xmm2
andpd %xmm0, %xmm3
orpd %xmm2, %xmm3
movapd %xmm3, %xmm0
mulsd %xmm3, %xmm0
addsd %xmm6, %xmm0
ucomisd %xmm4, %xmm0
jb 0x12530
sqrtsd %xmm0, %xmm0
jmp 0x12547
movapd %xmm3, -0x40(%rbp)
callq 0x7350
movapd -0x40(%rbp), %xmm3
movsd 0x13bc9(%rip), %xmm6    # 0x26110
divsd %xmm0, %xmm6
movapd %xmm6, %xmm0
mulsd %xmm3, %xmm0
movslq %ebx, %rcx
movslq %r13d, %rdx
movl %r15d, %eax
testl %r15d, %r15d
jle 0x125b8
movapd 0x13b87(%rip), %xmm1    # 0x260f0
xorpd %xmm0, %xmm1
leaq (%r14,%rcx,8), %rsi
leaq (%r14,%rdx,8), %rdi
xorl %r8d, %r8d
movsd (%rsi,%r8,8), %xmm2
movsd (%rdi,%r8,8), %xmm3
movapd %xmm0, %xmm4
mulsd %xmm3, %xmm4
movapd %xmm6, %xmm5
mulsd %xmm2, %xmm5
addsd %xmm4, %xmm5
movsd %xmm5, (%rsi,%r8,8)
mulsd %xmm1, %xmm2
mulsd %xmm6, %xmm3
addsd %xmm2, %xmm3
movsd %xmm3, (%rdi,%r8,8)
incq %r8
cmpq %r8, %rax
jne 0x12578
testl %r15d, %r15d
jle 0x1261e
movapd 0x13b2b(%rip), %xmm1    # 0x260f0
xorpd %xmm0, %xmm1
movslq %r12d, %rsi
movslq -0x48(%rbp), %rdi
leaq (,%rax,8), %r8
movq %rax, %r9
movq %r14, %r10
movsd (%r10,%rsi,8), %xmm2
movsd (%r10,%rdi,8), %xmm3
movapd %xmm0, %xmm4
mulsd %xmm3, %xmm4
movapd %xmm6, %xmm5
mulsd %xmm2, %xmm5
addsd %xmm4, %xmm5
movsd %xmm5, (%r10,%rsi,8)
mulsd %xmm1, %xmm2
mulsd %xmm6, %xmm3
addsd %xmm2, %xmm3
movsd %xmm3, (%r10,%rdi,8)
addq %r8, %r10
decq %r9
jne 0x125de
testl %r15d, %r15d
jle 0x12679
movapd 0x13ac5(%rip), %xmm1    # 0x260f0
xorpd %xmm0, %xmm1
movq -0x50(%rbp), %rsi
leaq (%rsi,%rcx,8), %rcx
leaq (%rsi,%rdx,8), %rdx
xorl %esi, %esi
movsd (%rcx,%rsi,8), %xmm2
movsd (%rdx,%rsi,8), %xmm3
movapd %xmm0, %xmm4
mulsd %xmm3, %xmm4
movapd %xmm6, %xmm5
mulsd %xmm2, %xmm5
addsd %xmm4, %xmm5
movsd %xmm5, (%rcx,%rsi,8)
mulsd %xmm1, %xmm2
mulsd %xmm6, %xmm3
addsd %xmm2, %xmm3
movsd %xmm3, (%rdx,%rsi,8)
incq %rsi
cmpq %rsi, %rax
jne 0x1263d
xorl %eax, %eax
movq -0x58(%rbp), %rcx
movq %rax, (%r14,%rcx,8)
addl %r12d, %r13d
movslq %r13d, %rcx
movq %rax, (%r14,%rcx,8)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq