// File: /workspace/github_c_makefile_star2_O1/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 0x8b52
cmpl %esi, 0x1c(%rdi)
jne 0x8a01
movl $0x1, %eax
movl $0x38, %ecx
movq %rcx, -0x8(%rsp)
movl $0x68, %edx
movl $0x30, %esi
movl $0x60, %edi
movl $0x28, %r8d
movl $0x58, %r9d
movl $0x88, %r10d
movl $0x98, %r11d
movl $0x70, %ebx
movl $0x80, %r14d
movl $0x18, %r15d
movl $0x20, %r12d
jmp 0x8a5c
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %esi, 0x20(%rdi)
jne 0x8b52
movl $0x2, %eax
movl $0x68, %ecx
movq %rcx, -0x8(%rsp)
movl $0x38, %edx
movl $0x60, %esi
movl $0x30, %edi
movl $0x58, %r8d
movl $0x28, %r9d
movl $0x98, %r10d
movl $0x88, %r11d
movl $0x80, %ebx
movl $0x70, %r14d
movl $0x20, %r15d
movl $0x18, %r12d
movq 0xcd5d(%rip), %r13      # 0x157c0
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)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq