// File: /workspace/github_c_makefile_star2_O2/markpeerdeman[P]mbemm/src/emath/singular.c
// Function: rotate_element
int rotate_element( const element e, const int l )
{ /* IN:          element e, integer l
   * OUT:         the number of node rotations applied, i.e. 0, 1 or 2.
   * USES:        theElement
   * MODIFIES:    theElement
   * DESCRIPTION: The function rotates the nodes with associated data in the
   *              element structure in such a way that the singular point 
   *              coincides with node 1 of the element e.
   */
int i;  /* :temporary variabeles: */
double r;


   if (e->p1==l) 
   { /* printf("No targeting applied.\n"); */
	 return(0); /* no rotation necessary */
   }

   if (e->p2==l)
   { /* rotate once: */
	  /* printf("Rotating over one node.\n"); */
	  i=theElement->p3;
	  theElement->p3=theElement->p1; theElement->p1=theElement->p2;
	  theElement->p2=i;
	  r=theElement->alpha3;
	  theElement->alpha3=theElement->alpha1;
	  theElement->alpha1=theElement->alpha2;
	  theElement->alpha2=r;
	  r=theElement->z3;
	  theElement->z3=theElement->z1; theElement->z1=theElement->z2;
	  theElement->z2=r;
	  r=theElement->p3x;
	  theElement->p3x=theElement->p1x; theElement->p1x=theElement->p2x;
	  theElement->p2x=r;
	  r=theElement->p3y;
	  theElement->p3y=theElement->p1y; theElement->p1y=theElement->p2y;
	  theElement->p2y=r;
	  r=theElement->p3z;
	  theElement->p3z=theElement->p1z; theElement->p1z=theElement->p2z;
	  theElement->p2z=r;
	  return(1); /* after rotating once. */
   }
   if (e->p3==l)
   { /* rotate twice: */
	  /* printf("Rotating over two nodes.\n"); */
	  i=theElement->p1;
	  theElement->p1=theElement->p3; theElement->p3=theElement->p2;
	  theElement->p2=i;
	  r=theElement->alpha1;
	  theElement->alpha1=theElement->alpha3;
	  theElement->alpha3=theElement->alpha2;
	  theElement->alpha2=r;
	  r=theElement->z1;
	  theElement->z1=theElement->z3; theElement->z3=theElement->z2;
	  theElement->z2=r;
	  r=theElement->p1x;
	  theElement->p1x=theElement->p3x; theElement->p3x=theElement->p2x;
	  theElement->p2x=r;
	  r=theElement->p1y;
	  theElement->p1y=theElement->p3y; theElement->p3y=theElement->p2y;
	  theElement->p2y=r;
	  r=theElement->p1z;
	  theElement->p1z=theElement->p3z; theElement->p3z=theElement->p2z;
	  theElement->p2z=r;
	  return(2);
   }
   return(-1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
xorl %eax, %eax
cmpl %esi, 0x18(%rdi)
je 0x7cad
cmpl %esi, 0x1c(%rdi)
jne 0x7b32
movl $0x1, %eax
movabsq $0x38, %rcx
movq %rcx, -0x8(%rsp)
movabsq $0x68, %rdx
movabsq $0x30, %rsi
movabsq $0x60, %rdi
movabsq $0x28, %r8
movabsq $0x58, %r9
movl $0x88, %r10d
movl $0x98, %r11d
movabsq $0x70, %rbx
movl $0x80, %r14d
movabsq $0x18, %r15
movabsq $0x20, %r12
jmp 0x7bb0
cmpl %esi, 0x20(%rdi)
jne 0x7ca8
movl $0x2, %eax
movabsq $0x68, %rcx
movq %rcx, -0x8(%rsp)
movabsq $0x38, %rdx
movabsq $0x60, %rsi
movabsq $0x30, %rdi
movabsq $0x58, %r8
movabsq $0x28, %r9
movl $0x98, %r10d
movl $0x88, %r11d
movl $0x80, %ebx
movabsq $0x70, %r14
movabsq $0x20, %r15
movabsq $0x18, %r12
movq 0xcbf9(%rip), %r13      # 0x147b0
movl (%r13,%r12), %ebp
movl (%r13,%r15), %ecx
movl %ecx, (%r13,%r12)
movl 0x1c(%r13), %ecx
movl %ecx, (%r13,%r15)
movl %ebp, 0x1c(%r13)
movsd (%r13,%r14), %xmm0
movsd (%r13,%rbx), %xmm1
movsd %xmm1, (%r13,%r14)
movsd 0x78(%r13), %xmm1
movsd %xmm1, (%r13,%rbx)
movsd %xmm0, 0x78(%r13)
movsd (%r13,%r11), %xmm0
movsd (%r13,%r10), %xmm1
movsd %xmm1, (%r13,%r11)
movsd 0x90(%r13), %xmm1
movsd %xmm1, (%r13,%r10)
movsd %xmm0, 0x90(%r13)
movsd (%r13,%r9), %xmm0
movsd (%r13,%r8), %xmm1
movsd %xmm1, (%r13,%r9)
movsd 0x40(%r13), %xmm1
movsd %xmm1, (%r13,%r8)
movsd %xmm0, 0x40(%r13)
movsd (%r13,%rdi), %xmm0
movsd (%r13,%rsi), %xmm1
movsd %xmm1, (%r13,%rdi)
movsd 0x48(%r13), %xmm1
movsd %xmm1, (%r13,%rsi)
movsd %xmm0, 0x48(%r13)
movsd (%r13,%rdx), %xmm0
movq -0x8(%rsp), %rcx
movsd (%r13,%rcx), %xmm1
movsd %xmm1, (%r13,%rdx)
movsd 0x50(%r13), %xmm1
movsd %xmm1, (%r13,%rcx)
movsd %xmm0, 0x50(%r13)
jmp 0x7cad
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq