// File: /workspace/github_c_makefile_star2_O1/markpeerdeman[P]mbemm/src/emath/fsol3d.c
// Function: makeUFandTF
void makeUFandTF( matrix u, matrix t,
		  double s1, double s2, double s3,
		  double c1, double c2, double c3,
		  double n1, double n2, double n3 )
/* matrices u and t are filled with the fundamental solutions,
 * s1, s2 and s3 are the sourcepoint coordinates,
 * c1, c2 and c3 are the collocation point coordinates
 * n1, n1 and n3 are the normal vector components
 */
{ double r, /* distance sourcenode to fieldnode (rho) */
	 rd1, /* rho,1 (i.e. drho/dx1) */
	 rd2, /* rho,2 (i.e. drho/dx2) */
	 rd3, /* rho,3 (i.e. drho/dx3) */
	  C1, /* constant */
	  C2, /* constant */
	 rdn, /* rho,j nj (i.e. rho,1n1 + rho,2n2 + rho,3n3) */
	 tmp, /* variabele */
	   A, /* variabeles too */
	   B,
	   C,
	   D;


  rd1 = c1-s1; /* this are not the definitive values! */
  rd2 = c2-s2;
  rd3 = c3-s3;
  /* calculate rho: */
  r  = rd1 * rd1;
  r += (rd2 * rd2);
  r += (rd3 * rd3);
  r  = sqrt(r);
  rd1 = rd1/r;   /* definitive values of rdx */
  rd2 = rd2/r;
  rd3 = rd3/r;

  C1 = (1.0+NU)/r;
  C2 = 3.0 - 4.0*NU; C2 = C1*C2;

  /* calculate fundamental solution displacement matrix: */
  M(u,1,1)  = C1;
  M(u,1,1) *= rd1;
  M(u,1,1) *= rd1;
  M(u,1,1) += C2;
  M(u,2,2)  = C1;
  M(u,2,2) *= rd2;
  M(u,2,2) *= rd2;
  M(u,2,2) += C2;
  M(u,3,3)  = C1;
  M(u,3,3) *= rd3;
  M(u,3,3) *= rd3;
  M(u,3,3) += C2;
  M(u,1,2)  = C1;
  M(u,1,2) *= rd1;
  M(u,1,2) *= rd2;
  M(u,2,1)  = M(u,1,2);
  M(u,1,3)  = C1;
  M(u,1,3) *= rd1;
  M(u,1,3) *= rd3;
  M(u,3,1)  = M(u,1,3);
  M(u,2,3)  = C1;
  M(u,2,3) *= rd2;
  M(u,2,3) *= rd3;
  M(u,3,2)  = M(u,2,3);

  /* assign values for processing speed: */
  C1  = r;
  C1 *= r;
  C1  = -1.0/C1;
  C2  = 1.0 - 2.0*NU;
  C2 *= C1;
  rdn = rd1*n1+rd2*n2+rd3*n3;

  /* calculate fundamental solution traction matrix: */
  /* first the diagonal terms: */
  A  = 3.0;
  A *= C1;
  A *= rdn; 
  B  = C2;
  B *= rdn;
  M(t,1,1)  = rd1; 
  M(t,1,1) *= rd1;
  M(t,1,1) *= A;
  M(t,1,1) += B;
  M(t,2,2)  = rd2;
  M(t,2,2) *= rd2;
  M(t,2,2) *= A;
  M(t,2,2) += B;
  M(t,3,3)  = rd3;
  M(t,3,3) *= rd3;
  M(t,3,3) *= A;
  M(t,3,3) += B;
  /* Now do the off diagonal terms: */
  C  = A;
  C *= rd1;
  C *= rd2;
  D  = n2;
  D *= rd1;
  B  = n1;
  B *= rd2;
  B -= D;
  B *= C2;
  M(t,1,2)  = C;
  M(t,1,2) += B;
  M(t,2,1)  = C;
  M(t,2,1) -= B;
  C  = A;
  C *= rd1;
  C *= rd3;
  D  = n3;
  D *= rd1;
  B  = n1;
  B *= rd3;
  B -= D;
  B *= C2;
  M(t,1,3)  = C;
  M(t,1,3) += B;
  M(t,3,1)  = C;
  M(t,3,1) -= B;
  C  = A;
  C *= rd2;
  C *= rd3;
  D  = n3;
  D *= rd2;
  B  = n2;
  B *= rd3;
  B -= D;
  B *= C2;
  M(t,2,3)  = C;
  M(t,2,3) += B;
  M(t,3,2)  = C;
  M(t,3,2) -= B;

}

// Assembly:
pushq %r14
pushq %rbx
subq $0x28, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movsd 0x40(%rsp), %xmm12
subsd %xmm0, %xmm3
subsd %xmm1, %xmm4
subsd %xmm2, %xmm5
movapd %xmm3, %xmm0
mulsd %xmm3, %xmm0
movapd %xmm4, %xmm1
mulsd %xmm4, %xmm1
addsd %xmm0, %xmm1
movapd %xmm5, %xmm0
mulsd %xmm5, %xmm0
addsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0xb574
sqrtsd %xmm0, %xmm0
jmp 0xb5ba
movsd %xmm5, 0x20(%rsp)
movsd %xmm7, 0x18(%rsp)
movsd %xmm4, 0x10(%rsp)
movsd %xmm6, 0x8(%rsp)
movsd %xmm3, (%rsp)
callq 0x11b0
movsd (%rsp), %xmm3
movsd 0x40(%rsp), %xmm12
movsd 0x8(%rsp), %xmm6
movsd 0x10(%rsp), %xmm4
movsd 0x18(%rsp), %xmm7
movsd 0x20(%rsp), %xmm5
divsd %xmm0, %xmm3
divsd %xmm0, %xmm4
divsd %xmm0, %xmm5
leaq 0x9e43(%rip), %rax      # 0x15410
movsd (%rax), %xmm2
movsd 0x2a2f(%rip), %xmm1     # 0xe008
movapd %xmm2, %xmm10
addsd %xmm1, %xmm10
divsd %xmm0, %xmm10
mulsd 0x3c48(%rip), %xmm2     # 0xf238
movsd 0x2e67(%rip), %xmm13    # 0xe460
addsd %xmm13, %xmm2
mulsd %xmm10, %xmm2
movq 0x8(%r14), %rcx
movq (%rcx), %rdx
movapd %xmm3, %xmm8
mulsd %xmm10, %xmm8
movapd %xmm3, %xmm9
mulsd %xmm8, %xmm9
addsd %xmm2, %xmm9
movsd %xmm9, (%rdx)
movq 0x8(%rcx), %rsi
movapd %xmm4, %xmm11
mulsd %xmm10, %xmm11
movapd %xmm4, %xmm9
mulsd %xmm11, %xmm9
addsd %xmm2, %xmm9
movsd %xmm9, 0x8(%rsi)
movq 0x10(%rcx), %rcx
mulsd %xmm5, %xmm10
mulsd %xmm5, %xmm10
addsd %xmm2, %xmm10
movsd %xmm10, 0x10(%rcx)
movapd %xmm4, %xmm2
mulsd %xmm8, %xmm2
movsd %xmm2, 0x8(%rdx)
movsd %xmm2, (%rsi)
mulsd %xmm5, %xmm8
movsd %xmm8, 0x10(%rdx)
movsd %xmm8, (%rcx)
mulsd %xmm5, %xmm11
movsd %xmm11, 0x10(%rsi)
movsd %xmm11, 0x8(%rcx)
mulsd %xmm0, %xmm0
movsd 0x395d(%rip), %xmm2     # 0xf000
divsd %xmm0, %xmm2
movsd (%rax), %xmm0
addsd %xmm0, %xmm0
subsd %xmm0, %xmm1
mulsd %xmm2, %xmm1
movapd %xmm4, %xmm0
mulsd %xmm7, %xmm0
movapd %xmm3, %xmm8
mulsd %xmm6, %xmm8
addsd %xmm0, %xmm8
movapd %xmm5, %xmm0
mulsd %xmm12, %xmm0
addsd %xmm8, %xmm0
mulsd %xmm13, %xmm2
mulsd %xmm0, %xmm2
mulsd %xmm1, %xmm0
movq 0x8(%rbx), %rcx
movq (%rcx), %rdx
movapd %xmm3, %xmm8
mulsd %xmm3, %xmm8
mulsd %xmm2, %xmm8
addsd %xmm0, %xmm8
movsd %xmm8, (%rdx)
movq 0x8(%rcx), %rax
movapd %xmm4, %xmm8
mulsd %xmm4, %xmm8
mulsd %xmm2, %xmm8
addsd %xmm0, %xmm8
movsd %xmm8, 0x8(%rax)
movq 0x10(%rcx), %rcx
movapd %xmm5, %xmm8
mulsd %xmm5, %xmm8
mulsd %xmm2, %xmm8
addsd %xmm0, %xmm8
movsd %xmm8, 0x10(%rcx)
movapd %xmm3, %xmm0
mulsd %xmm2, %xmm0
movapd %xmm4, %xmm10
mulsd %xmm0, %xmm10
movapd %xmm3, %xmm8
mulsd %xmm7, %xmm8
movapd %xmm4, %xmm9
mulsd %xmm6, %xmm9
subsd %xmm8, %xmm9
mulsd %xmm1, %xmm9
movapd %xmm10, %xmm8
addsd %xmm9, %xmm8
movsd %xmm8, 0x8(%rdx)
subsd %xmm9, %xmm10
movsd %xmm10, (%rax)
mulsd %xmm5, %xmm0
mulsd %xmm12, %xmm3
mulsd %xmm5, %xmm6
subsd %xmm3, %xmm6
mulsd %xmm1, %xmm6
movapd %xmm0, %xmm3
addsd %xmm6, %xmm3
movsd %xmm3, 0x10(%rdx)
subsd %xmm6, %xmm0
movsd %xmm0, (%rcx)
mulsd %xmm4, %xmm2
mulsd %xmm5, %xmm2
mulsd %xmm12, %xmm4
mulsd %xmm7, %xmm5
subsd %xmm4, %xmm5
mulsd %xmm1, %xmm5
movapd %xmm2, %xmm0
addsd %xmm5, %xmm0
movsd %xmm0, 0x10(%rax)
subsd %xmm5, %xmm2
movsd %xmm2, 0x8(%rcx)
addq $0x28, %rsp
popq %rbx
popq %r14
retq