// File: /workspace/github_c_makefile_star2_O1/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
movl $0x3, %edi
callq 0xbde7
movq %rax, 0x18(%rsp)
movl $0x3, %edi
movl $0x3, %esi
callq 0xbcb0
movq %rax, %r14
movl $0x3, %edi
movl $0x3, %esi
callq 0xbcb0
movq %rax, %r12
movl $0x3, %edi
movl $0x3, %esi
callq 0xbcb0
movq %rax, %rbp
movl $0x3, %edi
movl $0x3, %esi
callq 0xbcb0
movq %rax, %r15
movq %rax, 0x28(%rsp)
movl $0x3, %edi
movl $0x3, %esi
callq 0xbcb0
movq %rax, 0x8(%rsp)
movl $0x3, %edi
movl $0x3, %esi
callq 0xbcb0
movq %rax, 0x10(%rsp)
movl $0x3, %edi
movl $0x3, %esi
callq 0xbcb0
movq %rax, 0x30(%rsp)
callq 0xb7f0
movq %rax, 0xc057(%rip)      # 0x157c0
movq %r13, %rdi
movq %rax, %rsi
callq 0xd4c1
movq 0xc045(%rip), %rdi      # 0x157c0
movl %ebx, %esi
callq 0x8998
movl %eax, %r13d
callq 0x888c
movq 0x18(%rsp), %rbx
movq %rbx, %rdi
callq 0x8ba2
movsd %xmm0, (%rsp)
movq %r14, 0x20(%rsp)
movq %r14, %rdi
movq %r12, %rsi
movq %rbp, %rdx
callq 0x8ca5
movq %r14, %rdi
movq %r12, %rsi
movq %rbp, %rdx
movsd (%rsp), %xmm0
movq %r15, %rcx
callq 0x8db7
movq %r14, %rdi
movq %r12, %rsi
movq %rbp, %rdx
movsd (%rsp), %xmm0
movq 0x8(%rsp), %r14
movq %r14, %rcx
callq 0x8f3a
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq 0x38(%rsp), %r14
movq %r14, %rcx
callq 0x9194
movq 0x10(%rsp), %r15
movq %r15, %rdi
movsd (%rsp), %xmm0
callq 0x937a
movq 0x30(%rsp), %rbx
movq %rbx, %rdi
movsd (%rsp), %xmm0
callq 0x9429
movq %r15, %rdi
movq %rbx, %rsi
movq 0x40(%rsp), %r15
movq %r15, %rdx
callq 0x95e2
movl %r13d, %edi
movq %r15, %rsi
callq 0x8b5d
movl %r13d, %edi
movq %r14, %rsi
callq 0x8b5d
movq 0xbf76(%rip), %rdi      # 0x157c0
callq 0xb82f
movq 0x18(%rsp), %rdi
callq 0xbef3
movq 0x20(%rsp), %rdi
callq 0xbe4b
movq %r12, %rdi
callq 0xbe4b
movq %rbp, %rdi
callq 0xbe4b
movq 0x28(%rsp), %rdi
callq 0xbe4b
movq 0x8(%rsp), %rdi
callq 0xbe4b
movq 0x10(%rsp), %rdi
callq 0xbe4b
movq %rbx, %rdi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xbe4b
nop