// File: /workspace/github_c_makefile_star2_O1/markpeerdeman[P]mbemm/src/emath/post.c
// Function: U_write_mises_analytical
void U_write_mises_analytical(mesh themesh)
{ double zx, zy, zz; /* midpoint coordinates */
  matrix stress;
  double s1, s2, s3, mises;
  element e; point node1, node2, node3;

  stress = (matrix)newmatrix(3,3);

  printf("    -1\n");
  printf("  2414\n");
  printf("         4\n");
  printf(" von Mises stresses (analytical)\n");
  printf("         2\n");
  printf("ElastoMath BEM results\n");
  printf("ELASTOMATH_SOLVE\n");
  printf("LOAD SET 1\n");
  printf("Analysis time was     8-May-66       14:24:27\n");
  printf("NONE\n");
  printf("         1         1         1         2         2         1\n");
  printf("       -10         0         1         1         1         0");
  printf("         0         0\n");
  printf("         2         0\n");
  printf("  0.00000E+00  0.00000E+00  0.00000E+00  0.00000E+00  0.00000E+00");
  printf("  0.00000E+00\n");
  printf("  0.00000E+00  0.00000E+00  0.00000E+00  0.00000E+00  0.00000E+00");
  printf("  0.00000E+00\n");


e=(element)element_dll(themesh->mesh_e,START,0);
while (e!=(element)NULL)
{
  node1 = (point)point_dll(themesh->mesh_p,SEARCH,e->p1);
  node2 = (point)point_dll(themesh->mesh_p,SEARCH,e->p2);
  node3 = (point)point_dll(themesh->mesh_p,SEARCH,e->p3);

  zx = 1.0/3.0 * ( node1->x + node2->x + node3->x );
  zy = 1.0/3.0 * ( node1->y + node2->y + node3->y );
  zz = 1.0/3.0 * ( node1->z + node2->z + node3->z );

  M(stress,1,1) = zx;
  M(stress,2,2) = zy;
  M(stress,1,2) = M(stress,2,1) = zy;

  /* calculate the von Mises stress for this element: */

  s2 = 0.0;
  s1 = 0.5*(M(stress,1,1)+M(stress,2,2)+sqrt( (M(stress,1,1)-M(stress,2,2))*(M(stress,1,1)-M(stress,2,2)) +
       4.0*(M(stress,1,2)*M(stress,1,2))));
  s3 = 0.5*(M(stress,1,1)+M(stress,2,2)-sqrt( (M(stress,1,1)-M(stress,2,2))*(M(stress,1,1)-M(stress,2,2)) +
       4.0*(M(stress,1,2)*M(stress,1,2))));

  mises = 1.0/sqrt(2.0)*sqrt( (s1-s2)*(s1-s2)+(s1-s3)*(s1-s3)+(s2-s3)*(s2-s3) );

  printf("%10d%10d\n",e->label,1);
  printf(" % 1.5E\n",(double)mises);

  e=e->NEXT;
}

  printf("    -1\n");

  delmatrix(stress);

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movl $0x3, %edi
movl $0x3, %esi
callq 0xbcb0
movq %rax, %r14
leaq 0x9500(%rip), %rdi      # 0xeda0
callq 0x1060
leaq 0x9404(%rip), %rdi      # 0xecb0
callq 0x1060
leaq 0x936c(%rip), %rdi      # 0xec24
callq 0x1060
leaq 0x936b(%rip), %rdi      # 0xec2f
callq 0x1060
leaq 0x93e7(%rip), %rdi      # 0xecb7
callq 0x1060
leaq 0x93f7(%rip), %rdi      # 0xecd3
callq 0x1060
leaq 0x9402(%rip), %rdi      # 0xecea
callq 0x1060
leaq 0x9407(%rip), %rdi      # 0xecfb
callq 0x1060
leaq 0x9406(%rip), %rdi      # 0xed06
callq 0x1060
leaq 0x9428(%rip), %rdi      # 0xed34
callq 0x1060
leaq 0x9338(%rip), %rdi      # 0xec50
callq 0x1060
leaq 0x8ca7(%rip), %rdi      # 0xe5cb
xorl %eax, %eax
callq 0x1090
leaq 0x9444(%rip), %rdi      # 0xed76
callq 0x1060
leaq 0x944d(%rip), %rdi      # 0xed8b
callq 0x1060
leaq 0x8cbe(%rip), %r15      # 0xe608
movq %r15, %rdi
xorl %eax, %eax
callq 0x1090
leaq 0x8ce1(%rip), %r12      # 0xe63c
movq %r12, %rdi
callq 0x1060
movq %r15, %rdi
xorl %eax, %eax
callq 0x1090
movq %r12, %rdi
callq 0x1060
movq 0x8(%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xb834
testq %rax, %rax
je 0x5b72
movq %rax, %r15
leaq 0x8cb5(%rip), %r13      # 0xe64a
movq (%rbx), %rdi
movl 0x18(%r15), %edx
movl $0x2, %esi
callq 0xcf07
movq %rax, %rbp
movq (%rbx), %rdi
movl 0x1c(%r15), %edx
movl $0x2, %esi
callq 0xcf07
movq %rax, %r12
movq (%rbx), %rdi
movl 0x20(%r15), %edx
movl $0x2, %esi
callq 0xcf07
movsd 0x20(%rbp), %xmm0
addsd 0x20(%r12), %xmm0
addsd 0x20(%rax), %xmm0
movsd 0x28(%rbp), %xmm1
movsd 0x8a64(%rip), %xmm2     # 0xe450
mulsd %xmm2, %xmm0
addsd 0x28(%r12), %xmm1
addsd 0x28(%rax), %xmm1
mulsd %xmm2, %xmm1
movq 0x8(%r14), %rax
movq (%rax), %rcx
movsd %xmm0, (%rcx)
movq 0x8(%rax), %rax
movsd %xmm1, 0x8(%rax)
movsd %xmm1, (%rax)
movsd %xmm1, 0x8(%rcx)
movsd (%rcx), %xmm2
movsd 0x8(%rax), %xmm3
movapd %xmm2, %xmm0
subsd %xmm3, %xmm0
mulsd %xmm1, %xmm1
mulsd 0x8a46(%rip), %xmm1     # 0xe480
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
ucomisd 0x8a0e(%rip), %xmm0     # 0xe458
jb 0x5a52
sqrtsd %xmm0, %xmm0
jmp 0x5a6d
movsd %xmm2, (%rsp)
movsd %xmm3, 0x8(%rsp)
callq 0x11b0
movsd 0x8(%rsp), %xmm3
movsd (%rsp), %xmm2
addsd %xmm3, %xmm2
addsd %xmm0, %xmm2
mulsd 0x89eb(%rip), %xmm2     # 0xe468
movq 0x8(%r14), %rax
movq (%rax), %rcx
movq 0x8(%rax), %rax
movsd 0x8(%rax), %xmm4
movsd (%rcx), %xmm3
movsd 0x8(%rcx), %xmm1
movapd %xmm3, %xmm0
subsd %xmm4, %xmm0
mulsd %xmm1, %xmm1
mulsd 0x89d6(%rip), %xmm1     # 0xe480
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
ucomisd 0x899e(%rip), %xmm0     # 0xe458
jb 0x5ac2
sqrtsd %xmm0, %xmm0
jmp 0x5ae9
movsd %xmm2, (%rsp)
movsd %xmm3, 0x8(%rsp)
movsd %xmm4, 0x10(%rsp)
callq 0x11b0
movsd 0x10(%rsp), %xmm4
movsd 0x8(%rsp), %xmm3
movsd (%rsp), %xmm2
addsd %xmm4, %xmm3
subsd %xmm0, %xmm3
mulsd 0x896f(%rip), %xmm3     # 0xe468
movapd %xmm2, %xmm0
subsd %xmm3, %xmm0
mulsd %xmm0, %xmm0
mulsd %xmm2, %xmm2
addsd %xmm0, %xmm2
xorpd %xmm0, %xmm0
subsd %xmm3, %xmm0
mulsd %xmm0, %xmm0
addsd %xmm2, %xmm0
ucomisd 0x8933(%rip), %xmm0     # 0xe458
jb 0x5b2d
sqrtsd %xmm0, %xmm0
jmp 0x5b32
callq 0x11b0
mulsd 0x893e(%rip), %xmm0     # 0xe478
movsd %xmm0, (%rsp)
movl 0x14(%r15), %esi
leaq 0x8b54(%rip), %rdi      # 0xe69e
movl $0x1, %edx
xorl %eax, %eax
callq 0x1090
movq %r13, %rdi
movsd (%rsp), %xmm0
movb $0x1, %al
callq 0x1090
movq 0x8(%r15), %r15
testq %r15, %r15
jne 0x5995
leaq 0x9227(%rip), %rdi      # 0xeda0
callq 0x1060
movq %r14, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xbe4b