// File: /workspace/github_c_makefile_star2_O2/markpeerdeman[P]mbemm/src/emath/do_contact.c
// Function: do_contact
int do_contact(char *name1, char *name2)
{ mesh  mesh1;  /* mesh for body 1 */
  mesh  mesh2;  /* mesh for body 2 */
  cmesh meshC;  /* contact mesh for both bodies */
  element e;
  intvector nietnul;
  int i;
  int n, m;
  point po;

  WRITE_SPECIAL = NO;
  WRITE_UNIVERSAL = NO;
  READ_SOLUTION = NO;




  /* initialize global datastructures for mesh 1: */
  mesh1=(mesh)malloc(sizeof(meshtype));
  mesh1->mesh_p = point_dll((point)NULL,NEW,0);
  mesh1->mesh_e = element_dll((element)NULL,NEW,0);
  mesh1->mesh_t = restraint_dll((restraint)NULL,NEW,0); mesh1->mesh_t->type=TRACTION;
  mesh1->mesh_d = restraint_dll((restraint)NULL,NEW,0); mesh1->mesh_d->type=DISPLACEMENT;

  /* initialize global datastructures for mesh 2: */
  mesh2=(mesh)malloc(sizeof(meshtype));
  mesh2->mesh_p = point_dll((point)NULL,NEW,0);
  mesh2->mesh_e = element_dll((element)NULL,NEW,0);
  mesh2->mesh_t = restraint_dll((restraint)NULL,NEW,0); mesh2->mesh_t->type=TRACTION;
  mesh2->mesh_d = restraint_dll((restraint)NULL,NEW,0); mesh2->mesh_d->type=DISPLACEMENT;

  /* initialize global datastructures for the contactmesh: */
  meshC=(cmesh)malloc(sizeof(cmeshtype));

  /* parse the inputdeck: */
  parse(name1,mesh1); 
  parse(name2,mesh2); 


  /* join both meshes to a contact mesh: */
  makeCmesh(mesh1,mesh2,meshC);
  /* parse contact nodes: */
  parse_contact(name1,meshC);
  /* make the system dimensionless: */
  scalemesh(meshC->merged_mesh);

  printf("nr_of_nodes_basemesh %d\n",meshC->nr_of_nodes_basemesh);
  printf("nr_of_elements_basemesh %d\n",meshC->nr_of_elements_basemesh);

  find_contactnodes(meshC);

  contact3(meshC);

  /***/  
  po=meshC->merged_mesh->mesh_p;
  m=meshC->nr_of_nodes_basemesh*3;
  n=main_E->cols-m; 
  nietnul=(intvector)newivector(n+m);
  verwijdernullen(m, n, main_E, nietnul,po);


  if (READ_SOLUTION==NO)
  { solve_4(main_E, m, n, main_f, nietnul);
    printvector(main_f,"solution vector");
  }
  if (READ_SOLUTION==YES)
  { fprintf(stderr,"Parsing solution vector...\n"); 
	parse_solution(name1,main_f);
	fprintf(stderr,"Solution vector read.\n");
  }

  post(meshC->merged_mesh,meshC->nr_of_nodes_basemesh); 

  delivector(nietnul);
  delmatrix(main_E); delvector(main_f);
  point_dll(meshC->merged_mesh->mesh_p,KILL,0);
  element_dll(meshC->merged_mesh->mesh_e,KILL,0);
  restraint_dll(meshC->merged_mesh->mesh_t,KILL,0);
  restraint_dll(meshC->merged_mesh->mesh_d,KILL,0);
  free(mesh1); free(mesh2); free(meshC);
  evaluate_level(FINISH,41);
  return (int)1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, (%rsp)
movq %rdi, %r13
leaq 0xf3e9(%rip), %rax      # 0x14418
andl $0x0, (%rax)
leaq 0xf3e3(%rip), %rax      # 0x1441c
andl $0x0, (%rax)
leaq 0xf3e1(%rip), %rax      # 0x14424
andl $0x0, (%rax)
pushq $0x50
popq %r14
movq %r14, %rdi
callq 0x1120
movq %rax, %r15
pushq $0x4
popq %rbp
xorl %edi, %edi
movl %ebp, %esi
xorl %edx, %edx
callq 0xc14c
movq %rax, (%r15)
xorl %edi, %edi
movl %ebp, %esi
xorl %edx, %edx
callq 0xad45
movq %rax, 0x8(%r15)
xorl %edi, %edi
movl %ebp, %esi
xorl %edx, %edx
callq 0xc3a0
movq %rax, 0x18(%r15)
andl $0x0, 0x10(%rax)
xorl %edi, %edi
movl %ebp, %esi
xorl %edx, %edx
callq 0xc3a0
movq %rax, 0x10(%r15)
pushq $0x1
popq %rbx
movl %ebx, 0x10(%rax)
movq %r14, %rdi
callq 0x1120
movq %rax, %r14
xorl %edi, %edi
movl %ebp, %esi
xorl %edx, %edx
callq 0xc14c
movq %rax, (%r14)
xorl %edi, %edi
movl %ebp, %esi
xorl %edx, %edx
callq 0xad45
movq %rax, 0x8(%r14)
xorl %edi, %edi
movl %ebp, %esi
xorl %edx, %edx
callq 0xc3a0
movq %rax, 0x18(%r14)
andl $0x0, 0x10(%rax)
xorl %edi, %edi
movl %ebp, %esi
xorl %edx, %edx
callq 0xc3a0
movq %rax, 0x10(%r14)
movl %ebx, 0x10(%rax)
pushq $0x18
popq %rdi
callq 0x1120
movq %rax, %r12
movq %r13, %rdi
movq %r15, %rsi
callq 0x58d4
movq (%rsp), %rdi
movq %r14, %rsi
callq 0x58d4
movq %r15, (%rsp)
movq %r15, %rdi
movq %r14, 0x10(%rsp)
movq %r14, %rsi
movq %r12, %rdx
callq 0x4e21
movq %r13, 0x8(%rsp)
movq %r13, %rdi
movq %r12, %rsi
callq 0x5bc4
movq (%r12), %rdi
callq 0x8c50
movl 0x8(%r12), %esi
leaq 0x8d7e(%rip), %rdi      # 0xdec6
xorl %eax, %eax
callq 0x1090
movl 0xc(%r12), %esi
leaq 0x8d84(%rip), %rdi      # 0xdedf
xorl %eax, %eax
callq 0x1090
movq %r12, %rdi
callq 0x4c8c
movq %r12, %rdi
callq 0x787e
movq (%r12), %rax
movq (%rax), %rbx
imull $0x3, 0x8(%r12), %ebp
leaq 0xf2aa(%rip), %r14      # 0x14430
movq (%r14), %rax
movl 0x4(%rax), %edi
movl %edi, %r15d
subl %ebp, %r15d
callq 0xafb4
movq %rax, %r13
movq (%r14), %rdx
movl %ebp, %edi
movl %r15d, %esi
movq %rax, %rcx
movq %rbx, %r8
callq 0xbe99
leaq 0xf270(%rip), %rax      # 0x14424
movl (%rax), %eax
testl %eax, %eax
jne 0x51f3
leaq 0xf26f(%rip), %rax      # 0x14430
movq (%rax), %rdi
leaq 0xf26d(%rip), %rbx      # 0x14438
movq (%rbx), %rcx
movl %ebp, %esi
movl %r15d, %edx
movq %r13, %r8
callq 0x13eb
movq (%rbx), %rdi
leaq 0x7ef1(%rip), %rsi      # 0xd0d6
callq 0xbad7
leaq 0xf233(%rip), %rax      # 0x14424
movl (%rax), %eax
cmpl $0x1, %eax
je 0x52ae
movq (%r12), %rdi
movl 0x8(%r12), %esi
callq 0x4b29
movq %r13, %rdi
callq 0xb0b4
leaq 0xf217(%rip), %rax      # 0x14430
movq (%rax), %rdi
callq 0xb3b2
leaq 0xf210(%rip), %rax      # 0x14438
movq (%rax), %rdi
callq 0xb43d
movq (%r12), %rax
movq (%rax), %rdi
pushq $0x5
popq %rbx
movl %ebx, %esi
xorl %edx, %edx
callq 0xc14c
movq (%r12), %rax
movq 0x8(%rax), %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0xad45
movq (%r12), %rax
movq 0x18(%rax), %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0xc3a0
movq (%r12), %rax
movq 0x10(%rax), %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0xc3a0
movq (%rsp), %rdi
callq 0x1030
movq 0x10(%rsp), %rdi
callq 0x1030
movq %r12, %rdi
callq 0x1030
pushq $0x4
popq %rdi
pushq $0x29
popq %rsi
callq 0xb0f8
pushq $0x1
popq %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xed43(%rip), %r15      # 0x13ff8
movq (%r15), %rcx
leaq 0x7e5e(%rip), %rdi      # 0xd11d
pushq $0x1b
popq %rsi
pushq $0x1
popq %rbx
movq %rbx, %rdx
callq 0x1190
leaq 0xf164(%rip), %rax      # 0x14438
movq (%rax), %rsi
movq 0x8(%rsp), %rdi
callq 0x5ce5
movq (%r15), %rcx
leaq 0x7e4e(%rip), %rdi      # 0xd139
pushq $0x16
popq %rsi
movq %rbx, %rdx
callq 0x1190
jmp 0x51fc
nop