// File: /workspace/github_c_makefile_star2_O2/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
pushq $0x3
popq %rdi
movl %edi, %esi
callq 0xb24c
movq %rax, %r14
leaq 0x9c24(%rip), %rdi      # 0xdda0
callq 0x1060
leaq 0x9b28(%rip), %rdi      # 0xdcb0
callq 0x1060
leaq 0x9a90(%rip), %rdi      # 0xdc24
callq 0x1060
leaq 0x9a8f(%rip), %rdi      # 0xdc2f
callq 0x1060
leaq 0x9b0b(%rip), %rdi      # 0xdcb7
callq 0x1060
leaq 0x9b1b(%rip), %rdi      # 0xdcd3
callq 0x1060
leaq 0x9b26(%rip), %rdi      # 0xdcea
callq 0x1060
leaq 0x9b2b(%rip), %rdi      # 0xdcfb
callq 0x1060
leaq 0x9b2a(%rip), %rdi      # 0xdd06
callq 0x1060
leaq 0x9b4c(%rip), %rdi      # 0xdd34
callq 0x1060
leaq 0x9a5c(%rip), %rdi      # 0xdc50
callq 0x1060
leaq 0x93cb(%rip), %rdi      # 0xd5cb
xorl %eax, %eax
callq 0x1090
leaq 0x9b68(%rip), %rdi      # 0xdd76
callq 0x1060
leaq 0x9b71(%rip), %rdi      # 0xdd8b
callq 0x1060
leaq 0x93e2(%rip), %r15      # 0xd608
movq %r15, %rdi
xorl %eax, %eax
callq 0x1090
leaq 0x9405(%rip), %r12      # 0xd63c
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 0xad45
movq %rax, %r15
pushq $0x2
popq %rbp
testq %r15, %r15
je 0x4430
movq (%rbx), %rdi
movl 0x18(%r15), %edx
movl %ebp, %esi
callq 0xc14c
movq %rax, %r13
movq (%rbx), %rdi
movl 0x1c(%r15), %edx
movl %ebp, %esi
callq 0xc14c
movq %rax, %r12
movq (%rbx), %rdi
movl 0x20(%r15), %edx
movl %ebp, %esi
callq 0xc14c
movsd 0x20(%r13), %xmm0
addsd 0x20(%r12), %xmm0
addsd 0x20(%rax), %xmm0
movsd 0x28(%r13), %xmm1
movsd 0x9193(%rip), %xmm2     # 0xd450
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 0x916d(%rip), %xmm1     # 0xd478
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
ucomisd 0x9165(%rip), %xmm0     # 0xd480
jb 0x4323
sqrtsd %xmm0, %xmm0
jmp 0x433e
movsd %xmm2, (%rsp)
movsd %xmm3, 0x8(%rsp)
callq 0x11a0
movsd 0x8(%rsp), %xmm3
movsd (%rsp), %xmm2
addsd %xmm3, %xmm2
addsd %xmm0, %xmm2
mulsd 0x9112(%rip), %xmm2     # 0xd460
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 0x90fd(%rip), %xmm1     # 0xd478
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
ucomisd 0x90f5(%rip), %xmm0     # 0xd480
jb 0x4393
sqrtsd %xmm0, %xmm0
jmp 0x43ba
movsd %xmm2, (%rsp)
movsd %xmm3, 0x8(%rsp)
movsd %xmm4, 0x10(%rsp)
callq 0x11a0
movsd 0x10(%rsp), %xmm4
movsd 0x8(%rsp), %xmm3
movsd (%rsp), %xmm2
addsd %xmm4, %xmm3
subsd %xmm0, %xmm3
mulsd 0x9096(%rip), %xmm3     # 0xd460
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
sqrtsd %xmm0, %xmm0
mulsd 0x9076(%rip), %xmm0     # 0xd470
movsd %xmm0, (%rsp)
movl 0x14(%r15), %esi
leaq 0x9294(%rip), %rdi      # 0xd69e
pushq $0x1
popq %rdx
xorl %eax, %eax
callq 0x1090
leaq 0x922f(%rip), %rdi      # 0xd64a
movsd (%rsp), %xmm0
movb $0x1, %al
callq 0x1090
movq 0x8(%r15), %r15
jmp 0x4264
leaq 0x9969(%rip), %rdi      # 0xdda0
callq 0x1060
movq %r14, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xb3b2