// File: /workspace/github_c_makefile_star2_O0/markpeerdeman[P]mbemm/src/emath/contactc.c
// Function: makelocalsystem
void makelocalsystem(matrix tramat, point p)
{ double min; 
  double max;
  double tmp;
  int smallest;
  int largest;
  int middle;
  int sum;
  double len;
  /* STEP 1: copy the contents of the normal vector to the first matrix column: */
             M(tramat,1,1)=p->n1;
             M(tramat,2,1)=p->n2;
             M(tramat,3,1)=p->n3;
  /* STEP 2: construct a vector perpendicular to the normal vector: */
  /*      a: find minimum and maximum components: */
             min=fabs(p->n1); max=min; smallest=1; largest=1; 
             tmp=fabs(p->n2); if (tmp<min) { min=tmp; smallest=2; }
                              if (tmp>max) { max=tmp; largest=2; }
             tmp=fabs(p->n3); if (tmp<min) { min=tmp; smallest=3; }
                              if (tmp>max) { max=tmp; largest=3; }
             sum=smallest+largest;
             if (sum==3) middle=3; else
             if (sum==4) middle=2; else
             if (sum==5) middle=1; 
  /*      b: Put the results in the second matrix column and swap something: */
             M(tramat,smallest,2)=  0.0;
             M(tramat,middle,2)  = -M(tramat,largest,1);
             M(tramat,largest,2) =  M(tramat,middle,1);
             len=sqrt(M(tramat,middle,2)*M(tramat,middle,2)+M(tramat,largest,2)*M(tramat,largest,2));
             M(tramat,middle,2)=M(tramat,middle,2)/len;
             M(tramat,largest,2)=M(tramat,largest,2)/len;
             /* ^ moet genormeerd worden! */
  /* STEP 3: The third base vector is calculated as the vectorproduct of the
             two other vectors: */
             M(tramat,1,3) = p->n2*M(tramat,2,3)-p->n3*M(tramat,2,2);
             M(tramat,2,3) = p->n3*M(tramat,2,1)-p->n1*M(tramat,2,3);
             M(tramat,3,3) = p->n1*M(tramat,2,2)-p->n2*M(tramat,2,1);
}

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x40(%rsp)
movq %rsi, 0x38(%rsp)
movq 0x38(%rsp), %rax
movsd 0x68(%rax), %xmm0
movq 0x40(%rsp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movsd %xmm0, (%rax)
movq 0x38(%rsp), %rax
movsd 0x70(%rax), %xmm0
movq 0x40(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movsd %xmm0, (%rax)
movq 0x38(%rsp), %rax
movsd 0x78(%rax), %xmm0
movq 0x40(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rax
movsd %xmm0, (%rax)
movq 0x38(%rsp), %rax
movsd 0x68(%rax), %xmm0
movaps 0xe311(%rip), %xmm1     # 0x19010
pand %xmm1, %xmm0
movsd %xmm0, 0x30(%rsp)
movsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
movl $0x1, 0x1c(%rsp)
movl $0x1, 0x18(%rsp)
movq 0x38(%rsp), %rax
movsd 0x70(%rax), %xmm0
movaps 0xe2da(%rip), %xmm1     # 0x19010
pand %xmm1, %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x20(%rsp), %xmm1
movsd 0x30(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xad66
movsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
movl $0x2, 0x1c(%rsp)
movsd 0x20(%rsp), %xmm0
ucomisd 0x28(%rsp), %xmm0
jbe 0xad88
movsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
movl $0x2, 0x18(%rsp)
movq 0x38(%rsp), %rax
movsd 0x78(%rax), %xmm0
movaps 0xe277(%rip), %xmm1     # 0x19010
pand %xmm1, %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x20(%rsp), %xmm1
movsd 0x30(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xadc9
movsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
movl $0x3, 0x1c(%rsp)
movsd 0x20(%rsp), %xmm0
ucomisd 0x28(%rsp), %xmm0
jbe 0xadeb
movsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
movl $0x3, 0x18(%rsp)
movl 0x1c(%rsp), %eax
addl 0x18(%rsp), %eax
movl %eax, 0x10(%rsp)
cmpl $0x3, 0x10(%rsp)
jne 0xae08
movl $0x3, 0x14(%rsp)
jmp 0xae2c
cmpl $0x4, 0x10(%rsp)
jne 0xae19
movl $0x2, 0x14(%rsp)
jmp 0xae2a
cmpl $0x5, 0x10(%rsp)
jne 0xae28
movl $0x1, 0x14(%rsp)
jmp 0xae2a
jmp 0xae2c
movq 0x40(%rsp), %rax
movq 0x8(%rax), %rax
movl 0x1c(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x8(%rax)
movq 0x40(%rsp), %rax
movq 0x8(%rax), %rax
movl 0x18(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movsd (%rax), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movq 0x40(%rsp), %rax
movq 0x8(%rax), %rax
movl 0x14(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movsd %xmm0, 0x8(%rax)
movq 0x40(%rsp), %rax
movq 0x8(%rax), %rax
movl 0x14(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movsd (%rax), %xmm0
movq 0x40(%rsp), %rax
movq 0x8(%rax), %rax
movl 0x18(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movsd %xmm0, 0x8(%rax)
movq 0x40(%rsp), %rax
movq 0x8(%rax), %rax
movl 0x14(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movsd 0x8(%rax), %xmm0
movq 0x40(%rsp), %rax
movq 0x8(%rax), %rax
movl 0x14(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movsd 0x8(%rax), %xmm2
movq 0x40(%rsp), %rax
movq 0x8(%rax), %rax
movl 0x18(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movsd 0x8(%rax), %xmm1
movq 0x40(%rsp), %rax
movq 0x8(%rax), %rax
movl 0x18(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
mulsd 0x8(%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0x1150
movsd %xmm0, 0x8(%rsp)
movq 0x40(%rsp), %rax
movq 0x8(%rax), %rax
movl 0x14(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movsd 0x8(%rax), %xmm0
divsd 0x8(%rsp), %xmm0
movq 0x40(%rsp), %rax
movq 0x8(%rax), %rax
movl 0x14(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movsd %xmm0, 0x8(%rax)
movq 0x40(%rsp), %rax
movq 0x8(%rax), %rax
movl 0x18(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movsd 0x8(%rax), %xmm0
divsd 0x8(%rsp), %xmm0
movq 0x40(%rsp), %rax
movq 0x8(%rax), %rax
movl 0x18(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movsd %xmm0, 0x8(%rax)
movq 0x38(%rsp), %rax
movsd 0x70(%rax), %xmm0
movq 0x40(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movsd 0x10(%rax), %xmm2
movq 0x38(%rsp), %rax
movsd 0x78(%rax), %xmm1
movq 0x40(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
mulsd 0x8(%rax), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0x40(%rsp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movsd %xmm0, 0x10(%rax)
movq 0x38(%rsp), %rax
movsd 0x78(%rax), %xmm0
movq 0x40(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movsd (%rax), %xmm2
movq 0x38(%rsp), %rax
movsd 0x68(%rax), %xmm1
movq 0x40(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
mulsd 0x10(%rax), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0x40(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movsd %xmm0, 0x10(%rax)
movq 0x38(%rsp), %rax
movsd 0x68(%rax), %xmm0
movq 0x40(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movsd 0x8(%rax), %xmm2
movq 0x38(%rsp), %rax
movsd 0x70(%rax), %xmm1
movq 0x40(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
mulsd (%rax), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0x40(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rax
movsd %xmm0, 0x10(%rax)
addq $0x48, %rsp
retq
nopl (%rax)