// File: /workspace/github_c_makefile_star2_O1/markpeerdeman[P]mbemm/src/emath/post.c
// Function: write_force
void write_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 force1, force2; */

  printf("\n{---------------------------------------------------------------}\n");
  printf("{ POST output of the elemental forces.\n");
  printf("  format:\n");
  printf("  element_label force_x force_y force_z\n");
  printf("}\n");
  printf("element_forces\n");
  fxt=0.0; fyt=0.0; fzt=0.0;

  /* the calculated tractions: */
  e = (element)element_dll(theMesh->mesh_e,START,0);
  while (e!=(element)NULL)
  {  
    /* get the traction forces at the three nodes of the element: */ 
	/* NODE 1: */
	p=(point)point_dll(theMesh->mesh_p,SEARCH,e->p1);
	t1x=p->fx; t1y=p->fy; t1z=p->fz;
	/* NODE 2: */
	p=(point)point_dll(theMesh->mesh_p,SEARCH,e->p2);
	t2x=p->fx; t2y=p->fy; t2z=p->fz;
	/* NODE 3: */
	p=(point)point_dll(theMesh->mesh_p,SEARCH,e->p3);
	t3x=p->fx; t3y=p->fy; t3z=p->fz;
  
	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;
	fxt+=fx; fyt+=fy; fzt+=fz;
	printf("%4d % 8.8E % 8.8E % 8.8E\n", e->label,fx,fy,fz);
	e=e->NEXT;
  }

  printf("end_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 %r15
pushq %r14
pushq %rbx
subq $0x40, %rsp
movq %rdi, %rbx
leaq 0xa9f7(%rip), %rdi      # 0xead4
callq 0x1060
leaq 0xa888(%rip), %rdi      # 0xe971
callq 0x1060
leaq 0xaa4f(%rip), %rdi      # 0xeb44
callq 0x1060
leaq 0xa966(%rip), %rdi      # 0xea67
callq 0x1060
leaq 0xaa08(%rip), %rdi      # 0xeb15
callq 0x1060
leaq 0xa883(%rip), %rdi      # 0xe99c
callq 0x1060
movq 0x8(%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xb834
testq %rax, %rax
je 0x4250
movq %rax, %r14
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
leaq 0xa377(%rip), %r15      # 0xe4c9
movq (%rbx), %rdi
movl 0x18(%r14), %edx
movl $0x2, %esi
callq 0xcf07
movsd 0x48(%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movq (%rbx), %rdi
movl 0x1c(%r14), %edx
movups 0x38(%rax), %xmm0
movaps %xmm0, 0x30(%rsp)
movl $0x2, %esi
callq 0xcf07
movupd 0x38(%rax), %xmm0
addpd 0x30(%rsp), %xmm0
movapd %xmm0, 0x30(%rsp)
movq (%rbx), %rdi
movl 0x20(%r14), %edx
movsd 0x20(%rsp), %xmm0
addsd 0x48(%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movl $0x2, %esi
callq 0xcf07
movupd 0x38(%rax), %xmm0
addpd 0x30(%rsp), %xmm0
movsd 0xb8(%r14), %xmm1
movsd 0x30(%rbx), %xmm3
mulpd 0xa254(%rip), %xmm0     # 0xe430
movsd 0x20(%rsp), %xmm2
addsd 0x48(%rax), %xmm2
mulsd 0xa261(%rip), %xmm2     # 0xe450
mulsd %xmm1, %xmm2
unpcklpd %xmm1, %xmm1            # xmm1 = xmm1[0,0]
mulpd %xmm0, %xmm1
mulsd %xmm3, %xmm2
movapd %xmm3, %xmm0
unpcklpd %xmm3, %xmm0            # xmm0 = xmm0[0],xmm3[0]
mulpd %xmm1, %xmm0
movapd 0x10(%rsp), %xmm1
addpd %xmm0, %xmm1
movapd %xmm1, 0x10(%rsp)
movsd 0x8(%rsp), %xmm1
addsd %xmm2, %xmm1
movsd %xmm1, 0x8(%rsp)
movl 0x14(%r14), %esi
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
movq %r15, %rdi
movb $0x3, %al
callq 0x1090
movq 0x8(%r14), %r14
testq %r14, %r14
jne 0x4152
jmp 0x4264
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
leaq 0xa72d(%rip), %rdi      # 0xe998
callq 0x1060
leaq 0xa85d(%rip), %rdi      # 0xead4
callq 0x1060
leaq 0xa824(%rip), %rdi      # 0xeaa7
callq 0x1060
movaps 0x10(%rsp), %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
movaps %xmm1, 0x20(%rsp)
leaq 0xa243(%rip), %rdi      # 0xe4e3
movsd 0x8(%rsp), %xmm2
movb $0x3, %al
callq 0x1090
movsd 0x8(%rsp), %xmm0
movapd 0x20(%rsp), %xmm2
mulsd %xmm2, %xmm2
movapd 0x10(%rsp), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm2, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
ucomisd 0xa17d(%rip), %xmm0     # 0xe458
jb 0x42e3
sqrtsd %xmm0, %xmm0
jmp 0x42e8
callq 0x11b0
leaq 0xa20f(%rip), %rdi      # 0xe4fe
movb $0x1, %al
addq $0x40, %rsp
popq %rbx
popq %r14
popq %r15
jmp 0x1090