// File: /workspace/github_c_makefile_star2_O2/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 0xc14c
testq %rax, %rax
je 0x4e4f
incl %ebp
movq 0x8(%rax), %rax
jmp 0x4e42
movl %ebp, 0x20(%r14)
movl %ebp, 0x8(%r15)
movq 0x8(%r14), %rdi
xorl %ebp, %ebp
xorl %esi, %esi
xorl %edx, %edx
callq 0xad45
testq %rax, %rax
je 0x4e73
incl %ebp
movq 0x8(%rax), %rax
jmp 0x4e66
movl %ebp, 0x24(%r14)
movl %ebp, 0xc(%r15)
movq 0x18(%r14), %rdi
xorl %ebp, %ebp
xorl %esi, %esi
xorl %edx, %edx
callq 0xc3a0
testq %rax, %rax
je 0x4e97
incl %ebp
movq 0x8(%rax), %rax
jmp 0x4e8a
movl %ebp, 0x2c(%r14)
movl %ebp, 0x10(%r15)
movq 0x10(%r14), %rdi
xorl %ebp, %ebp
xorl %esi, %esi
xorl %edx, %edx
callq 0xc3a0
testq %rax, %rax
je 0x4ebb
incl %ebp
movq 0x8(%rax), %rax
jmp 0x4eae
movl %ebp, 0x28(%r14)
movl %ebp, 0x14(%r15)
movq (%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xc14c
testq %rax, %rax
je 0x4ee1
movl 0x8(%r15), %ecx
addl %ecx, 0x10(%rax)
movq 0x8(%rax), %rax
jmp 0x4ecf
movq 0x8(%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xad45
testq %rax, %rax
je 0x4f12
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
jmp 0x4eee
movq 0x18(%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xc3a0
testq %rax, %rax
je 0x4f31
movl 0x8(%r15), %ecx
addl %ecx, 0x14(%rax)
movq 0x8(%rax), %rax
jmp 0x4f1f
movq 0x10(%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xc3a0
testq %rax, %rax
je 0x4f50
movl 0x8(%r15), %ecx
addl %ecx, 0x14(%rax)
movq 0x8(%rax), %rax
jmp 0x4f3e
movq (%r14), %rdi
pushq $0x1
popq %rbp
movl %ebp, %esi
xorl %edx, %edx
callq 0xc14c
movq %rax, %r15
movq (%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xc14c
movq %rax, 0x8(%r15)
movq %r15, (%rax)
movq 0x8(%r14), %rdi
movl %ebp, %esi
xorl %edx, %edx
callq 0xad45
movq %rax, %r15
movq 0x8(%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xad45
movq %rax, 0x8(%r15)
movq %r15, (%rax)
movq 0x18(%r14), %rdi
movl %ebp, %esi
xorl %edx, %edx
callq 0xc3a0
movq %rax, %r15
movq 0x18(%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xc3a0
testq %r15, %r15
setne %cl
testq %rax, %rax
setne %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x4fd0
movq %rax, 0x8(%r15)
movq %r15, (%rax)
movq 0x10(%r14), %rdi
pushq $0x1
popq %rsi
xorl %edx, %edx
callq 0xc3a0
movq %rax, %r14
movq 0x10(%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xc3a0
testq %r14, %r14
setne %cl
testq %rax, %rax
setne %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x5008
movq %rax, 0x8(%r14)
movq %r14, (%rax)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq