// File: /workspace/github_c_makefile_star2_O1/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 0x12d6b(%rip), %r13     # 0x14ff8
movq (%r13), %rcx
leaq 0xcbc8(%rip), %rdi      # 0xee60
pushq $0x26
popq %rsi
pushq $0x1
popq %r14
movq %r14, %rdx
callq 0x11a0
movq (%r13), %rcx
leaq 0xcbd5(%rip), %rdi      # 0xee87
pushq $0x1f
popq %rsi
movq %r14, %rdx
callq 0x11a0
movq (%r13), %rcx
leaq 0xcbdf(%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 0xb834
testq %rax, %rax
jne 0x22f8
movsd 0xcb60(%rip), %xmm0     # 0xee50
movsd %xmm0, 0x8(%rsp)
jmp 0x233b
movsd 0xcb58(%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 0x2300
mulsd 0xc133(%rip), %xmm2     # 0xe468
movsd %xmm2, 0x8(%rsp)
movq (%rbx), %rax
movq (%rax), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xcf07
testq %rax, %rax
je 0x241f
movq %rax, %r14
leaq 0xcb54(%rip), %r15      # 0xeeb1
movq (%rbx), %rax
movq (%rax), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xcf07
testq %rax, %rax
movsd 0x8(%rsp), %xmm2
je 0x2412
movq %rax, %r12
movsd 0x20(%r14), %xmm1
movsd 0x28(%r14), %xmm0
subsd 0x20(%r12), %xmm1
subsd 0x28(%r12), %xmm0
mulsd %xmm0, %xmm0
mulsd %xmm1, %xmm1
addsd %xmm0, %xmm1
movsd 0x30(%r14), %xmm0
subsd 0x30(%r12), %xmm0
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
ucomisd 0xc097(%rip), %xmm0     # 0xe458
jb 0x23c9
sqrtsd %xmm0, %xmm0
jmp 0x23d4
callq 0x11b0
movsd 0x8(%rsp), %xmm2
ucomisd %xmm0, %xmm2
jbe 0x23ee
movl 0x10(%r14), %edx
movl 0x10(%r12), %ecx
cmpl %ecx, %edx
je 0x23ee
movl 0x8(%rbx), %eax
cmpl %eax, %edx
jle 0x23fa
movq 0x8(%r12), %r12
testq %r12, %r12
jne 0x237e
jmp 0x2412
movq (%r13), %rdi
subl %eax, %ecx
movq %r15, %rsi
xorl %eax, %eax
callq 0x1100
movsd 0x8(%rsp), %xmm2
jmp 0x23ee
movq 0x8(%r14), %r14
testq %r14, %r14
jne 0x235d
movq (%r13), %rcx
leaq 0xca95(%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