// File: /workspace/github_c_makefile_star2_O2/markpeerdeman[P]mbemm/src/emath/post.c
// Function: init_post
void init_post(vector f,mesh theMesh,int nr_of_nodes_body_1)
{ point p;
  point q;
  restraint r;
  matrix tramat;
  float c1, c2, c3;

  tramat=(matrix)newmatrix(3,3);

  /* STEP ONE: copy the solution vector into the point dll: */
  p=(point)point_dll(theMesh->mesh_p,START,0);
  while (p!=(point)NULL)
  { p->dx=V(f,p->label*3-2); p->fx=p->dx;
    p->dy=V(f,p->label*3-1); p->fy=p->dy;
    p->dz=V(f,p->label*3);   p->fz=p->dz;
    p->calculated = NONE;
    p=p->NEXT;
  }

  /* STEP TWO: copy the prescribed BC's into the point dll: */
  p=(point)point_dll(theMesh->mesh_p,START,0);
  while (p!=(point)NULL)
  { /* Look if there is a displacement connected to the node: */
	r=(restraint)restraint_dll(theMesh->mesh_d,START,0);
	while (r!=(restraint)NULL)
	{ if (p->label==r->label)
	  { p->calculated=TRACTION;
	    p->dx=r->u1;
	    p->dy=r->u2;
	    p->dz=r->u3;
	  }
	r=r->NEXT;
	}
	/* Look if there is a traction connected to the node: */
	r=(restraint)restraint_dll(theMesh->mesh_t,START,0);
	while (r!=(restraint)NULL)
	{ if (p->label==r->label)
	  { p->calculated=DISPLACEMENT;
	    p->fx=r->f1;
	    p->fy=r->f2;
	    p->fz=r->f3;
	  }
	r=r->NEXT;
	}
  p=p->NEXT;
  }

  /* STEP FOUR: transform the contact nodes back from their local systems to
                their global system of coordinates: */
  p=(point)point_dll(theMesh->mesh_p,START,0);
  while (p!=(point)NULL)
  { if ((p->type==CNODE)&&(p->label<=nr_of_nodes_body_1))
    { /* find the connected node on body 2: */ 
      q=(point)point_dll(theMesh->mesh_p,SEARCH,p->conn); 
      q->fx = -(p->fx);
      p->dx=q->dx;

      p->fy=0.0; p->fz=0.0; q->fy=0.0; q->fz=0.0;

      p->calculated=CNODE;
      q->calculated=CNODE;

      /* make the backtransformation matrix: */
      makelocalsystem(tramat,p);
      /* transform back: */
      c1=M(tramat,1,1)*p->fx+M(tramat,1,2)*p->fy+M(tramat,1,3)*p->fz;
      c2=M(tramat,2,1)*p->fx+M(tramat,2,2)*p->fy+M(tramat,2,3)*p->fz;
      c3=M(tramat,3,1)*p->fx+M(tramat,3,2)*p->fy+M(tramat,3,3)*p->fz;
      p->fx=c1; p->fy=c2; p->fz=c3;  
      c1=M(tramat,1,1)*p->dx+M(tramat,1,2)*p->dy+M(tramat,1,3)*p->dz;
      c2=M(tramat,2,1)*p->dx+M(tramat,2,2)*p->dy+M(tramat,2,3)*p->dz;
      c3=M(tramat,3,1)*p->dx+M(tramat,3,2)*p->dy+M(tramat,3,3)*p->dz;
      p->dx=c1; p->dy=c2; p->dz=c3;  
      c1=M(tramat,1,1)*q->fx+M(tramat,1,2)*q->fy+M(tramat,1,3)*q->fz;
      c2=M(tramat,2,1)*q->fx+M(tramat,2,2)*q->fy+M(tramat,2,3)*q->fz;
      c3=M(tramat,3,1)*q->fx+M(tramat,3,2)*q->fy+M(tramat,3,3)*q->fz;
      q->fx=c1; q->fy=c2; q->fz=c3; 
      c1=M(tramat,1,1)*q->dx+M(tramat,1,2)*q->dy+M(tramat,1,3)*q->dz;
      c2=M(tramat,2,1)*q->dx+M(tramat,2,2)*q->dy+M(tramat,2,3)*q->dz;
      c3=M(tramat,3,1)*q->dx+M(tramat,3,2)*q->dy+M(tramat,3,3)*q->dz;
      q->dx=c1; q->dy=c2; q->dz=c3; 
    }
    p=p->NEXT;
  }

  /* STEP FIVE: Look if there are any free nodes left: */
  p=(point)point_dll(theMesh->mesh_p,START,0);
  while (p!=(point)NULL)
  { if (p->calculated==NONE)
    { p->fx=0.0;
      p->fy=0.0;
      p->fz=0.0;
      p->calculated=DISPLACEMENT;
    }
  p=p->NEXT;
  } 


  /* All nodal results data is now copied into the point_dll */
  /* scaling_back: */
  scalesystemback(theMesh);

  /* NOTE: Not the element parameters are scaled back, only the results in the 
   * point_dll. All element parameters have to be scaled manually! */


  delmatrix(tramat);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, %r15
pushq $0x3
popq %rdi
movl %edi, %esi
callq 0xb24c
movq %rax, %r14
movq (%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xc14c
testq %rax, %rax
je 0x24b1
movq 0x8(%r15), %rcx
movslq 0x10(%rax), %rdx
imulq $0x18, %rdx, %rdx
movsd -0x18(%rcx,%rdx), %xmm0
movsd %xmm0, 0x50(%rax)
movsd %xmm0, 0x38(%rax)
movsd -0x10(%rcx,%rdx), %xmm0
movsd %xmm0, 0x58(%rax)
movsd %xmm0, 0x40(%rax)
movsd -0x8(%rcx,%rdx), %xmm0
movsd %xmm0, 0x60(%rax)
movsd %xmm0, 0x48(%rax)
movl $0x13, 0x80(%rax)
movq 0x8(%rax), %rax
jmp 0x2460
movq (%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xc14c
movq %rax, %r15
testq %r15, %r15
je 0x254f
movq 0x10(%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xc3a0
testq %rax, %rax
je 0x2506
movl 0x10(%r15), %ecx
cmpl 0x14(%rax), %ecx
jne 0x2500
andl $0x0, 0x80(%r15)
movups 0x30(%rax), %xmm0
movups %xmm0, 0x50(%r15)
movsd 0x40(%rax), %xmm0
movsd %xmm0, 0x60(%r15)
movq 0x8(%rax), %rax
jmp 0x24d6
movq 0x18(%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xc3a0
testq %rax, %rax
je 0x2546
movl 0x10(%r15), %ecx
cmpl 0x14(%rax), %ecx
jne 0x2540
movl $0x1, 0x80(%r15)
movups 0x18(%rax), %xmm0
movups %xmm0, 0x38(%r15)
movsd 0x28(%rax), %xmm0
movsd %xmm0, 0x48(%r15)
movq 0x8(%rax), %rax
jmp 0x2513
movq 0x8(%r15), %r15
jmp 0x24c0
movq (%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xc14c
movq %rax, %r15
pushq $0xf
popq %r12
testq %r15, %r15
je 0x2813
cmpl $0xf, 0x14(%r15)
jne 0x280a
cmpl %ebp, 0x10(%r15)
jg 0x280a
movq (%rbx), %rdi
movl 0x18(%r15), %edx
pushq $0x2
popq %rsi
callq 0xc14c
movq %rax, %r13
movsd 0x38(%r15), %xmm0
xorps 0xaa81(%rip), %xmm0     # 0xd020
movlps %xmm0, 0x38(%rax)
movsd 0x50(%rax), %xmm0
movsd %xmm0, 0x50(%r15)
xorps %xmm0, %xmm0
movups %xmm0, 0x40(%r15)
movups %xmm0, 0x40(%rax)
movl %r12d, 0x80(%r15)
movl %r12d, 0x80(%rax)
movq %r14, %rdi
movq %r15, %rsi
callq 0x680e
movq 0x8(%r14), %rcx
movsd 0x38(%r15), %xmm0
movsd 0x40(%r15), %xmm2
movsd 0x48(%r15), %xmm1
movq (%rcx), %rax
movq 0x10(%rcx), %rdx
movsd 0x8(%rdx), %xmm3
mulsd %xmm2, %xmm3
movsd (%rdx), %xmm4
mulsd %xmm0, %xmm4
addsd %xmm3, %xmm4
movsd 0x10(%rdx), %xmm3
mulsd %xmm1, %xmm3
addsd %xmm4, %xmm3
cvtsd2ss %xmm3, %xmm3
movq 0x8(%rcx), %rcx
unpcklpd %xmm2, %xmm2            # xmm2 = xmm2[0,0]
movsd (%rax), %xmm4
movsd 0x8(%rax), %xmm5
movsd 0x10(%rax), %xmm6
movhpd 0x8(%rcx), %xmm5        # xmm5 = xmm5[0],mem[0]
mulpd %xmm2, %xmm5
movhpd (%rcx), %xmm4           # xmm4 = xmm4[0],mem[0]
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
mulpd %xmm4, %xmm0
addpd %xmm5, %xmm0
movhpd 0x10(%rcx), %xmm6       # xmm6 = xmm6[0],mem[0]
unpcklpd %xmm1, %xmm1            # xmm1 = xmm1[0,0]
mulpd %xmm6, %xmm1
addpd %xmm0, %xmm1
cvtpd2ps %xmm1, %xmm0
cvtps2pd %xmm0, %xmm0
movups %xmm0, 0x38(%r15)
cvtss2sd %xmm3, %xmm0
movsd %xmm0, 0x48(%r15)
movsd 0x50(%r15), %xmm0
movsd 0x58(%r15), %xmm2
movsd 0x60(%r15), %xmm1
movsd 0x8(%rdx), %xmm3
mulsd %xmm2, %xmm3
movsd (%rdx), %xmm4
mulsd %xmm0, %xmm4
addsd %xmm3, %xmm4
movsd 0x10(%rdx), %xmm3
mulsd %xmm1, %xmm3
addsd %xmm4, %xmm3
cvtsd2ss %xmm3, %xmm3
unpcklpd %xmm2, %xmm2            # xmm2 = xmm2[0,0]
movsd (%rax), %xmm4
movsd 0x8(%rax), %xmm5
movhpd 0x8(%rcx), %xmm5        # xmm5 = xmm5[0],mem[0]
movsd 0x10(%rax), %xmm6
mulpd %xmm2, %xmm5
movhpd (%rcx), %xmm4           # xmm4 = xmm4[0],mem[0]
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
mulpd %xmm4, %xmm0
movhpd 0x10(%rcx), %xmm6       # xmm6 = xmm6[0],mem[0]
addpd %xmm5, %xmm0
unpcklpd %xmm1, %xmm1            # xmm1 = xmm1[0,0]
mulpd %xmm6, %xmm1
addpd %xmm0, %xmm1
cvtpd2ps %xmm1, %xmm0
cvtps2pd %xmm0, %xmm0
movups %xmm0, 0x50(%r15)
cvtss2sd %xmm3, %xmm0
movsd %xmm0, 0x60(%r15)
movsd 0x38(%r13), %xmm0
movsd 0x40(%r13), %xmm2
movsd 0x48(%r13), %xmm1
movsd 0x8(%rdx), %xmm3
mulsd %xmm2, %xmm3
movsd (%rdx), %xmm4
mulsd %xmm0, %xmm4
addsd %xmm3, %xmm4
movsd 0x10(%rdx), %xmm3
mulsd %xmm1, %xmm3
addsd %xmm4, %xmm3
cvtsd2ss %xmm3, %xmm3
unpcklpd %xmm2, %xmm2            # xmm2 = xmm2[0,0]
movsd (%rax), %xmm4
movsd 0x8(%rax), %xmm5
movsd 0x10(%rax), %xmm6
movhpd 0x8(%rcx), %xmm5        # xmm5 = xmm5[0],mem[0]
mulpd %xmm2, %xmm5
movhpd (%rcx), %xmm4           # xmm4 = xmm4[0],mem[0]
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
mulpd %xmm4, %xmm0
addpd %xmm5, %xmm0
movhpd 0x10(%rcx), %xmm6       # xmm6 = xmm6[0],mem[0]
unpcklpd %xmm1, %xmm1            # xmm1 = xmm1[0,0]
mulpd %xmm6, %xmm1
addpd %xmm0, %xmm1
cvtpd2ps %xmm1, %xmm0
cvtps2pd %xmm0, %xmm0
movups %xmm0, 0x38(%r13)
cvtss2sd %xmm3, %xmm0
movsd %xmm0, 0x48(%r13)
movsd 0x50(%r13), %xmm0
movsd 0x58(%r13), %xmm2
movsd 0x60(%r13), %xmm1
movsd 0x8(%rdx), %xmm3
mulsd %xmm2, %xmm3
movsd (%rdx), %xmm4
mulsd %xmm0, %xmm4
addsd %xmm3, %xmm4
movsd 0x10(%rdx), %xmm3
mulsd %xmm1, %xmm3
addsd %xmm4, %xmm3
cvtsd2ss %xmm3, %xmm3
unpcklpd %xmm2, %xmm2            # xmm2 = xmm2[0,0]
movsd (%rax), %xmm4
movsd 0x8(%rax), %xmm5
movhpd 0x8(%rcx), %xmm5        # xmm5 = xmm5[0],mem[0]
movsd 0x10(%rax), %xmm6
mulpd %xmm2, %xmm5
movhpd (%rcx), %xmm4           # xmm4 = xmm4[0],mem[0]
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
mulpd %xmm4, %xmm0
movhpd 0x10(%rcx), %xmm6       # xmm6 = xmm6[0],mem[0]
addpd %xmm5, %xmm0
unpcklpd %xmm1, %xmm1            # xmm1 = xmm1[0,0]
mulpd %xmm6, %xmm1
addpd %xmm0, %xmm1
cvtpd2ps %xmm1, %xmm0
cvtps2pd %xmm0, %xmm0
movups %xmm0, 0x50(%r13)
cvtss2sd %xmm3, %xmm0
movsd %xmm0, 0x60(%r13)
movq 0x8(%r15), %r15
jmp 0x2562
movq (%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xc14c
xorps %xmm0, %xmm0
testq %rax, %rax
je 0x2849
cmpl $0x13, 0x80(%rax)
jne 0x2843
movups %xmm0, 0x38(%rax)
andq $0x0, 0x48(%rax)
movl $0x1, 0x80(%rax)
movq 0x8(%rax), %rax
jmp 0x2822
movq %rbx, %rdi
callq 0x9154
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xb3b2