// File: /workspace/github_c_makefile_star2_O3/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 $0x58, %rsp
movl %ecx, %ebx
movq %rdx, 0x38(%rsp)
movq %rsi, 0x30(%rsp)
movq %rdi, (%rsp)
movl $0x3, %edi
callq 0xbb17
movq %rax, %rbp
movl $0x3, %edi
movl $0x3, %esi
callq 0xb9e0
movq %rax, %r12
movl $0x3, %edi
movl $0x3, %esi
callq 0xb9e0
movq %rax, %r14
movl $0x3, %edi
movl $0x3, %esi
callq 0xb9e0
movq %rax, %r13
movl $0x3, %edi
movl $0x3, %esi
callq 0xb9e0
movq %rax, 0x18(%rsp)
movl $0x3, %edi
movl $0x3, %esi
callq 0xb9e0
movq %rax, %r15
movl $0x3, %edi
movl $0x3, %esi
callq 0xb9e0
movq %rax, 0x20(%rsp)
movl $0x3, %edi
movl $0x3, %esi
callq 0xb9e0
movq %rax, 0x10(%rsp)
callq 0xb52c
movq %rax, 0xc1a3(%rip)      # 0x157c0
movq (%rsp), %rdi
movq %rax, %rsi
callq 0xd1d9
movq 0xc190(%rip), %rdi      # 0x157c0
movl %ebx, %esi
callq 0x885c
movl %eax, 0xc(%rsp)
callq 0x8750
movq %rbp, %rdi
callq 0x8a66
movsd %xmm0, (%rsp)
movq %r12, %rdi
movq %r14, %rbx
movq %r14, %rsi
movq %r13, %r14
movq %r13, %rdx
callq 0x8b69
movq %r12, %rdi
movq %rbx, %rsi
movq %r13, %rdx
movsd (%rsp), %xmm0
movq 0x18(%rsp), %r13
movq %r13, %rcx
callq 0x8c7b
movq %r12, 0x40(%rsp)
movq %r12, %rdi
movq %rbx, %r12
movq %rbx, %rsi
movq %r14, 0x28(%rsp)
movq %r14, %rdx
movsd (%rsp), %xmm0
movq %r15, %rcx
callq 0x8dfe
movq %r13, %rdi
movq %r15, 0x48(%rsp)
movq %r15, %rsi
movq 0x20(%rsp), %r15
movq %rbp, 0x50(%rsp)
movq %rbp, %rdx
movq 0x30(%rsp), %rbp
movq %rbp, %rcx
callq 0x9058
movq %r15, %rdi
movsd (%rsp), %xmm0
callq 0x9238
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movsd (%rsp), %xmm0
callq 0x92e7
movq %r15, %rdi
movq %rbx, %rsi
movq 0x38(%rsp), %rdx
movq %rdx, %rbx
callq 0x94ac
movl 0xc(%rsp), %eax
cmpl $0x1, %eax
je 0x9710
cmpl $0x2, %eax
jne 0x9762
movl $0x18, %eax
movl $0x8, %ecx
jmp 0x971a
movl $0x8, %eax
movl $0x18, %ecx
movq 0x8(%rbx), %rdx
movq (%rdx,%rcx), %rsi
movq 0x10(%rdx), %rdi
movq %rdi, (%rdx,%rcx)
movq 0x8(%rbx), %rdx
movq (%rdx,%rax), %rdi
movq %rdi, 0x10(%rdx)
movq 0x8(%rbx), %rdx
movq %rsi, (%rdx,%rax)
movq 0x8(%rbp), %rdx
movq (%rdx,%rcx), %rsi
movq 0x10(%rdx), %rdi
movq %rdi, (%rdx,%rcx)
movq 0x8(%rbp), %rcx
movq (%rcx,%rax), %rdx
movq %rdx, 0x10(%rcx)
movq 0x8(%rbp), %rcx
movq %rsi, (%rcx,%rax)
movq 0xc057(%rip), %rdi      # 0x157c0
callq 0xb56b
movq 0x50(%rsp), %rdi
callq 0xbc23
movq 0x40(%rsp), %rdi
callq 0xbb7b
movq %r12, %rdi
callq 0xbb7b
movq 0x28(%rsp), %rdi
callq 0xbb7b
movq 0x18(%rsp), %rdi
callq 0xbb7b
movq 0x48(%rsp), %rdi
callq 0xbb7b
movq %r15, %rdi
callq 0xbb7b
movq 0x10(%rsp), %rdi
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xbb7b