// File: /workspace/github_c_makefile_star2_O1/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
movl $0x3, %edi
movl $0x3, %esi
callq 0xbcb0
movq %rax, %r14
movq (%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xcf07
testq %rax, %rax
je 0x3a51
movq 0x8(%r15), %rcx
movslq 0x10(%rax), %rdx
leaq (%rdx,%rdx,2), %rdx
movsd -0x18(%rcx,%rdx,8), %xmm0
movsd %xmm0, 0x50(%rax)
movsd %xmm0, 0x38(%rax)
movsd -0x10(%rcx,%rdx,8), %xmm0
movsd %xmm0, 0x58(%rax)
movsd %xmm0, 0x40(%rax)
movsd -0x8(%rcx,%rdx,8), %xmm0
movsd %xmm0, 0x60(%rax)
movsd %xmm0, 0x48(%rax)
movl $0x13, 0x80(%rax)
movq 0x8(%rax), %rax
testq %rax, %rax
jne 0x3a06
movq (%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xcf07
testq %rax, %rax
je 0x3afc
movq %rax, %r15
movq 0x10(%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xd1d1
testq %rax, %rax
je 0x3aac
movl 0x10(%r15), %ecx
cmpl 0x14(%rax), %ecx
jne 0x3aa3
movl $0x0, 0x80(%r15)
movups 0x30(%rax), %xmm0
movups %xmm0, 0x50(%r15)
movsd 0x40(%rax), %xmm0
movsd %xmm0, 0x60(%r15)
movq 0x8(%rax), %rax
testq %rax, %rax
jne 0x3a7f
movq 0x18(%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xd1d1
testq %rax, %rax
je 0x3aef
movl 0x10(%r15), %ecx
cmpl 0x14(%rax), %ecx
jne 0x3ae6
movl $0x1, 0x80(%r15)
movups 0x18(%rax), %xmm0
movups %xmm0, 0x38(%r15)
movsd 0x28(%rax), %xmm0
movsd %xmm0, 0x48(%r15)
movq 0x8(%rax), %rax
testq %rax, %rax
jne 0x3ac2
movq 0x8(%r15), %r15
testq %r15, %r15
jne 0x3a69
movq (%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xcf07
testq %rax, %rax
je 0x3dde
movq %rax, %r15
movl $0xf, %r13d
cmpl $0xf, 0x14(%r15)
jne 0x3dd1
cmpl %ebp, 0x10(%r15)
jg 0x3dd1
movq (%rbx), %rdi
movl 0x18(%r15), %edx
movl $0x2, %esi
callq 0xcf07
movq %rax, %r12
movsd 0x38(%r15), %xmm0
xorps 0xa4d0(%rip), %xmm0     # 0xe020
movlps %xmm0, 0x38(%rax)
movsd 0x50(%rax), %xmm0
movsd %xmm0, 0x50(%r15)
xorps %xmm0, %xmm0
movups %xmm0, 0x40(%r15)
movups %xmm0, 0x40(%rax)
movl %r13d, 0x80(%r15)
movl %r13d, 0x80(%rax)
movq %r14, %rdi
movq %r15, %rsi
callq 0x7804
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)
xorps %xmm0, %xmm0
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)
xorps %xmm0, %xmm0
cvtss2sd %xmm3, %xmm0
movsd %xmm0, 0x60(%r15)
movsd 0x38(%r12), %xmm0
movsd 0x40(%r12), %xmm2
movsd 0x48(%r12), %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(%r12)
xorps %xmm0, %xmm0
cvtss2sd %xmm3, %xmm0
movsd %xmm0, 0x48(%r12)
movsd 0x50(%r12), %xmm0
movsd 0x58(%r12), %xmm2
movsd 0x60(%r12), %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(%r12)
xorps %xmm0, %xmm0
cvtss2sd %xmm3, %xmm0
movsd %xmm0, 0x60(%r12)
movq 0x8(%r15), %r15
testq %r15, %r15
jne 0x3b1a
movq (%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xcf07
testq %rax, %rax
je 0x3e1a
xorps %xmm0, %xmm0
cmpl $0x13, 0x80(%rax)
jne 0x3e11
movups %xmm0, 0x38(%rax)
movq $0x0, 0x48(%rax)
movl $0x1, 0x80(%rax)
movq 0x8(%rax), %rax
testq %rax, %rax
jne 0x3df2
movq %rbx, %rdi
callq 0x9f09
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xbe4b