// File: /workspace/github_c_makefile_star2_O3/markpeerdeman[P]mbemm/src/emath/post.c
// Function: write_distribution
void write_distribution(mesh theMesh)
{ point p;
  element e;
  int cnodes;
  int edgeels; 
  int vertexels;
  double fx, fy, fz;
  double tex, tey, tez; /* total force components on an edge element */
  double tvx, tvy, tvz;
  
  printf("Force distribution:\n");
  printf("nodelabel, x, y, z, fx, fy, fz\n");

  p=(point)point_dll(theMesh->mesh_p,START,0);
  while (p!=(point)NULL)
  { if (p->type==CNODE)
    { vertexels=0; edgeels=0;
      tex=0.0; tey=0.0; tez=0.0; tvx=0.0; tvy=0.0; tvz=0.0;
      e=(element)element_dll(theMesh->mesh_e,START,0);
      while (e!=(element)NULL)
      { if ( (e->p1==p->label)||(e->p2==p->label)||(e->p3==p->label) )
        { cnodes=cnodesonelement(e, theMesh); 
          elforce(e,&fx,&fy,&fz,theMesh);
          if (cnodes==1) { edgeels++; tex+=fx; tey+=fy; tez+=fz; }
          if (cnodes==2) { vertexels++; tvx+=fx; tvy+=fy; tvz+=fz; }
          if (cnodes==3) printf("Three contact nodes on an element?\n");
        }
        e=e->NEXT;
      }
      tvx+=0.5*tex; tvy+=0.5*tey; tvz+=0.5*tez;
      printf("%d % 8.8E % 8.8E % 8.8E % 8.8E %8.8E % 8.8E\n",
			  p->label,p->x, p->y, p->z ,tvx,tvy,tvz);
    }
    p=p->NEXT;
  }

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
leaq 0x9edf(%rip), %rdi      # 0xebaf
callq 0x1060
leaq 0x9ee7(%rip), %rdi      # 0xebc3
callq 0x1060
movq (%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xcc2f
testq %rax, %rax
je 0x4eb6
movq %rax, %r14
leaq 0x38(%rsp), %r13
leaq 0x30(%rsp), %rbp
cmpl $0xf, 0x14(%r14)
jne 0x4ea9
movq 0x8(%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xb570
testq %rax, %rax
je 0x4e27
movq %rax, %r15
xorpd %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
movsd %xmm0, 0x8(%rsp)
movsd %xmm0, (%rsp)
movsd %xmm0, 0x28(%rsp)
movsd %xmm0, 0x20(%rsp)
movsd %xmm0, 0x18(%rsp)
movl 0x10(%r14), %eax
cmpl %eax, 0x18(%r15)
je 0x4d68
cmpl %eax, 0x1c(%r15)
je 0x4d68
cmpl %eax, 0x20(%r15)
jne 0x4e18
movq %r15, %rdi
movq %rbx, %rsi
callq 0x49b6
movl %eax, %r12d
movq %r15, %rdi
leaq 0x40(%rsp), %rsi
movq %r13, %rdx
movq %rbp, %rcx
movq %rbx, %r8
callq 0x4a86
cmpl $0x3, %r12d
je 0x4e0c
cmpl $0x2, %r12d
je 0x4dd6
cmpl $0x1, %r12d
jne 0x4e18
movsd 0x18(%rsp), %xmm0
addsd 0x40(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x20(%rsp), %xmm0
addsd 0x38(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x28(%rsp), %xmm0
addsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
jmp 0x4e18
movsd (%rsp), %xmm0
addsd 0x40(%rsp), %xmm0
movsd %xmm0, (%rsp)
movsd 0x8(%rsp), %xmm0
addsd 0x38(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x10(%rsp), %xmm0
addsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
jmp 0x4e18
leaq 0x9dcf(%rip), %rdi      # 0xebe2
callq 0x1060
movq 0x8(%r15), %r15
testq %r15, %r15
jne 0x4d4e
jmp 0x4e4e
xorpd %xmm0, %xmm0
movsd %xmm0, 0x18(%rsp)
movsd %xmm0, 0x20(%rsp)
movsd %xmm0, 0x28(%rsp)
movsd %xmm0, (%rsp)
movsd %xmm0, 0x8(%rsp)
movsd %xmm0, 0x10(%rsp)
movsd 0x960a(%rip), %xmm0     # 0xe460
movsd 0x18(%rsp), %xmm3
mulsd %xmm0, %xmm3
addsd (%rsp), %xmm3
movsd 0x20(%rsp), %xmm4
mulsd %xmm0, %xmm4
addsd 0x8(%rsp), %xmm4
movsd 0x28(%rsp), %xmm5
mulsd %xmm0, %xmm5
addsd 0x10(%rsp), %xmm5
movl 0x10(%r14), %esi
movsd 0x20(%r14), %xmm0
movsd 0x28(%r14), %xmm1
movsd 0x30(%r14), %xmm2
leaq 0x96fc(%rip), %rdi      # 0xe59e
movb $0x6, %al
callq 0x1090
movq 0x8(%r14), %r14
testq %r14, %r14
jne 0x4d03
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq