// File: /workspace/github_c_makefile_star2_O3/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 0x12cf6(%rip), %r13     # 0x14ff8
movq (%r13), %rcx
leaq 0xcb53(%rip), %rdi      # 0xee60
pushq $0x26
popq %rsi
pushq $0x1
popq %r14
movq %r14, %rdx
callq 0x11a0
movq (%r13), %rcx
leaq 0xcb60(%rip), %rdi      # 0xee87
pushq $0x1f
popq %rsi
movq %r14, %rdx
callq 0x11a0
movq (%r13), %rcx
leaq 0xcb6a(%rip), %rdi      # 0xeea7
pushq $0x9
popq %rsi
movq %r14, %rdx
callq 0x11a0
movq (%rbx), %rax
movq 0x8(%rax), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xb570
testq %rax, %rax
jne 0x236d
movsd 0xcaeb(%rip), %xmm0     # 0xee50
movsd %xmm0, 0x8(%rsp)
jmp 0x23b0
movsd 0xcae3(%rip), %xmm2     # 0xee58
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
testq %rax, %rax
jne 0x2375
mulsd 0xc0b6(%rip), %xmm2     # 0xe460
movsd %xmm2, 0x8(%rsp)
movq (%rbx), %rax
movq (%rax), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xcc2f
testq %rax, %rax
je 0x247d
movq %rax, %r14
leaq 0xcadf(%rip), %r15      # 0xeeb1
movq (%rbx), %rax
movq (%rax), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xcc2f
testq %rax, %rax
movsd 0x8(%rsp), %xmm2
je 0x2470
movq %rax, %r12
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 0x244c
movl 0x10(%r14), %edx
movl 0x10(%r12), %ecx
cmpl %ecx, %edx
je 0x244c
movl 0x8(%rbx), %eax
cmpl %eax, %edx
jle 0x2458
movq 0x8(%r12), %r12
testq %r12, %r12
jne 0x23f3
jmp 0x2470
movq (%r13), %rdi
subl %eax, %ecx
movq %r15, %rsi
xorl %eax, %eax
callq 0x1100
movsd 0x8(%rsp), %xmm2
jmp 0x244c
movq 0x8(%r14), %r14
testq %r14, %r14
jne 0x23d2
movq (%r13), %rcx
leaq 0xca37(%rip), %rdi      # 0xeebf
pushq $0xe
popq %rsi
pushq $0x1
popq %rdx
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x11a0