// File: /workspace/github_c_makefile_star2_O2/markpeerdeman[P]mbemm/src/emath/post.c
// Function: write_contact_force
void write_contact_force(mesh theMesh)
{ point p;
  element e;
  double t1x, t1y, t1z, t2x, t2y, t2z, t3x, t3y, t3z;
  double fx, fy, fz;
  double fxt, fyt, fzt;
  double midx, midy, midz;
  int cnodes;
  /* double force1, force2; */

  printf("\n{---------------------------------------------------------------}\n");
  printf("{ POST output of the contact element forces.\n");
  printf("  format:\n");
  printf("  element_label force_x force_y force_z elementarea midx midy midz cnodes\n");
  printf("}\n");
  printf("contact_element_forces\n");
  fxt=0.0; fyt=0.0; fzt=0.0;
  midx=0.0; midy=0.0; midz=0.0;

  /* the calculated tractions: */
  e = (element)element_dll(theMesh->mesh_e,START,0);
  while (e!=(element)NULL)
  { cnodes=0; 
    /* get the traction forces at the three nodes of the element: */ 
	/* NODE 1: */
	p=(point)point_dll(theMesh->mesh_p,SEARCH,e->p1);
        if (p->type==CNODE) cnodes++;
	t1x=p->fx; t1y=p->fy; t1z=p->fz;
	midx=p->x; midy=p->y; midz=p->z;
	/* NODE 2: */
	p=(point)point_dll(theMesh->mesh_p,SEARCH,e->p2);
        if (p->type==CNODE) cnodes++;
	t2x=p->fx; t2y=p->fy; t2z=p->fz;
	midx+=p->x; midy+=p->y; midz+=p->z;
	/* NODE 3: */
	p=(point)point_dll(theMesh->mesh_p,SEARCH,e->p3);
        if (p->type==CNODE) cnodes++;
	t3x=p->fx; t3y=p->fy; t3z=p->fz;
	midx+=p->x; midy+=p->y; midz+=p->z;
  
	fx= 1.0/3.0*(t1x+t2x+t3x)*e->area*theMesh->G_SCALE;
	fy= 1.0/3.0*(t1y+t2y+t3y)*e->area*theMesh->G_SCALE;
	fz= 1.0/3.0*(t1z+t2z+t3z)*e->area*theMesh->G_SCALE;
	midx/=3.0; midy/=3.0; midz/=3.0;
	fxt+=fx; fyt+=fy; fzt+=fz;
        if (cnodes>0)
	printf("%4d % 8.8E % 8.8E % 8.8E % 8.8E % 8.8E % 8.8E % 8.8E %d \n", e->label,fx,fy,fz,e->area,midx, midy, midz,cnodes);
	e=e->NEXT;
  }

  printf("end_contact_element_forces\n");

  printf("\n{---------------------------------------------------------------}\n");
  printf("{ POST output of the resulting force vector.\n");
  printf(" Force: %5.8E %5.8E %5.8E\n",fxt,fyt,fzt);
  printf(" Modulus: %5.8E\n",sqrt((double)(fxt*fxt+fyt*fyt+fzt*fzt)));

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdi, %rbx
leaq 0xadc9(%rip), %rdi      # 0xdad4
callq 0x1060
leaq 0xac94(%rip), %rdi      # 0xd9ab
callq 0x1060
leaq 0xae21(%rip), %rdi      # 0xdb44
callq 0x1060
leaq 0xaca9(%rip), %rdi      # 0xd9d8
callq 0x1060
leaq 0xadda(%rip), %rdi      # 0xdb15
callq 0x1060
leaq 0xacdf(%rip), %rdi      # 0xda26
callq 0x1060
movq 0x8(%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xad45
movq %rax, %r14
xorpd %xmm0, %xmm0
movapd %xmm0, 0x30(%rsp)
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
pushq $0x2
popq %rbp
leaq 0xa795(%rip), %r15      # 0xd50f
testq %r14, %r14
je 0x2f3c
movq (%rbx), %rdi
movl 0x18(%r14), %edx
movl %ebp, %esi
callq 0xc14c
xorl %r13d, %r13d
cmpl $0xf, 0x14(%rax)
sete %r13b
movsd 0x48(%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x20(%rax), %xmm0
movsd %xmm0, 0x60(%rsp)
movsd 0x28(%rax), %xmm0
movsd %xmm0, 0x68(%rsp)
movsd 0x30(%rax), %xmm0
movsd %xmm0, 0x70(%rsp)
movq (%rbx), %rdi
movl 0x1c(%r14), %edx
leal 0x1(%r13), %r12d
movups 0x38(%rax), %xmm0
movaps %xmm0, 0x20(%rsp)
movl %ebp, %esi
callq 0xc14c
cmpl $0xf, 0x14(%rax)
cmovnel %r13d, %r12d
movupd 0x38(%rax), %xmm0
addpd 0x20(%rsp), %xmm0
movapd %xmm0, 0x20(%rsp)
movsd 0x20(%rax), %xmm0
movsd %xmm0, 0x58(%rsp)
movsd 0x28(%rax), %xmm0
movsd %xmm0, 0x50(%rsp)
movsd 0x30(%rax), %xmm0
movsd %xmm0, 0x48(%rsp)
movq (%rbx), %rdi
movl 0x20(%r14), %edx
movsd 0x10(%rsp), %xmm0
addsd 0x48(%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
movl %ebp, %esi
callq 0xc14c
movsd 0x10(%rsp), %xmm2
xorl %edx, %edx
cmpl $0xf, 0x14(%rax)
sete %dl
movupd 0x38(%rax), %xmm0
addpd 0x20(%rsp), %xmm0
movsd 0xb8(%r14), %xmm3
movsd 0x30(%rbx), %xmm7
mulpd 0xa5c4(%rip), %xmm0     # 0xd430
movapd %xmm3, %xmm4
unpcklpd %xmm3, %xmm4            # xmm4 = xmm4[0],xmm3[0]
addsd 0x48(%rax), %xmm2
mulpd %xmm0, %xmm4
mulsd 0xa5cb(%rip), %xmm2     # 0xd450
mulsd %xmm3, %xmm2
mulsd %xmm7, %xmm2
unpcklpd %xmm7, %xmm7            # xmm7 = xmm7[0,0]
mulpd %xmm4, %xmm7
addl %r12d, %edx
je 0x2f13
movsd 0x70(%rsp), %xmm6
addsd 0x48(%rsp), %xmm6
movsd 0x68(%rsp), %xmm5
addsd 0x50(%rsp), %xmm5
movsd 0x60(%rsp), %xmm4
addsd 0x58(%rsp), %xmm4
addsd 0x30(%rax), %xmm6
addsd 0x28(%rax), %xmm5
movsd 0xa588(%rip), %xmm0     # 0xd458
divsd %xmm0, %xmm6
divsd %xmm0, %xmm5
addsd 0x20(%rax), %xmm4
divsd %xmm0, %xmm4
movl 0x14(%r14), %esi
movapd %xmm7, %xmm1
unpckhpd %xmm7, %xmm1            # xmm1 = xmm1[1],xmm7[1]
movq %r15, %rdi
movapd %xmm7, %xmm0
movsd %xmm2, 0x10(%rsp)
movb $0x7, %al
movapd %xmm7, 0x20(%rsp)
callq 0x1090
movapd 0x20(%rsp), %xmm7
movsd 0x10(%rsp), %xmm2
movapd 0x30(%rsp), %xmm0
addpd %xmm7, %xmm0
movapd %xmm0, 0x30(%rsp)
movsd 0x8(%rsp), %xmm0
addsd %xmm2, %xmm0
movsd %xmm0, 0x8(%rsp)
movq 0x8(%r14), %r14
jmp 0x2d7a
leaq 0xaadf(%rip), %rdi      # 0xda22
callq 0x1060
leaq 0xab85(%rip), %rdi      # 0xdad4
callq 0x1060
leaq 0xab4c(%rip), %rdi      # 0xdaa7
callq 0x1060
movaps 0x30(%rsp), %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
movaps %xmm1, 0x10(%rsp)
leaq 0xa56b(%rip), %rdi      # 0xd4e3
movsd 0x8(%rsp), %xmm2
movb $0x3, %al
callq 0x1090
movapd 0x10(%rsp), %xmm1
mulsd %xmm1, %xmm1
movapd 0x30(%rsp), %xmm0
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
movsd 0x8(%rsp), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm0, %xmm1
sqrtsd %xmm1, %xmm0
leaq 0xa548(%rip), %rdi      # 0xd4fe
movb $0x1, %al
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1090