// File: /workspace/github_c_makefile_star2_O2/josch[P]stride/nsc.c
// Function: nsc_dclm
int nsc_dclm(
  double *co, double *radius, int nat,
  int densit, int mode,
  double *value_of_area, double **at_area,
  double *value_of_vol,
  double **lidots, int *nu_dots) {

  int iat, i, ii, iii, ix, iy, iz, ixe, ixs, iye, iys, ize, izs, i_ac;
  int jat, j, jj, jjj, jx, jy, jz;
  int distribution;
  int l;
  int maxnei, nnei, last, maxdots;
  point_int wkdot=NULL, wkbox=NULL, wkat1=NULL, wkatm=NULL;
  Neighb  *wknb, *ctnb;
  int iii1, iii2, iiat, lfnr, i_at, j_at;
  double dx, dy, dz, dd, ai, aisq, ajsq, aj, as, a;
  double xi, yi, zi, xs=0., ys=0., zs=0.;
  double dotarea, area, vol=0.;
  point_double xus, dots=NULL, atom_area=NULL;

  int    nxbox, nybox, nzbox, nxy, nxyz;
  double xmin, ymin, zmin, xmax, ymax, zmax, ra2max, d, *pco;

  distribution = unsp_type(densit);
  if (distribution != -last_unsp || last_cubus != 4 ||
     (densit != last_densit && densit != last_n_dot)) {
    if (make_unsp(densit, (-distribution), &n_dot, 4)) return 1;
    }
  xus = xpunsp;

  dotarea = FOURPI/(double) n_dot;
  area = 0.;

#if TEST_CUBE 
  printf("nsc_dclm: n_dot=%5d %9.3f\n", n_dot, dotarea);
#endif

/* start with neighbour list */
/* calculate neighbour list with the box algorithm */
  if (nat==0) {
    WARNING("nsc_dclm: no surface atoms selected");
    return 1;
    }
  if (mode & FLAG_VOLUME) vol=0.;
  if (mode & FLAG_DOTS) {
    maxdots = 3*n_dot*nat/10;
    dots = (double *) CALLOC(maxdots, sizeof(double));
    lfnr=0;
    }
  if (mode & FLAG_ATOM_AREA) {
    atom_area = (double *) CALLOC(nat, sizeof(double));
    }

/* dimensions of atomic set, cell edge is 2*ra_max */
  xmin = co[0]; xmax = xmin; xs=xmin;
  ymin = co[1]; ymax = ymin; ys=ymin;
  zmin = co[2]; zmax = zmin; zs=zmin;
  ra2max = radius[0];

  for (iat=1; iat<nat; iat++) {
    pco = co+3*iat;
    xmin = MINIMUM(xmin, *pco);     xmax = MAXIMUM(xmax, *pco);
    ymin = MINIMUM(ymin, *(pco+1)); ymax = MAXIMUM(ymax, *(pco+1));
    zmin = MINIMUM(zmin, *(pco+2)); zmax = MAXIMUM(zmax, *(pco+2));
    xs= xs+ *pco; ys = ys+ *(pco+1); zs= zs+ *(pco+2);
    ra2max = MAXIMUM(ra2max, radius[iat]);
    }
  xs = xs/ (double) nat;
  ys = ys/ (double) nat;
  zs = zs/ (double) nat;
  ra2max = 2.*ra2max;
#if TEST_CUBE
  printf("nsc_dclm: n_dot=%5d ra2max=%9.3f %9.3f\n", n_dot, ra2max, dotarea);
#endif

  d = xmax-xmin; nxbox = (int) MAXIMUM(ceil(d/ra2max), 1.);
  d = (((double)nxbox)*ra2max-d)/2.;
  xmin = xmin-d; xmax = xmax+d;
  d = ymax-ymin; nybox = (int) MAXIMUM(ceil(d/ra2max), 1.);
  d = (((double)nybox)*ra2max-d)/2.;
  ymin = ymin-d; ymax = ymax+d;
  d = zmax-zmin; nzbox = (int) MAXIMUM(ceil(d/ra2max), 1.);
  d = (((double)nzbox)*ra2max-d)/2.;
  zmin = zmin-d; zmax = zmax+d;
  nxy = nxbox*nybox;
  nxyz = nxy*nzbox;

/* box number of atoms */
  wkatm = (int *) CALLOC(3*nat, sizeof(int));
  wkat1 = wkatm+nat;
  wkdot = (int *) CALLOC(n_dot+nxyz+1, sizeof(int));
  wkbox = wkdot+n_dot;

  for (iat=0; iat<nat; iat++) {
    pco = co+3*iat;
    i = (int) MAXIMUM(floor((  *pco  -xmin)/ra2max), 0); i = MINIMUM(i,nxbox-1);
    j = (int) MAXIMUM(floor((*(pco+1)-ymin)/ra2max), 0); j = MINIMUM(j,nybox-1);
    l = (int) MAXIMUM(floor((*(pco+2)-zmin)/ra2max), 0); l = MINIMUM(l,nzbox-1);
    i = i+j*nxbox+l*nxy;
    wkat1[iat] = i; wkbox[i]++;
    }

/* sorting of atoms in accordance with box numbers */
  j = wkbox[0]; for (i=1; i<nxyz; i++) j= MAXIMUM(wkbox[i], j);
  for (i=1; i<=nxyz; i++) wkbox[i] += wkbox[i-1];
/*
  maxnei = (int) floor(ra2max*ra2max*ra2max*0.5);
*/
  maxnei = MINIMUM(nat, 27*j);
  wknb = (Neighb *) CALLOC(maxnei, sizeof(Neighb));
  for (iat=0; iat<nat; iat++) {
    wkatm[--wkbox[wkat1[iat]]] = iat;
#if TEST_CUBE
    printf("atom %5d on place %5d\n", iat, wkbox[wkat1[iat]]);
#endif
    }
#if TEST_CUBE
  printf("nsc_dclm: n_dot=%5d ra2max=%9.3f %9.3f\n", n_dot, ra2max, dotarea);
  printf("neighbour list calculated/box(xyz):%d %d %d\n", nxbox, nybox, nzbox);
  for (i=0; i<nxyz; i++) printf("box %6d : atoms %4d-%4d    %5d\n",
    i, wkbox[i], wkbox[i+1]-1, wkbox[i+1]-wkbox[i]);
  for (i=0; i<nat; i++) {
    printf("list place %5d by atom %7d\n", i, wkatm[i]);
    }
#endif

/* calculate surface for all atoms, step cube-wise */
  for (iz=0; iz<nzbox; iz++) {
    iii = iz*nxy;
    izs = MAXIMUM(iz-1,0); ize = MINIMUM(iz+2, nzbox);
  for (iy=0; iy<nybox; iy++) {
    ii = iy*nxbox+iii;
    iys = MAXIMUM(iy-1,0); iye = MINIMUM(iy+2, nybox);
  for (ix=0; ix<nxbox; ix++) {
    i = ii+ix;
    iii1=wkbox[i]; iii2=wkbox[i+1];
    if (iii1 >= iii2) continue;
    ixs = MAXIMUM(ix-1,0); ixe = MINIMUM(ix+2, nxbox);

    iiat = 0;
/* make intermediate atom list */
    for (jz=izs; jz<ize; jz++) {
      jjj = jz*nxy;
    for (jy=iys; jy<iye; jy++) {
      jj = jy*nxbox+jjj;
    for (jx=ixs; jx<ixe; jx++) {
      j = jj+jx;
      for (jat=wkbox[j]; jat<wkbox[j+1]; jat++) {
        wkat1[iiat] = wkatm[jat]; iiat++;
        }     /* end of cycle "jat" */
      }       /* end of cycle "jx" */
      }       /* end of cycle "jy" */
      }       /* end of cycle "jz" */
    for (iat=iii1; iat<iii2; iat++) {
      i_at = wkatm[iat];
      ai = radius[i_at]; aisq = ai*ai;
      pco = co+3*i_at;
      xi = *pco; yi = *(pco+1); zi = *(pco+2);
      for (i=0; i<n_dot; i++) *(wkdot+i)=0;

      ctnb = wknb; nnei = 0;
      for (j=0; j<iiat; j++) {
        j_at = *(wkat1+j);
        if (j_at == i_at) continue;

        aj = radius[j_at]; ajsq = aj*aj;
        pco = co+3*j_at;
        dx = *pco-xi; dy = *(pco+1)-yi; dz = *(pco+2)-zi;
        dd = dx*dx+dy*dy+dz*dz;

        as = ai+aj; if (dd > as*as) continue;
        nnei++;
        ctnb->x = dx; ctnb->y = dy; ctnb->z = dz;
        ctnb->dot = (dd+aisq-ajsq)/(2.*ai); /* reference dot product */
        ctnb++;
        }

/* check points on accessibility */
      if (nnei) {
        last = 0; i_ac = 0;
        for (l=0; l<n_dot; l++) {
          if (xus[3*l]*(wknb+last)->x+
              xus[1+3*l]*(wknb+last)->y+
              xus[2+3*l]*(wknb+last)->z <= (wknb+last)->dot) {
            for (j=0; j<nnei; j++) {
              if (xus[3*l]*(wknb+j)->x+xus[1+3*l]*(wknb+j)->y+
                  xus[2+3*l]*(wknb+j)->z > (wknb+j)->dot) {
                last = j; break;
                }
              }
            if (j >= nnei) { i_ac++; wkdot[l] = 1; }
            }     /* end of cycle j */
          }       /* end of cycle l */
        }
      else {
        i_ac  = n_dot;
        for (l=0; l < n_dot; l++) wkdot[l] = 1;
        }

#if TEST_CUBE
      printf("i_ac=%d, dotarea=%8.3f, aisq=%8.3f\n", i_ac, dotarea, aisq);
#endif
      a = aisq*dotarea* (double) i_ac;
      area = area + a;
      if (mode & FLAG_ATOM_AREA) {
        atom_area[i_at] = a;
        }
      if (mode & FLAG_DOTS) {
        for (l=0; l<n_dot; l++) {
          if (wkdot[l]) {
            lfnr++;
            if (maxdots <= 3*lfnr+1) {
              maxdots = maxdots+n_dot*3;
              dots = (double *) REALLOC(dots, maxdots*sizeof(double));
              }
            dots[3*lfnr-3] = ai*xus[3*l]+xi;
            dots[3*lfnr-2] = ai*xus[1+3*l]+yi;
            dots[3*lfnr-1] = ai*xus[2+3*l]+zi;
            }
          }
        }
      if (mode & FLAG_VOLUME) {
        dx=0.; dy=0.; dz=0.;
        for (l=0; l<n_dot; l++) {
          if (wkdot[l]) {
            dx=dx+xus[3*l];
            dy=dy+xus[1+3*l];
            dz=dz+xus[2+3*l];
            }
          }
        vol = vol+aisq*(dx*(xi-xs)+dy*(yi-ys)+dz*(zi-zs)+ai* (double) i_ac);
        }

      }         /* end of cycle "iat" */
    }           /* end of cycle "ix" */
    }           /* end of cycle "iy" */
    }           /* end of cycle "iz" */

  free(wkatm); free(wkdot); free(wknb);

  if (mode & FLAG_VOLUME) {
    vol = vol*FOURPI/(3.* (double) n_dot);
    *value_of_vol = vol;
    }
  if (mode & FLAG_DOTS) {
    *nu_dots = lfnr;
    *lidots = dots;
    }
  if (mode & FLAG_ATOM_AREA) {
    *at_area = atom_area;
    }
  *value_of_area = area;

#if TEST_CUBE
  printf("area=%8.3f\n", area);
#endif
  return 0;
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1e8, %rsp            # imm = 0x1E8
movq %r9, %rbx
movl %r8d, 0x8(%rsp)
movl %ecx, %ebp
movl %edx, %r15d
movq %rsi, 0x88(%rsp)
movq %rdi, 0x80(%rsp)
movl %ecx, %edi
callq 0x13016
movl 0xe1d8(%rip), %ecx      # 0x21640
pushq $0x1
popq %r12
addl %eax, %ecx
jne 0x13489
cmpl $0x4, 0xe1cd(%rip)      # 0x21644
jne 0x13489
cmpl %ebp, 0xe1bd(%rip)      # 0x2163c
je 0x134a6
cmpl %ebp, 0xe1b1(%rip)      # 0x21638
je 0x134a6
negl %eax
leaq 0xe1d6(%rip), %rdx      # 0x21668
pushq $0x4
popq %rcx
movl %ebp, %edi
movl %eax, %esi
callq 0x1304e
testl %eax, %eax
jne 0x14249
testl %r15d, %r15d
je 0x134d3
movq %rbx, 0x170(%rsp)
movq 0xe166(%rip), %rax      # 0x21620
movq %rax, 0x118(%rsp)
movl 0xe1a0(%rip), %ebx      # 0x21668
testb $0x1, 0x8(%rsp)
jne 0x134fe
xorl %eax, %eax
jmp 0x13528
leaq 0x641f(%rip), %rax      # 0x198f9
movq %rax, 0xe16f(%rip)      # 0x21650
movl $0x22f, 0xe15d(%rip)    # imm = 0x22F
leaq 0x65c7(%rip), %rdi      # 0x19ab9
xorl %eax, %eax
callq 0x11315
jmp 0x14249
movl %r15d, %eax
imull %ebx, %eax
leal (%rax,%rax,2), %eax
pushq $0xa
popq %rcx
cltd
idivl %ecx
movl %eax, 0xc(%rsp)
movslq %eax, %rdx
leaq 0x63de(%rip), %rdi      # 0x198f9
pushq $0x8
popq %rcx
movl $0x235, %esi            # imm = 0x235
callq 0x1146e
cvtsi2sd %ebx, %xmm1
movsd 0x6334(%rip), %xmm0     # 0x19868
movsd %xmm0, 0xc8(%rsp)
movslq %r15d, %r14
testb $0x4, 0x8(%rsp)
movq %rax, 0x50(%rsp)
jne 0x1355a
movq $0x0, 0xb8(%rsp)
jmp 0x13585
leaq 0x6398(%rip), %rdi      # 0x198f9
pushq $0x8
popq %rcx
movl $0x239, %esi            # imm = 0x239
movq %r14, %rdx
movsd %xmm1, 0x10(%rsp)
callq 0x1146e
movsd 0x10(%rsp), %xmm1
movq %rax, 0xb8(%rsp)
movsd 0xc8(%rsp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, 0xc8(%rsp)
movq 0x80(%rsp), %rcx
movsd (%rcx), %xmm0
movupd 0x8(%rcx), %xmm4
movq 0x88(%rsp), %rax
movsd (%rax), %xmm3
leaq 0x20(%rcx), %rax
pushq $0x1
popq %rcx
movapd %xmm0, %xmm6
movsd %xmm0, 0x40(%rsp)
movapd %xmm0, %xmm7
movapd %xmm4, %xmm5
movapd %xmm4, 0xe0(%rsp)
movq 0x88(%rsp), %rdx
cmpq %r14, %rcx
jge 0x13634
movsd -0x8(%rax), %xmm0
minsd %xmm0, %xmm6
maxsd %xmm0, %xmm7
movupd (%rax), %xmm1
minpd %xmm1, %xmm4
maxpd %xmm1, %xmm5
movsd 0x40(%rsp), %xmm2
addsd %xmm0, %xmm2
movsd %xmm2, 0x40(%rsp)
movapd 0xe0(%rsp), %xmm0
addpd %xmm1, %xmm0
movapd %xmm0, 0xe0(%rsp)
maxsd (%rdx,%rcx,8), %xmm3
incq %rcx
addq $0x18, %rax
jmp 0x135e2
cvtsi2sd %r15d, %xmm1
movapd 0xe0(%rsp), %xmm0
movsd %xmm1, 0x60(%rsp)
divsd %xmm1, %xmm0
movapd %xmm0, 0x1d0(%rsp)
addsd %xmm3, %xmm3
movapd %xmm3, 0xa0(%rsp)
subsd %xmm6, %xmm7
movsd %xmm7, 0x90(%rsp)
movapd %xmm7, %xmm0
divsd %xmm3, %xmm0
movapd %xmm4, 0xf0(%rsp)
movapd %xmm5, 0x10(%rsp)
movsd %xmm6, 0x70(%rsp)
callq 0x2270
maxsd 0x51cf(%rip), %xmm0     # 0x18868
cvttsd2si %xmm0, %ebx
movq %rbx, 0xb0(%rsp)
cvttpd2dq %xmm0, %xmm0
cvtdq2pd %xmm0, %xmm0
movapd 0xa0(%rsp), %xmm1
mulsd %xmm1, %xmm0
subsd 0x90(%rsp), %xmm0
mulsd 0x61a5(%rip), %xmm0     # 0x19870
addsd 0x70(%rsp), %xmm0
movapd %xmm0, 0x160(%rsp)
movapd 0x10(%rsp), %xmm0
subpd 0xf0(%rsp), %xmm0
movapd %xmm0, 0x10(%rsp)
unpcklpd %xmm1, %xmm1            # xmm1 = xmm1[0,0]
movapd %xmm1, 0x120(%rsp)
divpd %xmm1, %xmm0
movapd %xmm0, 0x90(%rsp)
callq 0x2270
movapd %xmm0, 0x70(%rsp)
movapd 0x90(%rsp), %xmm0
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
callq 0x2270
movapd 0x70(%rsp), %xmm1
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
maxpd 0x60b8(%rip), %xmm1     # 0x197f0
cvttpd2dq %xmm1, %xmm1
movapd %xmm1, 0x70(%rsp)
cvtdq2pd %xmm1, %xmm0
mulpd 0x120(%rsp), %xmm0
subpd 0x10(%rsp), %xmm0
mulpd 0x60a3(%rip), %xmm0     # 0x19800
addpd 0xf0(%rsp), %xmm0
movapd %xmm0, 0x150(%rsp)
movd %xmm1, %r13d
movl %r13d, 0x6c(%rsp)
imull %ebx, %r13d
pshufd $0x55, %xmm1, %xmm0     # xmm0 = xmm1[1,1,1,1]
movd %xmm0, %eax
movl %r13d, %ebx
movl %eax, 0x68(%rsp)
imull %eax, %ebx
leal (%r15,%r15,2), %eax
movslq %eax, %rdx
movq %r15, 0x38(%rsp)
leaq 0x6156(%rip), %r15      # 0x198f9
pushq $0x4
popq %rcx
movq %r15, %rdi
movl $0x25f, %esi            # imm = 0x25F
callq 0x1146e
movq %rax, %rbp
leaq (%rax,%r14,4), %rax
movq %rax, 0xd8(%rsp)
movl 0xdea0(%rip), %eax      # 0x21668
movq %rbx, 0x48(%rsp)
leal 0x1(%rbx,%rax), %eax
movslq %eax, %rdx
movq %r15, %rdi
movl $0x261, %esi            # imm = 0x261
pushq $0x4
popq %rcx
callq 0x1146e
movslq 0xde7d(%rip), %rcx      # 0x21668
movq %rax, 0x10(%rsp)
movq %rcx, 0xd0(%rsp)
leaq (%rax,%rcx,4), %rax
movq %rax, 0x28(%rsp)
movq 0xb0(%rsp), %rax
leal -0x1(%rax), %r15d
pcmpeqd %xmm0, %xmm0
paddd 0x70(%rsp), %xmm0
movdqa %xmm0, 0x140(%rsp)
xorl %ebx, %ebx
movq 0x38(%rsp), %rcx
testl %ecx, %ecx
movl $0x0, %esi
cmovgl %ecx, %esi
movl %r13d, 0x58(%rsp)
movd %r13d, %xmm0
movd %eax, %xmm1
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
movdqa %xmm1, 0x130(%rsp)
movq 0x80(%rsp), %rax
leaq 0x8(%rax), %r13
movq %rsi, 0x90(%rsp)
cmpq %rbx, %rsi
je 0x13961
movsd -0x8(%r13), %xmm0
subsd 0x160(%rsp), %xmm0
divsd 0xa0(%rsp), %xmm0
callq 0x21f0
maxsd 0x5fea(%rip), %xmm0     # 0x19878
cvttsd2si %xmm0, %r12d
cmpl %r15d, %r12d
cmovgel %r15d, %r12d
movupd (%r13), %xmm0
subpd 0x150(%rsp), %xmm0
divpd 0x120(%rsp), %xmm0
movapd %xmm0, 0x70(%rsp)
callq 0x21f0
movapd %xmm0, 0xf0(%rsp)
movapd 0x70(%rsp), %xmm0
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
callq 0x21f0
movq 0x90(%rsp), %rsi
movapd 0xf0(%rsp), %xmm1
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
maxpd 0x575e(%rip), %xmm1     # 0x19050
cvttpd2dq %xmm1, %xmm0
movdqa 0x140(%rsp), %xmm2
movdqa %xmm2, %xmm1
pcmpgtd %xmm0, %xmm1
pand %xmm1, %xmm0
pandn %xmm2, %xmm1
por %xmm0, %xmm1
pshufd $0xf5, %xmm1, %xmm0     # xmm0 = xmm1[1,1,3,3]
movdqa 0x130(%rsp), %xmm3
pshufd $0xf5, %xmm3, %xmm2     # xmm2 = xmm3[1,1,3,3]
pmuludq %xmm0, %xmm2
pmuludq %xmm3, %xmm1
movd %xmm1, %eax
addl %r12d, %eax
pushq $0x1
popq %r12
movd %xmm2, %ecx
addl %eax, %ecx
movslq %ecx, %rax
movq 0x28(%rsp), %rdx
incl (%rdx,%rax,4)
movq 0xd8(%rsp), %rax
movl %ecx, (%rax,%rbx,4)
incq %rbx
addq $0x18, %r13
jmp 0x13860
movsd 0x40(%rsp), %xmm0
divsd 0x60(%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
movq 0x28(%rsp), %rax
movl (%rax), %eax
movq 0x48(%rsp), %r8
movslq %r8d, %rcx
pushq $0x1
popq %rdx
movq 0xd8(%rsp), %rbx
movq 0x38(%rsp), %rdi
cmpq %rcx, %rdx
jge 0x139a9
movq 0x28(%rsp), %rsi
movl (%rsi,%rdx,4), %esi
cmpl %eax, %esi
cmovgl %esi, %eax
incq %rdx
jmp 0x13992
xorl %ecx, %ecx
testl %r8d, %r8d
cmovlel %ecx, %r8d
movq 0x10(%rsp), %rdx
movq 0xd0(%rsp), %rsi
leaq (%rdx,%rsi,4), %rdx
addq $0x4, %rdx
cmpq %rcx, %r8
je 0x139d8
movl -0x4(%rdx,%rcx,4), %esi
addl %esi, (%rdx,%rcx,4)
incq %rcx
jmp 0x139c7
imull $0x1b, %eax, %eax
cmpl %edi, %eax
cmovll %eax, %edi
movslq %edi, %rdx
leaq 0x5f0f(%rip), %rdi      # 0x198f9
pushq $0x20
popq %rcx
movl $0x274, %esi            # imm = 0x274
callq 0x1146e
movq 0x90(%rsp), %r9
movq %rax, 0xa0(%rsp)
xorl %eax, %eax
movl 0xc(%rsp), %edi
movq 0x28(%rsp), %r8
cmpq %rax, %r9
je 0x13a30
movslq (%rbx,%rax,4), %rcx
movslq (%r8,%rcx,4), %rdx
leaq -0x1(%rdx), %rsi
movl %esi, (%r8,%rcx,4)
movl %eax, -0x4(%rbp,%rdx,4)
incq %rax
jmp 0x13a12
movapd 0xe0(%rsp), %xmm0
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
divsd 0x60(%rsp), %xmm0
movapd %xmm0, 0xe0(%rsp)
movq 0xb0(%rsp), %rax
movslq %eax, %rcx
movq %rcx, 0x70(%rsp)
movslq 0x58(%rsp), %rcx
movq %rcx, 0x110(%rsp)
testl %eax, %eax
movl $0x0, %ecx
cmovgl %eax, %ecx
movq %rcx, 0x1b0(%rsp)
movl 0x6c(%rsp), %eax
testl %eax, %eax
movl $0x0, %ecx
cmovgl %eax, %ecx
movq %rcx, 0x190(%rsp)
movl 0x68(%rsp), %eax
testl %eax, %eax
movl $0x0, %ecx
cmovgl %eax, %ecx
movq %rcx, 0x178(%rsp)
movq 0xa0(%rsp), %rax
addq $0x18, %rax
movq %rax, 0x90(%rsp)
movq 0x118(%rsp), %rax
addq $0x10, %rax
movq %rax, 0x108(%rsp)
xorpd %xmm0, %xmm0
movsd %xmm0, 0x48(%rsp)
xorl %ecx, %ecx
xorl %esi, %esi
movsd %xmm0, 0xc0(%rsp)
movq 0x50(%rsp), %rdx
movq %rsi, %r15
cmpl $0x2, %ecx
movl %r12d, %eax
cmovgel %ecx, %eax
cmpq 0x178(%rsp), %rcx
je 0x141a3
decq %rax
movq %rax, 0x1a0(%rsp)
movq %rcx, %rax
imulq 0x110(%rsp), %rax
movq %rcx, 0x180(%rsp)
addl $0x2, %ecx
movl 0x68(%rsp), %esi
cmpl %esi, %ecx
cmovgel %esi, %ecx
movslq %ecx, %rcx
movq %rcx, 0x1c0(%rsp)
movq 0x28(%rsp), %rcx
leaq (%rcx,%rax,4), %rax
movq %rax, 0x188(%rsp)
xorl %ecx, %ecx
movq %r15, %rsi
cmpl $0x2, %ecx
movl %r12d, %eax
cmovgel %ecx, %eax
cmpq 0x190(%rsp), %rcx
je 0x14193
decq %rax
movq %rax, 0x1b8(%rsp)
movq %rcx, %rax
imulq 0x70(%rsp), %rax
movq %rcx, 0x198(%rsp)
addl $0x2, %ecx
movq %rsi, %r8
movl 0x6c(%rsp), %esi
cmpl %esi, %ecx
cmovgel %esi, %ecx
movq %r8, %rsi
movslq %ecx, %rcx
movq %rcx, 0xf0(%rsp)
movq 0x188(%rsp), %rcx
leaq (%rcx,%rax,4), %rax
movq %rax, 0x1a8(%rsp)
xorl %ecx, %ecx
cmpl $0x2, %ecx
movl %r12d, %eax
cmovgel %ecx, %eax
cmpq 0x1b0(%rsp), %rcx
je 0x14183
movq %rcx, 0x30(%rsp)
movq 0x1a8(%rsp), %rcx
movq 0x30(%rsp), %r8
movslq (%rcx,%r8,4), %r9
movq 0x30(%rsp), %r8
movslq 0x4(%rcx,%r8,4), %r8
movq 0x30(%rsp), %rcx
movq %r9, 0x58(%rsp)
movq %r8, 0x1c8(%rsp)
cmpl %r8d, %r9d
jge 0x1417b
movq %rdx, 0x50(%rsp)
decq %rax
addl $0x2, %ecx
movq 0xb0(%rsp), %rdx
cmpl %edx, %ecx
cmovgel %edx, %ecx
movslq %ecx, %rcx
xorl %r12d, %r12d
movq 0x1a0(%rsp), %rdx
movl %edi, 0xc(%rsp)
movq %rsi, 0x38(%rsp)
cmpq 0x1c0(%rsp), %rdx
jge 0x13cc6
movq %rdx, %rsi
imulq 0x110(%rsp), %rsi
movq 0x28(%rsp), %rdi
leaq (%rdi,%rsi,4), %rsi
movq 0x1b8(%rsp), %rdi
cmpq 0xf0(%rsp), %rdi
jge 0x13cb5
movq %rdi, %r8
imulq 0x70(%rsp), %r8
leaq (%rsi,%r8,4), %r8
movq %rax, %r9
cmpq %rcx, %r9
jge 0x13cb0
movslq (%r8,%r9,4), %r10
movslq 0x4(%r8,%r9,4), %r11
movslq %r12d, %r15
addq %r14, %r15
cmpq %r11, %r10
jge 0x13cab
movl (%rbp,%r10,4), %r13d
movl %r13d, (%rbp,%r15,4)
incq %r10
incl %r12d
incq %r15
jmp 0x13c91
incq %r9
jmp 0x13c7d
incq %rdi
jmp 0x13c63
incq %rdx
movl 0xc(%rsp), %edi
movq 0x38(%rsp), %rsi
jmp 0x13c38
testl %r12d, %r12d
movl $0x0, %eax
cmovlel %eax, %r12d
movq 0x50(%rsp), %rdx
movq 0x30(%rsp), %rcx
movq 0x58(%rsp), %rax
cmpq 0x1c8(%rsp), %rax
jge 0x14177
movq %rsi, 0x38(%rsp)
movq %rdx, 0x50(%rsp)
movq %rax, 0x58(%rsp)
movslq (%rbp,%rax,4), %rcx
movq 0x88(%rsp), %rax
movsd (%rax,%rcx,8), %xmm6
imulq $0x18, %rcx, %rax
movq 0x80(%rsp), %rdx
movupd (%rdx,%rax), %xmm7
movsd 0x10(%rdx,%rax), %xmm8
movl 0xd93a(%rip), %eax      # 0x21668
testl %eax, %eax
movl $0x0, %edx
cmovgl %eax, %edx
xorl %esi, %esi
cmpq %rsi, %rdx
je 0x13d4e
movq 0x10(%rsp), %r8
andl $0x0, (%r8,%rsi,4)
incq %rsi
jmp 0x13d3a
movl %edi, 0xc(%rsp)
movapd %xmm6, %xmm9
mulsd %xmm6, %xmm9
movapd %xmm6, %xmm0
addsd %xmm6, %xmm0
xorl %edi, %edi
movq 0xa0(%rsp), %r8
xorl %esi, %esi
cmpq %rdi, %r12
je 0x13e1f
movslq (%rbx,%rdi,4), %r9
cmpl %ecx, %r9d
je 0x13e17
movq 0x88(%rsp), %r10
movsd (%r10,%r9,8), %xmm1
leal (%r9,%r9,2), %r9d
movslq %r9d, %r9
movq 0x80(%rsp), %r10
movupd (%r10,%r9,8), %xmm2
subpd %xmm7, %xmm2
movsd 0x10(%r10,%r9,8), %xmm3
subsd %xmm8, %xmm3
movapd %xmm2, %xmm4
mulpd %xmm2, %xmm4
unpckhpd %xmm4, %xmm4            # xmm4 = xmm4[1,1]
movapd %xmm2, %xmm5
mulsd %xmm2, %xmm5
addsd %xmm4, %xmm5
movapd %xmm3, %xmm4
mulsd %xmm3, %xmm4
addsd %xmm5, %xmm4
movapd %xmm6, %xmm5
addsd %xmm1, %xmm5
mulsd %xmm5, %xmm5
ucomisd %xmm5, %xmm4
ja 0x13e17
mulsd %xmm1, %xmm1
incl %esi
movupd %xmm2, (%r8)
movsd %xmm3, 0x10(%r8)
addsd %xmm9, %xmm4
subsd %xmm1, %xmm4
divsd %xmm0, %xmm4
movsd %xmm4, 0x18(%r8)
addq $0x20, %r8
incq %rdi
jmp 0x13d70
testl %esi, %esi
je 0x13f05
xorl %r8d, %r8d
testl %esi, %esi
cmovlel %r8d, %esi
xorl %r9d, %r9d
xorl %edi, %edi
cmpq %rdx, %r8
je 0x13f1f
imulq $0x18, %r8, %r10
movq 0x118(%rsp), %r13
movsd (%r13,%r10), %xmm0
movsd 0x8(%r13,%r10), %xmm1
movslq %r9d, %r11
shlq $0x5, %r11
movq 0xa0(%rsp), %r15
movsd 0x8(%r15,%r11), %xmm2
mulsd %xmm1, %xmm2
movsd (%r15,%r11), %xmm3
mulsd %xmm0, %xmm3
addsd %xmm2, %xmm3
movsd 0x10(%r13,%r10), %xmm2
movsd 0x10(%r15,%r11), %xmm4
mulsd %xmm2, %xmm4
addsd %xmm3, %xmm4
movsd 0x18(%r15,%r11), %xmm3
ucomisd %xmm4, %xmm3
jb 0x13efd
movq 0x90(%rsp), %r11
xorl %r10d, %r10d
cmpq %r10, %rsi
je 0x13ee9
movsd -0x10(%r11), %xmm3
mulsd %xmm1, %xmm3
movsd -0x18(%r11), %xmm4
mulsd %xmm0, %xmm4
addsd %xmm3, %xmm4
movsd -0x8(%r11), %xmm3
mulsd %xmm2, %xmm3
addsd %xmm4, %xmm3
ucomisd (%r11), %xmm3
ja 0x13efa
incq %r10
addq $0x20, %r11
jmp 0x13eae
incl %edi
movq 0x10(%rsp), %r10
movl $0x1, (%r10,%r8,4)
jmp 0x13efd
movl %r10d, %r9d
incq %r8
jmp 0x13e35
xorl %esi, %esi
cmpq %rsi, %rdx
je 0x13f1d
movq 0x10(%rsp), %rdi
movl $0x1, (%rdi,%rsi,4)
incq %rsi
jmp 0x13f07
movl %eax, %edi
movsd 0xc8(%rsp), %xmm0
mulsd %xmm9, %xmm0
cvtsi2sd %edi, %xmm1
movsd %xmm1, 0xd0(%rsp)
mulsd %xmm1, %xmm0
movsd %xmm0, 0x60(%rsp)
testb $0x4, 0x8(%rsp)
movq 0x50(%rsp), %rdx
je 0x13f63
movq 0xb8(%rsp), %rsi
movsd 0x60(%rsp), %xmm0
movsd %xmm0, (%rsi,%rcx,8)
movapd %xmm7, %xmm3
unpckhpd %xmm7, %xmm3            # xmm3 = xmm3[1],xmm7[1]
testb $0x1, 0x8(%rsp)
movl 0xc(%rsp), %edi
movq 0x38(%rsp), %rsi
jne 0x13fd3
testb $0x2, 0x8(%rsp)
je 0x14153
movq %rsi, %r9
movq %rdx, %rsi
testl %eax, %eax
movl $0x0, %ecx
cmovlel %ecx, %eax
xorpd %xmm1, %xmm1
xorpd %xmm0, %xmm0
movq 0x108(%rsp), %rcx
xorl %edx, %edx
cmpq %rdx, %rax
je 0x140ee
movq 0x10(%rsp), %r8
cmpl $0x0, (%r8,%rdx,4)
je 0x13fca
movupd -0x10(%rcx), %xmm2
addpd %xmm2, %xmm1
addsd (%rcx), %xmm0
incq %rdx
addq $0x18, %rcx
jmp 0x13fa8
movq 0x108(%rsp), %r13
xorl %r15d, %r15d
movsd %xmm6, 0x120(%rsp)
movapd %xmm7, 0x160(%rsp)
movsd %xmm8, 0x150(%rsp)
movsd %xmm9, 0x140(%rsp)
movapd %xmm3, 0x130(%rsp)
movslq %eax, %rcx
cmpq %rcx, %r15
jge 0x13f7b
movq 0x10(%rsp), %rcx
cmpl $0x0, (%rcx,%r15,4)
je 0x140e2
incl %esi
leal (%rsi,%rsi,2), %ecx
incl %ecx
cmpl %ecx, %edi
jg 0x1409f
leal (%rax,%rax,2), %eax
addl %eax, %edi
movl %edi, 0xc(%rsp)
movslq %edi, %rcx
shlq $0x3, %rcx
leaq 0x58ae(%rip), %rdi      # 0x198f9
movq %rsi, %rbx
movl $0x2dc, %esi            # imm = 0x2DC
callq 0x114bf
movapd 0x130(%rsp), %xmm3
movsd 0x140(%rsp), %xmm9
movsd 0x150(%rsp), %xmm8
movapd 0x160(%rsp), %xmm7
movsd 0x120(%rsp), %xmm6
movq %rbx, %rsi
movl 0xc(%rsp), %edi
movq 0xd8(%rsp), %rbx
movq %rax, %rdx
movl 0xd5c9(%rip), %eax      # 0x21668
leal (%rsi,%rsi,2), %ecx
movsd -0x10(%r13), %xmm0
mulsd %xmm6, %xmm0
addsd %xmm7, %xmm0
movslq %ecx, %rcx
movsd %xmm0, -0x18(%rdx,%rcx,8)
movsd -0x8(%r13), %xmm0
mulsd %xmm6, %xmm0
addsd %xmm3, %xmm0
movsd %xmm0, -0x10(%rdx,%rcx,8)
movsd (%r13), %xmm0
mulsd %xmm6, %xmm0
addsd %xmm8, %xmm0
movsd %xmm0, -0x8(%rdx,%rcx,8)
incq %r15
addq $0x18, %r13
jmp 0x1400d
subsd 0x40(%rsp), %xmm7
subsd 0x1d0(%rsp), %xmm3
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
mulsd %xmm3, %xmm2
mulsd %xmm1, %xmm7
addsd %xmm2, %xmm7
subsd 0xe0(%rsp), %xmm8
mulsd %xmm8, %xmm0
addsd %xmm7, %xmm0
mulsd 0xd0(%rsp), %xmm6
addsd %xmm0, %xmm6
mulsd %xmm6, %xmm9
movsd 0xc0(%rsp), %xmm0
addsd %xmm9, %xmm0
movsd %xmm0, 0xc0(%rsp)
movq %rsi, %rdx
movq %r9, %rsi
movq 0x30(%rsp), %rcx
movsd 0x48(%rsp), %xmm0
addsd 0x60(%rsp), %xmm0
movsd %xmm0, 0x48(%rsp)
movq 0x58(%rsp), %rax
incq %rax
jmp 0x13ce1
pushq $0x1
popq %r12
incq %rcx
jmp 0x13bb7
movq 0x198(%rsp), %rcx
incq %rcx
jmp 0x13b51
movq 0x180(%rsp), %rcx
incq %rcx
jmp 0x13aeb
movq %rdx, %r14
movq %rbp, %rdi
callq 0x2040
movq 0x10(%rsp), %rdi
callq 0x2040
movq 0xa0(%rsp), %rdi
callq 0x2040
testb $0x2, 0x8(%rsp)
je 0x141fd
movsd 0xc0(%rsp), %xmm1
mulsd 0x568b(%rip), %xmm1     # 0x19868
cvtsi2sdl 0xd483(%rip), %xmm0 # 0x21668
mulsd 0x495b(%rip), %xmm0     # 0x18b48
divsd %xmm0, %xmm1
movq 0x228(%rsp), %rax
movsd %xmm1, (%rax)
testb $0x1, 0x8(%rsp)
movq 0x170(%rsp), %rax
je 0x14222
movq 0x238(%rsp), %rcx
movl %r15d, (%rcx)
movq 0x230(%rsp), %rcx
movq %r14, (%rcx)
testb $0x4, 0x8(%rsp)
je 0x1423c
movq 0xb8(%rsp), %rcx
movq 0x220(%rsp), %rdx
movq %rcx, (%rdx)
movsd 0x48(%rsp), %xmm0
movsd %xmm0, (%rax)
xorl %r12d, %r12d
movl %r12d, %eax
addq $0x1e8, %rsp            # imm = 0x1E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop