// File: /workspace/github_c_makefile_star2_O1/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 0x9ec5(%rip), %rdi      # 0xebaf
callq 0x1060
leaq 0x9ecd(%rip), %rdi      # 0xebc3
callq 0x1060
movq (%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xcf07
testq %rax, %rax
je 0x4ecc
movq %rax, %r14
leaq 0x38(%rsp), %r13
leaq 0x30(%rsp), %rbp
cmpl $0xf, 0x14(%r14)
jne 0x4ebf
movq 0x8(%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xb834
testq %rax, %rax
je 0x4e3d
movq %rax, %r15
xorpd %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
movsd %xmm0, 0x8(%rsp)
movsd %xmm0, (%rsp)
movsd %xmm0, 0x28(%rsp)
movsd %xmm0, 0x18(%rsp)
movsd %xmm0, 0x20(%rsp)
movl 0x10(%r14), %eax
cmpl %eax, 0x18(%r15)
je 0x4d82
cmpl %eax, 0x1c(%r15)
je 0x4d82
cmpl %eax, 0x20(%r15)
jne 0x4e2e
movq %r15, %rdi
movq %rbx, %rsi
callq 0x49d0
movl %eax, %r12d
movq %r15, %rdi
leaq 0x40(%rsp), %rsi
movq %r13, %rdx
movq %rbp, %rcx
movq %rbx, %r8
callq 0x4aa0
cmpl $0x1, %r12d
jne 0x4de2
movsd 0x20(%rsp), %xmm0
addsd 0x40(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x18(%rsp), %xmm0
addsd 0x38(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x28(%rsp), %xmm0
addsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
cmpl $0x2, %r12d
jne 0x4e1c
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)
cmpl $0x3, %r12d
jne 0x4e2e
leaq 0x9db9(%rip), %rdi      # 0xebe2
callq 0x1060
movq 0x8(%r15), %r15
testq %r15, %r15
jne 0x4d68
jmp 0x4e64
xorpd %xmm0, %xmm0
movsd %xmm0, 0x20(%rsp)
movsd %xmm0, 0x18(%rsp)
movsd %xmm0, 0x28(%rsp)
movsd %xmm0, (%rsp)
movsd %xmm0, 0x8(%rsp)
movsd %xmm0, 0x10(%rsp)
movsd 0x95fc(%rip), %xmm0     # 0xe468
movsd 0x20(%rsp), %xmm3
mulsd %xmm0, %xmm3
addsd (%rsp), %xmm3
movsd 0x18(%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 0x96e6(%rip), %rdi      # 0xe59e
movb $0x6, %al
callq 0x1090
movq 0x8(%r14), %r14
testq %r14, %r14
jne 0x4d1d
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq