// File: /workspace/github_c_makefile_star2_O1/markpeerdeman[P]mbemm/src/emath/do_contact.c
// Function: makeCmesh
void makeCmesh(mesh mesh1, mesh mesh2, cmesh meshC)
{ int i;
  point p, q;
  element e, f;
  restraint dt, dt2;

  /* STEP 1: Put mesh1 into the cmesh-structure: */
             meshC->merged_mesh=mesh1;

  /* STEP 2: Count the numbers of the items in mesh1 and put into cmesh: */
  /*      A: Count nodes: */
             p=(point)point_dll(mesh1->mesh_p,START,0); i=0;
             while (p!=(point)NULL) { i++; p=p->NEXT; }
             mesh1->nr_of_nodes=i; meshC->nr_of_nodes_basemesh=i;
  /*      B: Count elements: */
             e=(element)element_dll(mesh1->mesh_e,START,0); i=0;
             while (e!=(element)NULL) { i++; e=e->NEXT; }
             mesh1->nr_of_elements=i; meshC->nr_of_elements_basemesh=i;
  /*      C: Count tractions: */
             dt=(restraint)restraint_dll(mesh1->mesh_t,START,0); i=0;
             while (dt!=(restraint)NULL) { i++; dt=dt->NEXT; }
             mesh1->nr_of_tractions=i; meshC->nr_of_tractions_basemesh=i;
  /*      D: Count displacements: */
             dt=(restraint)restraint_dll(mesh1->mesh_d,START,0); i=0;
             while (dt!=(restraint)NULL) { i++; dt=dt->NEXT; }
             mesh1->nr_of_displacements=i; meshC->nr_of_displacements_basemesh=i;

  /* STEP 3: Renumber mesh 2: */
  /*      A: Renumber nodes: */
             p=(point)point_dll(mesh2->mesh_p,START,0); 
             while (p!=(point)NULL) 
             { p->label+=meshC->nr_of_nodes_basemesh;
               p=p->NEXT; 
             }
  /*      B: Renumber elements: */
             e=(element)element_dll(mesh2->mesh_e,START,0);
             while (e!=(element)NULL) 
             { e->label+=meshC->nr_of_elements_basemesh;
               e->p1+=meshC->nr_of_nodes_basemesh;
               e->p2+=meshC->nr_of_nodes_basemesh;
               e->p3+=meshC->nr_of_nodes_basemesh;
               e=e->NEXT; 
             }
  /*      C: Renumber tractions: */
             dt=(restraint)restraint_dll(mesh2->mesh_t,START,0);
             while (dt!=(restraint)NULL) 
             { dt->label+=meshC->nr_of_nodes_basemesh;
               dt=dt->NEXT; 
             }
  /*      C: Renumber displacements: */
             dt=(restraint)restraint_dll(mesh2->mesh_d,START,0);
             while (dt!=(restraint)NULL) 
             { dt->label+=meshC->nr_of_nodes_basemesh;
               dt=dt->NEXT; 
             }

  /* STEP 4: Append mesh 2 to mesh 1 in the contact mesh: */
  /*      A: Append points: */
             p=(point)point_dll(mesh1->mesh_p,END,0);
             q=(point)point_dll(mesh2->mesh_p,START,0);
             p->NEXT=q; q->PREV=p;
  /*      B: Append elements: */
             e=(element)element_dll(mesh1->mesh_e,END,0);
             f=(element)element_dll(mesh2->mesh_e,START,0);
             e->NEXT=f; f->PREV=e;
  /*      C: Append tractions: */
             dt =(restraint)restraint_dll(mesh1->mesh_t,END,0);
             dt2=(restraint)restraint_dll(mesh2->mesh_t,START,0);
             if ((dt!=(restraint)NULL)&&(dt2!=(restraint)NULL))
             { dt->NEXT=dt2; dt2->PREV=dt; }
  /*      D: Append displacements: */
             dt =(restraint)restraint_dll(mesh1->mesh_d,END,0);
             dt2=(restraint)restraint_dll(mesh2->mesh_d,START,0);
             if ((dt!=(restraint)NULL)&&(dt2!=(restraint)NULL))
             { dt->NEXT=dt2; dt2->PREV=dt; }

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
movq %rdi, (%rdx)
movq (%rdi), %rdi
xorl %ebp, %ebp
xorl %esi, %esi
xorl %edx, %edx
callq 0xcf07
movl $0x0, %ecx
testq %rax, %rax
je 0x6344
xorl %ecx, %ecx
incl %ecx
movq 0x8(%rax), %rax
testq %rax, %rax
jne 0x6339
movl %ecx, 0x20(%r14)
movl %ecx, 0x8(%r15)
movq 0x8(%r14), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xb834
testq %rax, %rax
je 0x636b
xorl %ebp, %ebp
incl %ebp
movq 0x8(%rax), %rax
testq %rax, %rax
jne 0x6360
movl %ebp, 0x24(%r14)
movl %ebp, 0xc(%r15)
movq 0x18(%r14), %rdi
xorl %ebp, %ebp
xorl %esi, %esi
xorl %edx, %edx
callq 0xd1d1
movl $0x0, %ecx
testq %rax, %rax
je 0x6399
xorl %ecx, %ecx
incl %ecx
movq 0x8(%rax), %rax
testq %rax, %rax
jne 0x638e
movl %ecx, 0x2c(%r14)
movl %ecx, 0x10(%r15)
movq 0x10(%r14), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xd1d1
testq %rax, %rax
je 0x63c0
xorl %ebp, %ebp
incl %ebp
movq 0x8(%rax), %rax
testq %rax, %rax
jne 0x63b5
movl %ebp, 0x28(%r14)
movl %ebp, 0x14(%r15)
movq (%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xcf07
testq %rax, %rax
je 0x63e9
movl 0x8(%r15), %ecx
addl %ecx, 0x10(%rax)
movq 0x8(%rax), %rax
testq %rax, %rax
jne 0x63dd
movq 0x8(%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xb834
testq %rax, %rax
je 0x641d
movq 0x8(%r15), %xmm0
pshufd $0x1, %xmm0, %xmm0      # xmm0 = xmm0[1,0,0,0]
movdqu 0x14(%rax), %xmm1
paddd %xmm0, %xmm1
movdqu %xmm1, 0x14(%rax)
movq 0x8(%rax), %rax
testq %rax, %rax
jne 0x6406
movq 0x18(%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xd1d1
testq %rax, %rax
je 0x643f
movl 0x8(%r15), %ecx
addl %ecx, 0x14(%rax)
movq 0x8(%rax), %rax
testq %rax, %rax
jne 0x6433
movq 0x10(%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xd1d1
testq %rax, %rax
je 0x6461
movl 0x8(%r15), %ecx
addl %ecx, 0x14(%rax)
movq 0x8(%rax), %rax
testq %rax, %rax
jne 0x6455
movq (%r14), %rdi
movl $0x1, %esi
xorl %edx, %edx
callq 0xcf07
movq %rax, %r15
movq (%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xcf07
movq %rax, 0x8(%r15)
movq %r15, (%rax)
movq 0x8(%r14), %rdi
movl $0x1, %esi
xorl %edx, %edx
callq 0xb834
movq %rax, %r15
movq 0x8(%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xb834
movq %rax, 0x8(%r15)
movq %r15, (%rax)
movq 0x18(%r14), %rdi
movl $0x1, %esi
xorl %edx, %edx
callq 0xd1d1
movq %rax, %r15
movq 0x18(%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xd1d1
testq %r15, %r15
setne %cl
testq %rax, %rax
setne %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x64e7
movq %rax, 0x8(%r15)
movq %r15, (%rax)
movq 0x10(%r14), %rdi
movl $0x1, %esi
xorl %edx, %edx
callq 0xd1d1
movq %rax, %r14
movq 0x10(%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xd1d1
testq %r14, %r14
setne %cl
testq %rax, %rax
setne %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x6521
movq %rax, 0x8(%r14)
movq %r14, (%rax)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq