// File: /workspace/github_c_makefile_star2_O1/markpeerdeman[P]mbemm/src/emath/mcheck.c
// Function: process_results
void process_results(mesh theMesh, vector resultvector)
{ point p;
  element e;
  double t1x, t1y, t1z; /* the calculated tractions on an element */
  double t2x, t2y, t2z;
  double t3x, t3y, t3z;
  double fx, fy, fz;    /* the calculated elemental force */
  double sfx=0.0;
  double sfy=0.0;
  double sfz=0.0;
  double a1x, a1y, a1z; /* the analytical tractions on an element */
  double a2x, a2y, a2z;
  double a3x, a3y, a3z;
  double ax, ay, az;    /* the analytical force on the element: */
  double sax=0.0;
  double say=0.0;
  double saz=0.0;
  double fmax=0.0;
  double dx, dy, dz;
  double dmax;
  int dmaxe;
  double sd=0.0;

  printf("\n\n================================================================================\n");
  printf(" VERIFICATION RESULTS FOR THIS MESH:\n");
  printf(" (A): analytical\n (C): calculated\n (N): normalized to the maximum calculated force modulus\n");
  printf(" (S): the error components are treated signed\n");
  
  /* copy the data from the results vector to the point_dll: */
  p=(point)point_dll(theMesh->mesh_p,START,0);
  while (p!=(point)NULL)
  { p->fx=V(resultvector,p->label*3-2);
    p->fy=V(resultvector,p->label*3-2);
    p->fz=V(resultvector,p->label*3  );
    p=p->NEXT;
  }

  scalesystemback(theMesh);

  /* scan through all elements and calculate the resulting element forces: */
  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;
        a1x=traction1(p->x,p->y,p->z,e->nx,e->ny,e->nz);
        a1y=traction2(p->x,p->y,p->z,e->nx,e->ny,e->nz);
        a1z=traction3(p->x,p->y,p->z,e->nx,e->ny,e->nz);
        /* NODE 2: */
        p=(point)point_dll(theMesh->mesh_p,SEARCH,e->p2);
        t2x=p->fx; t2y=p->fy; t2z=p->fz;
        a2x=traction1(p->x,p->y,p->z,e->nx,e->ny,e->nz);
        a2y=traction2(p->x,p->y,p->z,e->nx,e->ny,e->nz);
        a2z=traction3(p->x,p->y,p->z,e->nx,e->ny,e->nz);
        /* NODE 3: */
        p=(point)point_dll(theMesh->mesh_p,SEARCH,e->p3);
        t3x=p->fx; t3y=p->fy; t3z=p->fz;
        a3x=traction1(p->x,p->y,p->z,e->nx,e->ny,e->nz);
        a3y=traction2(p->x,p->y,p->z,e->nx,e->ny,e->nz);
        a3z=traction3(p->x,p->y,p->z,e->nx,e->ny,e->nz);

        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;
        ax= 1.0/3.0*(a1x+a2x+a3x)*e->area*theMesh->G_SCALE;
        ay= 1.0/3.0*(a1y+a2y+a3y)*e->area*theMesh->G_SCALE;
        az= 1.0/3.0*(a1z+a2z+a3z)*e->area*theMesh->G_SCALE;
        sfx+=fx; sfy+=fy; sfz+=fz;
        sax+=ax; say+=ay; saz+=az;
        fmax=maxof(fmax,sqrt(fx*fx+fy*fy+fz*fz));
        dx=fx-ax; dy=fy-ay; dz=fz-az;
        dmax=maxof(dmax,sqrt(dx*dx+dy*dy+dz*dz));
        if (dmax>sqrt(dx*dx+dy*dy+dz*dz)) dmaxe=e->label;
        sd+=sqrt(dx*dx+dy*dy+dz*dz);
        

        e=e->NEXT;
  }
  
  printf("\n REACTION FORCES:\n");
  printf(" Resulting net force vector (A):   [% 8.8E % 8.8E % 8.8E]\n",sax,say,saz);
  printf(" Resulting net force vector (C):   [% 8.8E % 8.8E % 8.8E]\n",sfx,sfy,sfz);
  printf(" Resulting net force vector (C,N): [% 8.8E % 8.8E % 8.8E]\n",sfx/fmax,sfy/fmax,sfz/fmax);
  printf("\n ERRORS:\n");
  printf(" Maximum traction error (N):        % 8.8E on element %d\n",dmax/fmax,dmaxe);
  printf(" Average traction error (N):        % 8.8E\n",(sd/theMesh->nr_of_elements)/fmax);
  printf(" Average traction error (S,N):      % 8.8E\n",(sqrt(sfx*sfx+sfy*sfy+sfz*sfz)/
                                                           theMesh->nr_of_elements)/fmax);

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x482d(%rip), %rdi      # 0xf443
callq 0x1060
leaq 0x4874(%rip), %rdi      # 0xf496
callq 0x1060
leaq 0x488d(%rip), %rdi      # 0xf4bb
callq 0x1060
leaq 0x48dc(%rip), %rdi      # 0xf516
callq 0x1060
movq (%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xcf07
testq %rax, %rax
je 0xac86
movq 0x8(%r14), %rcx
movslq 0x10(%rax), %rdx
leaq (%rdx,%rdx,2), %rdx
movsd -0x18(%rcx,%rdx,8), %xmm0
movsd %xmm0, 0x38(%rax)
movsd -0x18(%rcx,%rdx,8), %xmm0
movsd %xmm0, 0x40(%rax)
movsd -0x8(%rcx,%rdx,8), %xmm0
movsd %xmm0, 0x48(%rax)
movq 0x8(%rax), %rax
testq %rax, %rax
jne 0xac54
movq %rbx, %rdi
callq 0x9f09
movq 0x8(%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xb834
testq %rax, %rax
je 0xb228
movq %rax, %r14
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x18(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x20(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x30(%rsp)
xorpd %xmm2, %xmm2
movapd %xmm2, 0x40(%rsp)
movq (%rbx), %rdi
movl 0x18(%r14), %edx
movl $0x2, %esi
callq 0xcf07
movq %rax, %r15
movups 0x40(%rax), %xmm0
movaps %xmm0, (%rsp)
movsd 0x20(%rax), %xmm0
movsd 0x28(%rax), %xmm1
movsd 0x30(%rax), %xmm2
movsd 0xa0(%r14), %xmm3
movsd 0xa8(%r14), %xmm4
movsd 0xb0(%r14), %xmm5
movsd 0x38(%rax), %xmm6
movaps %xmm6, 0x70(%rsp)
callq 0x98a8
movaps %xmm0, 0x80(%rsp)
movsd 0x20(%r15), %xmm0
movsd 0x28(%r15), %xmm1
movsd 0x30(%r15), %xmm2
movsd 0xa0(%r14), %xmm3
movsd 0xa8(%r14), %xmm4
movsd 0xb0(%r14), %xmm5
callq 0x98c5
movaps %xmm0, 0x50(%rsp)
movsd 0x20(%r15), %xmm0
movsd 0x28(%r15), %xmm1
movsd 0x30(%r15), %xmm2
movsd 0xa0(%r14), %xmm3
movsd 0xa8(%r14), %xmm4
movsd 0xb0(%r14), %xmm5
callq 0x98de
movaps %xmm0, 0xc0(%rsp)
movq (%rbx), %rdi
movl 0x1c(%r14), %edx
movl $0x2, %esi
callq 0xcf07
movq %rax, %r15
movupd 0x40(%rax), %xmm0
addpd (%rsp), %xmm0
movapd %xmm0, (%rsp)
movsd 0x20(%rax), %xmm0
movsd 0x28(%rax), %xmm1
movsd 0x30(%rax), %xmm2
movsd 0xa0(%r14), %xmm3
movsd 0xa8(%r14), %xmm4
movsd 0xb0(%r14), %xmm5
movsd 0x38(%rax), %xmm6
movaps %xmm6, 0xb0(%rsp)
callq 0x98a8
movaps %xmm0, 0x110(%rsp)
movsd 0x20(%r15), %xmm0
movsd 0x28(%r15), %xmm1
movsd 0x30(%r15), %xmm2
movsd 0xa0(%r14), %xmm3
movsd 0xa8(%r14), %xmm4
movsd 0xb0(%r14), %xmm5
callq 0x98c5
movaps %xmm0, 0x100(%rsp)
movsd 0x20(%r15), %xmm0
movsd 0x28(%r15), %xmm1
movsd 0x30(%r15), %xmm2
movsd 0xa0(%r14), %xmm3
movsd 0xa8(%r14), %xmm4
movsd 0xb0(%r14), %xmm5
callq 0x98de
movaps %xmm0, 0xa0(%rsp)
movq (%rbx), %rdi
movl 0x20(%r14), %edx
movl $0x2, %esi
callq 0xcf07
movq %rax, %r15
movupd 0x40(%rax), %xmm0
addpd (%rsp), %xmm0
movapd %xmm0, (%rsp)
movsd 0x20(%rax), %xmm0
movsd 0x28(%rax), %xmm1
movsd 0x30(%rax), %xmm2
movsd 0xa0(%r14), %xmm3
movsd 0xa8(%r14), %xmm4
movsd 0xb0(%r14), %xmm5
movsd 0x38(%rax), %xmm6
movaps %xmm6, 0x90(%rsp)
callq 0x98a8
movaps %xmm0, 0xd0(%rsp)
movsd 0x20(%r15), %xmm0
movsd 0x28(%r15), %xmm1
movsd 0x30(%r15), %xmm2
movsd 0xa0(%r14), %xmm3
movsd 0xa8(%r14), %xmm4
movsd 0xb0(%r14), %xmm5
callq 0x98c5
movaps %xmm0, 0xf0(%rsp)
movsd 0x20(%r15), %xmm0
movsd 0x28(%r15), %xmm1
movsd 0x30(%r15), %xmm2
movsd 0xa0(%r14), %xmm3
movsd 0xa8(%r14), %xmm4
movsd 0xb0(%r14), %xmm5
callq 0x98de
movapd (%rsp), %xmm4
shufpd $0x1, %xmm4, %xmm4      # xmm4 = xmm4[1,0]
movapd 0x34cc(%rip), %xmm1     # 0xe430
mulpd %xmm1, %xmm4
movsd 0xb8(%r14), %xmm5
unpcklpd %xmm5, %xmm5            # xmm5 = xmm5[0,0]
mulpd %xmm5, %xmm4
movsd 0x30(%rbx), %xmm6
unpcklpd %xmm6, %xmm6            # xmm6 = xmm6[0,0]
mulpd %xmm6, %xmm4
movapd 0x70(%rsp), %xmm2
unpcklpd 0xc0(%rsp), %xmm2       # xmm2 = xmm2[0],mem[0]
movapd 0xb0(%rsp), %xmm3
unpcklpd 0xa0(%rsp), %xmm3       # xmm3 = xmm3[0],mem[0]
addpd %xmm2, %xmm3
movapd 0x90(%rsp), %xmm2
unpcklpd %xmm0, %xmm2            # xmm2 = xmm2[0],xmm0[0]
addpd %xmm3, %xmm2
mulpd %xmm1, %xmm2
mulpd %xmm5, %xmm2
mulpd %xmm6, %xmm2
movapd %xmm4, %xmm3
unpckhpd %xmm4, %xmm3            # xmm3 = xmm3[1],xmm4[1]
movapd %xmm3, %xmm0
mulsd %xmm3, %xmm0
movapd %xmm2, 0x90(%rsp)
movapd %xmm2, %xmm1
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movapd %xmm4, (%rsp)
movapd %xmm4, %xmm0
mulsd %xmm4, %xmm0
addsd %xmm1, %xmm0
ucomisd 0x3452(%rip), %xmm0     # 0xe458
jb 0xb00e
sqrtsd %xmm0, %xmm0
jmp 0xb049
movapd %xmm5, 0xc0(%rsp)
movapd %xmm6, 0xb0(%rsp)
movapd %xmm3, 0xa0(%rsp)
callq 0x11b0
movapd 0xa0(%rsp), %xmm3
movapd 0xb0(%rsp), %xmm6
movapd 0xc0(%rsp), %xmm5
movapd %xmm0, 0x70(%rsp)
movapd 0x80(%rsp), %xmm0
unpcklpd 0x50(%rsp), %xmm0       # xmm0 = xmm0[0],mem[0]
movapd 0x110(%rsp), %xmm2
unpcklpd 0x100(%rsp), %xmm2      # xmm2 = xmm2[0],mem[0]
addpd %xmm0, %xmm2
movapd 0xd0(%rsp), %xmm1
unpcklpd 0xf0(%rsp), %xmm1       # xmm1 = xmm1[0],mem[0]
addpd %xmm2, %xmm1
mulpd 0x339e(%rip), %xmm1     # 0xe430
mulpd %xmm5, %xmm1
mulpd %xmm6, %xmm1
movapd 0x90(%rsp), %xmm2
movapd %xmm2, %xmm0
subsd %xmm1, %xmm0
movapd %xmm1, 0xd0(%rsp)
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
subsd %xmm1, %xmm3
movapd %xmm2, %xmm1
unpckhpd %xmm2, %xmm1            # xmm1 = xmm1[1],xmm2[1]
movapd (%rsp), %xmm2
subsd %xmm1, %xmm2
mulsd %xmm3, %xmm3
mulsd %xmm0, %xmm0
addsd %xmm3, %xmm0
mulsd %xmm2, %xmm2
addsd %xmm0, %xmm2
xorps %xmm3, %xmm3
sqrtsd %xmm2, %xmm3
ucomisd 0x3368(%rip), %xmm2     # 0xe458
movapd %xmm3, %xmm4
movsd %xmm2, 0x80(%rsp)
jae 0xb121
movapd %xmm2, %xmm0
movsd %xmm3, 0x50(%rsp)
callq 0x11b0
movsd 0x50(%rsp), %xmm3
movsd 0x80(%rsp), %xmm2
movapd %xmm0, %xmm4
ucomisd 0x332f(%rip), %xmm2     # 0xe458
jae 0xb14d
movapd %xmm2, %xmm0
movapd %xmm4, 0x50(%rsp)
callq 0x11b0
movapd 0x50(%rsp), %xmm4
movsd 0x80(%rsp), %xmm2
movapd %xmm0, %xmm3
movapd 0xe0(%rsp), %xmm1
movapd %xmm1, %xmm0
cmplesd %xmm4, %xmm0
andpd %xmm0, %xmm4
andnpd %xmm1, %xmm0
orpd %xmm4, %xmm0
ucomisd %xmm3, %xmm0
jbe 0xb175
movl 0x14(%r14), %ebp
movapd %xmm0, 0xe0(%rsp)
ucomisd 0x32d2(%rip), %xmm2     # 0xe458
jb 0xb191
xorps %xmm0, %xmm0
sqrtsd %xmm2, %xmm0
jmp 0xb19a
movapd %xmm2, %xmm0
callq 0x11b0
movapd 0x20(%rsp), %xmm1
movapd 0x30(%rsp), %xmm2
movsd 0x18(%rsp), %xmm3
movapd 0x60(%rsp), %xmm4
addsd %xmm0, %xmm3
movsd %xmm3, 0x18(%rsp)
addpd 0xd0(%rsp), %xmm4
movapd %xmm4, 0x60(%rsp)
addpd (%rsp), %xmm2
movapd %xmm2, 0x30(%rsp)
movapd 0x40(%rsp), %xmm2
addpd 0x90(%rsp), %xmm2
movapd %xmm1, %xmm0
movapd 0x70(%rsp), %xmm3
cmplesd %xmm3, %xmm0
andpd %xmm0, %xmm3
andnpd %xmm1, %xmm0
orpd %xmm3, %xmm0
movapd %xmm0, 0x20(%rsp)
movq 0x8(%r14), %r14
testq %r14, %r14
jne 0xacd0
movapd %xmm2, %xmm0
unpckhpd %xmm2, %xmm0            # xmm0 = xmm0[1],xmm2[1]
movapd %xmm0, (%rsp)
movapd %xmm2, 0x40(%rsp)
jmp 0xb255
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x40(%rsp)
xorpd %xmm0, %xmm0
movsd %xmm0, 0x18(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x30(%rsp)
leaq 0x42e8(%rip), %rdi      # 0xf544
callq 0x1060
movaps 0x60(%rsp), %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
leaq 0x408c(%rip), %rdi      # 0xf300
movaps (%rsp), %xmm2
movb $0x3, %al
callq 0x1090
movaps 0x30(%rsp), %xmm2
movaps %xmm2, %xmm1
unpckhpd %xmm2, %xmm1            # xmm1 = xmm1[1],xmm2[1]
movaps %xmm1, (%rsp)
leaq 0x40a5(%rip), %rdi      # 0xf33b
movaps 0x40(%rsp), %xmm0
movb $0x3, %al
callq 0x1090
movapd 0x40(%rsp), %xmm0
movapd 0x20(%rsp), %xmm3
divsd %xmm3, %xmm0
movapd (%rsp), %xmm1
divsd %xmm3, %xmm1
movapd 0x30(%rsp), %xmm2
divsd %xmm3, %xmm2
leaq 0x40aa(%rip), %rdi      # 0xf376
movb $0x3, %al
callq 0x1090
leaq 0x427d(%rip), %rdi      # 0xf557
callq 0x1060
movapd 0xe0(%rsp), %xmm0
divsd 0x20(%rsp), %xmm0
leaq 0x40bc(%rip), %rdi      # 0xf3b1
movl %ebp, %esi
movb $0x1, %al
callq 0x1090
xorps %xmm1, %xmm1
cvtsi2sdl 0x24(%rbx), %xmm1
movsd 0x18(%rsp), %xmm0
divsd %xmm1, %xmm0
divsd 0x20(%rsp), %xmm0
leaq 0x40ce(%rip), %rdi      # 0xf3eb
movb $0x1, %al
callq 0x1090
movapd (%rsp), %xmm1
mulsd %xmm1, %xmm1
movapd 0x40(%rsp), %xmm0
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
movapd %xmm0, %xmm1
movapd 0x30(%rsp), %xmm0
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
ucomisd 0x3103(%rip), %xmm0     # 0xe458
jb 0xb35d
sqrtsd %xmm0, %xmm0
jmp 0xb362
callq 0x11b0
xorps %xmm1, %xmm1
cvtsi2sdl 0x24(%rbx), %xmm1
divsd %xmm1, %xmm0
divsd 0x20(%rsp), %xmm0
leaq 0x409c(%rip), %rdi      # 0xf417
movb $0x1, %al
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x1090