// File: /workspace/github_c_makefile_star2_O2/markpeerdeman[P]mbemm/src/emath/singular.c
// Function: sing_int
void sing_int( const element El, const hypermatrix C, const hypermatrix E,
			   const int sourcelabel )
{ /* IN:          the element El, matrices C, E and integer sourcelabel
   * OUT:         nothing
   * USES:        theElement
   * MODIFIES:    matrices C and E
   * DESCRIPTION: This function is the entry point of this module. The kernel-
   *			  shape function products are integrated in the case when the
   *			  sourcenode P (identified by 'sourcelabel') is a part
   *			  of the element El. The hypermatrices C and E are filled. The 
   *			  Finite part integrals are all calculated analytically. For 
   *              the field nodes are chosen the nodes of the elements under
   *              consideration.
   */

double beta;
int nr_of_rotations;
vector v = (vector)newvector(3);
matrix p = (matrix)newmatrix(3,3); matrix q = (matrix)newmatrix(3,3);
matrix r = (matrix)newmatrix(3,3); matrix A = (matrix)newmatrix(3,3);
matrix B = (matrix)newmatrix(3,3); matrix D = (matrix)newmatrix(3,3);
matrix S = (matrix)newmatrix(3,3);

     theElement = (element)newelement();

  /* first make a copy of the element El in the element theElement: */
     TRILcopy(El,theElement);

  /* rotate theElement so that the singular point coincidences with node 1: */
	 nr_of_rotations = rotate_element(theElement,sourcelabel);

  /* initialize this module: */
	 init_singular();

  /* calculate the E and C matrices: */
     beta = make_v(v);
	 make_p_q_r(p,q,r);
	 make_A(p,q,r,beta,A);
	 make_B(p,q,r,beta,B);
	 make_C(A,B,v,C);
	 make_D(D,beta);
	 make_S(S,beta);
	 make_E(D,S,E); 
 
  /* rotate the results back so they apply to the original element: */
	 rotate_hypermatrix(nr_of_rotations,E);
	 rotate_hypermatrix(nr_of_rotations,C);

  /* cleanup: */
	 delelement(theElement); delvector(v);
     delmatrix(p); delmatrix(q); delmatrix(r); delmatrix(A);
     delmatrix(B); delmatrix(D); delmatrix(S); 

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %ecx, %ebx
movq %rdx, 0x40(%rsp)
movq %rsi, 0x38(%rsp)
movq %rdi, %r13
pushq $0x3
popq %r14
movl %r14d, %edi
callq 0xb358
movq %rax, 0x20(%rsp)
movl %r14d, %edi
movl %r14d, %esi
callq 0xb24c
movq %rax, %r15
movl %r14d, %edi
movl %r14d, %esi
callq 0xb24c
movq %rax, %r12
movl %r14d, %edi
movl %r14d, %esi
callq 0xb24c
movq %rax, %rbp
movl %r14d, %edi
movl %r14d, %esi
callq 0xb24c
movq %rax, 0x8(%rsp)
movl %r14d, %edi
movl %r14d, %esi
callq 0xb24c
movq %rax, 0x10(%rsp)
movl %r14d, %edi
movl %r14d, %esi
callq 0xb24c
movq %rax, 0x18(%rsp)
movl %r14d, %edi
movl %r14d, %esi
callq 0xb24c
movq %rax, 0x30(%rsp)
callq 0xad08
movq %rax, 0xbf02(%rip)      # 0x147b0
movq %r13, %rdi
movq %rax, %rsi
callq 0xc665
movq 0xbef0(%rip), %rdi      # 0x147b0
movl %ebx, %esi
callq 0x7aa0
movl %eax, %r13d
callq 0x7994
movq 0x20(%rsp), %rbx
movq %rbx, %rdi
callq 0x7cf4
movsd %xmm0, (%rsp)
movq %r15, 0x28(%rsp)
movq %r15, %rdi
movq %r12, %rsi
movq %rbp, %rdx
callq 0x7df7
movq %r15, %rdi
movq %r12, %rsi
movq %rbp, %rdx
movsd (%rsp), %xmm0
movq 0x8(%rsp), %r14
movq %r14, %rcx
callq 0x7f15
movq %r15, %rdi
movq %r12, %rsi
movq %rbp, %rdx
movsd (%rsp), %xmm0
movq 0x10(%rsp), %r15
movq %r15, %rcx
callq 0x8098
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movq 0x38(%rsp), %r14
movq %r14, %rcx
callq 0x82ea
movq 0x18(%rsp), %r15
movq %r15, %rdi
movsd (%rsp), %xmm0
callq 0x84d8
movq 0x30(%rsp), %rbx
movq %rbx, %rdi
movsd (%rsp), %xmm0
callq 0x8588
movq %r15, %rdi
movq %rbx, %rsi
movq 0x40(%rsp), %r15
movq %r15, %rdx
callq 0x873c
movl %r13d, %edi
movq %r15, %rsi
callq 0x7cb8
movl %r13d, %edi
movq %r14, %rsi
callq 0x7cb8
movq 0xbe1c(%rip), %rdi      # 0x147b0
callq 0xad40
movq 0x20(%rsp), %rdi
callq 0xb43d
movq 0x28(%rsp), %rdi
callq 0xb3b2
movq %r12, %rdi
callq 0xb3b2
movq %rbp, %rdi
callq 0xb3b2
movq 0x8(%rsp), %rdi
callq 0xb3b2
movq 0x10(%rsp), %rdi
callq 0xb3b2
movq 0x18(%rsp), %rdi
callq 0xb3b2
movq %rbx, %rdi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xb3b2
nopl (%rax)