// File: /workspace/github_c_makefile_star2_O1/markpeerdeman[P]mbemm/src/emath/contactc.c
// Function: make_a
void make_a(point i, hypermatrix crow, hypermatrix erow, cmesh theCMesh)
{ vector B;
  point  j;
  matrix tramat;
  int    nnds;
  restraint r;
  restraint t;
  double t1, t2, t3;

  B=(vector)newvector(3);
  tramat=(matrix)newmatrix(3,3);
  nnds=theCMesh->nr_of_nodes_basemesh;

  j=(point)point_dll(theCMesh->merged_mesh->mesh_p,START,0);
  while (j!=(point)NULL)
  { if ((j->label<=nnds)&&(i->label<=nnds) )  /* if both points on body 1: */
    { if (j->type==CNODE)
      { /* transform to local coordinates: */
	makelocalsystem(tramat,j);
        matcopy3x3(crow->data[j->label],ctemp); matmul(crow->data[j->label],ctemp,tramat);
        matcopy3x3(erow->data[j->label],ctemp); matmul(erow->data[j->label],ctemp,tramat);
	/* make the submatrix for j: */
	H(crow,1,2,j->label)=-H(erow,1,2,j->label);
	H(crow,2,2,j->label)=-H(erow,2,2,j->label);
	H(crow,3,2,j->label)=-H(erow,3,2,j->label);
	H(crow,1,3,j->label)=-H(erow,1,3,j->label);
	H(crow,2,3,j->label)=-H(erow,2,3,j->label);
	H(crow,3,3,j->label)=-H(erow,3,3,j->label);
	/* make the submatrix for j->connecting: */
	H(crow,1,1,j->conn )=-H(erow,1,1,j->label);
	H(crow,2,1,j->conn )=-H(erow,2,1,j->label);
	H(crow,3,1,j->conn )=-H(erow,3,1,j->label);
      }
      else /* the node is NOT a CNODE: */
      { r=(restraint)restraint_dll(theCMesh->merged_mesh->mesh_d,SEARCH,j->label);
        if (r==(restraint)NULL) /* i.e. the traction is prescribed */
        { t=(restraint)restraint_dll(theCMesh->merged_mesh->mesh_t,SEARCH,j->label); 
          if (t==(restraint)NULL) { t1=0.0; t2=0.0; t3=0.0; } else { t1=t->f1; t2=t->f2; t3=t->f3; }
          V(B,1)=V(B,1)-H(crow,1,1,j->label)*t1 
                       -H(crow,1,2,j->label)*t2
                       -H(crow,1,3,j->label)*t3;
          V(B,2)=V(B,2)-H(crow,2,1,j->label)*t1 
                       -H(crow,2,2,j->label)*t2
                       -H(crow,2,3,j->label)*t3;
          V(B,3)=V(B,3)-H(crow,3,1,j->label)*t1 
                       -H(crow,3,2,j->label)*t2
                       -H(crow,3,3,j->label)*t3;
          matcopy3x3(erow->data[j->label],crow->data[j->label]);
          scalemat3x3(crow->data[j->label],-1.0);
        }
        else /* i.e. the displacement is prescribed */
        { V(B,1)=V(B,1)+H(erow,1,1,j->label)*r->u1 
                       +H(erow,1,2,j->label)*r->u2
                       +H(erow,1,3,j->label)*r->u3;
          V(B,2)=V(B,2)+H(erow,2,1,j->label)*r->u1 
                       +H(erow,2,2,j->label)*r->u2
                       +H(erow,2,3,j->label)*r->u3;
          V(B,3)=V(B,3)+H(erow,3,1,j->label)*r->u1 
                       +H(erow,3,2,j->label)*r->u2
                       +H(erow,3,3,j->label)*r->u3;
        } 
      }
    }
    if ( (j->label>nnds)&&(i->label>nnds) )   /* if both points on body 2: */
    { if (j->type==CNODE)
      { /* transform to local coordinates: */
	makelocalsystem(tramat,j);
        matcopy3x3(crow->data[j->label],ctemp); matmul(crow->data[j->label],ctemp,tramat);
        matcopy3x3(erow->data[j->label],ctemp); matmul(erow->data[j->label],ctemp,tramat);
	/* make the submatrix for j->connecting: */
	H(crow,1,1,j->conn)=-H(crow,1,1,j->label);
	H(crow,2,1,j->conn)=-H(crow,2,1,j->label);
	H(crow,3,1,j->conn)=-H(crow,3,1,j->label);
	/* make the submatrix for j: */
        matcopy3x3(erow->data[j->label],crow->data[j->label]);
        scalemat3x3(crow->data[j->label],-1.0);
      }
      else
      { r=(restraint)restraint_dll(theCMesh->merged_mesh->mesh_d,SEARCH,j->label);
        if (r==(restraint)NULL) /* i.e. the traction is prescribed */
        { t=(restraint)restraint_dll(theCMesh->merged_mesh->mesh_t,SEARCH,j->label); 
          if (t==(restraint)NULL) { t1=0.0; t2=0.0; t3=0.0; } else { t1=t->f1; t2=t->f2; t3=t->f3; }
          V(B,1)=V(B,1)-H(crow,1,1,j->label)*t1 
                       -H(crow,1,2,j->label)*t2
                       -H(crow,1,3,j->label)*t3;
          V(B,2)=V(B,2)-H(crow,2,1,j->label)*t1 
                       -H(crow,2,2,j->label)*t2
                       -H(crow,2,3,j->label)*t3;
          V(B,3)=V(B,3)-H(crow,3,1,j->label)*t1 
                       -H(crow,3,2,j->label)*t2
                       -H(crow,3,3,j->label)*t3;
          matcopy3x3(erow->data[j->label],crow->data[j->label]);
          scalemat3x3(crow->data[j->label],-1.0);
        }
        else /* i.e. the displacement is prescribed */
        { V(B,1)=V(B,1)+H(erow,1,1,j->label)*r->u1 
                       +H(erow,1,2,j->label)*r->u2
                       +H(erow,1,3,j->label)*r->u3;
          V(B,2)=V(B,2)+H(erow,2,1,j->label)*r->u1 
                       +H(erow,2,2,j->label)*r->u2
                       +H(erow,2,3,j->label)*r->u3;
          V(B,3)=V(B,3)+H(erow,3,1,j->label)*r->u1 
                       +H(erow,3,2,j->label)*r->u2
                       +H(erow,3,3,j->label)*r->u3;
        } 
      }
    }
    j=j->NEXT;
  }

  V(main_f,i->label*3-2)=V(B,1);
  V(main_f,i->label*3-1)=V(B,2);
  V(main_f,i->label*3  )=V(B,3);

  delvector(B);
  delmatrix(tramat);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %r15
movq %rdx, %r13
movq %rsi, %rbp
movq %rdi, %r14
movl $0x3, %edi
callq 0xbde7
movq %rax, (%rsp)
movl $0x3, %edi
movl $0x3, %esi
callq 0xbcb0
movq %rax, 0x10(%rsp)
movl 0x8(%r15), %r12d
movq (%r15), %rax
movq (%rax), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xcf07
testq %rax, %rax
je 0x882f
movq %rax, %rbx
movq %r15, 0x8(%rsp)
movl 0x10(%rbx), %edx
cmpl %r12d, %edx
jg 0x8559
cmpl %r12d, 0x10(%r14)
jg 0x8559
cmpl $0xf, 0x14(%rbx)
jne 0x8389
movq 0x10(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0x7804
movq 0x8(%rbp), %rax
movslq 0x10(%rbx), %rcx
movq (%rax,%rcx,8), %rdi
movq 0xd539(%rip), %rsi      # 0x15798
callq 0xc92e
movq 0x8(%rbp), %rax
movslq 0x10(%rbx), %rcx
movq (%rax,%rcx,8), %rdi
movq 0xd521(%rip), %rsi      # 0x15798
movq %r15, %rdx
callq 0xc421
movq 0x8(%r13), %rax
movslq 0x10(%rbx), %rcx
movq (%rax,%rcx,8), %rdi
movq 0xd506(%rip), %rsi      # 0x15798
callq 0xc92e
movq 0x8(%r13), %rax
movslq 0x10(%rbx), %rcx
movq (%rax,%rcx,8), %rdi
movq 0xd4ee(%rip), %rsi      # 0x15798
movq %r15, %rdx
callq 0xc421
movq 0x8(%r13), %rax
movslq 0x10(%rbx), %rdx
movq (%rax,%rdx,8), %rax
movq 0x8(%rax), %rsi
movq (%rsi), %rax
movsd 0x8(%rax), %xmm0
movapd 0x5d4e(%rip), %xmm1     # 0xe020
xorpd %xmm1, %xmm0
movq 0x8(%rbp), %rcx
movq (%rcx,%rdx,8), %rdx
movq 0x8(%rdx), %rdi
movq (%rdi), %r8
movlpd %xmm0, 0x8(%r8)
movq 0x8(%rsi), %rdx
movsd 0x8(%rdx), %xmm0
xorpd %xmm1, %xmm0
movq 0x8(%rdi), %r9
movlpd %xmm0, 0x8(%r9)
movq 0x10(%rsi), %rsi
movsd 0x8(%rsi), %xmm0
xorpd %xmm1, %xmm0
movq 0x10(%rdi), %rdi
movlpd %xmm0, 0x8(%rdi)
movsd 0x10(%rax), %xmm0
xorpd %xmm1, %xmm0
movlpd %xmm0, 0x10(%r8)
movsd 0x10(%rdx), %xmm0
xorpd %xmm1, %xmm0
movlpd %xmm0, 0x10(%r9)
movsd 0x10(%rsi), %xmm0
xorpd %xmm1, %xmm0
movlpd %xmm0, 0x10(%rdi)
movsd (%rax), %xmm0
xorpd %xmm1, %xmm0
movslq 0x18(%rbx), %rax
movq (%rcx,%rax,8), %rax
movq 0x8(%rax), %rax
movq (%rax), %rcx
movlpd %xmm0, (%rcx)
movsd (%rdx), %xmm0
xorpd %xmm1, %xmm0
movq 0x8(%rax), %rcx
movlpd %xmm0, (%rcx)
movq 0x8(%rsp), %r15
movsd (%rsi), %xmm0
xorpd %xmm1, %xmm0
movq 0x10(%rax), %rax
movlpd %xmm0, (%rax)
jmp 0x8559
movq (%r15), %rax
movq 0x10(%rax), %rdi
movl $0x2, %esi
callq 0xd1d1
movslq 0x10(%rbx), %rdx
testq %rax, %rax
je 0x8456
movq (%rsp), %rcx
movq 0x8(%rcx), %rcx
movq 0x8(%r13), %rsi
movq (%rsi,%rdx,8), %rdx
movq 0x8(%rdx), %rdx
movq (%rdx), %rsi
movsd (%rsi), %xmm0
movsd 0x8(%rsi), %xmm1
mulsd 0x30(%rax), %xmm0
addsd (%rcx), %xmm0
mulsd 0x38(%rax), %xmm1
addsd %xmm0, %xmm1
movsd 0x10(%rsi), %xmm0
mulsd 0x40(%rax), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rcx)
movq 0x8(%rdx), %rsi
movsd (%rsi), %xmm0
mulsd 0x30(%rax), %xmm0
addsd 0x8(%rcx), %xmm0
movsd 0x8(%rsi), %xmm1
mulsd 0x38(%rax), %xmm1
addsd %xmm0, %xmm1
movsd 0x10(%rsi), %xmm0
mulsd 0x40(%rax), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rcx)
movq 0x10(%rdx), %rdx
movsd (%rdx), %xmm0
movsd 0x8(%rdx), %xmm1
mulsd 0x30(%rax), %xmm0
addsd 0x10(%rcx), %xmm0
mulsd 0x38(%rax), %xmm1
addsd %xmm0, %xmm1
movsd 0x10(%rdx), %xmm0
mulsd 0x40(%rax), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rcx)
jmp 0x8559
movq (%r15), %rax
movq 0x18(%rax), %rdi
movl $0x2, %esi
callq 0xd1d1
testq %rax, %rax
je 0x847d
movsd 0x18(%rax), %xmm1
movsd 0x20(%rax), %xmm2
movsd 0x28(%rax), %xmm0
jmp 0x8489
xorpd %xmm1, %xmm1
xorpd %xmm2, %xmm2
xorpd %xmm0, %xmm0
movq (%rsp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rbp), %rdx
movslq 0x10(%rbx), %rcx
movq (%rdx,%rcx,8), %rsi
movq 0x8(%rsi), %rdx
movq (%rdx), %rdi
movsd (%rdi), %xmm3
mulsd %xmm1, %xmm3
movsd (%rax), %xmm4
subsd %xmm3, %xmm4
movsd 0x8(%rax), %xmm3
movsd 0x8(%rdi), %xmm5
mulsd %xmm2, %xmm5
subsd %xmm5, %xmm4
movsd 0x10(%rdi), %xmm5
mulsd %xmm0, %xmm5
subsd %xmm5, %xmm4
movsd %xmm4, (%rax)
movq 0x8(%rdx), %rdi
movsd (%rdi), %xmm4
mulsd %xmm1, %xmm4
subsd %xmm4, %xmm3
movsd 0x8(%rdi), %xmm4
mulsd %xmm2, %xmm4
subsd %xmm4, %xmm3
movsd 0x10(%rdi), %xmm4
mulsd %xmm0, %xmm4
subsd %xmm4, %xmm3
movsd %xmm3, 0x8(%rax)
movsd 0x10(%rax), %xmm3
movq 0x10(%rdx), %rdx
mulsd (%rdx), %xmm1
mulsd 0x8(%rdx), %xmm2
subsd %xmm1, %xmm3
subsd %xmm2, %xmm3
mulsd 0x10(%rdx), %xmm0
subsd %xmm0, %xmm3
movsd %xmm3, 0x10(%rax)
movq 0x8(%r13), %rax
movq (%rax,%rcx,8), %rdi
callq 0xc92e
movq 0x8(%rbp), %rax
movslq 0x10(%rbx), %rcx
movq (%rax,%rcx,8), %rdi
movsd 0x6ab1(%rip), %xmm0     # 0xf000
callq 0xc558
movq 0x8(%rsp), %r15
movl 0x10(%rbx), %edx
cmpl %r12d, %edx
jle 0x8822
cmpl %r12d, 0x10(%r14)
jle 0x8822
cmpl $0xf, 0x14(%rbx)
jne 0x8652
movq 0x10(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0x7804
movq 0x8(%rbp), %rax
movslq 0x10(%rbx), %rcx
movq (%rax,%rcx,8), %rdi
movq 0xd1fc(%rip), %rsi      # 0x15798
callq 0xc92e
movq 0x8(%rbp), %rax
movslq 0x10(%rbx), %rcx
movq (%rax,%rcx,8), %rdi
movq 0xd1e4(%rip), %rsi      # 0x15798
movq %r15, %rdx
callq 0xc421
movq 0x8(%r13), %rax
movslq 0x10(%rbx), %rcx
movq (%rax,%rcx,8), %rdi
movq 0xd1c9(%rip), %rsi      # 0x15798
callq 0xc92e
movq 0x8(%r13), %rax
movslq 0x10(%rbx), %rcx
movq (%rax,%rcx,8), %rdi
movq 0xd1b1(%rip), %rsi      # 0x15798
movq %r15, %rdx
callq 0xc421
movq 0x8(%rbp), %rax
movslq 0x10(%rbx), %rcx
movq (%rax,%rcx,8), %rsi
movq 0x8(%rsi), %rdx
movq (%rdx), %rdi
movsd (%rdi), %xmm0
movapd 0x5a12(%rip), %xmm1     # 0xe020
xorpd %xmm1, %xmm0
movslq 0x18(%rbx), %rdi
movq (%rax,%rdi,8), %rax
movq 0x8(%rax), %rax
movq (%rax), %rdi
movlpd %xmm0, (%rdi)
movq 0x8(%rdx), %rdi
movsd (%rdi), %xmm0
xorpd %xmm1, %xmm0
movq 0x8(%rax), %rdi
movlpd %xmm0, (%rdi)
movq 0x10(%rdx), %rdx
movsd (%rdx), %xmm0
xorpd %xmm1, %xmm0
movq 0x10(%rax), %rax
movlpd %xmm0, (%rax)
jmp 0x87f7
movq (%r15), %rax
movq 0x10(%rax), %rdi
movl $0x2, %esi
callq 0xd1d1
movslq 0x10(%rbx), %rdx
testq %rax, %rax
je 0x871f
movq (%rsp), %rcx
movq 0x8(%rcx), %rcx
movq 0x8(%r13), %rsi
movq (%rsi,%rdx,8), %rdx
movq 0x8(%rdx), %rdx
movq (%rdx), %rsi
movsd (%rsi), %xmm0
movsd 0x8(%rsi), %xmm1
mulsd 0x30(%rax), %xmm0
addsd (%rcx), %xmm0
mulsd 0x38(%rax), %xmm1
addsd %xmm0, %xmm1
movsd 0x10(%rsi), %xmm0
mulsd 0x40(%rax), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rcx)
movq 0x8(%rdx), %rsi
movsd (%rsi), %xmm0
mulsd 0x30(%rax), %xmm0
addsd 0x8(%rcx), %xmm0
movsd 0x8(%rsi), %xmm1
mulsd 0x38(%rax), %xmm1
addsd %xmm0, %xmm1
movsd 0x10(%rsi), %xmm0
mulsd 0x40(%rax), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rcx)
movq 0x10(%rdx), %rdx
movsd (%rdx), %xmm0
movsd 0x8(%rdx), %xmm1
mulsd 0x30(%rax), %xmm0
addsd 0x10(%rcx), %xmm0
mulsd 0x38(%rax), %xmm1
addsd %xmm0, %xmm1
movsd 0x10(%rdx), %xmm0
mulsd 0x40(%rax), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rcx)
jmp 0x8822
movq (%r15), %rax
movq 0x18(%rax), %rdi
movl $0x2, %esi
callq 0xd1d1
testq %rax, %rax
je 0x8746
movsd 0x18(%rax), %xmm1
movsd 0x20(%rax), %xmm2
movsd 0x28(%rax), %xmm0
jmp 0x8752
xorpd %xmm1, %xmm1
xorpd %xmm2, %xmm2
xorpd %xmm0, %xmm0
movq (%rsp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rbp), %rdx
movslq 0x10(%rbx), %rcx
movq (%rdx,%rcx,8), %rsi
movq 0x8(%rsi), %rdx
movq (%rdx), %rdi
movsd (%rdi), %xmm3
mulsd %xmm1, %xmm3
movsd (%rax), %xmm4
subsd %xmm3, %xmm4
movsd 0x8(%rax), %xmm3
movsd 0x8(%rdi), %xmm5
mulsd %xmm2, %xmm5
subsd %xmm5, %xmm4
movsd 0x10(%rdi), %xmm5
mulsd %xmm0, %xmm5
subsd %xmm5, %xmm4
movsd %xmm4, (%rax)
movq 0x8(%rdx), %rdi
movsd (%rdi), %xmm4
mulsd %xmm1, %xmm4
subsd %xmm4, %xmm3
movsd 0x8(%rdi), %xmm4
mulsd %xmm2, %xmm4
subsd %xmm4, %xmm3
movsd 0x10(%rdi), %xmm4
mulsd %xmm0, %xmm4
subsd %xmm4, %xmm3
movsd %xmm3, 0x8(%rax)
movsd 0x10(%rax), %xmm3
movq 0x10(%rdx), %rdx
mulsd (%rdx), %xmm1
mulsd 0x8(%rdx), %xmm2
subsd %xmm1, %xmm3
subsd %xmm2, %xmm3
mulsd 0x10(%rdx), %xmm0
subsd %xmm0, %xmm3
movsd %xmm3, 0x10(%rax)
movq 0x8(%r13), %rax
movq (%rax,%rcx,8), %rdi
callq 0xc92e
movq 0x8(%rbp), %rax
movslq 0x10(%rbx), %rcx
movq (%rax,%rcx,8), %rdi
movsd 0x67e8(%rip), %xmm0     # 0xf000
callq 0xc558
movq 0x8(%rsp), %r15
movq 0x8(%rbx), %rbx
testq %rbx, %rbx
jne 0x821c
movq (%rsp), %rdi
movq 0x8(%rdi), %rax
movsd (%rax), %xmm0
leaq 0xcc06(%rip), %rcx      # 0x15448
movq (%rcx), %rcx
movq 0x8(%rcx), %rcx
movslq 0x10(%r14), %rdx
leaq (%rdx,%rdx,2), %rdx
movsd %xmm0, -0x18(%rcx,%rdx,8)
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x10(%rcx,%rdx,8)
movsd 0x10(%rax), %xmm0
movsd %xmm0, -0x8(%rcx,%rdx,8)
callq 0xbef3
movq 0x10(%rsp), %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xbe4b
nop