// File: /workspace/github_c_makefile_star2_O2/markpeerdeman[P]mbemm/src/emath/do_contact.c
// Function: find_contactnodes
void find_contactnodes(cmesh theCmesh)
{ double mindist=1.0E6;
  double curdist;
  element e;
  point p;
  point q;

  fprintf(stderr,"* Running automatic contact detection\n");
  fprintf(stderr,"  Candidate contact node list:\n");
  fprintf(stderr,"  cnodes\n");

  /* 1: determine smallest element size */
  e=(element)element_dll(theCmesh->merged_mesh->mesh_e,START,0);
  while (e!=(element)NULL)
  { if (e->z1<mindist) mindist=e->z1;
    if (e->z2<mindist) mindist=e->z2;
    if (e->z3<mindist) mindist=e->z3;
    e=e->NEXT;
  }

  /* 2: divide this size by 20.0: */
  mindist/=2.0;

  p=(point)point_dll(theCmesh->merged_mesh->mesh_p,START,0);
  while (p!=(point)NULL)
  { q=(point)point_dll(theCmesh->merged_mesh->mesh_p,START,0);
    while (q!=(point)NULL)
    { curdist=sqrt( (p->x-q->x)*(p->x-q->x) +
                    (p->y-q->y)*(p->y-q->y) +
                    (p->z-q->z)*(p->z-q->z) );
      if ( (curdist<mindist) && (p->label!=q->label) && (p->label<=theCmesh->nr_of_nodes_basemesh) )
      { fprintf(stderr,"  % 5d  % 5d\n",p->label,q->label-
                 theCmesh->nr_of_nodes_basemesh);
      }
      q=q->NEXT;
    }
    p=p->NEXT;
  }


  fprintf(stderr,"  end_cnodes\n\n");
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
movq 0xf355(%rip), %r13      # 0x13ff8
movq (%r13), %rcx
leaq 0x91aa(%rip), %rdi      # 0xde58
pushq $0x26
popq %rsi
pushq $0x1
popq %r14
movq %r14, %rdx
callq 0x1190
movq (%r13), %rcx
leaq 0x91b7(%rip), %rdi      # 0xde7f
pushq $0x1f
popq %rsi
movq %r14, %rdx
callq 0x1190
movq (%r13), %rcx
leaq 0x91c1(%rip), %rdi      # 0xde9f
pushq $0x9
popq %rsi
movq %r14, %rdx
callq 0x1190
movq (%rbx), %rax
movq 0x8(%rax), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xad45
movsd 0x914f(%rip), %xmm2     # 0xde50
testq %rax, %rax
je 0x4d30
movsd 0x88(%rax), %xmm0
minsd %xmm2, %xmm0
movsd 0x90(%rax), %xmm1
minsd %xmm0, %xmm1
movsd 0x98(%rax), %xmm2
minsd %xmm1, %xmm2
movq 0x8(%rax), %rax
jmp 0x4d01
mulsd 0x8728(%rip), %xmm2     # 0xd460
movsd %xmm2, 0x8(%rsp)
movq (%rbx), %rax
movq (%rax), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xc14c
movq %rax, %r14
leaq 0x9152(%rip), %r15      # 0xdea9
testq %r14, %r14
je 0x4dfe
movq (%rbx), %rax
movq (%rax), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xc14c
movsd 0x8(%rsp), %xmm2
movq %rax, %r12
testq %r12, %r12
je 0x4df5
movsd 0x20(%r14), %xmm0
movsd 0x28(%r14), %xmm1
subsd 0x20(%r12), %xmm0
subsd 0x28(%r12), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
movsd 0x30(%r14), %xmm1
subsd 0x30(%r12), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm0, %xmm1
sqrtsd %xmm1, %xmm0
ucomisd %xmm0, %xmm2
jbe 0x4dd6
movl 0x10(%r14), %edx
movl 0x10(%r12), %ecx
cmpl %ecx, %edx
je 0x4dd6
movl 0x8(%rbx), %eax
cmpl %eax, %edx
jle 0x4ddd
movq 0x8(%r12), %r12
jmp 0x4d78
movq (%r13), %rdi
subl %eax, %ecx
movq %r15, %rsi
xorl %eax, %eax
callq 0x10f0
movsd 0x8(%rsp), %xmm2
jmp 0x4dd6
movq 0x8(%r14), %r14
jmp 0x4d57
movq (%r13), %rcx
leaq 0x90ae(%rip), %rdi      # 0xdeb7
pushq $0xe
popq %rsi
pushq $0x1
popq %rdx
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x1190