// File: /workspace/github_c_makefile_star2_O3/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 $0x218, %rsp            # imm = 0x218
movq %r9, %rbx
movl %r8d, 0x8(%rsp)
movl %edx, %r15d
movq %rsi, %r9
movl $0x1, %edx
movl $0xa, %esi
movl %esi, %eax
imull %edx, %eax
leal 0x2(%rax), %r8d
incl %edx
addl $0xa, %esi
cmpl %ecx, %r8d
jl 0x1360c
movl $0x1, %edx
movl $0x1e, %esi
movl %esi, %r10d
imull %edx, %r10d
leal 0x2(%r10), %r8d
incl %edx
addl $0x1e, %esi
cmpl %ecx, %r8d
jl 0x13629
xorl %esi, %esi
cmpl %r10d, %eax
setb %sil
leal 0x9(%rsi), %eax
addl 0xefe0(%rip), %eax      # 0x22630
movq %r9, 0x20(%rsp)
movq %rdi, 0x58(%rsp)
jne 0x13675
cmpl $0x4, 0xefd1(%rip)      # 0x22634
jne 0x13675
cmpl %ecx, 0xefc1(%rip)      # 0x2262c
je 0x1369a
cmpl %ecx, 0xefb5(%rip)      # 0x22628
je 0x1369a
xorl $-0x9, %esi
leaq 0xefd9(%rip), %rdx      # 0x22658
movl %ecx, %edi
movl $0x4, %ecx
callq 0x131fb
movl %eax, %ecx
movl $0x1, %eax
testl %ecx, %ecx
jne 0x14681
testl %r15d, %r15d
je 0x14693
movq 0xef66(%rip), %rax      # 0x22610
movq %rax, 0x148(%rsp)
movl 0xefa0(%rip), %ecx      # 0x22658
testb $0x1, 0x8(%rsp)
movl %ecx, 0xd8(%rsp)
je 0x13705
movl %r15d, %eax
imull %ecx, %eax
leal (%rax,%rax,2), %eax
cltq
imulq $0x66666667, %rax, %rcx # imm = 0x66666667
movq %rcx, %rax
shrq $0x3f, %rax
sarq $0x22, %rcx
addl %eax, %ecx
movq %rcx, 0x50(%rsp)
movslq %ecx, %rdx
leaq 0x7255(%rip), %rdi      # 0x1a949
movl $0x8, %ecx
movl $0x235, %esi            # imm = 0x235
callq 0x11571
jmp 0x1370c
xorl %eax, %eax
movq %rcx, 0x50(%rsp)
movq %rax, 0x18(%rsp)
movslq %r15d, %rdx
testb $0x4, 0x8(%rsp)
movq %rdx, 0x10(%rsp)
jne 0x1372e
movq $0x0, 0xd0(%rsp)
jmp 0x1374c
leaq 0x7214(%rip), %rdi      # 0x1a949
movl $0x8, %ecx
movl $0x239, %esi            # imm = 0x239
callq 0x11571
movq %rax, 0xd0(%rsp)
movq 0x20(%rsp), %rdx
movq 0x58(%rsp), %rax
movupd (%rax), %xmm6
movsd 0x10(%rax), %xmm7
movsd (%rdx), %xmm4
movl %r15d, %r12d
cmpl $0x2, %r15d
movq %rbx, 0x188(%rsp)
jl 0x137c3
addq $0x28, %rax
movl $0x1, %ecx
movapd %xmm7, %xmm8
movapd %xmm7, %xmm2
movapd %xmm6, %xmm5
movapd %xmm6, %xmm3
movupd -0x10(%rax), %xmm0
minpd %xmm0, %xmm5
maxpd %xmm0, %xmm6
movsd (%rax), %xmm1
minsd %xmm1, %xmm8
maxsd %xmm1, %xmm7
addpd %xmm0, %xmm3
maxsd (%rdx,%rcx,8), %xmm4
addsd %xmm1, %xmm2
incq %rcx
addq $0x18, %rax
cmpq %rcx, %r12
jne 0x1378e
jmp 0x137d4
movapd %xmm7, %xmm2
movapd %xmm7, %xmm8
movapd %xmm6, %xmm5
movapd %xmm6, %xmm3
movapd %xmm8, 0x90(%rsp)
movapd %xmm7, 0x60(%rsp)
movapd %xmm3, 0x170(%rsp)
movsd %xmm2, 0xb8(%rsp)
addsd %xmm4, %xmm4
movapd %xmm4, 0x120(%rsp)
movapd %xmm5, 0x80(%rsp)
subpd %xmm5, %xmm6
unpcklpd %xmm4, %xmm4            # xmm4 = xmm4[0,0]
movapd %xmm6, 0x100(%rsp)
movapd %xmm6, %xmm0
movapd %xmm4, 0x110(%rsp)
divpd %xmm4, %xmm0
movapd %xmm0, 0xc0(%rsp)
callq 0x2260
movapd %xmm0, 0xf0(%rsp)
movapd 0xc0(%rsp), %xmm0
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
callq 0x2260
movapd 0xf0(%rsp), %xmm1
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
maxpd 0x6fb4(%rip), %xmm1     # 0x1a820
cvttpd2dq %xmm1, %xmm0
pshufd $0x55, %xmm0, %xmm1     # xmm1 = xmm0[1,1,1,1]
movdqa %xmm1, 0xc0(%rsp)
movd %xmm1, %ebx
movaps %xmm0, 0x150(%rsp)
movd %xmm0, %r14d
movapd 0x60(%rsp), %xmm0
subsd 0x90(%rsp), %xmm0
movapd %xmm0, 0x60(%rsp)
divsd 0x120(%rsp), %xmm0
callq 0x2260
maxsd 0x5fae(%rip), %xmm0     # 0x19868
cvttsd2si %xmm0, %eax
movq %r14, 0xa8(%rsp)
movl %r14d, %ecx
movl %ebx, 0x7c(%rsp)
imull %ebx, %ecx
movl %ecx, 0x48(%rsp)
movl %ecx, %r13d
movl %eax, 0x28(%rsp)
imull %eax, %r13d
leal (%r15,%r15,2), %eax
movslq %eax, %rdx
leaq 0x705c(%rip), %rbp      # 0x1a949
movl $0x4, %ecx
movq %rbp, %rdi
movl $0x25f, %esi            # imm = 0x25F
callq 0x11571
movq %rax, %rbx
movq 0x10(%rsp), %rax
leaq (%rbx,%rax,4), %r14
movq %r13, 0x38(%rsp)
leal 0x1(%r13), %ecx
movl 0xed3e(%rip), %eax      # 0x22658
movl %ecx, 0x2c(%rsp)
addl %ecx, %eax
movslq %eax, %rdx
movl $0x4, %ecx
movq %rbp, %rdi
movl $0x261, %esi            # imm = 0x261
callq 0x11571
movapd 0x120(%rsp), %xmm3
movslq 0xed13(%rip), %rcx      # 0x22658
movq %rax, 0x10(%rsp)
leaq (%rax,%rcx,4), %rdi
movq %r15, 0x40(%rsp)
testl %r15d, %r15d
movq %rdi, 0xb0(%rsp)
jle 0x13b2d
movq 0xa8(%rsp), %rax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd %xmm3, %xmm0
movapd 0x100(%rsp), %xmm5
subsd %xmm5, %xmm0
mulsd 0x6f34(%rip), %xmm0     # 0x1a8c0
movapd 0x80(%rsp), %xmm4
addsd %xmm4, %xmm0
movsd %xmm0, 0xf0(%rsp)
movss 0x28(%rsp), %xmm0
unpcklpd 0xc0(%rsp), %xmm0       # xmm0 = xmm0[0],mem[0]
movaps 0x150(%rsp), %xmm2
shufps $0x52, %xmm2, %xmm0     # xmm0 = xmm0[2,0],xmm2[1,1]
cvtdq2pd %xmm0, %xmm1
shufpd $0x1, 0x60(%rsp), %xmm5 # xmm5 = xmm5[1],mem[0]
mulpd 0x110(%rsp), %xmm1
subpd %xmm5, %xmm1
mulpd 0x6e53(%rip), %xmm1     # 0x1a830
shufpd $0x1, 0x90(%rsp), %xmm4 # xmm4 = xmm4[1],mem[0]
addpd %xmm1, %xmm4
movapd %xmm4, 0x80(%rsp)
leal -0x1(%rax), %eax
movl %eax, 0xc0(%rsp)
pcmpeqd %xmm1, %xmm1
paddd %xmm0, %xmm1
movdqa %xmm1, 0x100(%rsp)
movss 0x48(%rsp), %xmm0
movlhps %xmm2, %xmm0            # xmm0 = xmm0[0],xmm2[0]
shufps $0xe2, %xmm2, %xmm0     # xmm0 = xmm0[2,0],xmm2[2,3]
movaps %xmm0, 0x160(%rsp)
movq 0x58(%rsp), %rax
leaq 0x8(%rax), %r13
xorl %r15d, %r15d
movsd -0x8(%r13), %xmm0
subsd 0xf0(%rsp), %xmm0
divsd %xmm3, %xmm0
callq 0x21e0
maxsd 0x6e78(%rip), %xmm0     # 0x1a8c8
movq %r12, %rbp
cvttsd2si %xmm0, %r12d
movl 0xc0(%rsp), %eax
cmpl %eax, %r12d
cmovgel %eax, %r12d
movupd (%r13), %xmm0
subpd 0x80(%rsp), %xmm0
divpd 0x110(%rsp), %xmm0
movapd %xmm0, 0x90(%rsp)
callq 0x21e0
movapd %xmm0, 0x60(%rsp)
movapd 0x90(%rsp), %xmm0
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
callq 0x21e0
movapd 0x120(%rsp), %xmm3
movq 0xb0(%rsp), %rdi
movapd 0x60(%rsp), %xmm1
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
maxpd 0x65b9(%rip), %xmm1     # 0x1a080
cvttpd2dq %xmm1, %xmm0
movdqa 0x100(%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 0x160(%rsp), %xmm4
pshufd $0xf5, %xmm4, %xmm2     # xmm2 = xmm4[1,1,3,3]
pmuludq %xmm0, %xmm2
pmuludq %xmm4, %xmm1
movd %xmm1, %eax
addl %r12d, %eax
movq %rbp, %r12
movd %xmm2, %ecx
addl %eax, %ecx
movslq %ecx, %rax
incl (%rdi,%rax,4)
movl %ecx, (%r14,%r15,4)
incq %r15
addq $0x18, %r13
cmpq %r15, %rbp
jne 0x13a30
movl (%rdi), %eax
movq 0x38(%rsp), %r8
cmpl $0x2, %r8d
jl 0x13b52
movl %r8d, %ecx
movl $0x1, %edx
movl (%rdi,%rdx,4), %esi
cmpl %eax, %esi
cmovgl %esi, %eax
incq %rdx
cmpq %rdx, %rcx
jne 0x13b42
testl %r8d, %r8d
movq 0x40(%rsp), %r15
jle 0x13b75
movl 0x2c(%rsp), %ecx
movl (%rdi), %edx
movl $0x1, %esi
addl (%rdi,%rsi,4), %edx
movl %edx, (%rdi,%rsi,4)
incq %rsi
cmpq %rsi, %rcx
jne 0x13b67
leal (%rax,%rax,8), %eax
leal (%rax,%rax,2), %eax
cmpl %r15d, %eax
cmovgel %r15d, %eax
movslq %eax, %rdx
leaq 0x6dbd(%rip), %rdi      # 0x1a949
movl $0x20, %ecx
movl $0x274, %esi            # imm = 0x274
callq 0x11571
movq 0xb0(%rsp), %rdi
movq %rax, 0x90(%rsp)
testl %r15d, %r15d
jle 0x13bcd
xorl %eax, %eax
movslq (%r14,%rax,4), %rcx
movslq (%rdi,%rcx,4), %rdx
leaq -0x1(%rdx), %rsi
movl %esi, (%rdi,%rcx,4)
movl %eax, -0x4(%rbx,%rdx,4)
incq %rax
cmpq %rax, %r12
jne 0x13bb2
movl 0x28(%rsp), %ecx
testl %ecx, %ecx
movq 0x50(%rsp), %r8
movsd 0xb8(%rsp), %xmm7
jle 0x145cf
xorps %xmm0, %xmm0
cvtsi2sdl 0xd8(%rsp), %xmm0
movsd 0x6cbd(%rip), %xmm1     # 0x1a8b8
divsd %xmm0, %xmm1
movsd %xmm1, 0x1f0(%rsp)
xorps %xmm0, %xmm0
cvtsi2sd %r15d, %xmm0
movapd 0x170(%rsp), %xmm1
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
divsd %xmm0, %xmm1
movapd %xmm1, 0x170(%rsp)
divsd %xmm0, %xmm2
movapd %xmm2, 0x200(%rsp)
divsd %xmm0, %xmm7
pshufd $0x50, 0x150(%rsp), %xmm0 # xmm0 = mem[0,0,1,1]
xorpd %xmm1, %xmm1
pcmpgtd %xmm1, %xmm0
movmskpd %xmm0, %eax
movl %eax, 0xe4(%rsp)
shrb %al
movb %al, 0xf(%rsp)
movq 0xa8(%rsp), %rax
movslq %eax, %rdx
movq %rdx, 0x100(%rsp)
movslq 0x48(%rsp), %rdx
movq %rdx, 0x138(%rsp)
movl %ecx, %ecx
movq %rcx, 0x190(%rsp)
movl 0x7c(%rsp), %ecx
movq %rcx, 0x1a8(%rsp)
movl %eax, %eax
movq %rax, 0x1c0(%rsp)
movq 0x90(%rsp), %rax
addq $0x18, %rax
movq %rax, 0x150(%rsp)
movq 0x148(%rsp), %rax
addq $0x10, %rax
movq %rax, 0x140(%rsp)
xorl %eax, %eax
xorpd %xmm0, %xmm0
movsd %xmm0, 0x30(%rsp)
movdqa 0x5bf1(%rip), %xmm8     # 0x198d0
pcmpeqd %xmm9, %xmm9
movdqa 0x6b63(%rip), %xmm10    # 0x1a850
movsd %xmm0, 0x38(%rsp)
xorl %r9d, %r9d
movq 0x18(%rsp), %rdx
movsd %xmm7, 0xb8(%rsp)
cmpl $0x2, %eax
movl $0x1, %esi
cmovgel %eax, %esi
cmpb $0x0, 0xf(%rsp)
movq %rax, 0x198(%rsp)
je 0x1459e
leaq -0x1(%rsi), %rcx
movq %rcx, 0x1b8(%rsp)
movq %rax, %rcx
imulq 0x138(%rsp), %rcx
movq %rcx, 0x1a0(%rsp)
leal 0x2(%rax), %ecx
movl 0x28(%rsp), %eax
cmpl %eax, %ecx
cmovgel %eax, %ecx
movl %ecx, 0xe8(%rsp)
movslq %ecx, %rax
movq %rax, 0x1e0(%rsp)
xorl %ecx, %ecx
movq %rsi, 0x1c8(%rsp)
cmpl $0x2, %ecx
movl $0x1, %eax
cmovgel %ecx, %eax
testb $0x1, 0xe4(%rsp)
movq %rcx, 0x1b0(%rsp)
je 0x14585
movq %rax, 0x1e8(%rsp)
decq %rax
movq %rax, 0x1d8(%rsp)
leal 0x2(%rcx), %edi
movl 0x7c(%rsp), %eax
cmpl %eax, %edi
cmovgel %eax, %edi
movl %ecx, %eax
imull 0xa8(%rsp), %eax
addl 0x1a0(%rsp), %eax
movl %edi, 0xec(%rsp)
movslq %edi, %rcx
movq %rcx, 0x120(%rsp)
movq 0xb0(%rsp), %rcx
leaq (%rcx,%rax,4), %rax
movq %rax, 0x1d0(%rsp)
xorl %edi, %edi
cmpl $0x2, %edi
movl $0x1, %eax
cmovgel %edi, %eax
movq 0x1d0(%rsp), %rcx
movslq (%rcx,%rdi,4), %r10
movq %rdi, 0x130(%rsp)
movl 0x4(%rcx,%rdi,4), %ecx
movl %ecx, 0x2c(%rsp)
cmpl %ecx, %r10d
jge 0x14564
movq %r10, 0x40(%rsp)
movq %r9, 0x48(%rsp)
movq %r8, 0x50(%rsp)
movq %rdx, 0x18(%rsp)
xorl %ecx, %ecx
cmpl 0xe8(%rsp), %esi
jg 0x13f14
movq 0x130(%rsp), %rcx
leal 0x2(%rcx), %edx
movq 0xa8(%rsp), %rcx
cmpl %ecx, %edx
cmovgel %ecx, %edx
leaq -0x1(%rax), %rcx
movq %rcx, 0x60(%rsp)
movslq %edx, %rdi
xorl %ecx, %ecx
movq 0x1b8(%rsp), %r8
movl 0xec(%rsp), %esi
cmpl %esi, 0x1e8(%rsp)
movq %r8, 0x80(%rsp)
jg 0x13efb
imulq 0x138(%rsp), %r8
movq 0xb0(%rsp), %rsi
leaq (%rsi,%r8,4), %r9
movq 0x1d8(%rsp), %r10
cmpl %edx, %eax
jg 0x13eee
movq %r10, %r8
imulq 0x100(%rsp), %r8
leaq (%r9,%r8,4), %r11
movq 0x60(%rsp), %r15
movslq (%r11,%r15,4), %r8
movslq 0x4(%r11,%r15,4), %r12
cmpl %r12d, %r8d
jge 0x13ee6
movslq %ecx, %r13
leaq (%r14,%r13,4), %r13
leaq (%rbx,%r8,4), %rbp
subq %r8, %r12
xorl %r8d, %r8d
movl (%rbp,%r8,4), %esi
movl %esi, (%r13,%r8,4)
incq %r8
cmpq %r8, %r12
jne 0x13ed1
addl %r8d, %ecx
incq %r15
cmpq %rdi, %r15
jl 0x13eb2
incq %r10
cmpq 0x120(%rsp), %r10
jl 0x13e99
movq 0x80(%rsp), %r8
incq %r8
cmpq 0x1e0(%rsp), %r8
jl 0x13e64
movl 0xe73e(%rip), %ebp      # 0x22658
movl %ecx, %eax
movq %rax, 0x1f8(%rsp)
movl %ebp, %r12d
movq 0x20(%rsp), %r13
movq 0x58(%rsp), %r11
movq 0x18(%rsp), %rdx
movq 0x50(%rsp), %r8
movq 0x10(%rsp), %rdi
movq 0x48(%rsp), %r9
movq 0x40(%rsp), %r10
movq %r9, 0x48(%rsp)
movq %r8, 0x50(%rsp)
movq %rdx, 0x18(%rsp)
movq %r10, 0x40(%rsp)
movslq (%rbx,%r10,4), %r15
movsd (%r13,%r15,8), %xmm11
leaq (%r15,%r15,2), %rax
movupd (%r11,%rax,8), %xmm13
movsd 0x10(%r11,%rax,8), %xmm12
movl %r12d, %r9d
testl %r12d, %r12d
movsd %xmm11, 0x110(%rsp)
movsd %xmm12, 0xf0(%rsp)
movapd %xmm13, 0xc0(%rsp)
movq %r9, 0x60(%rsp)
jle 0x14006
leaq (,%r9,4), %rdx
xorl %esi, %esi
callq 0x20f0
movq 0x60(%rsp), %r9
movapd 0xc0(%rsp), %xmm13
movsd 0xf0(%rsp), %xmm12
movsd 0x110(%rsp), %xmm11
movdqa 0x6870(%rip), %xmm10    # 0x1a850
pcmpeqd %xmm9, %xmm9
movdqa 0x58e2(%rip), %xmm8     # 0x198d0
movq 0x10(%rsp), %rdi
movsd 0xb8(%rsp), %xmm7
movq 0x58(%rsp), %r11
movq 0x20(%rsp), %r13
movapd %xmm11, %xmm0
mulsd %xmm11, %xmm0
movsd %xmm0, 0x80(%rsp)
movq 0x1f8(%rsp), %r8
testl %r8d, %r8d
jle 0x141cf
movapd %xmm11, %xmm0
addsd %xmm11, %xmm0
xorl %ecx, %ecx
xorl %eax, %eax
movq 0x90(%rsp), %rdx
movslq (%r14,%rcx,4), %rsi
cmpl %r15d, %esi
je 0x140d1
movsd (%r13,%rsi,8), %xmm1
leal (%rsi,%rsi,2), %esi
movslq %esi, %rsi
movupd (%r11,%rsi,8), %xmm2
subpd %xmm13, %xmm2
movsd 0x10(%r11,%rsi,8), %xmm3
subsd %xmm12, %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 %xmm11, %xmm5
addsd %xmm1, %xmm5
mulsd %xmm5, %xmm5
ucomisd %xmm5, %xmm4
ja 0x140d1
mulsd %xmm1, %xmm1
incl %eax
movupd %xmm2, (%rdx)
movsd %xmm3, 0x10(%rdx)
addsd 0x80(%rsp), %xmm4
subsd %xmm1, %xmm4
divsd %xmm0, %xmm4
movsd %xmm4, 0x18(%rdx)
addq $0x20, %rdx
incq %rcx
cmpq %rcx, %r8
jne 0x14040
testl %eax, %eax
je 0x141cf
testl %r12d, %r12d
jle 0x142cb
movl %eax, %edx
xorl %esi, %esi
xorl %ecx, %ecx
xorl %r10d, %r10d
leaq (%rsi,%rsi,2), %r8
movq 0x148(%rsp), %r13
movsd (%r13,%r8,8), %xmm0
movsd 0x8(%r13,%r8,8), %xmm1
movslq %r10d, %r9
shlq $0x5, %r9
movq 0x90(%rsp), %rdi
movsd 0x8(%rdi,%r9), %xmm2
mulsd %xmm1, %xmm2
movsd (%rdi,%r9), %xmm3
mulsd %xmm0, %xmm3
addsd %xmm2, %xmm3
movsd 0x10(%r13,%r8,8), %xmm2
movsd 0x10(%rdi,%r9), %xmm4
mulsd %xmm2, %xmm4
addsd %xmm3, %xmm4
movsd 0x18(%rdi,%r9), %xmm3
ucomisd %xmm4, %xmm3
jb 0x141b7
testl %eax, %eax
jle 0x141a4
movq 0x150(%rsp), %r9
xorl %r8d, %r8d
movsd -0x10(%r9), %xmm3
mulsd %xmm1, %xmm3
movsd -0x18(%r9), %xmm4
mulsd %xmm0, %xmm4
addsd %xmm3, %xmm4
movsd -0x8(%r9), %xmm3
mulsd %xmm2, %xmm3
addsd %xmm4, %xmm3
ucomisd (%r9), %xmm3
ja 0x141b4
incq %r8
addq $0x20, %r9
cmpq %r8, %rdx
jne 0x1416b
incl %ecx
movq 0x10(%rsp), %rdi
movl $0x1, (%rdi,%rsi,4)
jmp 0x141bc
movl %r8d, %r10d
movq 0x10(%rsp), %rdi
incq %rsi
cmpq 0x60(%rsp), %rsi
jne 0x140f7
jmp 0x142cd
movl %r12d, %ecx
testl %r12d, %r12d
jle 0x142cd
leal 0x3(%r12), %eax
decq %r9
movq %r9, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
shrl $0x2, %eax
shlq $0x4, %rax
xorl %ecx, %ecx
movdqa 0x5ae2(%rip), %xmm1     # 0x19ce0
movdqa 0x663a(%rip), %xmm2     # 0x1a840
movdqa %xmm0, %xmm3
pxor %xmm8, %xmm3
movdqa %xmm1, %xmm4
pxor %xmm8, %xmm4
movdqa %xmm4, %xmm5
pcmpgtd %xmm3, %xmm5
pcmpeqd %xmm3, %xmm4
pshufd $0xf5, %xmm4, %xmm6     # xmm6 = xmm4[1,1,3,3]
pand %xmm5, %xmm6
pshufd $0xf5, %xmm5, %xmm4     # xmm4 = xmm5[1,1,3,3]
por %xmm6, %xmm4
movd %xmm4, %edx
notl %edx
testb $0x1, %dl
je 0x14248
movl $0x1, (%rdi,%rcx)
pxor %xmm9, %xmm4
pextrw $0x4, %xmm4, %edx
testb $0x1, %dl
je 0x1425f
movl $0x1, 0x4(%rdi,%rcx)
movdqa %xmm2, %xmm4
pxor %xmm8, %xmm4
movdqa %xmm4, %xmm5
pcmpgtd %xmm3, %xmm5
pcmpeqd %xmm3, %xmm4
pshufd $0xf5, %xmm4, %xmm4     # xmm4 = xmm4[1,1,3,3]
pand %xmm5, %xmm4
pshufd $0xf5, %xmm5, %xmm3     # xmm3 = xmm5[1,1,3,3]
por %xmm4, %xmm3
pxor %xmm9, %xmm3
pextrw $0x0, %xmm3, %edx
testb $0x1, %dl
je 0x1429d
movl $0x1, 0x8(%rdi,%rcx)
pextrw $0x4, %xmm3, %edx
testb $0x1, %dl
je 0x142af
movl $0x1, 0xc(%rdi,%rcx)
paddq %xmm10, %xmm1
paddq %xmm10, %xmm2
addq $0x10, %rcx
cmpq %rcx, %rax
jne 0x14206
movl %r12d, %ecx
jmp 0x142cd
xorl %ecx, %ecx
movsd 0x1f0(%rsp), %xmm0
mulsd 0x80(%rsp), %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %ecx, %xmm1
movsd %xmm1, 0xd8(%rsp)
mulsd %xmm1, %xmm0
movsd %xmm0, 0x160(%rsp)
testb $0x4, 0x8(%rsp)
je 0x1431a
movq 0xd0(%rsp), %rax
movsd 0x160(%rsp), %xmm0
movsd %xmm0, (%rax,%r15,8)
testb $0x1, 0x8(%rsp)
movq 0x18(%rsp), %rdx
movq 0x50(%rsp), %r8
movq 0x48(%rsp), %r9
je 0x14466
testl %r12d, %r12d
movq 0x20(%rsp), %rsi
jle 0x14461
movapd %xmm13, %xmm1
unpckhpd %xmm13, %xmm1           # xmm1 = xmm1[1],xmm13[1]
movq 0x140(%rsp), %r15
xorl %r13d, %r13d
movapd %xmm1, 0x60(%rsp)
cmpl $0x0, (%rdi,%r13,4)
je 0x14447
incl %r9d
leal (%r9,%r9,2), %eax
incl %eax
cmpl %eax, %r8d
jg 0x14401
leal (%r12,%r12,2), %eax
addl %eax, %r8d
movslq %r8d, %rcx
shlq $0x3, %rcx
movq %r8, %r12
leaq 0x65b7(%rip), %rdi      # 0x1a949
movl $0x2dc, %esi            # imm = 0x2DC
movq %r9, %rbp
callq 0x115c4
movapd 0x60(%rsp), %xmm1
movapd 0xc0(%rsp), %xmm13
movsd 0xf0(%rsp), %xmm12
movsd 0x110(%rsp), %xmm11
movdqa 0x6484(%rip), %xmm10    # 0x1a850
pcmpeqd %xmm9, %xmm9
movdqa 0x54f6(%rip), %xmm8     # 0x198d0
movq %rbp, %r9
movq 0x10(%rsp), %rdi
movsd 0xb8(%rsp), %xmm7
movq %r12, %r8
movq 0x58(%rsp), %r11
movq 0x20(%rsp), %rsi
movq %rax, %rdx
movl 0xe257(%rip), %ebp      # 0x22658
leal (%r9,%r9,2), %eax
movsd -0x10(%r15), %xmm0
mulsd %xmm11, %xmm0
addsd %xmm13, %xmm0
cltq
movsd %xmm0, -0x18(%rdx,%rax,8)
movsd -0x8(%r15), %xmm0
mulsd %xmm11, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x10(%rdx,%rax,8)
movsd (%r15), %xmm0
mulsd %xmm11, %xmm0
addsd %xmm12, %xmm0
movsd %xmm0, -0x8(%rdx,%rax,8)
incq %r13
movslq %ebp, %rcx
addq $0x18, %r15
movl %ebp, %r12d
movl %ebp, %eax
cmpq %rcx, %r13
jl 0x1435d
jmp 0x1446e
movl %r12d, %eax
jmp 0x1446e
movl %r12d, %eax
movq 0x20(%rsp), %rsi
movq %rsi, %r13
testb $0x2, 0x8(%rsp)
jne 0x14482
movq 0x40(%rsp), %r10
jmp 0x1453e
movq %rdx, %rsi
testl %ebp, %ebp
movq 0x40(%rsp), %r10
jle 0x144c3
movl %ebp, %eax
xorpd %xmm1, %xmm1
xorpd %xmm0, %xmm0
movq 0x140(%rsp), %rcx
xorl %edx, %edx
cmpl $0x0, (%rdi,%rdx,4)
je 0x144b5
movupd -0x10(%rcx), %xmm2
addpd %xmm2, %xmm1
addsd (%rcx), %xmm0
incq %rdx
addq $0x18, %rcx
cmpq %rdx, %rax
jne 0x144a2
jmp 0x144cb
xorpd %xmm1, %xmm1
xorpd %xmm0, %xmm0
movapd %xmm13, %xmm2
subsd 0x170(%rsp), %xmm2
unpckhpd %xmm13, %xmm13          # xmm13 = xmm13[1,1]
subsd 0x200(%rsp), %xmm13
movapd %xmm1, %xmm3
unpckhpd %xmm1, %xmm3            # xmm3 = xmm3[1],xmm1[1]
mulsd %xmm13, %xmm3
mulsd %xmm1, %xmm2
addsd %xmm3, %xmm2
subsd %xmm7, %xmm12
mulsd %xmm0, %xmm12
addsd %xmm2, %xmm12
mulsd 0xd8(%rsp), %xmm11
addsd %xmm12, %xmm11
movsd 0x80(%rsp), %xmm1
mulsd %xmm11, %xmm1
movsd 0x30(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x30(%rsp)
movl %ebp, %eax
movq %rsi, %rdx
movsd 0x38(%rsp), %xmm0
addsd 0x160(%rsp), %xmm0
movsd %xmm0, 0x38(%rsp)
incq %r10
movl %eax, %r12d
cmpl %r10d, 0x2c(%rsp)
jne 0x13f4a
movq 0x130(%rsp), %rdi
incq %rdi
cmpq 0x1c0(%rsp), %rdi
movq 0x1c8(%rsp), %rsi
jne 0x13de3
movq 0x1b0(%rsp), %rcx
incq %rcx
cmpq 0x1a8(%rsp), %rcx
jne 0x13d6a
movq 0x198(%rsp), %rax
incq %rax
cmpq 0x190(%rsp), %rax
jne 0x13d04
movq %r9, %r14
movq %rdx, 0x18(%rsp)
movsd 0x30(%rsp), %xmm0
mulsd 0x62eb(%rip), %xmm0     # 0x1a8b8
jmp 0x145dc
xorpd %xmm0, %xmm0
movsd %xmm0, 0x38(%rsp)
xorl %r14d, %r14d
movsd %xmm0, 0x30(%rsp)
movq %rbx, %rdi
callq 0x2040
movq 0x10(%rsp), %rdi
callq 0x2040
movq 0x90(%rsp), %rdi
callq 0x2040
testb $0x2, 0x8(%rsp)
movq 0x250(%rsp), %rcx
movq 0x260(%rsp), %rdx
movq 0x268(%rsp), %rsi
movq 0x258(%rsp), %rax
je 0x14649
xorps %xmm0, %xmm0
cvtsi2sdl 0xe025(%rip), %xmm0 # 0x22658
mulsd 0x550d(%rip), %xmm0     # 0x19b48
movsd 0x30(%rsp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, (%rax)
testb $0x1, 0x8(%rsp)
movq 0x188(%rsp), %rax
je 0x14663
movl %r14d, (%rsi)
movq 0x18(%rsp), %rsi
movq %rsi, (%rdx)
testb $0x4, 0x8(%rsp)
je 0x14675
movq 0xd0(%rsp), %rdx
movq %rdx, (%rcx)
movsd 0x38(%rsp), %xmm0
movsd %xmm0, (%rax)
xorl %eax, %eax
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2711
movl $0x1, %eax
jmp 0x14681
nop