// File: /workspace/github_c_makefile_star2_O2/josch[P]stride/nsc.c
// Function: ico_dot_arc
int ico_dot_arc(int densit) { /* densit...required dots per unit sphere */
/* dot distribution on a unit sphere based on an icosaeder *
 * great circle average refining of icosahedral face       */

  int i, j, k, tl, tl2, tn, tess;
  double a, d, x, y, z, x2, y2, z2, x3, y3, z3;
  double xij, yij, zij, xji, yji, zji, xik, yik, zik, xki, yki, zki,
    xjk, yjk, zjk, xkj, ykj, zkj;
  point_double xus=NULL;

/* calculate tessalation level */
  a = sqrt((((double) densit)-2.)/10.);
  tess = (int) ceil(a);
  n_dot = 10*tess*tess+2;
  if (n_dot < densit) {
    ERROR("ico_dot_arc: error in formula for tessalation level (%d->%d, %d)",
      tess, n_dot, densit);
    }

  xus = (double *) CALLOC(3*n_dot, sizeof(double));
  xpunsp = xus;
  icosaeder_vertices(xus);

  if (tess > 1) {
    tn = 12;
    a = rh*rh*2.*(1.-cos(TORAD(72.)));
/* calculate tessalation of icosaeder edges */
    for (i=0; i<11; i++) {
      for (j=i+1; j<12; j++) {
        x = xus[3*i]-xus[3*j];
        y = xus[1+3*i]-xus[1+3*j]; z = xus[2+3*i]-xus[2+3*j];
        d = x*x+y*y+z*z;
        if (fabs(a-d) > DP_TOL) continue;
        for (tl=1; tl<tess; tl++) {
          if (tn >= n_dot) { ERROR("ico_dot: tn exceeds dimension of xus"); }
          divarc(xus[3*i], xus[1+3*i], xus[2+3*i],
                 xus[3*j], xus[1+3*j], xus[2+3*j],
            tl, tess, &xus[3*tn], &xus[1+3*tn], &xus[2+3*tn]);
          tn++;
          }
        }
      }
/* calculate tessalation of icosaeder faces */
    for (i=0; i<10; i++) {
      for (j=i+1; j<11; j++) {
        x = xus[3*i]-xus[3*j];
        y = xus[1+3*i]-xus[1+3*j]; z = xus[2+3*i]-xus[2+3*j];
        d = x*x+y*y+z*z;
        if (fabs(a-d) > DP_TOL) continue;

        for (k=j+1; k<12; k++) {
          x = xus[3*i]-xus[3*k];
          y = xus[1+3*i]-xus[1+3*k]; z = xus[2+3*i]-xus[2+3*k];
          d = x*x+y*y+z*z;
          if (fabs(a-d) > DP_TOL) continue;
          x = xus[3*j]-xus[3*k];
          y = xus[1+3*j]-xus[1+3*k]; z = xus[2+3*j]-xus[2+3*k];
          d = x*x+y*y+z*z;
          if (fabs(a-d) > DP_TOL) continue;
          for (tl=1; tl<tess-1; tl++) {
            divarc(xus[3*j], xus[1+3*j], xus[2+3*j],
                   xus[3*i], xus[1+3*i], xus[2+3*i],
              tl, tess, &xji, &yji, &zji);
            divarc(xus[3*k], xus[1+3*k], xus[2+3*k],
                   xus[3*i], xus[1+3*i], xus[2+3*i],
              tl, tess, &xki, &yki, &zki);

            for (tl2=1; tl2<tess-tl; tl2++) {
              divarc(xus[3*i], xus[1+3*i], xus[2+3*i],
                     xus[3*j], xus[1+3*j], xus[2+3*j],
                tl2, tess, &xij, &yij, &zij);
              divarc(xus[3*k], xus[1+3*k], xus[2+3*k],
                     xus[3*j], xus[1+3*j], xus[2+3*j],
                tl2, tess, &xkj, &ykj, &zkj);
              divarc(xus[3*i], xus[1+3*i], xus[2+3*i],
                     xus[3*k], xus[1+3*k], xus[2+3*k],
                tess-tl-tl2, tess, &xik, &yik, &zik);
              divarc(xus[3*j], xus[1+3*j], xus[2+3*j],
                     xus[3*k], xus[1+3*k], xus[2+3*k],
                tess-tl-tl2, tess, &xjk, &yjk, &zjk);
              if (tn >= n_dot) ERROR("ico_dot: tn exceeds dimension of xus");
              divarc(xki, yki, zki, xji, yji, zji, tl2, tess-tl,
                &x, &y, &z);
              divarc(xkj, ykj, zkj, xij, yij, zij, tl, tess-tl2,
                &x2, &y2, &z2);
              divarc(xjk, yjk, zjk, xik, yik, zik, tl, tl+tl2,
                &x3, &y3, &z3);
              x = x+x2+x3; y = y+y2+y3; z = z+z2+z3;
              d = sqrt(x*x+y*y+z*z);
              xus[3*tn] = x/d;
              xus[1+3*tn] = y/d;
              xus[2+3*tn] = z/d;
              tn++;
              }		/* cycle tl2 */
            }		/* cycle tl */
          }		/* cycle k */
        }		/* cycle j */
      }			/* cycle i */
    if (n_dot != tn) {
      ERROR("ico_dot: n_dot(%d) and tn(%d) differ", n_dot, tn);
      }
    }		/* end of if (tess > 1) */
  return n_dot;
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1b8, %rsp            # imm = 0x1B8
movl %edi, %ebx
cvtsi2sd %edi, %xmm0
addsd 0x7e66(%rip), %xmm0     # 0x19830
divsd 0x7e66(%rip), %xmm0     # 0x19838
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x119e2
sqrtsd %xmm0, %xmm0
jmp 0x119e7
callq 0x2260
callq 0x2270
cvttsd2si %xmm0, %r14d
movl %r14d, %eax
imull %r14d, %eax
imull $0xa, %eax, %edx
addl $0x2, %edx
movl %edx, 0xfc64(%rip)      # 0x21668
cmpl %ebx, %edx
jge 0x11a39
leaq 0x7eea(%rip), %rax      # 0x198f9
movq %rax, 0xfc3a(%rip)      # 0x21650
movl $0xbd, 0xfc28(%rip)     # 0x21648
leaq 0x7fa5(%rip), %rdi      # 0x199cc
movl %r14d, %esi
movl %ebx, %ecx
xorl %eax, %eax
callq 0x11240
movl 0xfc2f(%rip), %edx      # 0x21668
leal (%rdx,%rdx,2), %eax
movslq %eax, %rdx
leaq 0x7eb3(%rip), %rdi      # 0x198f9
pushq $0x8
popq %rcx
movl $0xc1, %esi
callq 0x1146e
movq %rax, %rbp
movq %rax, 0xfbc3(%rip)      # 0x21620
movq %rax, %rdi
callq 0x11510
cmpl $0x2, %r14d
jl 0x1239e
movsd 0xfbe1(%rip), %xmm0     # 0x21658
mulsd %xmm0, %xmm0
addsd %xmm0, %xmm0
mulsd 0x7db9(%rip), %xmm0     # 0x19840
movsd %xmm0, 0x30(%rsp)
movq %r14, 0x38(%rsp)
leal -0x1(%r14), %eax
pushq $0xc
popq %r13
pushq $0x1
popq %r15
xorl %ecx, %ecx
movq %rax, 0x50(%rsp)
movq %rbp, (%rsp)
cmpq $0xb, %rcx
je 0x11bfb
movq %rcx, 0x68(%rsp)
imulq $0x18, %rcx, %r12
movq %r15, 0x60(%rsp)
cmpq $0xc, %r15
je 0x11be6
imulq $0x18, %r15, %rbx
movsd (%rbp,%r12), %xmm0
subsd (%rbp,%rbx), %xmm0
movsd 0x8(%rbp,%r12), %xmm1
subsd 0x8(%rbp,%rbx), %xmm1
movsd 0x10(%rbp,%r12), %xmm2
subsd 0x10(%rbp,%rbx), %xmm2
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
mulsd %xmm2, %xmm2
addsd %xmm0, %xmm2
movsd 0x30(%rsp), %xmm0
subsd %xmm2, %xmm0
andpd 0x6da4(%rip), %xmm0     # 0x188c0
ucomisd 0x7cf4(%rip), %xmm0     # 0x19818
ja 0x11bde
movslq %r13d, %r13
addl %r13d, %eax
movl %eax, 0xc(%rsp)
cltq
movq %rax, 0x48(%rsp)
imulq $0x18, %r13, %r14
addq %rbp, %r14
pushq $0x1
popq %rbp
cmpq %r13, 0x48(%rsp)
je 0x11bd0
movslq 0xfb11(%rip), %rax      # 0x21668
cmpq %rax, %r13
jl 0x11b82
leaq 0x7d96(%rip), %rax      # 0x198f9
movq %rax, 0xfae6(%rip)      # 0x21650
movl $0xd0, 0xfad4(%rip)     # 0x21648
leaq 0x7e92(%rip), %rdi      # 0x19a0d
xorl %eax, %eax
callq 0x11240
movq (%rsp), %rax
movsd (%rax,%r12), %xmm0
movsd 0x8(%rax,%r12), %xmm1
movsd 0x10(%rax,%r12), %xmm2
movsd (%rax,%rbx), %xmm3
movsd 0x8(%rax,%rbx), %xmm4
movsd 0x10(%rax,%rbx), %xmm5
leaq 0x8(%r14), %rcx
leaq 0x10(%r14), %r8
movl %ebp, %edi
movq 0x38(%rsp), %rsi
movq %r14, %rdx
callq 0x11622
incq %r13
incl %ebp
addq $0x18, %r14
jmp 0x11b45
movl 0xc(%rsp), %r13d
movq 0x50(%rsp), %rax
movq (%rsp), %rbp
incq %r15
jmp 0x11ac1
movq 0x68(%rsp), %rcx
incq %rcx
movq 0x60(%rsp), %r15
incq %r15
jmp 0x11aa9
leaq 0x28(%rbp), %rcx
movq %rbp, %rax
addq $0x10, %rax
movq %rax, 0xa8(%rsp)
movq 0x38(%rsp), %rax
addl $-0x2, %eax
movl %eax, 0x70(%rsp)
movq 0x50(%rsp), %rax
pushq $0x1
popq %rdx
movq %rdx, 0x78(%rsp)
xorl %edx, %edx
movq %rcx, 0x90(%rsp)
cmpq $0xa, %rdx
je 0x1236a
imulq $0x18, %rdx, %rsi
movq %rsi, 0x40(%rsp)
movq 0x78(%rsp), %rdi
movq %rdx, 0x98(%rsp)
cmpq $0xb, %rdi
je 0x1235d
imulq $0x18, %rdi, %r8
movq 0x40(%rsp), %rsi
movsd (%rbp,%rsi), %xmm0
subsd (%rbp,%r8), %xmm0
movsd 0x8(%rbp,%rsi), %xmm1
subsd 0x8(%rbp,%r8), %xmm1
movsd 0x10(%rbp,%rsi), %xmm2
movq %r8, 0x58(%rsp)
subsd 0x10(%rbp,%r8), %xmm2
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
mulsd %xmm2, %xmm2
addsd %xmm0, %xmm2
movsd 0x30(%rsp), %xmm0
subsd %xmm2, %xmm0
andpd 0x6c0a(%rip), %xmm0     # 0x188c0
ucomisd 0x7b5a(%rip), %xmm0     # 0x19818
ja 0x12355
movq %rdi, 0xa0(%rsp)
movsd 0x20(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
movsd 0x10(%rsp), %xmm2
imulq $0x18, %rdi, %rsi
addq %rcx, %rsi
cmpq $0xa, %rdi
ja 0x12333
movsd -0x10(%rsi), %xmm4
movsd -0x8(%rsi), %xmm3
movq 0x40(%rsp), %rdx
movsd (%rbp,%rdx), %xmm0
movsd 0x8(%rbp,%rdx), %xmm1
subsd %xmm4, %xmm0
subsd %xmm3, %xmm1
movsd 0x10(%rbp,%rdx), %xmm2
movsd (%rsi), %xmm5
subsd %xmm5, %xmm2
movapd %xmm1, %xmm6
mulsd %xmm1, %xmm6
movapd %xmm0, %xmm7
mulsd %xmm0, %xmm7
addsd %xmm6, %xmm7
movapd %xmm2, %xmm6
mulsd %xmm2, %xmm6
addsd %xmm7, %xmm6
movsd 0x30(%rsp), %xmm7
subsd %xmm6, %xmm7
andpd 0x6b6e(%rip), %xmm7     # 0x188c0
ucomisd 0x7abe(%rip), %xmm7     # 0x19818
ja 0x11dbb
movq 0x58(%rsp), %rdx
movsd (%rbp,%rdx), %xmm0
movsd 0x8(%rbp,%rdx), %xmm1
subsd %xmm4, %xmm0
subsd %xmm3, %xmm1
movsd 0x10(%rbp,%rdx), %xmm2
subsd %xmm5, %xmm2
movapd %xmm1, %xmm3
mulsd %xmm1, %xmm3
movapd %xmm0, %xmm4
mulsd %xmm0, %xmm4
addsd %xmm3, %xmm4
movapd %xmm2, %xmm3
mulsd %xmm2, %xmm3
addsd %xmm4, %xmm3
movsd 0x30(%rsp), %xmm4
subsd %xmm3, %xmm4
andpd 0x6b0f(%rip), %xmm4     # 0x188c0
ucomisd 0x7a5f(%rip), %xmm4     # 0x19818
jbe 0x11dc7
addq $0x18, %rsi
incq %rdi
jmp 0x11ce5
movsd %xmm0, 0x20(%rsp)
movsd %xmm1, 0x18(%rsp)
movsd %xmm2, 0x10(%rsp)
incq %rdi
pushq $0x2
popq %rcx
movq %rcx, 0x80(%rsp)
movl 0x70(%rsp), %ecx
movl %ecx, 0x28(%rsp)
pushq $0x1
popq %r15
movq %rdi, 0xb0(%rsp)
movq %rsi, 0x88(%rsp)
cmpl %eax, %r15d
je 0x12326
movq 0x58(%rsp), %rcx
movsd (%rbp,%rcx), %xmm0
movsd 0x8(%rbp,%rcx), %xmm1
movsd 0x10(%rbp,%rcx), %xmm2
movq 0x40(%rsp), %r14
movsd (%rbp,%r14), %xmm3
movsd 0x8(%rbp,%r14), %xmm4
movsd 0x10(%rbp,%r14), %xmm5
movl %r15d, %edi
movq 0x38(%rsp), %rbx
movl %r15d, 0x2c(%rsp)
movq %rsi, %r15
movl %ebx, %esi
leaq 0x168(%rsp), %rdx
leaq 0x160(%rsp), %rcx
leaq 0x158(%rsp), %r8
movq %rax, %r12
callq 0x11622
movsd -0x10(%r15), %xmm0
movsd -0x8(%r15), %xmm1
movsd (%r15), %xmm2
movl 0x2c(%rsp), %r15d
movsd (%rbp,%r14), %xmm3
movsd 0x8(%rbp,%r14), %xmm4
movsd 0x10(%rbp,%r14), %xmm5
movl %r15d, %edi
movl %ebx, %esi
leaq 0x138(%rsp), %rdx
leaq 0x130(%rsp), %rcx
leaq 0x128(%rsp), %r8
callq 0x11622
movl %ebx, %r14d
subl %r15d, %r14d
movsd 0x138(%rsp), %xmm0
movsd %xmm0, 0xe8(%rsp)
movsd 0x130(%rsp), %xmm0
movsd %xmm0, 0xe0(%rsp)
movsd 0x128(%rsp), %xmm0
movsd %xmm0, 0xd8(%rsp)
movsd 0x168(%rsp), %xmm0
movsd %xmm0, 0xd0(%rsp)
movsd 0x160(%rsp), %xmm0
movsd %xmm0, 0xc8(%rsp)
movsd 0x158(%rsp), %xmm0
movsd %xmm0, 0xc0(%rsp)
movl %r13d, 0xc(%rsp)
movslq %r13d, %rax
movq %rax, 0xb8(%rsp)
imulq $0x18, %rax, %rax
addq 0xa8(%rsp), %rax
movl 0x28(%rsp), %edx
movl %edx, 0x48(%rsp)
xorl %r13d, %r13d
movl %r14d, 0x74(%rsp)
leaq 0x1(%r13), %rbx
cmpl %r14d, %ebx
jge 0x122f3
movq %rax, 0x68(%rsp)
movq 0xb8(%rsp), %rax
addq %r13, %rax
movq %rax, 0xf0(%rsp)
movq 0x40(%rsp), %r14
movsd (%rbp,%r14), %xmm0
movsd 0x8(%rbp,%r14), %xmm1
movsd 0x10(%rbp,%r14), %xmm2
movq 0x58(%rsp), %rbp
movq (%rsp), %rax
movsd (%rax,%rbp), %xmm3
movq (%rsp), %rax
movsd 0x8(%rax,%rbp), %xmm4
movq (%rsp), %rax
movsd 0x10(%rax,%rbp), %xmm5
movl %ebx, %edi
movl %r12d, 0x60(%rsp)
movq 0x38(%rsp), %r12
movl %r12d, %esi
leaq 0x180(%rsp), %rdx
leaq 0x178(%rsp), %rcx
leaq 0x170(%rsp), %r8
callq 0x11622
movq 0x88(%rsp), %r15
movsd -0x10(%r15), %xmm0
movsd -0x8(%r15), %xmm1
movsd (%r15), %xmm2
movq (%rsp), %rax
movsd (%rax,%rbp), %xmm3
movq (%rsp), %rax
movsd 0x8(%rax,%rbp), %xmm4
movq (%rsp), %rax
movsd 0x10(%rax,%rbp), %xmm5
movl %ebx, %edi
movl %r12d, %esi
leaq 0x108(%rsp), %rdx
leaq 0x100(%rsp), %rcx
leaq 0xf8(%rsp), %r8
callq 0x11622
movq (%rsp), %rax
movsd (%rax,%r14), %xmm0
movq (%rsp), %rax
movsd 0x8(%rax,%r14), %xmm1
movq (%rsp), %rax
movsd 0x10(%rax,%r14), %xmm2
movsd -0x10(%r15), %xmm3
movsd -0x8(%r15), %xmm4
movsd (%r15), %xmm5
movl 0x48(%rsp), %r14d
movl %r14d, %edi
movl %r12d, %esi
leaq 0x150(%rsp), %rdx
leaq 0x148(%rsp), %rcx
leaq 0x140(%rsp), %r8
callq 0x11622
movq (%rsp), %rax
movsd (%rax,%rbp), %xmm0
movq (%rsp), %rax
movsd 0x8(%rax,%rbp), %xmm1
movq (%rsp), %rax
movsd 0x10(%rax,%rbp), %xmm2
movq (%rsp), %rbp
movsd -0x10(%r15), %xmm3
movsd -0x8(%r15), %xmm4
movsd (%r15), %xmm5
movl %r14d, %edi
movl %r12d, %esi
leaq 0x120(%rsp), %rdx
leaq 0x118(%rsp), %rcx
leaq 0x110(%rsp), %r8
callq 0x11622
movslq 0xf574(%rip), %rax      # 0x21668
cmpq %rax, 0xf0(%rsp)
jl 0x12124
leaq 0x77f4(%rip), %rax      # 0x198f9
movq %rax, 0xf544(%rip)      # 0x21650
movl $0xfe, 0xf532(%rip)     # 0x21648
leaq 0x78f0(%rip), %rdi      # 0x19a0d
xorl %eax, %eax
callq 0x11240
movsd 0xe8(%rsp), %xmm0
movsd 0xe0(%rsp), %xmm1
movsd 0xd8(%rsp), %xmm2
movsd 0xd0(%rsp), %xmm3
movsd 0xc8(%rsp), %xmm4
movsd 0xc0(%rsp), %xmm5
movl %ebx, %edi
movl 0x74(%rsp), %r14d
movl %r14d, %esi
leaq 0x20(%rsp), %rdx
leaq 0x18(%rsp), %rcx
leaq 0x10(%rsp), %r8
callq 0x11622
movsd 0x108(%rsp), %xmm0
movsd 0x100(%rsp), %xmm1
movsd 0xf8(%rsp), %xmm2
movsd 0x180(%rsp), %xmm3
movsd 0x178(%rsp), %xmm4
movsd 0x170(%rsp), %xmm5
movl 0x2c(%rsp), %r15d
movl %r15d, %edi
movl 0x60(%rsp), %r12d
movl %r12d, %esi
leaq 0x1b0(%rsp), %rdx
leaq 0x1a8(%rsp), %rcx
leaq 0x1a0(%rsp), %r8
callq 0x11622
movsd 0x120(%rsp), %xmm0
movsd 0x118(%rsp), %xmm1
movsd 0x110(%rsp), %xmm2
movsd 0x150(%rsp), %xmm3
movsd 0x148(%rsp), %xmm4
movsd 0x140(%rsp), %xmm5
addl 0x80(%rsp), %r13d
movl %r15d, %edi
movl %r13d, %esi
leaq 0x198(%rsp), %rdx
leaq 0x190(%rsp), %rcx
leaq 0x188(%rsp), %r8
callq 0x11622
movsd 0x10(%rsp), %xmm0
addsd 0x1a0(%rsp), %xmm0
addsd 0x188(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x20(%rsp), %xmm1
movhpd 0x18(%rsp), %xmm1       # xmm1 = xmm1[0],mem[0]
movsd 0x1b0(%rsp), %xmm2
movhpd 0x1a8(%rsp), %xmm2      # xmm2 = xmm2[0],mem[0]
addpd %xmm1, %xmm2
movsd 0x198(%rsp), %xmm1
movhpd 0x190(%rsp), %xmm1      # xmm1 = xmm1[0],mem[0]
addpd %xmm2, %xmm1
movlpd %xmm1, 0x20(%rsp)
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
movhpd %xmm1, 0x18(%rsp)
mulsd %xmm2, %xmm2
movapd %xmm1, %xmm3
mulsd %xmm1, %xmm3
addsd %xmm2, %xmm3
movapd %xmm0, %xmm2
mulsd %xmm0, %xmm2
addsd %xmm3, %xmm2
sqrtsd %xmm2, %xmm2
divsd %xmm2, %xmm0
unpcklpd %xmm2, %xmm2            # xmm2 = xmm2[0,0]
divpd %xmm2, %xmm1
movq 0x68(%rsp), %rax
movupd %xmm1, -0x10(%rax)
movsd %xmm0, (%rax)
addq $0x18, %rax
decl 0x48(%rsp)
decl %r12d
movq %rbx, %r13
jmp 0x11f5a
movl 0xc(%rsp), %eax
addl %r13d, %eax
movl %eax, %r13d
incl %r15d
decl 0x28(%rsp)
incq 0x80(%rsp)
movq 0x50(%rsp), %rax
movq 0xb0(%rsp), %rdi
movq 0x88(%rsp), %rsi
jmp 0x11e03
movq 0x90(%rsp), %rcx
jmp 0x11ccc
movsd %xmm0, 0x20(%rsp)
movsd %xmm1, 0x18(%rsp)
movsd %xmm2, 0x10(%rsp)
movq 0x98(%rsp), %rdx
movq 0xa0(%rsp), %rdi
incq %rdi
jmp 0x11c51
incq %rdx
incq 0x78(%rsp)
jmp 0x11c31
movl 0xf2f8(%rip), %esi      # 0x21668
cmpl %r13d, %esi
je 0x1239e
leaq 0x757d(%rip), %rax      # 0x198f9
movq %rax, 0xf2cd(%rip)      # 0x21650
movl $0x111, 0xf2bb(%rip)    # imm = 0x111
leaq 0x769e(%rip), %rdi      # 0x19a32
movl %r13d, %edx
xorl %eax, %eax
callq 0x11240
movl 0xf2c4(%rip), %eax      # 0x21668
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq