// File: /workspace/github_c_makefile_star2_O3/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 $0x1c8, %rsp            # imm = 0x1C8
movl %edi, %ebx
cvtsi2sd %edi, %xmm0
addsd 0x8d3a(%rip), %xmm0     # 0x1a880
divsd 0x8d3a(%rip), %xmm0     # 0x1a888
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x11b5e
sqrtsd %xmm0, %xmm0
jmp 0x11b63
callq 0x2250
callq 0x2260
cvttsd2si %xmm0, %r14d
movl %r14d, %eax
imull %eax, %eax
leal (%rax,%rax,4), %eax
leal 0x2(,%rax,2), %edx
movl %edx, 0x10ad5(%rip)     # 0x22658
cmpl %ebx, %edx
jl 0x124e8
leal (%rdx,%rdx,2), %eax
movslq %eax, %rdx
leaq 0x8db1(%rip), %rdi      # 0x1a949
movl $0x8, %ecx
movl $0xc1, %esi
callq 0x11571
movq %rax, %r15
movq %rax, 0x10a5f(%rip)     # 0x22610
movq %rax, %rdi
callq 0x11617
cmpl $0x2, %r14d
jl 0x124d0
movsd 0x10a7d(%rip), %xmm6    # 0x22648
mulsd %xmm6, %xmm6
addsd %xmm6, %xmm6
mulsd 0x8cb5(%rip), %xmm6     # 0x1a890
movq %r14, 0x8(%rsp)
leal -0x1(%r14), %eax
movq %rax, 0x70(%rsp)
movl $0xc, %ebx
movl $0x1, %ecx
xorl %eax, %eax
movapd 0x7cc3(%rip), %xmm7     # 0x198c0
movsd 0x8c62(%rip), %xmm8     # 0x1a868
movsd %xmm6, 0x68(%rsp)
leaq 0x1(%rax), %rdx
movq %rdx, 0x48(%rsp)
shlq $0x3, %rax
leaq (%rax,%rax,2), %rbp
movq %rcx, 0x50(%rsp)
leaq (,%rcx,8), %rax
leaq (%rax,%rax,2), %r13
movsd (%r15,%rbp), %xmm0
subsd (%r15,%r13), %xmm0
movsd 0x8(%r15,%rbp), %xmm1
subsd 0x8(%r15,%r13), %xmm1
movsd 0x10(%r15,%rbp), %xmm2
subsd 0x10(%r15,%r13), %xmm2
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
mulsd %xmm2, %xmm2
addsd %xmm0, %xmm2
movapd %xmm6, %xmm0
subsd %xmm2, %xmm0
andpd %xmm7, %xmm0
ucomisd %xmm8, %xmm0
ja 0x11d20
movq %rcx, 0x58(%rsp)
movl %ebx, 0x14(%rsp)
movslq %ebx, %r12
leaq (%r12,%r12,2), %rax
leaq (%r15,%rax,8), %r14
xorl %ebx, %ebx
leaq (%r12,%rbx), %rax
movslq 0x109b6(%rip), %rcx     # 0x22658
cmpq %rcx, %rax
jge 0x11cf5
incq %rbx
movsd (%r15,%rbp), %xmm0
movsd 0x8(%r15,%rbp), %xmm1
movsd 0x10(%r15,%rbp), %xmm2
movsd (%r15,%r13), %xmm3
movsd 0x8(%r15,%r13), %xmm4
movsd 0x10(%r15,%r13), %xmm5
leaq 0x8(%r14), %rcx
leaq 0x10(%r14), %r8
movl %ebx, %edi
movq 0x8(%rsp), %rsi
movq %r14, %rdx
callq 0x11729
addq $0x18, %r14
cmpl %ebx, 0x70(%rsp)
jne 0x11c97
jmp 0x11cfc
callq 0x2679
jmp 0x11ca7
movl 0x14(%rsp), %eax
addl %ebx, %eax
movl %eax, %ebx
movsd 0x68(%rsp), %xmm6
movapd 0x7bae(%rip), %xmm7     # 0x198c0
movsd 0x8b4d(%rip), %xmm8     # 0x1a868
movq 0x58(%rsp), %rcx
incq %rcx
cmpq $0xc, %rcx
jne 0x11c22
movq 0x50(%rsp), %rcx
incq %rcx
movq 0x48(%rsp), %rax
cmpq $0xb, %rax
jne 0x11c0c
movq %r15, %rax
addq $0x10, %rax
movq %rax, 0xd0(%rsp)
movl $0x2, %eax
movq 0x8(%rsp), %rsi
subl %esi, %eax
movq %rax, 0xc0(%rsp)
movl $0x1, %eax
xorl %edx, %edx
leaq 0xa0(%rsp), %r14
leaq 0x98(%rsp), %r12
leaq 0x90(%rsp), %r13
movq %rax, %rcx
movq %rdx, %rax
incq %rdx
movq %rdx, 0xa8(%rsp)
shlq $0x3, %rax
leaq (%rax,%rax,2), %rax
movq %rax, 0x18(%rsp)
movq %rcx, 0xb0(%rsp)
leaq (,%rcx,8), %rax
leaq (%rax,%rax,2), %rdx
movq 0x18(%rsp), %rax
movsd (%r15,%rax), %xmm0
movsd 0x8(%r15,%rax), %xmm1
subsd (%r15,%rdx), %xmm0
subsd 0x8(%r15,%rdx), %xmm1
movsd 0x10(%r15,%rax), %xmm2
movq %rdx, 0x38(%rsp)
subsd 0x10(%r15,%rdx), %xmm2
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
mulsd %xmm2, %xmm2
addsd %xmm0, %xmm2
movapd %xmm6, %xmm0
subsd %xmm2, %xmm0
andpd %xmm7, %xmm0
ucomisd %xmm8, %xmm0
seta %al
cmpq $0xb, %rcx
movq %rcx, %rdx
setae %cl
orb %al, %cl
movq %rdx, 0xb8(%rsp)
jne 0x1248d
movq 0x18(%rsp), %rcx
movsd (%r15,%rcx), %xmm3
leaq 0x8(,%rdx,8), %rax
leaq (%rax,%rax,2), %rax
movsd (%r15,%rax), %xmm0
subsd %xmm0, %xmm3
movsd %xmm3, 0x30(%rsp)
movsd 0x8(%r15,%rcx), %xmm4
movsd 0x8(%r15,%rax), %xmm1
subsd %xmm1, %xmm4
movsd %xmm4, 0x28(%rsp)
movsd 0x10(%r15,%rcx), %xmm5
movq %rax, 0x88(%rsp)
movsd 0x10(%r15,%rax), %xmm2
subsd %xmm2, %xmm5
movsd %xmm5, 0x20(%rsp)
mulsd %xmm4, %xmm4
mulsd %xmm3, %xmm3
addsd %xmm4, %xmm3
mulsd %xmm5, %xmm5
addsd %xmm3, %xmm5
movapd %xmm6, %xmm3
subsd %xmm5, %xmm3
andpd %xmm7, %xmm3
ucomisd %xmm8, %xmm3
movq %rdx, 0xc8(%rsp)
ja 0x12460
movq 0x38(%rsp), %rax
movsd (%r15,%rax), %xmm3
subsd %xmm0, %xmm3
movsd %xmm3, 0x30(%rsp)
movsd 0x8(%r15,%rax), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, 0x28(%rsp)
movsd 0x10(%r15,%rax), %xmm1
subsd %xmm2, %xmm1
movsd %xmm1, 0x20(%rsp)
mulsd %xmm0, %xmm0
mulsd %xmm3, %xmm3
addsd %xmm0, %xmm3
mulsd %xmm1, %xmm1
addsd %xmm3, %xmm1
movapd %xmm6, %xmm0
subsd %xmm1, %xmm0
andpd %xmm7, %xmm0
ucomisd %xmm8, %xmm0
ja 0x12460
cmpl $0x2, %esi
je 0x12460
movl $0x1, %eax
movl $0x2, %ecx
movq %rcx, 0x80(%rsp)
movl $0xfffffffe, %ecx       # imm = 0xFFFFFFFE
movq %rcx, 0x40(%rsp)
movq 0xc0(%rsp), %rcx
movq %rcx, 0x78(%rsp)
movl %eax, 0x4(%rsp)
movq 0x38(%rsp), %rax
movsd (%r15,%rax), %xmm0
movsd 0x8(%r15,%rax), %xmm1
movsd 0x10(%r15,%rax), %xmm2
movq 0x18(%rsp), %rbp
movsd (%r15,%rbp), %xmm3
movsd 0x8(%r15,%rbp), %xmm4
movsd 0x10(%r15,%rbp), %xmm5
movl 0x4(%rsp), %edi
movq 0x8(%rsp), %rsi
movq %r14, %rdx
movq %r12, %rcx
movq %r13, %r8
callq 0x11729
movq 0x88(%rsp), %rax
movsd (%r15,%rax), %xmm0
movsd 0x8(%r15,%rax), %xmm1
movsd 0x10(%r15,%rax), %xmm2
movsd (%r15,%rbp), %xmm3
movsd 0x8(%r15,%rbp), %xmm4
movsd 0x10(%r15,%rbp), %xmm5
movl 0x4(%rsp), %edi
movq 0x8(%rsp), %rsi
leaq 0x160(%rsp), %rdx
leaq 0x158(%rsp), %rcx
leaq 0x150(%rsp), %r8
callq 0x11729
movl 0x4(%rsp), %eax
movq 0x8(%rsp), %rsi
movl %esi, %ecx
subl %eax, %ecx
movl %ecx, 0x64(%rsp)
cmpl $0x2, %ecx
jl 0x1243b
movsd 0x160(%rsp), %xmm0
movsd %xmm0, 0x108(%rsp)
movsd 0x158(%rsp), %xmm0
movsd %xmm0, 0x100(%rsp)
movsd 0x150(%rsp), %xmm0
movsd %xmm0, 0xf8(%rsp)
movsd 0xa0(%rsp), %xmm0
movsd %xmm0, 0xf0(%rsp)
movsd 0x98(%rsp), %xmm0
movsd %xmm0, 0xe8(%rsp)
movsd 0x90(%rsp), %xmm0
movsd %xmm0, 0xe0(%rsp)
movl %ebx, 0x14(%rsp)
movslq %ebx, %rax
movq %rax, 0xd8(%rsp)
leaq (%rax,%rax,2), %rax
movq 0xd0(%rsp), %rcx
leaq (%rcx,%rax,8), %rcx
movl %esi, %r14d
xorl %edx, %edx
movq %rdx, 0x118(%rsp)
movq %rcx, 0x48(%rsp)
movq %r14, 0x58(%rsp)
movq 0xd8(%rsp), %rax
addq %rdx, %rax
movq %rax, 0x110(%rsp)
leaq 0x1(%rdx), %r12
movq 0x18(%rsp), %rbp
movsd (%r15,%rbp), %xmm0
movsd 0x8(%r15,%rbp), %xmm1
movsd 0x10(%r15,%rbp), %xmm2
movq 0x38(%rsp), %r13
movsd (%r15,%r13), %xmm3
movsd 0x8(%r15,%r13), %xmm4
movsd 0x10(%r15,%r13), %xmm5
movl %r12d, %edi
movq 0x8(%rsp), %r14
movl %r14d, %esi
leaq 0x190(%rsp), %rdx
leaq 0x188(%rsp), %rcx
leaq 0x180(%rsp), %r8
callq 0x11729
movq 0x88(%rsp), %rbx
movsd (%r15,%rbx), %xmm0
movsd 0x8(%r15,%rbx), %xmm1
movsd 0x10(%r15,%rbx), %xmm2
movsd (%r15,%r13), %xmm3
movsd 0x8(%r15,%r13), %xmm4
movsd 0x10(%r15,%r13), %xmm5
movq %r12, 0x50(%rsp)
movl %r12d, %edi
movl %r14d, %esi
movq 0x58(%rsp), %r14
leaq 0x130(%rsp), %rdx
leaq 0x128(%rsp), %rcx
leaq 0x120(%rsp), %r8
callq 0x11729
movsd (%r15,%rbp), %xmm0
movsd 0x8(%r15,%rbp), %xmm1
movsd 0x10(%r15,%rbp), %xmm2
movsd (%r15,%rbx), %xmm3
movsd 0x8(%r15,%rbx), %xmm4
movsd 0x10(%r15,%rbx), %xmm5
movq 0x40(%rsp), %rax
leal (%rax,%r14), %ebp
movl %ebp, %edi
movq 0x8(%rsp), %rsi
leaq 0x178(%rsp), %rdx
leaq 0x170(%rsp), %rcx
leaq 0x168(%rsp), %r8
callq 0x11729
movsd (%r15,%r13), %xmm0
movsd 0x8(%r15,%r13), %xmm1
movsd 0x10(%r15,%r13), %xmm2
movsd (%r15,%rbx), %xmm3
movsd 0x8(%r15,%rbx), %xmm4
movsd 0x10(%r15,%rbx), %xmm5
movl %ebp, %edi
movq 0x8(%rsp), %rsi
leaq 0x148(%rsp), %rdx
leaq 0x140(%rsp), %rcx
leaq 0x138(%rsp), %r8
callq 0x11729
movslq 0x10431(%rip), %rax     # 0x22658
cmpq %rax, 0x110(%rsp)
jge 0x12409
movsd 0x108(%rsp), %xmm0
movsd 0x100(%rsp), %xmm1
movsd 0xf8(%rsp), %xmm2
movsd 0xf0(%rsp), %xmm3
movsd 0xe8(%rsp), %xmm4
movsd 0xe0(%rsp), %xmm5
movq 0x50(%rsp), %r13
movl %r13d, %edi
movl 0x64(%rsp), %esi
leaq 0x30(%rsp), %rdx
leaq 0x28(%rsp), %rcx
leaq 0x20(%rsp), %r8
callq 0x11729
movsd 0x130(%rsp), %xmm0
movsd 0x128(%rsp), %xmm1
movsd 0x120(%rsp), %xmm2
movsd 0x190(%rsp), %xmm3
movsd 0x188(%rsp), %xmm4
movsd 0x180(%rsp), %xmm5
decl %r14d
movl 0x4(%rsp), %ebx
movl %ebx, %edi
movl %r14d, %esi
leaq 0x1c0(%rsp), %rdx
leaq 0x1b8(%rsp), %rcx
leaq 0x1b0(%rsp), %r8
callq 0x11729
movsd 0x148(%rsp), %xmm0
movsd 0x140(%rsp), %xmm1
movsd 0x138(%rsp), %xmm2
movsd 0x178(%rsp), %xmm3
movsd 0x170(%rsp), %xmm4
movsd 0x168(%rsp), %xmm5
movq 0x118(%rsp), %rsi
addl 0x80(%rsp), %esi
movl %ebx, %edi
leaq 0x1a8(%rsp), %rdx
leaq 0x1a0(%rsp), %rcx
leaq 0x198(%rsp), %r8
callq 0x11729
movsd 0x20(%rsp), %xmm0
addsd 0x1b0(%rsp), %xmm0
addsd 0x198(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x30(%rsp), %xmm1
movhpd 0x28(%rsp), %xmm1       # xmm1 = xmm1[0],mem[0]
movsd 0x1c0(%rsp), %xmm2
movhpd 0x1b8(%rsp), %xmm2      # xmm2 = xmm2[0],mem[0]
addpd %xmm1, %xmm2
movsd 0x1a8(%rsp), %xmm1
movhpd 0x1a0(%rsp), %xmm1      # xmm1 = xmm1[0],mem[0]
addpd %xmm2, %xmm1
movlpd %xmm1, 0x30(%rsp)
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
movhpd %xmm1, 0x28(%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 0x48(%rsp), %rcx
movupd %xmm1, -0x10(%rcx)
movsd %xmm0, (%rcx)
addq $0x18, %rcx
movq 0x78(%rsp), %rax
movq %r13, %rdx
addl %r13d, %eax
jne 0x1209f
jmp 0x12413
callq 0x269f
jmp 0x12235
movl 0x14(%rsp), %ebx
addl %r13d, %ebx
leaq 0xa0(%rsp), %r14
leaq 0x98(%rsp), %r12
leaq 0x90(%rsp), %r13
movq 0x8(%rsp), %rsi
movl 0x4(%rsp), %eax
incl %eax
incq 0x78(%rsp)
incq 0x80(%rsp)
movq 0x40(%rsp), %rcx
decl %ecx
movq %rcx, 0x40(%rsp)
cmpl 0x70(%rsp), %eax
jne 0x11f52
movq 0xc8(%rsp), %rcx
leaq 0x1(%rcx), %rdx
cmpq $0xa, %rcx
movsd 0x68(%rsp), %xmm6
movapd 0x7442(%rip), %xmm7     # 0x198c0
movsd 0x83e1(%rip), %xmm8     # 0x1a868
jb 0x11e2c
movq 0xb8(%rsp), %rcx
incq %rcx
cmpq $0xb, %rcx
jne 0x11dac
movq 0xb0(%rsp), %rax
incq %rax
movq 0xa8(%rsp), %rdx
cmpq $0xa, %rdx
jne 0x11d86
movl 0x10193(%rip), %esi     # 0x22658
cmpl %ebx, %esi
leaq 0x847b(%rip), %rax      # 0x1a949
jne 0x1251e
movl 0x10182(%rip), %eax     # 0x22658
addq $0x1c8, %rsp            # imm = 0x1C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x845a(%rip), %rax      # 0x1a949
movq %rax, 0x1014a(%rip)     # 0x22640
movl $0xbd, 0x10138(%rip)    # 0x22638
leaq 0x8515(%rip), %rdi      # 0x1aa1c
movl %r14d, %esi
movl %ebx, %ecx
xorl %eax, %eax
callq 0x24b8
movl 0x1013f(%rip), %edx     # 0x22658
jmp 0x11b8b
movq %rax, 0x1011b(%rip)     # 0x22640
movl $0x111, 0x10109(%rip)   # imm = 0x111
leaq 0x854c(%rip), %rdi      # 0x1aa82
movl %ebx, %edx
xorl %eax, %eax
callq 0x24b8
jmp 0x124d0